public Table SelectRecords(FilterExpressionGroup filter, string[] fieldList, string[] orderByList) { int length; FwNs.Data.FyleDbNs.Fields fields = new FwNs.Data.FyleDbNs.Fields(this._fields.Count); if (fieldList != null) { length = fieldList.Length; for (int i = 0; i < length; i++) { string fieldName = fieldList[i]; if (!this._fields.ContainsKey(fieldName)) { throw new Exception(string.Format("Invalid field name - {0}", fieldName)); } Field field = this._fields[fieldName]; fields.Add(new Field(fieldName, field.DataType, i)); } } else { length = this._fields.Count; for (int i = 0; i < length; i++) { Field field2 = this._fields[i]; fields.Add(new Field(field2.Name, field2.DataType, i)); } } Records records = new Records(Math.Min(10, base.Count)); foreach (Record record in this) { if (FileDbEngine.evaluate(filter, record.Values.ToArray(), this._fields)) { object[] values = new object[length]; if (fieldList != null) { for (int i = 0; i < length; i++) { string str2 = fieldList[i]; values[i] = record[str2]; } } else { for (int i = 0; i < length; i++) { values[i] = record[i]; } } Record item = new Record(fields, values); records.Add(item); } } if (orderByList != null) { this.orderBy(records, fieldList, orderByList); } return(new Table(fields, records, false)); }
public NxPriceMgr(RobotFactory factory,UnityContainer container) { this.container = container; this.container.RegisterInstance(container); this.factory = factory; this.dbEngine = new FileDbEngine<FileDb> (); }
private void orderBy(Records records, string[] fieldList, string[] orderByList) { List <Field> sortFields = new List <Field>(orderByList.Length); List <bool> sortDirLst = new List <bool>(orderByList.Length); List <bool> caseLst = new List <bool>(orderByList.Length); FileDbEngine.GetOrderByLists(this._fields, fieldList, orderByList, sortFields, sortDirLst, caseLst); records.Sort(new RecordComparer(sortFields, sortDirLst, caseLst)); }
private void FileWatcherOnFileCreated(object sender, FileSystemEventArgs e) { if (e.FullPath.Contains(".temp")) return; string temp = e.FullPath + ".temp"; try { if(File.Exists(temp)) File.Delete(temp); File.Copy(e.FullPath, temp); }catch{} try { FileDbEngine<ExchangeDataContainer> exContainerEngine = new FileDbEngine<ExchangeDataContainer>(temp); this.container = exContainerEngine.LoadFileDB(); } catch { MessageBox.Show("load failed."); } this.Invoke((MethodInvoker)(() => { if (this.cbIgnoreRefresh.Checked) return; try { this.dataGridView1.DataSource = container.FisrtList; this.dataGridView2.DataSource = container.SecondList; this.tbProductId.Text = container.FisrtList.First().ProductionID; this.webBrowser1.Navigate("https://zhaocaibao.alipay.com/pf/purchase.htm?productId=" + this.tbProductId.Text); File.Delete(e.FullPath); File.Delete(temp); } catch { } })); }
public int Compare(Record x, Record y) { if ((x == null) || (y == null)) { return(0); } for (int i = 0; i < this._fieldLst.Count; i++) { Field field = this._fieldLst[i]; bool caseInsensitive = this._caseLst[i]; object obj2 = y[field.Ordinal]; int num3 = FileDbEngine.CompareVals(x[field.Ordinal], obj2, field.DataType, caseInsensitive); if (this._sortDirLst[i]) { num3 = -num3; } if (num3 != 0) { return(num3); } } return(0); }
private void ExportListToBuyUi(ExchangeDataContainer exContaienr) { string dirExchange = DirectoryHelper.CombineWithCurrentExeDir("ZcbListExchange"); if (!Directory.Exists(dirExchange)) Directory.CreateDirectory(dirExchange); string filePath = Path.Combine(dirExchange, "list.xml"); FileInfo file = new FileInfo(filePath); if (file.Exists) file.Delete(); var dbEngine = new FileDbEngine<ExchangeDataContainer>(filePath); dbEngine.SetDB(exContaienr); dbEngine.Save(false); }
private void btnLoad_Click(object sender, EventArgs e) { try { string filePath = DirectoryHelper.CombineWithCurrentExeDir("ZcbListExchange\\list.xml"); FileDbEngine<ExchangeDataContainer> exContainerEngine = new FileDbEngine<ExchangeDataContainer>(filePath); this.container = exContainerEngine.LoadFileDB(); this.dataGridView1.DataSource = container.FisrtList; this.dataGridView2.DataSource = container.SecondList; var first = container.FisrtList.FirstOrDefault(); if (first != null) { this.tbProductId.Text = container.FisrtList.First().ProductionID; this.webBrowser1.Navigate("https://zhaocaibao.alipay.com/pf/purchase.htm?productId=" + this.tbProductId.Text); } } catch { } }