示例#1
0
        private async void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            var  obj  = iS3Property.GetInstance(_domain, _objType);
            Type type = iS3Property.GetType(_domain, _objType);

            foreach (PropertyDef def in _propertyDefs)
            {
                PropertyInfo info = type.GetProperty(def.key); //获取指定名称的属性
                if (TBDict.ContainsKey(def.id))
                {
                    string value = TBDict[def.id].Text.ToString();
                    if (!info.PropertyType.IsGenericType)
                    {
                        //非泛型
                        info.SetValue(obj, string.IsNullOrEmpty(value) ? null : Convert.ChangeType(value, info.PropertyType), null);
                    }
                    else
                    {
                        //泛型Nullable<>
                        Type genericTypeDefinition = info.PropertyType.GetGenericTypeDefinition();
                        if (genericTypeDefinition == typeof(Nullable <>))
                        {
                            info.SetValue(obj, string.IsNullOrEmpty(value) ? null : Convert.ChangeType(value, Nullable.GetUnderlyingType(info.PropertyType)), null);
                        }
                    }
                }
            }
            DGObject _obj = await RepositoryForClient.Create(obj as DGObject, _domain, _objType);

            if (DGObjectHandler != null)
            {
                DGObjectHandler(this, _obj);
            }
            this.Close();
        }
示例#2
0
        public async Task SetDGObjectShow(DGObject _obj)
        {
            DGObject obj = await RepositoryForClient.RetrieveObj(_obj);

            string             domainName = _obj.parent.parent.name;
            string             objType    = _obj.parent.definition.Type;
            Extensions         extensions = DllImport.domainExtension[domainName];
            DGObjectViewConfig dw         = extensions.treeItems().Where(x => x.objType == objType).FirstOrDefault();
            IDGObjectView      view       = dw.func();

            view.SetObjContent(obj);
            CommonWindow.GetInstance(view.ChartView()).Show();
        }
示例#3
0
        public async Task Set(DGObjects objs)
        {
            List <DGObject> dGObjects = await RepositoryForClient.RetrieveObjs(objs);

            string domain  = objs.parent.name;
            string objtype = objs.definition.Type;

            //获取对应属性数据
            iS3Property property = new iS3Property();
            Type        objType  = iS3Property.GetType(objs.parent.name, objs.definition.Type);
            Type        _t       = property.GetType();
            MethodInfo  mi       = _t.GetMethod("Convert").MakeGenericMethod(objType);

            DGObjectsHolder.ItemsSource = mi.Invoke(property, new object[] { dGObjects }) as IEnumerable;
        }
示例#4
0
        private async void DeleteBtn_Click(object sender, RoutedEventArgs e)
        {
            DGObject obj = DGObjectDataGrid.SelectedItem as DGObject;

            try
            {
                int result = await RepositoryForClient.Delete(obj, domainName, objTypeName);

                if (result > 0)
                {
                    await GetData(lastObj);
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#5
0
        public async Task GetData(DGObjects objs)
        {
            lastObj           = objs;
            domainName        = objs.parent.name;
            objTypeName       = objs.definition.Type;
            AddBtn.Content    = "新增" + objs.definition.Type + "对象";
            DeleteBtn.Content = "删除" + objs.definition.Type + "对象";
            List <DGObject> objList = await RepositoryForClient.RetrieveObjs(objs);

            string domain  = objs.parent.name;
            string objtype = objs.definition.Type;

            //获取对应属性数据
            Type       objType = ObjectHelper.GetType(objs.parent.name, objs.definition.Type);
            Type       _t      = typeof(ObjectHelper);
            MethodInfo mi      = _t.GetMethod("Convert").MakeGenericMethod(objType);

            DGObjectDataGrid.ItemsSource = mi.Invoke(null, new object[] { objList }) as IEnumerable;
        }
        public async Task LoadProject(string definitionFile)
        {
            try
            {
                if (definitionFile == null ||
                    definitionFile.Length == 0)
                {
                    return;
                }
                _prj = new Project()
                {
                    projectID = projectID
                };
                _prj.projectInfo = await CommonRepo.GetProjectInfo(_prj.projectID);

                _prj.domains = await CommonRepo.GetDomains(_prj.projectID);

                _prj.emaps = await CommonRepo.GetEMaps(_prj.projectID);

                Globals.project = _prj;
                foreach (Domain domain in _prj.domains)
                {
                    try
                    {
                        domain.objectsDefinitions = await CommonRepo.GetObjectsDefinition(_prj.projectID, domain.name);

                        domain.DGObjectsList = new List <DGObjects>();
                        foreach (ObjectsDefinition definition in domain.objectsDefinitions)
                        {
                            if ((definition.Layer3DName == null) || (definition.Layer3DName == ""))
                            {
                                definition.Layer3DName = definition.Domain + "/" + definition.Type;
                            }
                            DGObjects objs = new DGObjects()
                            {
                                parent = domain, definition = definition,
                            };
                            domain.DGObjectsList.Add(objs);
                            objs.objContainer = await RepositoryForClient.RetrieveObjs(objs);

                            _prj.objsDefIndex[definition.Name] = objs;
                        }
                    }
                    catch (Exception ex)
                    {
                        //  MessageBox.Show(ex.ToString());
                    }
                }

                loadDomainPanels();
                await LoadViews();


                if (projectLoaded != null)
                {
                    projectLoaded(this, EventArgs.Empty);
                }

                ViewHolder.SelectedIndex = 1;
            }
            catch (Exception ex)
            {
            }
        }
示例#7
0
        private async void OpenCSVFile(string filepath)
        {
            string strpath = filepath; //csv文件的路径

            try
            {
                int  intColCount = 0;
                bool blnFlag     = true;

                string                   strline;
                string[]                 aryline;
                StreamReader             mysr          = new StreamReader(strpath, System.Text.Encoding.Default);
                Dictionary <string, int> Propertyindex = new Dictionary <string, int>();
                while ((strline = mysr.ReadLine()) != null)
                {
                    aryline     = strline.Split(new char[] { ',' });
                    intColCount = aryline.Length;

                    //给属性建立索引,可以根据属性名找到对应的列
                    if (blnFlag)
                    {
                        blnFlag = false;
                        for (int i = 0; i < aryline.Length; i++)
                        {
                            Propertyindex[aryline[i]] = i;
                        }
                    }
                    else
                    {
                        var  obj  = iS3Property.GetInstance(_domain, _objType);
                        Type type = iS3Property.GetType(_domain, _objType);
                        foreach (PropertyDef def in _propertyDefs)
                        {
                            PropertyInfo info = type.GetProperty(def.key); //获取指定名称的属性
                            if (Propertyindex.ContainsKey(def.key))
                            {
                                var value = aryline[Propertyindex[def.key]];
                                if (!info.PropertyType.IsGenericType)
                                {
                                    //非泛型
                                    info.SetValue(obj, string.IsNullOrEmpty(value) ? null : Convert.ChangeType(value, info.PropertyType), null);
                                }
                                else
                                {
                                    //泛型Nullable<>
                                    Type genericTypeDefinition = info.PropertyType.GetGenericTypeDefinition();
                                    if (genericTypeDefinition == typeof(Nullable <>))
                                    {
                                        info.SetValue(obj, string.IsNullOrEmpty(value) ? null : Convert.ChangeType(value, Nullable.GetUnderlyingType(info.PropertyType)), null);
                                    }
                                }
                            }
                        }
                        DGObject _obj = await RepositoryForClient.Create(obj as DGObject, _domain, _objType);

                        if (DGObjectHandler != null)
                        {
                            DGObjectHandler(this, _obj);
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
示例#8
0
        public async Task GetData(DGObjects objs)
        {
            List <DGObject> objList = await RepositoryForClient.RetrieveObjs(objs);

            currenttable = ReadFromDgobjects(objList);
        }
示例#9
0
        private async void SaveChangeBT_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TreeNode node = LYTunnelTreeview.SelectedItem as TreeNode;
                if ((node == null) || (node.Level != 2))
                {
                    return;
                }
                if (newdatatable == null)
                {
                    return;
                }


                DGObjectDef objectDef = LYTunnelStandard.GetDGObjectDefByName(newdatatable.TableName);
                StageDef    _domain   = LYTunnelStandard.GetStageDefByName(newdatatable.TableName);
                if ((objectDef == null) || (_domain == null))
                {
                    MessageBox.Show("检查数据标准表!");
                    return;
                }

                var                         obj            = iS3Property.GetInstance(_domain.Code, objectDef.Code);
                Type                        _type          = iS3Property.GetType(_domain.Code, objectDef.Code);
                MethodInfo                  mi             = typeof(iS3Property).GetMethod("GetProperty").MakeGenericMethod(_type);
                List <PropertyDef>          _propertyDefs  = mi.Invoke(new iS3Property(), new object[] { Activator.CreateInstance(_type) }) as List <PropertyDef>;
                Dictionary <string, object> Property2Value = new Dictionary <string, object>();

                foreach (DataRow row in newdatatable.Rows)
                {
                    foreach (PropertyMeta meta in objectDef.PropertyContainer)
                    {
                        Property2Value[meta.PropertyName] = row[meta.LangStr];
                        if (Property2Value[meta.PropertyName].ToString() == "")
                        {
                            Property2Value[meta.PropertyName] = null;
                        }
                    }
                    foreach (PropertyDef def in _propertyDefs)
                    {
                        PropertyInfo info = _type.GetProperty(def.key); //获取指定名称的属性
                        if (Property2Value.ContainsKey(def.key))
                        {
                            var value = Property2Value[def.key];
                            if (!info.PropertyType.IsGenericType)
                            {
                                //非泛型
                                info.SetValue(obj, (value != null) ? Convert.ChangeType(value, info.PropertyType) : null);
                            }
                            else
                            {
                                //泛型Nullable<>
                                Type genericTypeDefinition = info.PropertyType.GetGenericTypeDefinition();
                                if (genericTypeDefinition == typeof(Nullable <>))
                                {
                                    info.SetValue(obj, (value != null) ? Convert.ChangeType(value, Nullable.GetUnderlyingType(info.PropertyType)) : null);
                                }
                            }
                        }
                    }
                    DGObject _obj = await RepositoryForClient.Create(obj as DGObject, _domain.Code, objectDef.Code);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            System.Windows.MessageBox.Show("数据已存储至数据库"); //Data has been stored to DataBase!
            DataTemplateTreeview_SelectedItemChanged(this, new RoutedEventArgs());
            newdatatable = null;
        }