Ejemplo n.º 1
0
 public RCB(string aiName, List <KeyValuePair <string, string> > aiData, TreeNode tn, MasterTypes mType, int mNo, int iNo)
 {
     masterType = mType;
     masterNo   = mNo;
     IEDNo      = iNo;
     SetSupportedRCBAttributes();
     try
     {
         ainType = (RcbType)Enum.Parse(typeof(RcbType), aiName);
     }
     catch (System.ArgumentException)
     {
         Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", aiName);
     }
     //Parse n store values...
     if (aiData != null && aiData.Count > 0)
     {
         foreach (KeyValuePair <string, string> aikp in aiData)
         {
             Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", aikp.Key, aikp.Value);
             try
             {
                 if (this.GetType().GetProperty(aikp.Key) != null) //Ajay: 03/07/2018
                 {
                     this.GetType().GetProperty(aikp.Key).SetValue(this, aikp.Value);
                 }
             }
             catch (System.NullReferenceException)
             {
                 Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", aikp.Key, aikp.Value);
             }
         }
         Utils.Write(VerboseLevel.DEBUG, "\n");
     }
 }
        public RCB(XmlNode aiNode, MasterTypes mType, int mNo, int iNo, bool imported)
        {
            string strRoutineName = "AI";

            try
            {
                masterType = mType;
                masterNo   = mNo;
                IEDNo      = iNo;
                SetSupportedRCBAttributes();

                //Parse n store values...
                Utils.WriteLine(VerboseLevel.DEBUG, "aiNode name: '{0}'", aiNode.Name);
                if (aiNode.Attributes != null)
                {
                    //First set the root element value...
                    try
                    {
                        ainType = (RcbType)Enum.Parse(typeof(RcbType), aiNode.Name);
                    }
                    catch (System.ArgumentException)
                    {
                        Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", aiNode.Name);
                    }

                    foreach (XmlAttribute item in aiNode.Attributes)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                        try
                        {
                            if (this.GetType().GetProperty(item.Name) != null) //Ajay: 10/08/2018
                            {
                                this.GetType().GetProperty(item.Name).SetValue(this, item.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", item.Name, item.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
                else if (aiNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = aiNode.Value;
                }

                if (imported)//Generate a new unique id...
                {
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + Ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 加载补贴类型列表
        /// </summary>
        public void LoadTypeData()
        {
            var list = EnumAttribute.GetDict <SubsidyType>();

            RcbType.DataSource     = list;
            RcbType.DataTextField  = "Value";
            RcbType.DataValueField = "Key";
            RcbType.DataBind();
        }