123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using OTSCLRINTERFACE;
- using OTSDataType;
- using OTSModelSharp.DTLBase;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SQLite;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OTSModelSharp
- {
- public class CSegmentDB: CSQLiteDB
- {
-
- public CSegmentDB(IDBStoreBase _conStr, CSQLiteTable _table):base(_conStr,_table)
- {
-
- }
-
- public List<KeyValuePair<string,SQLiteParameter[]>> GetSavingFeatureCmd(COTSParticleClr a_pParticle)
- {
- var tableInfoPtr = GetTableInfo();
- var datastorePtr = GetDatastore();
- var sInsertFormat = tableInfoPtr.GetInsertCommand(true);//CSQLiteTable修改完再修改此处
- //String sSQLCommand = "";
- COTSFeatureClr pFeature = a_pParticle.GetFeature();
- List<COTSSegmentClr> listSegments = pFeature.GetSegmentsList();
- int nSize = (int)listSegments.Count;
- int nSegmentIndex = 0;
- List<KeyValuePair<string, SQLiteParameter[]>> cmds = new List<KeyValuePair<string, SQLiteParameter[]>>();
- var parasTemplate = (SQLiteParameter[])sInsertFormat.Value;
- foreach (var pSegment in listSegments)
- {
- var paras = new SQLiteParameter[8];
- for (int j = 0; j < 8; j++)
- {
- paras[j] = new SQLiteParameter(parasTemplate[j].ParameterName);
-
- }
-
- paras[0].Value = a_pParticle.GetAnalysisId();
-
- paras[1].Value = a_pParticle.GetFieldId();
- paras[2].Value = nSegmentIndex;
- paras[3].Value = nSize;
- paras[4].Value = pSegment.GetStart();
- paras[5].Value = pSegment.GetHeight();
- paras[6].Value = pSegment.GetLength();
- paras[7].Value= a_pParticle.GetTagId();
-
- nSegmentIndex++;
- cmds.Add(new KeyValuePair<string, SQLiteParameter[]>(sInsertFormat.Key, paras));
- }
- return cmds;
- }
-
-
- public bool GetAllSegmentsRecord(Dictionary<string, List<COTSSegmentClr>> mapSegments)
- {
- var allRecords = this.GetQueryOfAllRecord();
- for (int i = 0; i < allRecords.Rows.Count; i++)
- {
- int curFldId = Convert.ToInt32(allRecords.Rows[i][(int)CSegmentTable.ColumnID.N_FIELD_ID]);
- int curParticleId = Convert.ToInt32(allRecords.Rows[i][(int)CSegmentTable.ColumnID.N_PARTICLE_ID]);
- string fldvec = "";
- fldvec+=curFldId.ToString();
- fldvec += "_";
- fldvec += curParticleId.ToString();
-
- if (mapSegments.ContainsKey(fldvec))
- {
- List<COTSSegmentClr> segments = mapSegments[fldvec];
- COTSSegmentClr segment = new COTSSegmentClr();
- segment.SetStart(Convert.ToInt32(allRecords.Rows[i][(int)CSegmentTable.ColumnID.N_START]));
- segment.SetHeight(Convert.ToInt32(allRecords.Rows[i][(int)CSegmentTable.ColumnID.N_HEIGHT]));
- segment.SetLength(Convert.ToInt32(allRecords.Rows[i][(int)CSegmentTable.ColumnID.N_LENGTH]));
-
- segments.Add(segment);
-
- }
- else
- {
-
- List<COTSSegmentClr> segments = new List<COTSSegmentClr>();
- COTSSegmentClr segment = new COTSSegmentClr();
- segment.SetStart(Convert.ToInt32(allRecords.Rows[i][(int)CSegmentTable.ColumnID.N_START]));
- segment.SetHeight(Convert.ToInt32(allRecords.Rows[i][(int)CSegmentTable.ColumnID.N_HEIGHT]));
- segment.SetLength(Convert.ToInt32(allRecords.Rows[i][(int)CSegmentTable.ColumnID.N_LENGTH]));
- segments.Add(segment);
- mapSegments.Add(fldvec, segments);
- }
-
- }
-
- return true;
- }
-
- public DataTable GetQueryOfAllRecord()
- {
- DataTable query;
- var datastorestr = GetDatastore();
-
- var tableInfoPtr = GetTableInfo();
- String sSQLCommand=String.Format("SELECT * FROM \'{0}\';", tableInfoPtr.GetTableName());
-
- query = datastorestr.QueryByCmdForDataTable(sSQLCommand);
-
-
-
- return query;
- }
- }
- }
|