public ConfigServiceClient()
        {
            _solutionConfig = new SolutionConfiguration()
            {
                Components = new List<ComponentConfiguration>(),
                Content = "",
                IsRemote = false,
                SolutionId = Guid.Empty,
                Enable = true,
                IsActive = true,
                Environment = 0,
                IsDelete = false,
                IsFile = true,
                SolutionName = "本地配置",
                Status = 1,
                Version = 0

            };//构造函数默认对象内属性数值,默认为本地模式参数
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        internal static int Create(SolutionConfiguration model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into SolutionConfiguration(");
            strSql.Append("CreateTime,CreateBy,ModifyTime,ModifyBy,IsDelete,SolutionId,SolutionName,Version,IsFile,Content,Enable,Environment,IsRemote");
            strSql.Append(") values (");
            strSql.Append("@CreateTime,@CreateBy,@ModifyTime,@ModifyBy,@IsDelete,@SolutionId,@SolutionName,@Version,@IsFile,@Content,@Enable,@Environment,@IsRemote");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            List<DbParameter> parameters = new List<DbParameter>();

            parameters.Add(new MdsDbParameter("@CreateTime", DbType.DateTime));
            parameters.Add(new MdsDbParameter("@CreateBy", DbType.Int32, 11));
            parameters.Add(new MdsDbParameter("@ModifyTime", DbType.DateTime));
            parameters.Add(new MdsDbParameter("@ModifyBy", DbType.Int32, 11));
            parameters.Add(new MdsDbParameter("@IsDelete", DbType.Boolean));
            parameters.Add(new MdsDbParameter("@SolutionId", DbType.Guid, 64));
            parameters.Add(new MdsDbParameter("@SolutionName", DbType.String, 200));
            parameters.Add(new MdsDbParameter("@Version", DbType.Int32, 11));
            parameters.Add(new MdsDbParameter("@IsFile", DbType.Boolean));
            parameters.Add(new MdsDbParameter("@Content", DbType.String));
            parameters.Add(new MdsDbParameter("@Enable", DbType.Boolean));
            parameters.Add(new MdsDbParameter("@Environment", DbType.Int32, 11));
            parameters.Add(new MdsDbParameter("@IsRemote", DbType.Boolean));

            parameters[0].Value =DateTime.Now;
            parameters[1].Value = model.CreateBy;
            parameters[2].Value = DateTime.Now;
            parameters[3].Value = model.ModifyBy;
            parameters[4].Value = false;
            parameters[5].Value = model.SolutionId;
            parameters[6].Value = model.SolutionName;
            parameters[7].Value = model.Version;
            parameters[8].Value = model.IsFile;
            parameters[9].Value = model.Content;
            parameters[10].Value = model.Enable;
            parameters[11].Value = model.Environment;
            parameters[12].Value = model.IsRemote;
            return _dalService.GetPrimarykey(parameters, strSql.ToString());
        }
 static void Main(string[] args)
 {
     string path = @"D:\Github\Micro-enterpriseDistributedSystem\InformationModule\C#\mds\UnitTest\Config";
     SolutionConfiguration sc = new SolutionConfiguration()
     {
         Components = new List<ComponentConfiguration>(),
         Content = "",
         Enable = true,
         Environment = 0,
         ID = 1,
         IsFile = true,
         IsRemote = false,
         SolutionId = Guid.NewGuid(),
         SolutionName = "方案名称",
         Version = 1
     };
     ConfigServerConfig csc = new ConfigServerConfig()
     {
         DalConfigs = new List<DataAccessConfiguration>()
     };
     csc.DalConfigs.Add(new DataAccessConfiguration()
     {
         ConnectionName = "SolutionConfiguration",
         DatabaseConnection = "Data Source=192.168.100.4;Initial Catalog=systembase;Persist Security Info=True;User ID=webuser;password=123456",
         DatabaseType = EnumDatabaseType.MySql,
         Multiple = false
     });
     csc.DalConfigs.Add(new DataAccessConfiguration()
     {
         ConnectionName = "ComponentConnection",
         DatabaseConnection = "Data Source=192.168.100.4;Initial Catalog=systembase;Persist Security Info=True;User ID=webuser;password=123456",
         DatabaseType = EnumDatabaseType.MySql,
         Multiple = false
     });
     csc.DalConfigs.Add(new DataAccessConfiguration()
     {
         ConnectionName = "ComponentConfiguration",
         DatabaseConnection = "Data Source=192.168.100.4;Initial Catalog=systembase;Persist Security Info=True;User ID=webuser;password=123456",
         DatabaseType = EnumDatabaseType.MySql,
         Multiple = false
     });
     sc.Components.Add(new ComponentConfiguration()
     {
         Version = 1,
         Status = 1,
         ComponentConfigId = 1,
         ComponentId = 1001,
         Content = XmlConfigSerializer.Instance.ToXml<ConfigServerConfig>(csc),
         Enable = true,
         Environment = 1,
         IsDebug = false,
         Signature = "软件签名"
     });
     ServiceFactoryServerConfig sfs = new ServiceFactoryServerConfig()
     {
         DalConfigs = new List<DataAccessConfiguration>()
     };
     sfs.DalConfigs = new List<DataAccessConfiguration>();
     sfs.DalConfigs.Add(new DataAccessConfiguration()
     {
         ConnectionName = "SolutionServiceFactoryConnection",
         DatabaseConnection = "Data Source=192.168.100.4;Initial Catalog=systembase;Persist Security Info=True;User ID=webuser;password=123456",
         DatabaseType = EnumDatabaseType.MySql,
         Multiple = false
     });
     sc.Components.Add(new ComponentConfiguration()
     {
         Version = 1,
         Status = 1,
         ComponentConfigId = 2,
         ComponentId = 1003,
         Content = XmlConfigSerializer.Instance.ToXml<ServiceFactoryServerConfig>(sfs),
         Enable = true,
         Environment = 1,
         IsDebug = false,
         Signature = "软件签名"
     });
     XmlConfigSerializer.Instance.Serializer(path + "\\RemoteConfig.xml", sc);
 }
 /// <summary>
 /// 本地配置模式下只有一个方案序列化文件
 /// </summary>
 /// <param name="appConfig"></param>
 private void ReadLocal(AppConfiguration appConfig,InitResult result)
 {
     if (string.IsNullOrEmpty(appConfig.LocalConfigFilePath))//如果没有默认路径不读取
     {
         result.Result = false;
         result.Message ="本地配置文件路径为空";
         return;//构造函数里默认数值
     }
     try
     {
       var temp=XmlConfigSerializer.Instance.DeserializeSingle<SolutionConfiguration>(appConfig.LocalConfigFilePath);
       if (temp != null)//使用构造函数里的数值,避免多位置同效代码赋值
       {
           _solutionConfig = temp;
       }
     }
     catch (Exception ex)//预期异常:格式错误,错误内容
     {
         result.Result = false;
         result.Message = ex.Message;
         return;
     }
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        internal static int Edit(SolutionConfiguration model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SolutionConfiguration set ");

            strSql.Append(" CreateTime = @CreateTime , ");
            strSql.Append(" CreateBy = @CreateBy , ");
            strSql.Append(" ModifyTime = @ModifyTime , ");
            strSql.Append(" ModifyBy = @ModifyBy , ");
            strSql.Append(" IsDelete = @IsDelete , ");
            strSql.Append(" SolutionId = @SolutionId , ");
            strSql.Append(" SolutionName = @SolutionName , ");
            strSql.Append(" Version = @Version , ");
            strSql.Append(" IsFile = @IsFile , ");
            strSql.Append(" Content = @Content , ");
            strSql.Append(" Enable = @Enable , ");
            strSql.Append(" Environment = @Environment , ");
            strSql.Append(" IsRemote = @IsRemote  ");
            strSql.Append(" where ID=@ID ");

            List<DbParameter> parameters = new List<DbParameter>();

            parameters.Add(new MdsDbParameter("@ID", DbType.Int32, 11));

            parameters.Add(new MdsDbParameter("@CreateTime", DbType.DateTime));

            parameters.Add(new MdsDbParameter("@CreateBy", DbType.Int32, 11));

            parameters.Add(new MdsDbParameter("@ModifyTime", DbType.DateTime));

            parameters.Add(new MdsDbParameter("@ModifyBy", DbType.Int32, 11));

            parameters.Add(new MdsDbParameter("@IsDelete", DbType.Boolean));

            parameters.Add(new MdsDbParameter("@SolutionId", DbType.String, 64));

            parameters.Add(new MdsDbParameter("@SolutionName", DbType.String, 200));

            parameters.Add(new MdsDbParameter("@Version", DbType.Int32, 11));

            parameters.Add(new MdsDbParameter("@IsFile", DbType.Boolean));

            parameters.Add(new MdsDbParameter("@Content", DbType.String));

            parameters.Add(new MdsDbParameter("@Enable", DbType.Boolean));

            parameters.Add(new MdsDbParameter("@Environment", DbType.Int32, 11));

            parameters.Add(new MdsDbParameter("@IsRemote", DbType.Boolean));

            parameters[0].Value = model.ID;
            parameters[1].Value = model.CreateTime;
            parameters[2].Value = model.CreateBy;
            parameters[3].Value = model.ModifyTime;
            parameters[4].Value = model.ModifyBy;
            parameters[5].Value = model.IsDelete;
            parameters[6].Value = model.SolutionId;
            parameters[7].Value = model.SolutionName;
            parameters[8].Value = model.Version;
            parameters[9].Value = model.IsFile;
            parameters[10].Value = model.Content;
            parameters[11].Value = model.Enable;
            parameters[12].Value = model.Environment;
            parameters[13].Value = model.IsRemote;
            return _dalService.ExecuteNonQuery(parameters, strSql.ToString());
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        internal static SolutionConfiguration Get(Guid ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID, SolutionId, SolutionName, Version, IsFile, Content, Enable, Environment, IsRemote  ");
            strSql.Append("  from SolutionConfiguration ");
            strSql.Append(" where SolutionId=@ID");
            List<DbParameter> parameters = new List<DbParameter>();
            parameters.Add(new MdsDbParameter("@ID",DbType.String) {
                  Value=ID.ToString()
            });
            SolutionConfiguration r = new SolutionConfiguration();
            r = _dalService.GetDataByReader<SolutionConfiguration>(parameters, strSql.ToString(), delegate (DbDataReader dr) {
                r = null;
                if (dr.Read())
                {
                    r = new SolutionConfiguration()
                    {
                        ID = int.Parse(dr["ID"].ToString()),
                        SolutionId = Guid.Parse(dr["SolutionId"].ToString()),
                        SolutionName = dr["SolutionName"].ToString(),
                        Version = int.Parse(dr["Version"].ToString()),
                        IsFile =Convert.ToBoolean(int.Parse(dr["IsFile"].ToString())),
                        Content = dr["Content"].ToString(),
                         Enable = Convert.ToBoolean(int.Parse(dr["Enable"].ToString())),
                        Environment = int.Parse(dr["Environment"].ToString()),
                         IsRemote = Convert.ToBoolean(int.Parse(dr["IsRemote"].ToString())),

                    };
                }
                return r;
            });
            return r;
        }