Ejemplo n.º 1
0
        /// <summary>
        /// 反安装
        /// </summary>
        /// <param name="moduleName"></param>
        public static void UninstallModule(string moduleName)
        {
            CreateNecessaryDirectories(moduleName);

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

            IList <ModuleInfo> moduleInfos = ADInfoBll.Instance.GetInfos <ModuleInfo>("from Feng.ModuleInfo where Id = '" + moduleName + "'");

            if (moduleInfos.Count == 0)
            {
                throw new ArgumentException("There is no module named " + moduleName);
            }
            CompressionHelper.DecompressToFolder(moduleInfos[0].ModuleData, System.IO.Directory.GetCurrentDirectory());

            // ReferenceData
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\referencedata\\standard\\"))
            {
                ADUtils.DeleteFromXmlFile(file);
            }
            // ApplicationDictionaryData
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\sourcedata\\"))
            {
                string s = System.IO.Path.GetFileNameWithoutExtension(file);
                if (s.StartsWith("AD_Module"))
                {
                    continue;
                }

                ADUtils.DeleteFromXmlFile(file);
            }

            //// DbTable
            //foreach (string file in System.IO.Directory.GetFiles(dir + "src-db\\database\\model\\tables\\"))
            //{
            //}

            // DbView
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\views\\"))
            {
                string script = "DROP VIEW " + System.IO.Path.GetFileNameWithoutExtension(file);
                DbHelper.Instance.ExecuteNonQuery(script);
            }
            // DbFunction
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\functions\\"))
            {
                string script = "DROP FUNCTION " + System.IO.Path.GetFileNameWithoutExtension(file);
                DbHelper.Instance.ExecuteNonQuery(script);
            }
            // DbTrigger
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\triggers\\"))
            {
                string script = "DROP TRIGGER " + System.IO.Path.GetFileNameWithoutExtension(file);
                DbHelper.Instance.ExecuteNonQuery(script);
            }
            // DbProcedure
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\procedures\\"))
            {
                string script = "DROP PROCEDURE " + System.IO.Path.GetFileNameWithoutExtension(file);
                DbHelper.Instance.ExecuteNonQuery(script);
            }
        }
        /// <summary>
        /// 下载,和本地合并
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="userDirectory"></param>
        public static DateTime?DownloadConfiguration(string userName, string userDirectory)
        {
            UserConfigurationInfo userInfo = ADInfoBll.Instance.GetUserConfigurationInfo(userName);

            if (userInfo == null)
            {
                return(null);
            }

            bool   downloadNew     = true;
            string versionFileName = Path.Combine(userDirectory, m_configurationVersionFile);

            if (Directory.Exists(userDirectory))
            {
                //byte[] userData = CompressionHelper.CompressFromFolder(userDirectory);
                //if (userInfo.UserDataLength == userData.Length)
                //{
                //    downloadNew = false;
                //}
                if (File.Exists(versionFileName))
                {
                    using (StreamReader sr = new StreamReader(versionFileName))
                    {
                        string s       = sr.ReadLine();
                        int?   version = Feng.Utils.ConvertHelper.ToInt(s);
                        if (version.HasValue && version.Value == userInfo.Version)
                        {
                            downloadNew = false;
                        }
                    }
                }
            }
            else
            {
                System.IO.Directory.CreateDirectory(userDirectory);
            }

            if (downloadNew)
            {
                try
                {
                    try
                    {
                        Feng.Utils.IOHelper.HardDirectoryDelete(userDirectory);
                    }
                    catch (Exception)
                    {
                    }

                    ADInfoBll.Instance.GetUserConfigurationData(userInfo);
                    CompressionHelper.DecompressToFolder(userInfo.UserData, SystemDirectory.DataDirectory);

                    using (StreamWriter sw = new StreamWriter(versionFileName))
                    {
                        sw.WriteLine(userInfo.Version.ToString());
                    }
                }
                catch (Exception)
                {
                }
            }
            return(userInfo.Updated.HasValue ? userInfo.Updated : userInfo.Created);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 安装Module
        /// </summary>
        /// <param name="moduleName"></param>
        public static void InstallModule(string moduleName)
        {
            CreateNecessaryDirectories(moduleName);

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

            //// CheckModuleDependency
            //IList<ModuleDependencyInfo> moduleDependencyInfos = ADInfoBll.Instance.GetInfos<ModuleDependencyInfo>(
            //    "from ModuleDependencyInfo where Module.Name = :moduleName", new Dictionary<string, object> { { "moduleName", moduleName } });
            //foreach (ModuleDependencyInfo dependency in moduleDependencyInfos)
            //{
            //    if (dependency.DependentModule
            //}
            //// No use now
            ////ModuleByClientInfo moduleByClientInfo = null;
            ////ModuleByOrgInfo moduleByOrgInfo = null;

            IList <ModuleInfo> moduleInfos = ADInfoBll.Instance.GetInfos <ModuleInfo>("from Feng.ModuleInfo where Id = '" + moduleName + "'");

            if (moduleInfos.Count == 0)
            {
                throw new ArgumentException("There is no module named " + moduleName);
            }
            CompressionHelper.DecompressToFolder(moduleInfos[0].ModuleData, System.IO.Directory.GetCurrentDirectory());

            // ReferenceData
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\referencedata\\standard\\"))
            {
                ADUtils.ImportFromXmlFile(file);
            }
            // ApplicationDictionaryData
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\sourcedata\\"))
            {
                string s = System.IO.Path.GetFileNameWithoutExtension(file);
                if (s.StartsWith("AD_Module"))
                {
                    continue;
                }
                ADUtils.ImportFromXmlFile(file);
            }

            //// DbTable
            //foreach (string file in System.IO.Directory.GetFiles(dir + "src-db\\database\\model\\tables\\"))
            //{
            //}

            // DbView
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\views\\"))
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(file))
                {
                    string script = sr.ReadToEnd();
                    DbHelper.Instance.ExecuteNonQuery(script);
                }
            }
            // DbFunction
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\functions\\"))
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(file))
                {
                    string script = sr.ReadToEnd();
                    DbHelper.Instance.ExecuteNonQuery(script);
                }
            }
            // DbTrigger
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\triggers\\"))
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(file))
                {
                    string script = sr.ReadToEnd();
                    DbHelper.Instance.ExecuteNonQuery(script);
                }
            }
            // DbProcedure
            foreach (string file in System.IO.Directory.GetFiles(dir + "\\src-db\\database\\model\\procedures\\"))
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(file))
                {
                    string script = sr.ReadToEnd();
                    DbHelper.Instance.ExecuteNonQuery(script);
                }
            }

            //// SourceModel
            //foreach (string file in System.IO.Directory.GetFiles(dir + "\\src\\model\\"))
            //{
            //}

            //// SourceScript
            //foreach (string file in System.IO.Directory.GetFiles(dir + "\\src\\script\\"))
            //{
            //}

            //// SourceReport
            //foreach (string file in System.IO.Directory.GetFiles(dir + "\\src\\report\\"))
            //{
            //}
        }