public void DoSaveToFile(object source, ElapsedEventArgs e) { try { string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); if (plotScope.PlotObjects[2].Index == 0) { return; } string filename = string.Format("{0:yyyyMMdd_HHmmss}_{1:X4}_{2:X2}.csv", datenow, plotScope.PlotObjects[2].Index, plotScope.PlotObjects[2].Subindex, CultureInfo.CurrentCulture); path = path + @"\Saves\" + filename; if (plotScope.PlotObjects[2].Index != 0) { DictItem item = device.ObjectDictionary.GetItem(plotScope.PlotObjects[2].Index, plotScope.PlotObjects[2].Subindex); WriteCSV(new CsvWriteItem { TimeStamp = (Math.Round(Convert.ToDouble(item.TimeStamp) / 1000.0, 0) - Convert.ToUInt32(_x_0)), Value = item.Value }, path); } } catch (Exception err) { saveTimer.Stop(); MessageBox.Show(err.ToString()); MessageBox.Show("Something went wrong and saving process has been stopped. If you think the issue has been solved, stop and start the scope again."); } }
/// <summary> /// 基础数据子项编辑-保存 /// Created:20170324(ChengMengjia) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveItem_Click(object sender, EventArgs e) { DictItem item = new DictItem(); item.ID = txtItemName.Tag == null ? "" : txtItemName.Tag.ToString().Trim(); item.Name = txtItemName.Text.Trim(); item.DictNo = _dictNo.Trim(); item.Remark = txtItemRemark.Text.Trim(); #region 判断空 if (string.IsNullOrEmpty(item.DictNo)) { MessageHelper.ShowMsg(MessageID.W000000002, MessageType.Alert, "数据项"); return; } if (string.IsNullOrEmpty(item.Name)) { MessageHelper.ShowMsg(MessageID.W000000001, MessageType.Alert, "内容"); return; } #endregion JsonResult result = bll.SaveItem(item); if (result.result) { btnClearItem_Click(sender, e); List <DictItem> listD = bll.GetDictItems((DictCategory)int.Parse(item.DictNo)); gridDictItem.PrimaryGrid.DataSource = listD; } else { MessageBox.Show(result.msg); } }
void LoadItems(string itemFile) { if (itemFile != null && itemFile != "") { using (StreamReader sr = new StreamReader(itemFile)) { // read const tableConst = TableReader.ItemConst_Read(sr.ReadLine); } editAbillR = new DicAbilityRate(tableConst.abillR); using (StreamReader sr = new StreamReader(itemFile)) { // read item tItemDict = TableReader.DictItem_Read(sr.ReadLine); } } int k = itemFile.IndexOf("Assets/"); if (k > 0) { itemFile = itemFile.Substring(k, itemFile.Length - k); } itemAsset = (TextAsset)AssetDatabase.LoadAssetAtPath(itemFile, typeof(TextAsset)); }
public void TestReadValues() { DictItem di = new DictItem(); di.Read("mismatch=несоответствие/несовпадение=choice;0;0#write;0;0#line;0;0"); Assert.AreEqual(2, di.ValuesCount); }
public void TestRemoveFisdItem() { var tempConnection = DataBaseLink.Fabricate.CreateConnection(_connection, ConnectionType.Npgsql); DbLink dbLink = new DbLink(tempConnection); //создать финансовый инструмент fin_instrument fin_instrument = new fin_instrument("roman", 13, "bushuev"); if (FinInstrument.FindId(dbLink, fin_instrument.ident) == null) { FinInstrument.Insert(dbLink, fin_instrument); } var resultFI = FinInstrument.FindId(dbLink, fin_instrument.ident); //ffd ffd ffd = new ffd() { ds_id = 17, fi_id = resultFI.fi_id, fif_id = 8, }; if (FFD.Find(dbLink, resultFI.fi_id, ffd.ds_id, ffd.fif_id) == null) { FFD.Insert(dbLink, ffd); } var ffdResult = FFD.Find(dbLink, resultFI.fi_id, ffd.ds_id, ffd.fif_id); //dict_item dict_item dict_item = new dict_item() { fif_id = 8, key_v = "RUB", }; var resultDictItem = DictItem.FindId(dbLink, dict_item.key_v, dict_item.fif_id); //fisd_item fisd_item fisd_item = new fisd_item() { dat_from = new DateTime(2017, 08, 05), fisd_id = ffdResult.fisd_id, val = resultDictItem.key_v }; if (FisdItem.FindId(dbLink, fisd_item.fisd_id, fisd_item.dat_from) == null) { FisdItem.Insert(dbLink, fisd_item); var one = FisdItem.FindId(dbLink, fisd_item.fisd_id, fisd_item.dat_from); FisdItem.Remove(dbLink, one.fisd_id, one.dat_from); } else { var one = FisdItem.FindId(dbLink, fisd_item.fisd_id, fisd_item.dat_from); FisdItem.Remove(dbLink, one.fisd_id, one.dat_from); } }
public DictItemOutputDto GetForm(string keyValue) { long id = Convert.ToInt64(keyValue); DictItemOutputDto dictItemOutputDto = new DictItemOutputDto(); DictItem dict = dictItemRepository.Get(id); AutoMapper.Mapper.Map <DictItem, DictItemOutputDto>(dict, dictItemOutputDto); return(dictItemOutputDto); }
/// <summary> /// Definition of the AsyncRead funcion for the SOEM functionality. /// It takes the slave number to communicate to, the index, and subindex of an object /// and it will call the respective needed low level SDO function to read the value of the object. /// The return value will be set on the value of the object dictionary /// </summary> /// <param name="slave_number">number of position of the slave to address</param> /// <param name="index">index of the object to read</param> /// <param name="subindex">subindex of the object to read</param> public override void AsyncRead(int slave_number, ushort index, byte subindex) { try { DictItem item = MW.ObjectDictionary.GetItem(index, subindex); switch (item.Type) { case "SINT": lock (comm_locker) item.Value = SdoReadInt8(slave_number, index, subindex); break; case "BOOL": case "USINT": lock (comm_locker) item.Value = SdoReadUInt8(slave_number, index, subindex); break; case "INT": lock (comm_locker) item.Value = SdoReadInt16(slave_number, index, subindex); break; case "UINT": lock (comm_locker) item.Value = SdoReadUInt16(slave_number, index, subindex); break; case "DINT": lock (comm_locker) item.Value = SdoReadInt32(slave_number, index, subindex); break; case "UDINT": lock (comm_locker) item.Value = SdoReadUInt32(slave_number, index, subindex); break; case "STRING": byte[] buf = new byte[item.Length]; lock (comm_locker) SdoReadString(slave_number, index, subindex, buf, item.Length); item.Value = buf; break; default: throw new NotImplementedException(); } DictionaryBuilder.FormatDisplayString(item); /* formats the display string of the value (dec, bin, hex) */ item.TimeStamp = Convert.ToUInt32(stopwatch.ElapsedMilliseconds); } catch (Exception err) { MessageBox.Show(err.ToString()); } }
public void CreateTest() { var doc = Doc.New(); Assert.IsFalse(doc.CanRedo); Assert.IsFalse(doc.CanUndo); doc = DictItem.Create(doc, out var dictID); var dict = doc.Item <DictItem>(dictID); }
public void DeleteForm(string keyValue) { var id = Convert.ToInt64(keyValue); DictItem dictItem = dictItemRepository.Get(id); dictItem.DeletedMark = true; dictItem.DeletionTime = DateTime.Now; dictItemRepository.Update(dictItem); }
public void GetDictItem(ref DictItem item) { if (item == null) { return; } if (string.IsNullOrEmpty(item.itemId)) { } }
protected void btnUserImport_Click(object sender, EventArgs e) { string fileName = this.fileXls.FileName; if (string.IsNullOrEmpty(fileName) || this.fileXls.PostedFile.ContentLength == 0) { this.Alert("请选择导入的文件!"); return; } //将文件流读取到内存 var hpf = this.fileXls.PostedFile; Workbook workbook = new Workbook(hpf.InputStream); DictItemBus dbus = new DictItemBus(); Cells cells = workbook.Worksheets[0].Cells; for (int i = 1; i <= cells.MaxDataRow; i++) //行 { DictItem item = new DictItem(); for (int j = 1; j <= cells.MaxDataColumn; j++) //单元格 //获取单元格的值 { switch (j) { case 1: item.Name = cells[i, j].StringValue.Trim(); break; case 2: item.Code = cells[i, j].StringValue.Trim(); break; case 3: item.Value = cells[i, j].StringValue.Trim(); break; case 4: item.Memo = cells[i, j].StringValue.Trim(); break; //case 5: item.OrderBy = cells[i, j].IntValue; break; } if (string.IsNullOrEmpty(item.Value)) { item.Value = item.Name; } } item.CreateDate = DateTime.Now; item.GroupCode = this.ddlDictGroup.SelectedValue; item.Creator = this.CurrentUserName; item.IsEnabled = 1; if (!string.IsNullOrEmpty(item.Name) && !string.IsNullOrEmpty(item.Code) && !string.IsNullOrEmpty(item.Value)) { if (!dbus.Update(item, "Name='" + item.Name + "'")) { dbus.Insert(item); } } } this.Alert("导入成功!"); BindData(); }
private static DictItem GetExtendPropertiesOfItem(DictItem item) { if (item == null) { return(new DictItem()); } int subItemCount = 0; DictItemService.itemGateway.GetDictItemsBy(item.ItemID, "", false, 0, 0, out subItemCount); item.SubItemCount = subItemCount; return(item); }
public mainForm() { InitializeComponent(); yd = new YandexDict(); usingLetters = new Stack <Button>(); storage = new Storage(); int max = storage.LongCount(); LongWord = storage.GetLongWord(max); }
private void AddItem(DictItem item) { var check = new CheckBox(this.Ace); check.Id = $"{Id}_{Items.Count}"; check.Type = Type; check.Text = item.text; check.Value = item.value; check.Group = Id; check.Checked = Value.HasValue() && Value.Split(',').Contains(item.value); Events.Each(e => check.Events.Add(e)); Items.Add(check); }
private void BoundDictItem(DictItem dictItem,TreeListNode nodeParent) { if (dictItem == null) return; TreeListNode nodeItem= tlDictionary.AppendNode(new object[] { dictItem.Name, dictItem.Code }, nodeParent, dictItem); if (dictItem.SubItems != null) { foreach (DictItem diSub in dictItem.SubItems) { BoundDictItem(diSub, nodeItem); } } }
public KeyValuePair <K, V>[] Add(K key, V value) { KeyValuePair <K, V>[] rm = null; lock (this) { DoubleLinkedListNode <K> v = _queue.AddHead(key); //O(1) _dict[key] = new DictItem() { Node = v, Value = value }; //O(1) rm = checkAndTruncate(); } return(rm); }
public override void AsyncWrite(int slave_number, ushort index, byte subindex, object value) { try { DictItem item = MW.ObjectDictionary.GetItem(index, subindex); var len = Math.Max(item.Length, 4); byte[] buf = new byte[len]; switch (item.Type) { case "SINT": BitConverter.GetBytes((sbyte)value).CopyTo(buf, 0); break; case "BOOL": case "USINT": BitConverter.GetBytes((byte)value).CopyTo(buf, 0); break; case "INT": BitConverter.GetBytes((short)value).CopyTo(buf, 0); break; case "UINT": BitConverter.GetBytes((ushort)value).CopyTo(buf, 0); break; case "DINT": BitConverter.GetBytes((int)value).CopyTo(buf, 0); break; case "UDINT": BitConverter.GetBytes((uint)value).CopyTo(buf, 0); break; case "STRING": ((byte[])value).CopyTo(buf, 0); break; default: throw new NotImplementedException(); } FillServiceBuffer(CMD.sdo_W, index, subindex, buf); } catch (Exception err) { MessageBox.Show(err.ToString()); } }
public void AddWord() { WordEditForm wef = new WordEditForm(); wef.SetEditMode(EditMode.Append); if (wef.ShowDialog() == DialogResult.OK) { DictItem di = new DictItem(); di.Caption = wef.Caption; di.ReadValues(wef.Values); WordSet.Instance().Add(di); listView.Items.Add(new ListViewItem(di.Caption)); } }
public static Province GetProvinceByID(string provinceID) { DictItem dictItemByID = DictItemService.GetDictItemByID(provinceID); if (dictItemByID != null) { return(new Province { ProvinceID = dictItemByID.ItemID, ProvinceName = dictItemByID.Title, Sequence = dictItemByID.Sequence }); } return(null); }
public void RemoveTest() { var doc = Doc.New(); doc = DictItem.Create(doc, out var dictID); var dict = doc.Item <DictItem>(dictID); doc = StringItem.Create(doc, out var stringID, "abc"); dict = doc.Item <DictItem>(dictID); doc = DictItem.Set(doc, dict, "Foo", stringID); dict = doc.Item <DictItem>(dictID); doc = DictItem.Remove(doc, "Foo", dict); dict = doc.Item <DictItem>(dictID); Assert.IsFalse(dict.ContainsKey("Foo")); }
void EditConstRateAllItem() { DictItem newDic = new DictItem(); foreach (var pair in tItemDict) { TableItem newitem = EditConstAuto(pair.Value); newDic[pair.Key] = newitem; } tItemDict = newDic; tableConst.abillR = new DicAbilityRate(editAbillR); ReadyNowList(); }
public void EditWord() { WordEditForm wef = new WordEditForm(); wef.SetEditMode(EditMode.Update); wef.Caption = WordSet.Instance().CurrentItem.Caption; wef.AddValues(WordSet.Instance().CurrentItem.Values); if (wef.ShowDialog() == DialogResult.OK) { DictItem di = new DictItem(); di.Caption = wef.Caption; di.UpdateValues(wef.Values); WordSet.Instance().Update(di); } }
public static City GetCityByID(string cityID) { DictItem dictItemByID = DictItemService.GetDictItemByID(cityID); if (dictItemByID != null) { return(new City { CityID = dictItemByID.ItemID, CityName = dictItemByID.Title, ProvinceID = dictItemByID.ParentItemID, Sequence = dictItemByID.Sequence }); } return(null); }
/// <summary> /// 数据项子项的新增或修改 /// Created:2017.03.28(ChengMengjia) /// </summary> /// <param name="item"></param> /// <returns></returns> public JsonResult SaveItem(DictItem item) { JsonResult jsonreslut = new JsonResult(); try { List <QueryField> qf = new List <QueryField>(); qf.Add(new QueryField() { Name = "DictNo", Type = QueryFieldType.String, Value = item.DictNo }); SortField sf = new SortField() { Name = "No", Direction = SortDirection.Asc }; List <DictItem> listOld = new Repository <DictItem>().GetList(qf, sf) as List <DictItem>; if (listOld.Where(t => t.Name.Equals(item.Name)).Count() > 0) { jsonreslut.result = false; jsonreslut.msg = "内容重复,请修改!"; } else { if (string.IsNullOrEmpty(item.ID)) { item.No = (listOld.Count() + 1).ToString(); new Repository <DictItem>().Insert(item); } else { DictItem old = new Repository <DictItem>().Get(item.ID); old.Name = item.Name; old.Remark = item.Remark; new Repository <DictItem>().Update(old); } jsonreslut.result = true; jsonreslut.msg = "保存成功!"; } } catch (Exception ex) { LogHelper.WriteException(ex, LogType.BussinessDLL); jsonreslut.result = false; jsonreslut.msg = ex.Message; } return(jsonreslut); }
private void BoundDictItem(DictItem dictItem, TreeListNode nodeParent) { if (dictItem == null) { return; } TreeListNode nodeItem = tlDictionary.AppendNode(new object[] { dictItem.Name, dictItem.Code }, nodeParent, dictItem); if (dictItem.SubItems != null) { foreach (DictItem diSub in dictItem.SubItems) { BoundDictItem(diSub, nodeItem); } } }
public void TestInsertDictItem() { var tempConnection = DataBaseLink.Fabricate.CreateConnection(_connection, DataBaseLink.ConnectionType.Npgsql); DataBaseLink.DbLink dbLink = new DbLink(tempConnection); dict_item dict_item = new dict_item() { fif_id = 8, key_v = "RUB_roman", val = "RUB_roman", }; if (DictItem.FindId(dbLink, dict_item.key_v, dict_item.fif_id) == null) { DictItem.Insert(dbLink, dict_item); } }
// model weight void EditConstWeightAllItem() { DictItem newDic = new DictItem(); foreach (var pair in tItemDict) { TableItem item = pair.Value; int model = item.itemID / 100; if (tableConst.modelW.ContainsKey(model)) { item.capBody = tableConst.modelW[model]; } newDic[pair.Key] = item; } tItemDict = newDic; ReadyNowList(); }
private void SaveNode(TreeListNode nodeItem) { SendMessage(string.Format("正在保存第{0}个字典项...", ++m_SaveIndex)); DictItem dItem = CollectItem(nodeItem); if (dItem != null) { DictHelper.SaveItem(dItem); //if (dItem.Parent != null) //{ // DictHelper.ReLoadItem(dItem.Parent); //} } foreach (TreeListNode nodeSub in nodeItem.Nodes) { SaveNode(nodeSub); } }
DictItem SortItemDict(DictItem itemdic) { List <TableItem> list = new List <TableItem>(); foreach (var pair in tItemDict) { list.Add(pair.Value); } list.Sort(Compare); DictItem dic = new DictItem(); foreach (TableItem item in list) { dic.Add(item.itemID, item); } return(dic); }
public void SubmitForm(DictItemInputDto dictItemInputDto, string keyValue) { DictItem dictItem = new DictItem(); if (!string.IsNullOrEmpty(keyValue)) { var id = Convert.ToInt64(keyValue); dictItem = dictItemRepository.Get(id); AutoMapper.Mapper.Map <DictItemInputDto, DictItem>(dictItemInputDto, dictItem); dictItemRepository.Update(dictItem); } else { AutoMapper.Mapper.Map <DictItemInputDto, DictItem>(dictItemInputDto, dictItem); dictItem.Id = IdWorkerHelper.GenId64(); dictItem.CreationTime = DateTime.Now; dictItem.CreatorUserId = 1; dictItemRepository.Add(dictItem); } }
private void lsvWord_AfterLabelEdit(object sender, LabelEditEventArgs e) { if (e.Label == null) { //表示没有进行修改 this.lsvWord.Items.Remove(this.lsvWord.Items[e.Item]); this.lsvWord.LabelEdit = false; return; } if (e.Label.ToString().Trim() == "") { e.CancelEdit = true; this.lsvWord.Items.Remove(this.lsvWord.Items[e.Item]); this.lsvWord.LabelEdit = false; return; } Dict dictEntity = dictList.Where(q => q.CategoryName.Value == SelectNodeText).FirstOrDefault(); if (dictEntity == null) { WinFormLib.Core.MessageBoxHelper.ShowError("请先选择字典分类!"); return; } if (!string.IsNullOrEmpty(SelectListViewText)) { DictItem dictItemEntity = dictEntity.DictItemList.Where(q => q.DictName.Value == SelectListViewText).FirstOrDefault(); if (dictItemEntity != null) { dictItemEntity.DictName = CDataItem.Instance(e.Label.Trim()); } } else { dictEntity.DictItemList.Add(new DictItem() { DictName = CDataItem.Instance(e.Label.Trim()) }); } SelectListViewText = string.Empty; }
/// <summary> /// 删除字典项 /// </summary> /// <param name="dItem"></param> /// <returns></returns> public static bool DeleteItem(DictItem dItem) { try { //if (dItem.Parent != null) // dItem.Parent.SubItems.Remove(dItem); Environment.NhibernateHelper.DeleteObject(dItem); Environment.NhibernateHelper.Flush(); if (dItem.Parent != null) ReLoadItem(dItem.Parent); return true; } catch(Exception exp) { Environment.Logger.AppendMessage(Define.enumLogType.Error, string.Format("删除字典时出错:{0}", exp.ToString())); return false; } }
public static void ReLoadItem(DictItem dItem) { Environment.NhibernateHelper.RefreshObject(dItem, Define.enumLockMode.UpgradeNoWait); }
public int Add(object a) { var s = a as string; if (a == null) { throw new ArgumentException ("object should be an string"); } var arr = s.Split ('\t'); if (arr.Length == 1) { var item = new DictItem (null, s, null, null); this.Items.Add (item); } else { var item = new DictItem (arr [0], arr [1], arr [2], arr [3]); this.Items.Add (item); } return this.Items.Count - 1; }
private DictItem CollectItem(TreeListNode nodeItem) { if(nodeItem ==null) return null; DictItem dItem = nodeItem.Tag as DictItem; if (dItem==null) { dItem=new DictItem(); } dItem.Name=nodeItem.GetValue(tlColName) as string; dItem.Code=nodeItem.GetValue(tlColCode) as string; dItem.Parent = nodeItem.ParentNode == null ? null : nodeItem.ParentNode.Tag as DictItem; nodeItem.Tag = dItem; return dItem; }