/// <summary>
 ///
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="userDirectory"></param>
 public static DateTime?UploadConfiguration(string userName, string userDirectory)
 {
     byte[] s = CompressionHelper.CompressFromFolder(userDirectory);
     UploadConfiguration(userName, s);
     return(null);
 }
예제 #2
0
        /// <summary>
        /// 按照模块文件信息,生成响应ModuleInfo。(粗略,可修改)
        /// </summary>
        /// <param name="moduleName"></param>
        public static void GenerateModuleInfos(string moduleName)
        {
            MultiOrgEntityDao <ModuleInfo>        moduleDao        = new MultiOrgEntityDao <ModuleInfo>();
            MultiOrgEntityDao <ModuleIncludeInfo> moduleIncludeDao = new MultiOrgEntityDao <ModuleIncludeInfo>();

            string dir = System.IO.Directory.GetCurrentDirectory() + "\\" + moduleName;

            using (var rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <ModuleInfo>())
            {
                try
                {
                    rep.BeginTransaction();

                    ModuleInfo moduleInfo = new ModuleInfo();
                    moduleInfo.Author        = "system";
                    moduleInfo.ID            = System.IO.Path.GetFileNameWithoutExtension(moduleName);
                    moduleInfo.ModuleData    = CompressionHelper.CompressFromFolder(dir);
                    moduleInfo.IsActive      = true;
                    moduleInfo.ModuleVersion = "1.0.0.0";
                    moduleDao.Save(rep, moduleInfo);

                    foreach (string s in System.IO.Directory.GetFiles(dir + "\\referencedata\\standard\\"))
                    {
                        string name = System.IO.Path.GetFileNameWithoutExtension(s);

                        ModuleIncludeInfo includeInfo = new ModuleIncludeInfo();
                        includeInfo.Module            = moduleInfo;
                        includeInfo.ModuleIncludeType = ModuleIncludeType.ReferenceData;
                        includeInfo.ID       = moduleInfo.ID + "_RD_" + name;
                        includeInfo.Params   = name;
                        includeInfo.IsActive = true;
                        includeInfo.ID       = includeInfo.ID.Substring(0, Math.Min(50, includeInfo.Name.Length));
                        moduleIncludeDao.Save(rep, includeInfo);
                    }

                    foreach (string s in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\functions\\"))
                    {
                        string name = System.IO.Path.GetFileNameWithoutExtension(s);

                        ModuleIncludeInfo includeInfo = new ModuleIncludeInfo();
                        includeInfo.Module            = moduleInfo;
                        includeInfo.ModuleIncludeType = ModuleIncludeType.DbFunction;
                        includeInfo.ID       = moduleInfo.Name + "_DF_" + name;
                        includeInfo.Params   = name;
                        includeInfo.IsActive = true;
                        includeInfo.ID       = includeInfo.Name.Substring(0, Math.Min(50, includeInfo.ID.Length));
                        moduleIncludeDao.Save(rep, includeInfo);
                    }
                    foreach (string s in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\triggers\\"))
                    {
                        string name = System.IO.Path.GetFileNameWithoutExtension(s);

                        ModuleIncludeInfo includeInfo = new ModuleIncludeInfo();
                        includeInfo.Module            = moduleInfo;
                        includeInfo.ModuleIncludeType = ModuleIncludeType.DbTrigger;
                        includeInfo.ID       = moduleInfo.ID + "_DT_" + name;
                        includeInfo.Params   = name;
                        includeInfo.IsActive = true;
                        includeInfo.ID       = includeInfo.ID.Substring(0, Math.Min(50, includeInfo.ID.Length));
                        moduleIncludeDao.Save(rep, includeInfo);
                    }
                    foreach (string s in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\views\\"))
                    {
                        string name = System.IO.Path.GetFileNameWithoutExtension(s);

                        ModuleIncludeInfo includeInfo = new ModuleIncludeInfo();
                        includeInfo.Module            = moduleInfo;
                        includeInfo.ModuleIncludeType = ModuleIncludeType.DbView;
                        includeInfo.ID       = moduleInfo.ID + "_DV_" + name;
                        includeInfo.Params   = name;
                        includeInfo.IsActive = true;
                        includeInfo.ID       = includeInfo.ID.Substring(0, Math.Min(50, includeInfo.ID.Length));
                        moduleIncludeDao.Save(rep, includeInfo);
                    }
                    foreach (string s in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\procedures\\"))
                    {
                        string name = System.IO.Path.GetFileNameWithoutExtension(s);

                        ModuleIncludeInfo includeInfo = new ModuleIncludeInfo();
                        includeInfo.Module            = moduleInfo;
                        includeInfo.ModuleIncludeType = ModuleIncludeType.DbProcedure;
                        includeInfo.ID       = moduleInfo.ID + "_DP_" + name;
                        includeInfo.Params   = name;
                        includeInfo.IsActive = true;
                        includeInfo.ID       = includeInfo.ID.Substring(0, Math.Min(50, includeInfo.ID.Length));
                        moduleIncludeDao.Save(rep, includeInfo);
                    }

                    foreach (string s in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\sourcedata\\"))
                    {
                        string name = System.IO.Path.GetFileNameWithoutExtension(s);

                        ModuleIncludeInfo includeInfo = new ModuleIncludeInfo();
                        includeInfo.Module            = moduleInfo;
                        includeInfo.ModuleIncludeType = ModuleIncludeType.ApplicationDictionaryData;
                        includeInfo.ID       = moduleInfo.ID + "_AD_" + name;
                        includeInfo.Params   = name;
                        includeInfo.IsActive = true;
                        includeInfo.ID       = includeInfo.ID.Substring(0, Math.Min(50, includeInfo.ID.Length));
                        moduleIncludeDao.Save(rep, includeInfo);
                    }

                    rep.CommitTransaction();
                }
                catch (Exception ex)
                {
                    rep.RollbackTransaction();
                    ExceptionProcess.ProcessWithNotify(ex);
                }
            }
        }