Beispiel #1
0
        public SMSUser(XmlNode sNode, TreeNode tn)
        {
            string strRoutineName = "SMSUser";

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

                    foreach (XmlAttribute item in sNode.Attributes)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", item.Name, item.Value);
                        try
                        {
                            if (this.GetType().GetProperty(item.Name) != null) //Ajay: 03/07/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 (sNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = sNode.Value;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Not Used: uciec.lblMain.Text += slaveNum;
        }
Beispiel #2
0
        public SMSUser(string smsUserName, List <KeyValuePair <string, string> > smsuserData, TreeNode tn, int mNo)
        {
            string strRoutineName = "SMSUser";

            try
            {
                try
                {
                    SmsUser = (SMSUserType)Enum.Parse(typeof(SMSUserType), smsUserName);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", smsUserName);
                }
                if (smsuserData != null && smsuserData.Count > 0)
                {
                    foreach (KeyValuePair <string, string> lpfilekp in smsuserData)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", lpfilekp.Key, lpfilekp.Value);
                        try
                        {
                            if (this.GetType().GetProperty(lpfilekp.Key) != null)
                            {
                                this.GetType().GetProperty(lpfilekp.Key).SetValue(this, lpfilekp.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "LPFile: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", lpfilekp.Key, lpfilekp.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error:" + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }