protected virtual KeyValueObject GetKeyValueObjectFromReader(IDataReader reader) { EntityConverter <KeyValueObject> KeyValueEntity = new EntityConverter <KeyValueObject>(); KeyValueObject keyValueObject = KeyValueEntity.Convert(reader); return(keyValueObject); }
public bool?Analyze(string xaml) { var list = GetParameterList(xaml); this.xaml = xaml; if (list.Length > 0) { KeyValueList.Clear(); stackPanel.Children.Clear(); foreach (var item in list) { var i = new KeyValueObject() { Key = item, Value = string.Empty }; var dt = this.Resources["KeyValueRow"] as DataTemplate; var vt = dt.LoadContent() as FrameworkElement; vt.DataContext = i; stackPanel.Children.Add(vt); KeyValueList.Add(i); } return(this.ShowDialog()); } else { return(true); } }
public List <KeyValueObject> GetAppSettings() { List <KeyValueObject> list = new List <KeyValueObject>(); try { using (SqlCeConnection conn = new SqlCeConnection(connectionString)) { StringBuilder sql = new StringBuilder(); sql.Append("SELECT * FROM AppSettingsTable"); SqlCeCommand command = new SqlCeCommand(); command.Connection = conn; command.CommandText = sql.ToString(); conn.Open(); using (SqlCeDataReader reader = command.ExecuteReader()) { while (reader.Read()) { KeyValueObject temp = new KeyValueObject(); temp.Key = reader["Name"].ToString(); temp.Value = reader["Value"].ToString(); list.Add(temp); } } conn.Close(); } } catch (Exception) { } return(list); }
public KeyValueObject GetValue(string key) { KeyValueObject obj = null; try { using (SqlCeConnection conn = new SqlCeConnection(connectionString)) { StringBuilder sql = new StringBuilder(); sql.Append("SELECT * FROM ValuesTable WHERE Name='" + key + "'"); SqlCeCommand command = new SqlCeCommand(); command.Connection = conn; command.CommandText = sql.ToString(); conn.Open(); using (SqlCeDataReader reader = command.ExecuteReader()) { if (reader.Read()) { obj = new KeyValueObject(); obj.Key = key; obj.Value = reader["Value"].ToString(); } } conn.Close(); } } catch (Exception) { obj = null; } return(obj); }
public bool? Analyze(string xaml) { var list= GetParameterList(xaml); this.xaml = xaml; if (list.Length > 0) { KeyValueList.Clear(); stackPanel.Children.Clear(); foreach (var item in list) { var i = new KeyValueObject() { Key = item, Value = string.Empty }; var dt = this.Resources["KeyValueRow"] as DataTemplate; var vt = dt.LoadContent() as FrameworkElement; vt.DataContext = i; stackPanel.Children.Add(vt); KeyValueList.Add(i); } return this.ShowDialog(); } else { return true; } }
public DocumentModel() { Customers = new KeyValueObject[0]; DocumentDetails = new DocumentGridViewModel[0]; }
public override bool Work(int index) { try { switch (index) { //0 号线程 主进程是扫描任务加入到等待队列,不是主进程就处理任务。 case 0: { var mainProcessKey = "MainSevice-Process"; string lockKey = $"{mainProcessKey}-lock"; var isMain = false; //第一次进入时,判断当前是否存在主。 bool existMain = false; using (var dl = TestRedis.TestClient.AcquireLock(lockKey, new TimeSpan(0, 0, 0, 0, 1000))) { if (dl != null) { existMain = TestRedis.TestClient.ContainsKey(mainProcessKey); if (existMain) { KeyValueObject <string, DateTime> kvpMainFlag = TestRedis.TestClient.Get <KeyValueObject <string, DateTime> >(mainProcessKey); if (kvpMainFlag.Key.Equals(ServiceName)) { isMain = true; TestRedis.TestClient.Set(mainProcessKey, new KeyValueObject <string, DateTime>(ServiceName, DateTime.Now)); } else { if (kvpMainFlag.Value.AddMinutes(5d) < DateTime.Now) { isMain = true; TestRedis.TestClient.Set(mainProcessKey, new KeyValueObject <string, DateTime>(ServiceName, DateTime.Now)); } } } else { isMain = true; TestRedis.TestClient.Set(mainProcessKey, new KeyValueObject <string, DateTime>(ServiceName, DateTime.Now)); } } else { LogUtilities.WriteLine("获取锁失败!!!"); } } TestQueueService testQueueService = new TestQueueService(); if (isMain) { testQueueService.ScanQueue(); LogUtilities.WriteLog("加入等待队列完毕"); //ScanProcess //加入到等待队列 } else { testQueueService.StartToQueueProcess(TestRedis.TestClient); LogUtilities.WriteLog("处理任务完毕"); //处理任务 } break; } default: { TestQueueService testQueueService = new TestQueueService(); testQueueService.StartToQueueProcess(TestRedis.TestClient); } break; } } catch (Exception ex) { LogUtilities.WriteException(ex); } return(base.Work(index)); }