/// <summary> /// Items will be added only if the "Add" method was found, which exactly 2 parameters (key, value) has /// </summary> /// <param name="property"></param> /// <returns></returns> private object CreateObjectFromDictionaryProperty(DictionaryProperty property) { var dictionary = Tools.CreateInstance(property.Type); if (property.Reference != null) { _objectCache.Add(property.Reference.Id, dictionary); } // fill the properties FillProperties(dictionary, property.Properties); // fill items, but only if Add(key, value) was found var methodInfo = dictionary.GetType().GetMethod("Add"); var parameters = methodInfo?.GetParameters(); if (parameters?.Length == 2) { foreach (var item in property.Items) { var keyValue = CreateObject(item.Key); var valueValue = CreateObject(item.Value); methodInfo.Invoke(dictionary, new[] { keyValue, valueValue }); } } return(dictionary); }
/// <summary> /// 保存节点属性 /// </summary> /// <param name="dp">属性</param> public void SaveDictionaryProperty(DictionaryProperty dp) { using (var dbContext = new StoreDbContext()) { dbContext.Insert <DictionaryProperty>(dp); } }
/// <summary> /// Gets the connect time property. /// </summary> /// <param name="name">The name.</param> /// <returns></returns> public DictionaryProperty GetConnectTimeProperty(string name) { if (this.State != FdoConnectionState.Open && this.State != FdoConnectionState.Pending) { throw new InvalidOperationException(Res.GetString("ERR_CONNECTION_NOT_OPEN")); } IConnectionPropertyDictionary dict = this.InternalConnection.ConnectionInfo.ConnectionProperties; bool enumerable = dict.IsPropertyEnumerable(name); DictionaryProperty dp = null; if (enumerable) { EnumerableDictionaryProperty ep = new EnumerableDictionaryProperty(); ep.Values = dict.EnumeratePropertyValues(name); dp = ep; } else { dp = new DictionaryProperty(); } dp.Name = name; dp.LocalizedName = dict.GetLocalizedName(name); dp.DefaultValue = dict.GetPropertyDefault(name); dp.Protected = dict.IsPropertyProtected(name); dp.Required = dict.IsPropertyRequired(name); return(dp); }
/// <summary> /// Items will be added only if the "Add" method was found, which exactly 2 parameters (key, value) has /// </summary> /// <param name = "property"></param> /// <returns></returns> private object createObjectFromDictionaryProperty(DictionaryProperty property) { object dictionary = Tools.CreateInstance(property.Type); if (property.Reference != null) { // property has Reference, only objects referenced multiple times // have properties with references. Object must be cached to // resolve its references in the future. _objectCache.Add(property.Reference.Id, dictionary); } // fill the properties fillProperties(dictionary, property.Properties); // fill items, but only if Add(key, value) was found MethodInfo methodInfo = dictionary.GetType().GetMethod("Add"); if (methodInfo != null) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 2) { foreach (KeyValueItem item in property.Items) { object keyValue = CreateObject(item.Key); object valueValue = CreateObject(item.Value); methodInfo.Invoke(dictionary, new[] { keyValue, valueValue }); } } } return(dictionary); }
public void AddConnectProperty(DictionaryProperty p) { DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell nameCell = new DataGridViewTextBoxCell(); nameCell.Value = p.LocalizedName; DataGridViewTextBoxCell valueCell = new DataGridViewTextBoxCell(); if (p.IsFile || p.IsPath) { valueCell.ContextMenuStrip = ctxHelper; valueCell.ToolTipText = "Right click for helpful options"; } valueCell.Value = p.DefaultValue; row.Cells.Add(nameCell); row.Cells.Add(valueCell); grdConnectionProperties.Rows.Add(row); if (p.Protected) { pwdCells.Add(valueCell); } }
public ActionResult InBoundEdit(FormCollection collection) { var model = new StoreTable(); //this.TryUpdateModel<StoreTable>(model); InBoundRecord ibr = new InBoundRecord(); if (collection.AllKeys.Contains("DictionaryProperty.dpid")) { Guid proid = new Guid(collection["clID"]); int temp = 0; if (!int.TryParse(collection["InBoundCount"], out temp)) { ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); return(PartialView()); } model.number = int.Parse(collection["InBoundCount"]); DictionaryProperty dp = this.StoreService.GetDicProperty(proid, collection["Materialnames"]); model.store_item_id = dp.dpid; //插入数据到入库记录表 ibr.inbound_id = dp.dpid; ibr.rkid = Guid.NewGuid(); ibr.number = model.number; ibr.boundtype = "入库"; ibr.khmc = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value); this.StoreService.InsertInboundRecord(ibr); ///入库 this.StoreService.InsertStoreItem(model); } return(this.RefreshParent()); }
public PartialViewResult AddProperty(StoreTreeNameRequests request, FormCollection collection) { var model = new DictionaryProperty(); this.TryUpdateModel <DictionaryProperty>(model); string id = null; if (this.TempData.ContainsKey("treeid")) { id = this.TempData["treeid"].ToString(); //TempData.Remove("treeid"); request.treeID = new Guid(id.ToString()); } if (id != null) { Guid treeid = new Guid(id); Guid keyid = Guid.NewGuid(); model.leaf_id = treeid; model.dpid = keyid; } this.StoreService.SaveDictionaryProperty(model); //Dictionary<string, string> dp = new Dictionary<string, string>(); //dp.Add("clmc", model.clmc); //dp.Add("pm", model.pm); //dp.Add("mf", model.mf); //dp.Add("js", model.js); request.PageSize = 500; var result = this.StoreService.GetNodeProperty(request); return(PartialView("_DPropertyPartialPage", result)); }
/// <summary> /// 保存属性编辑数据 /// </summary> /// <param name="dp">字典属性</param> public void SaveEditProperty(DictionaryProperty dp) { using (var dbContext = new StoreDbContext()) { dbContext.Update <DictionaryProperty>(dp); } }
/// <summary> /// 根据属性ID获取单个属性 /// </summary> /// <param name="id"></param> /// <returns></returns> public DictionaryProperty GetDicProperty(Guid id, string name) { using (var dbContext = new StoreDbContext()) { DictionaryProperty dp = dbContext.DictionaryProperty.Where(u => u.dpid == id).FirstOrDefault(); return(dp); } }
public WellKh(Borehole SelectedWell, Property SelectedPermeability, DictionaryProperty SelectedZoneIndex) { this.permeability = SelectedPermeability; this.well = SelectedWell; this.ZoneIndex = SelectedZoneIndex; this.root = ColorTableRoot.Get(PetrelProject.PrimaryProject); this.ListOfNamesOfIntersectedZones = new List<string>(); this.KhWellTesting = -1; }
public ActionResult Create() { var model = new DictionaryProperty(); if (this.TempData.ContainsKey("treeid")) { } model.dpid = new Guid("00000000-0000-0000-0000-000000000000"); return(View("Edit", model)); }
/// <summary> /// 点击编辑按钮 /// </summary> /// <param name="id">树节点ID</param> /// <returns>返回所选节点属性</returns> public ActionResult Edit(string id) { var model = new DictionaryProperty(); if (id != null || id != "") { Guid treeid = new Guid(id); model = this.StoreService.GetDictionaryProperty(treeid); } return(View("Edit", model)); }
private void parseDictionaryProperty(DictionaryProperty property) { // expected key type property.KeyType = this._reader.ReadType(); // expected value type property.ValueType = this._reader.ReadType(); // Properties this.readProperties(property.Properties, property.Type); // Items this.readDictionaryItems(property.Items, property.KeyType, property.ValueType); }
private void backgroundLoading_DoWork(object sender, DoWorkEventArgs e) { DictionaryProperty property = (DictionaryProperty)e.Argument; foreach (Language language in property.Languages) { foreach (SpellDictionary d in property.Dictionaries.Items.Where(x => x.Locale == language.DictionaryLocale)) { d.Load(); } } property.Dictionaries.Loaded = true; }
private bool FillDictionaryProperty(DictionaryProperty property, InternalTypeInfo info, object value) { if (property == null) { return(false); } // Properties ParseProperties(property, info, value); // Items ParseDictionaryItems(property, info, value); return(true); }
public StoreTable ExistDPInStore(DictionaryProperty dp) { using (var dbContext = new StoreDbContext()) { var StoreItem = dbContext.StoreTable.Include("DictionaryProperty").Where(u => u.store_item_id.Value == dp.dpid).FirstOrDefault(); if (StoreItem == null) { return(null);//库存里不存在的数据为false } else { return(StoreItem); } } }
private bool fillDictionaryProperty(DictionaryProperty property, TypeInfo info, object value) { if (property == null) { return(false); } // Properties this.parseProperties(property, info, value); // Items this.parseDictionaryItems(property, info, value); return(true); }
private void ParseDictionaryItems(DictionaryProperty property, InternalTypeInfo info, object value) { property.KeyType = info.KeyType; property.ValueType = info.ElementType; var dictionary = (IDictionary)value; foreach (DictionaryEntry entry in dictionary) { var keyProperty = CreateProperty(null, entry.Key); var valueProperty = CreateProperty(null, entry.Value); property.Items.Add(new KeyValueItem(keyProperty, valueProperty)); } }
/// <summary> /// 初始化修改库房数量 /// </summary> /// <returns></returns> public ActionResult StoreEdit(string id) { StoreTable st = this.StoreService.GetStoreItem(new Guid(id)); DictionaryProperty dp = this.StoreService.GetDictionaryProperty(st.store_item_id.Value); string leafname = this.StoreService.GetTreeName(dp.leaf_id.Value); string parentname = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value); StoreWindowModel swm = new StoreWindowModel(); swm.clmc = dp.clmc; swm.ddlx = leafname; swm.khmc = parentname; swm.pm = dp.pm; swm.mf = dp.mf; swm.js = dp.js.ToString(); swm.number = st.number.Value.ToString(); return(View("StoreEdit", swm)); }
private void parseDictionaryProperty(DictionaryProperty property) { if (property.Type != null) { var typeInfo = TypeInfo.GetTypeInfo(property.Type); property.KeyType = typeInfo.KeyType; property.ValueType = typeInfo.ElementType; } foreach (string subElement in _reader.ReadSubElements()) { if (subElement == SubElements.Properties) { // Properties readProperties(property.Properties, property.Type); continue; } if (subElement == SubElements.Items) { // Items readDictionaryItems(property.Items, property.KeyType, property.ValueType); } } }
/// <summary> /// Items will be added only if the "Add" method was found, which exactly 2 parameters (key, value) has /// </summary> /// <param name="property"></param> /// <returns></returns> private object createObjectFromDictionaryProperty(DictionaryProperty property) { var dictionary = Tools.CreateInstance(property.Type); // fill the properties fillProperties(dictionary, property.Properties); // fill items, but only if Add(key, value) was found var methodInfo = dictionary.GetType().GetMethod("Add"); if (methodInfo != null) { var parameters = methodInfo.GetParameters(); if (parameters.Length == 2) { foreach (var item in property.Items) { var keyValue = CreateObject(item.Key); var valueValue = CreateObject(item.Value); methodInfo.Invoke(dictionary, new[] { keyValue, valueValue }); } } } return dictionary; }
/// <summary> /// Items will be added only if the "Add" method was found, which exactly 2 parameters (key, value) has /// </summary> /// <param name = "property"></param> /// <returns></returns> private object createObjectFromDictionaryProperty(DictionaryProperty property) { object dictionary = Tools.CreateInstance(property.Type); if (property.Reference != null) { // property has Reference, only objects referenced multiple times // have properties with references. Object must be cached to // resolve its references in the future. _objectCache.Add(property.Reference.Id, dictionary); } // fill the properties fillProperties(dictionary, property.Properties); // fill items, but only if Add(key, value) was found MethodInfo methodInfo = dictionary.GetType().GetMethod("Add"); if (methodInfo != null) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 2) { foreach (KeyValueItem item in property.Items) { object keyValue = CreateObject(item.Key); object valueValue = CreateObject(item.Value); methodInfo.Invoke(dictionary, new[] {keyValue, valueValue}); } } } return dictionary; }
private void parseDictionaryProperty(DictionaryProperty property) { // expected key type property.KeyType = _reader.ReadType(); // expected value type property.ValueType = _reader.ReadType(); // Properties readProperties(property.Properties, property.Type); // Items readDictionaryItems(property.Items, property.KeyType, property.ValueType); }
/// <summary> /// EXCEL材料导入 /// </summary> /// <param name="request"></param> /// <param name="Filedata"></param> /// <returns></returns> public PartialViewResult UploadFile(StoreTreeNameRequests request, HttpPostedFileBase Filedata, string treeidt) { // 如果没有上传文件 if (Filedata == null || string.IsNullOrEmpty(Filedata.FileName) || Filedata.ContentLength == 0) { //return this.HttpNotFound(); } // 保存到 ~/photos 文件夹中,名称不变 string filename = System.IO.Path.GetFileName(Filedata.FileName); string virtualPath = string.Format("~/UploadFiles/{0}", filename); // 文件系统不能使用虚拟路径 string path = this.Server.MapPath(virtualPath); Filedata.SaveAs(path); var model = new DictionaryProperty(); string id = null; if (this.TempData.ContainsKey("treeid")) { id = this.TempData["treeid"].ToString(); //TempData.Remove("treeid"); request.treeID = new Guid(id.ToString()); } if (treeidt != null) { Guid treeid = new Guid(treeidt); request.treeID = treeid; model.leaf_id = treeid; } DataTable dt = this.StoreService.ReadExcel(path); foreach (DataRow row in dt.Rows) {//判断exel数据异常返回,不存数据 var clmc = row[0].ToString(); var pm = row[1].ToString(); var mf = row[2].ToString(); if (row[3].ToString() == "" || row[3].ToString() == null) { row[3] = 1; } var temp = decimal.Parse(row[3].ToString()); } foreach (DataRow row in dt.Rows) { Guid keyid = Guid.NewGuid(); model.dpid = keyid; model.clmc = row[0].ToString(); model.pm = row[1].ToString(); model.mf = row[2].ToString(); model.js = decimal.Parse(row[3].ToString()); this.StoreService.SaveDictionaryProperty(model); } //Dictionary<string, string> dp = new Dictionary<string, string>(); //dp.Add("clmc", model.clmc); //dp.Add("pm", model.pm); //dp.Add("mf", model.mf); //dp.Add("js", model.js); request.PageSize = 500; var result = this.StoreService.GetNodeProperty(request); return(PartialView("_DPropertyPartialPage", result)); }
private void parseDictionaryProperty(XmlReader reader, DictionaryProperty property) { property.KeyType = getKeyTypeAttribute(reader); property.ValueType = getValueTypeAttribute(reader); while (reader.Read()) { // Properties if (arePropertiesFound(reader)) { using (var subReader = new SubtreeReader(reader)) { readProperties(subReader.Reader, property.Properties, property.Type); } } // Items if (areItemsFound(reader)) { using (var subReader = new SubtreeReader(reader)) { readDictionaryItems(subReader.Reader, property.Items, property.KeyType, property.ValueType); } } } }
private bool FillDictionaryProperty(DictionaryProperty property, TypeInfo info, object value) { if (property == null) { return false; } // Properties ParseProperties(property, info, value); // Items ParseDictionaryItems(property, info, value); return true; }
private void ParseDictionaryProperty(DictionaryProperty property) { if (property.Type != null) { var typeInfo = TypeInfo.GetTypeInfo(property.Type); property.KeyType = typeInfo.KeyType; property.ValueType = typeInfo.ElementType; } foreach (var subElement in _reader.ReadSubElements()) { if (subElement == SubElements.Properties) { // Properties ReadProperties(property.Properties, property.Type); continue; } if (subElement == SubElements.Items) { // Items ReadDictionaryItems(property.Items, property.KeyType, property.ValueType); } } }
private void parseDictionaryProperty(DictionaryProperty property) { if (property.Type!=null) { var typeInfo = Polenter.Serialization.Serializing.TypeInfo.GetTypeInfo(property.Type, _simpleTypes); property.KeyType = typeInfo.KeyType; property.ValueType = typeInfo.ElementType; } foreach (string subElement in _reader.ReadSubElements()) { if (subElement == SubElements.Properties) { // Properties readProperties(property.Properties, property.Type); continue; } if (subElement == SubElements.Items) { // Items readDictionaryItems(property.Items, property.KeyType, property.ValueType); } } }
public ActionResult InBoundEdit(FormCollection collection) { var model = new StoreTable(); var inBoundCounts = collection["InBoundCounts"]; //this.TryUpdateModel<StoreTable>(model); InBoundRecord ibr = new InBoundRecord(); if (bool.Parse(collection["pllr"].Split(',')[0])) { //批量添加材料 //var tempdpids = TempData["dpids"]; string dpids = collection["cllb"]; string[] arrTemp = dpids.Split(','); string[] arrCountTemp = inBoundCounts.Split(','); for (int i = 1; i < arrTemp.Length; i++) { decimal temp = 0; if (!decimal.TryParse(arrCountTemp[i - 1], out temp)) { temp = 0; } var modelTemp = new StoreTable(); InBoundRecord ibrTemp = new InBoundRecord(); Guid proid = new Guid(arrTemp[i]); modelTemp.number = temp; DictionaryProperty dp = this.StoreService.GetDicProperty(proid, collection["Materialnames"]); modelTemp.store_item_id = dp.dpid; //插入数据到入库记录表 ibrTemp.inbound_id = dp.dpid; ibrTemp.rkid = Guid.NewGuid(); ibrTemp.number = modelTemp.number; ibrTemp.boundtype = "入库"; ibrTemp.khmc = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value); this.StoreService.InsertInboundRecord(ibrTemp); ///入库 this.StoreService.InsertStoreItem(modelTemp); } return(this.RefreshParent()); } if (collection.AllKeys.Contains("DictionaryProperty.dpid")) { Guid proid = new Guid(collection["clID"]); decimal temp = 0; if (!decimal.TryParse(collection["InBoundCount"], out temp)) { temp = 0; } model.number = temp; DictionaryProperty dp = this.StoreService.GetDicProperty(proid, collection["Materialnames"]); model.store_item_id = dp.dpid; //插入数据到入库记录表 ibr.inbound_id = dp.dpid; ibr.rkid = Guid.NewGuid(); ibr.number = model.number; ibr.boundtype = "入库"; ibr.khmc = this.StoreService.GetParentNameByLeafID(dp.leaf_id.Value); this.StoreService.InsertInboundRecord(ibr); ///入库 this.StoreService.InsertStoreItem(model); } return(this.RefreshParent()); }
set => SetValue(DictionaryProperty, value);
private void ParseDictionaryItems(DictionaryProperty property, TypeInfo info, object value) { property.KeyType = info.KeyType; property.ValueType = info.ElementType; var dictionary = (IDictionary)value; foreach (DictionaryEntry entry in dictionary) { var keyProperty = CreateProperty(null, entry.Key); var valueProperty = CreateProperty(null, entry.Value); property.Items.Add(new KeyValueItem(keyProperty, valueProperty)); } }
//Method that returns a list of integers containing the dictionary property values corresponding to a list of cell indices. //PLEASE NOTE: a PROPERTY is used to check (CheckProperty) if the cell should be used for processing or not. For example: If I am interested in // cells that have a defined value for porosity then my CheckProperty should be Porosity. If a value for porosity is not defined then // the program returns a -1 for the DICTIONARY PROPERTY value entry (Zone Index for example) corresponding to that cell index. // public static List<int> GetThePropertyValueCorrespondingToTheCells(Property CheckProperty, List<Index3> CellIndeces, DictionaryProperty Property) //{ // NoBoundaryCheckDictionaryPropertyIndexer MyDictionaryPropertyIndexer = Property.SpecializedAccess.OpenNoBoundaryCheckDictionaryPropertyIndexer(); // NoBoundaryCheckPropertyIndexer CheckPropertyIndexer = CheckProperty.SpecializedAccess.OpenNoBoundaryCheckPropertyIndexer(); // List<int> ListOfPropertieValuesCorrespondingToCellIndices = new List<int>(); // foreach (Index3 cell in CellIndeces) // { // if (!double.IsNaN(CheckPropertyIndexer[cell])) //checking if it is Nan or not // { // ListOfPropertieValuesCorrespondingToCellIndices.Add(MyDictionaryPropertyIndexer[cell]); // } // else // { // ListOfPropertieValuesCorrespondingToCellIndices.Add(-1); // PetrelLogger.InfoOutputWindow("One of the intersected cells has an undefined Check property"); // } // } // MyDictionaryPropertyIndexer.Close(); // MyDictionaryPropertyIndexer.Dispose(); // CheckPropertyIndexer.Close(); // CheckPropertyIndexer.Dispose(); // return ListOfPropertieValuesCorrespondingToCellIndices; //} public static List<int> GetThePropertyValueCorrespondingToTheCells(Property CheckProperty, List<Index3> CellIndeces, DictionaryProperty Property) { NoBoundaryCheckDictionaryPropertyIndexer MyDictionaryPropertyIndexer = Property.SpecializedAccess.OpenNoBoundaryCheckDictionaryPropertyIndexer(); NoBoundaryCheckPropertyIndexer CheckPropertyIndexer = CheckProperty.SpecializedAccess.OpenNoBoundaryCheckPropertyIndexer(); List<int> ListOfPropertieValuesCorrespondingToCellIndices = new List<int>(); foreach (Index3 cell in CellIndeces) { if (!double.IsNaN(CheckPropertyIndexer[cell])) //checking if it is Nan or not { ListOfPropertieValuesCorrespondingToCellIndices.Add(MyDictionaryPropertyIndexer[cell]); } else { ListOfPropertieValuesCorrespondingToCellIndices.Add(-1); PetrelLogger.InfoOutputWindow("One of the intersected cells has an undefined Check property"); } } MyDictionaryPropertyIndexer.Close(); MyDictionaryPropertyIndexer.Dispose(); CheckPropertyIndexer.Close(); CheckPropertyIndexer.Dispose(); return ListOfPropertieValuesCorrespondingToCellIndices; }