예제 #1
0
파일: AgeDeployVm.cs 프로젝트: unicloud/FRP
 private void OnAdd(object sender)
 {
     var ageDeploy = new AgeDeployClass {Color = "#FFEFF8F8"};
     var collection = new List<AgeDeployClass>();
     collection.AddRange(AgeDeployCollection);
     collection.Add(ageDeploy);
     AgeDeployCollection = collection;
     _ageDeployGridView.SelectedItem = ageDeploy;
     //设置保存、放弃修改按钮的可用性
     IsChanged = true;
 }
예제 #2
0
파일: AgeDeployVm.cs 프로젝트: unicloud/FRP
        /// <summary>
        ///     将机龄配置XML转换成机龄配置对象的集合
        /// </summary>
        /// <returns></returns>
        protected void CreatAgeDeployCollection()
        {
            if (_loadXmlConfig && _loadXmlSetting)
            {
                _loadXmlConfig = false;
                _loadXmlSetting = false;
                IsBusy = false;
                var collection = new List<AgeDeployClass>(); //将机龄配置XML转换成机龄配置对象的集合
                if (XmlConfigs.FirstOrDefault(p => p.ConfigType.Equals("机龄配置", StringComparison.OrdinalIgnoreCase)) !=
                    null)
                {
                    var xmlConfig =
                        XmlConfigs.FirstOrDefault(p => p.ConfigType.Equals("机龄配置", StringComparison.OrdinalIgnoreCase));
                    if (xmlConfig != null)
                    {
                        var xelement = XElement.Parse(xmlConfig.ConfigContent);

                        XElement ageColor = null;
                        var colorConfig =
                            XmlSettings.FirstOrDefault(
                                p => p.SettingType.Equals("颜色配置", StringComparison.OrdinalIgnoreCase));
                        if (colorConfig != null && XElement.Parse(colorConfig.SettingContent).Descendants("Type")
                            .Any(p => p.Attribute("TypeName").Value.Equals("机龄", StringComparison.OrdinalIgnoreCase)))
                        {
                            ageColor = XElement.Parse(colorConfig.SettingContent)
                                .Descendants("Type")
                                .FirstOrDefault(
                                    p => p.Attribute("TypeName").Value.Equals("机龄", StringComparison.OrdinalIgnoreCase));
                        }
                        if (xelement != null)
                        {
                            foreach (var item in xelement.Descendants("Item"))
                            {
                                var ageDeploy = new AgeDeployClass
                                {
                                    Name = item.Value,
                                    StartYear = Convert.ToUInt32(item.Attribute("Start").Value),
                                    EndYear = Convert.ToUInt32(item.Attribute("End").Value)
                                };
                                if (ageColor != null)
                                {
                                    var firstOrDefault =
                                        ageColor.Descendants("Item")
                                            .FirstOrDefault(
                                                p =>
                                                    p.Attribute("Name")
                                                        .Value.Equals(ageDeploy.Name, StringComparison.OrdinalIgnoreCase));
                                    if (firstOrDefault != null)
                                        ageDeploy.Color = firstOrDefault.Attribute("Color").Value;
                                }
                                collection.Add(ageDeploy);
                            }
                        }
                    }
                }
                AgeDeployCollection = collection;
            }
        }