示例#1
0
        public int Create(ServiceConfig item)
        {
            int modifyRowCount = 0;

            try
            {
                //判断磁盘未找到文件,创建XML文件
                if (!System.IO.File.Exists(_serviceConfigDiskPath))
                {
                    this.Update(item);
                }
            }
            catch (SystemException se)
            { Log.SysLog.WriteLogFromException(se); }
            return(modifyRowCount);
        }
示例#2
0
        public ServiceConfig Row()
        {
            ServiceConfig cfg = null;

            try
            {
                //查询语句: 获得根节点下name子节点(此时的子节点可以跨层次:孙节点、重孙节点......)
                IEnumerable <XElement> serviceConfigNodes = from target in serviceConfig.Descendants("Config")
                                                            select target;
                foreach (XElement node in serviceConfigNodes)
                {
                    cfg = new ServiceConfig()
                    {
                        IsDebug = node.Element("IsDebug") != null?node.Element("IsDebug").Value : "0",

                        SystemCode = node.Element("SystemCode") != null?node.Element("SystemCode").Value : "",

                        ServiceIP   = node.Element("ServiceIP") != null?node.Element("ServiceIP").Value     : "",
                        ServicePort = node.Element("ServicePort") != null?node.Element("ServicePort").Value : "",

                        SmsAliyun = new SMSAliyun()
                                    //RelayControllerList = new List<Device.RelayController>()
                    };
                }

                //读取SMSAliyun 配置
                serviceConfigNodes = from target in serviceConfig.Descendants("SMSAliyun")
                                     select target;
                foreach (XElement node in serviceConfigNodes)
                {
                    cfg.SmsAliyun.AccessKeyId = node.Element("AccessKeyId") != null?node.Element("AccessKeyId").Value : "";

                    cfg.SmsAliyun.AccessKeySecret = node.Element("AccessKeySecret") != null?node.Element("AccessKeySecret").Value : "";

                    cfg.SmsAliyun.SignName = node.Element("SignName") != null?node.Element("SignName").Value : "";

                    cfg.SmsAliyun.TemplateCode = node.Element("TemplateCode") != null?node.Element("TemplateCode").Value : "";
                }
            }
            catch (SystemException se)
            { Log.SysLog.WriteLogFromException(se); }
            return(cfg);
        }