Exemplo n.º 1
0
        /// <summary>
        /// 获取md5值
        /// </summary>
        /// <param name="source">源文件</param>
        /// <param name="type">获取md5中的长度</param>
        /// <returns></returns>
        public static string GetMd5(string source, CodeOption type = CodeOption.Char32)
        {
            string hash = "";

            if (string.IsNullOrWhiteSpace(source))
            {
                return(hash);
            }
            using (MD5 md5Hash = MD5.Create())
            {
                hash = GetMd5Hash(md5Hash, source);
            }
            switch (type)
            {
            case CodeOption.Char8:
                return(hash.Substring(12, 8));

            case CodeOption.Char16:
                return(hash.Substring(8, 16));

            case CodeOption.Char32:
            default:
                return(hash);
            }
        }
Exemplo n.º 2
0
 public EntityClass(CodeOption option)
     : base(option.DomainModelName, option.ModelNamespaceName)
 {
     this.columns = option.Columns;
     this.tbName  = option.FullTableName;
     this.idName  = option.IdColumn.Name;
     this.Attributes.Add("Serializable");
 }
Exemplo n.º 3
0
 public QueryEntityClass(CodeOption option)
     : base(option.QueryModelName, option.QueryNamespaceName)
 {
     this.columns     = option.Columns;
     this.tbName      = option.FullTableName;
     this.idName      = option.IdColumn.Name;
     this.ParentClass = "IQueryEntity";
     this.NameSpaces.Add("System.Collections.Generic");
     this.NameSpaces.Add("InstagramPhotos.Utility.CommonQuery");
 }
Exemplo n.º 4
0
Arquivo: Job.cs Projeto: tgiqfe/MdJob
 /// <summary>
 /// CodeTitleからCodeOptionをセット
 /// </summary>
 public void SetCodeOption()
 {
     if (!string.IsNullOrEmpty(CodeTitle) && CodeTitle.Contains(":"))
     {
         _option = Enum.TryParse(
             CodeTitle.Substring(CodeTitle.IndexOf(":") + 1), true, out CodeOption tempOption) ?
                   tempOption :
                   CodeOption.None;
     }
 }
Exemplo n.º 5
0
        public string GenerateSqlCode(CodeOption option, string tablename)
        {
            var table = new Table(tablename);
            var sql   = new StringBuilder();

            StoredProcedure sqlCreateEntitiy = new CreateEntitySP(option.CreateEntityStoredProcedureName, option.Author,
                                                                  option.Columns, option.IdColumn, table, option.GetNewAutoGUID);

            sql.AppendLine(sqlCreateEntitiy.Sql);
            sql.AppendLine();

            StoredProcedure sqlUpdateEntitiy = new UpdateEntitySP(option.UpdateEntityStoredProcedureName, option.Author,
                                                                  option.Columns, option.IdColumn, table);

            sql.AppendLine(sqlUpdateEntitiy.Sql);
            sql.AppendLine();

            if (option.CreateBatOperation)
            {
                StoredProcedure sqlCreateEntitiys = new BatCreateEntity(
                    option.CreateEntityStoredProcedureName + "_Bat", option.Author, option.Columns, option.IdColumn,
                    table, option.GetNewAutoGUID);
                sql.AppendLine(sqlCreateEntitiys.Sql);
                sql.AppendLine();

                StoredProcedure sqlUpdateEntitiys =
                    new BatUpdateEntitySP(option.UpdateEntityStoredProcedureName + "_Bat", option.Author, option.Columns,
                                          option.IdColumn, table);
                sql.AppendLine(sqlUpdateEntitiys.Sql);
                sql.AppendLine();
            }

            StoredProcedure sqlDeleteEntitiy = new DeleteEntitySP(option.DeleteEntityStoredProcedureName, option.Author,
                                                                  option.IdColumn, table);

            sql.AppendLine(sqlDeleteEntitiy.Sql);
            sql.AppendLine();

            StoredProcedure sqlGetIds = new GetIdsSP(option.GetEntityIdsStoredProcedureName, option.Author,
                                                     option.IdColumn, table);

            sql.AppendLine(sqlGetIds.Sql);
            sql.AppendLine();

            StoredProcedure sqlGetEntities = new GetEntitiesSP(option.GetEntitiesStoredProcedureName, option.Author,
                                                               option.Columns, option.IdColumn, table);

            sql.AppendLine(sqlGetEntities.Sql);
            sql.AppendLine();

            return(sql.ToString());
        }
Exemplo n.º 6
0
        public EntityDtoClass(CodeOption option)
            : base(option.EntityModelName, option.DtoNamespaceName)
        {
            this.columns  = option.Columns;
            this.protobuf = option.ProtoBuf;
            this.tbName   = option.FullTableName;
            this.idName   = option.IdColumn.Name;

            if (this.protobuf)
            {
                this.NameSpaces.Add("ProtoBuf");
                this.Attributes.Add("ProtoContract");
            }
            else
            {
                this.Attributes.Add("Serializable");
            }
        }
        /// <summary>
        /// 获取md5值
        /// </summary>
        /// <param name="source">源文件</param>
        /// <param name="type">获取md5中的长度</param>
        /// <returns></returns>
        public static string GetMd5(string source, CodeOption type = CodeOption.Char32)
        {
            string hash = "";
            if (string.IsNullOrWhiteSpace(source))
            {
                return hash;
            }
            using (MD5 md5Hash = MD5.Create())
            {
                hash = GetMd5Hash(md5Hash, source);
            }
            switch (type)
            {
                case CodeOption.Char8:
                    return hash.Substring(12, 8);
                case CodeOption.Char16:
                    return hash.Substring(8, 16);
                case CodeOption.Char32:
                default:
                    return hash;
            }

        }
Exemplo n.º 8
0
        public string GenerateDataAccessCode(CodeOption option)
        {
            var code = new StringBuilder();

            code.AppendLine();

            code.AppendFormat("#region {0}", option.ClassName);
            code.AppendLine();
            code.AppendLine();

            Function funCreateEntity = new CreateEntityDAFunc(option.ClassName, option.CreateEntityStoredProcedureName,
                                                              option.Columns, option.IdColumn, option.EnableParamCache, option.GetNewAutoGUID);

            code.Append(funCreateEntity.Code);
            code.AppendLine();

            if (option.CreateBatOperation)
            {
                Function batfunCreateEntity = new BatCreateDAFunc(option.ClassName,
                                                                  option.CreateEntityStoredProcedureName + "_Bat", option.Columns, option.IdColumn,
                                                                  option.EnableParamCache, option.GetNewAutoGUID);
                code.Append(batfunCreateEntity.Code);
                code.AppendLine();
            }

            Function funUpdateEntity = new UpdateEntityDAFunc(option.ClassName, option.UpdateEntityStoredProcedureName,
                                                              option.Columns, option.IdColumn, option.EnableParamCache);

            code.Append(funUpdateEntity.Code);
            code.AppendLine();

            if (option.CreateBatOperation)
            {
                //Function batfunUpdateEntity = new BatCreateDAFunc(option.ClassName, option.UpdateEntityStoredProcedureName + "_Bat", option.Columns, option.IdColumn, option.EnableParamCache);
                //code.Append(batfunUpdateEntity.Code);
                //code.AppendLine();
            }

            Function funDeleteEntity = new DeleteEntityDAFunc(option.ClassName, option.DeleteEntityStoredProcedureName,
                                                              option.IdColumn);

            code.Append(funDeleteEntity.Code);
            code.AppendLine();

            if (option.WithTrans)
            {
                Function funCreateEntityT = new CreateEntityDAFunc(option.ClassName,
                                                                   option.CreateEntityStoredProcedureName, option.Columns, option.IdColumn, option.EnableParamCache,
                                                                   option.GetNewAutoGUID, true);
                code.Append(funCreateEntityT.Code);
                code.AppendLine();

                Function batfunCreateEntityT = new BatCreateDAFunc(option.ClassName,
                                                                   option.CreateEntityStoredProcedureName + "_Bat", option.Columns, option.IdColumn,
                                                                   option.EnableParamCache, option.GetNewAutoGUID, true);
                code.Append(batfunCreateEntityT.Code);
                code.AppendLine();

                Function funUpdateEntityT = new UpdateEntityDAFunc(option.ClassName,
                                                                   option.UpdateEntityStoredProcedureName, option.Columns, option.IdColumn, option.EnableParamCache,
                                                                   true);
                code.Append(funUpdateEntityT.Code);
                code.AppendLine();

                Function funDeleteEntityT = new DeleteEntityDAFunc(option.ClassName,
                                                                   option.DeleteEntityStoredProcedureName, option.IdColumn, true);
                code.Append(funDeleteEntityT.Code);
                code.AppendLine();
            }

            Function fun1 = new GetEntityIdsDAFunc(option.ClassName, option.GetEntityIdsStoredProcedureName,
                                                   option.IdColumn);

            code.Append(fun1.Code);
            code.AppendLine();

            Function fun2 = new GetEntitiesDAFunc(option.ClassName, option.GetEntitiesStoredProcedureName,
                                                  option.IdColumn, option.ClassName);

            code.Append(fun2.Code);
            code.AppendLine();

            code.AppendLine();
            code.AppendFormat("#endregion");

            return(code.ToString());
        }
Exemplo n.º 9
0
Arquivo: Job.cs Projeto: tgiqfe/MdJob
 /// <summary>
 /// チェック対象のCodeOptionが含まれているかどうかの判定
 /// </summary>
 /// <param name="option"></param>
 /// <returns></returns>
 public bool CheckOption(CodeOption option)
 {
     return((_option & option) == option);
 }
Exemplo n.º 10
0
 public TinyEntityClass(CodeOption option)
     : base(option.ClassName, option.ModelNamespaceName)
 {
     this.columns = option.Columns;
 }