Ejemplo n.º 1
0
        //ajax定时请求
        private void AjaxJSON()
        {
            string ajaxQS = Request["ajaxstr"];
            if (ajaxQS == "getstate")
            {
                Max.Installs.Progress p = Settings.Current.ProgressAccess;
                int isCompleted = Settings.Current.IsCompleted ? 1 : 0;
                string isError = string.IsNullOrEmpty(p.Error) ? "false" : "true";
                string error = p.Error;
                string step = p.Step.ToString();
                string percent = p.Percent.ToString();
                string indx = Settings.Current.Error.ToString();

                string message = Settings.Current.Message;

                if (string.IsNullOrEmpty(message))
                    message = string.Empty;

                if (Settings.Current.IsCompleted)
                {
                    //删除、修改文件



                    SetupManager.ConvertDefaultEmotions();
#if SQLITE
                    if (Settings.Current.SetupMode == Max.Installs.SetupMode.New)
                        error = SetupManager.SetDatabase();
#endif
                    error += SetupManager.ConfigConnectionString();

                    //try
                    //{
                    //    tryDeleteDirectory("/UserFiles/Avatar");
                    //}
                    //catch (Exception ex)
                    //{
                    //    CreateLog(ex.Message);
                    //}

                    if (string.IsNullOrEmpty(error))
                        error = SetupManager.AlterGolbals();

                    if (string.IsNullOrEmpty(error))
                    {
                        SetupManager.DeleteOldFiles();

                        bool deleteImages = (SetupManager.ErrorMessages.Count == 0);
                        if (string.IsNullOrEmpty(message))
                            message += SetupManager.DeleteSetupFiles(deleteImages);
                        else
                            message += "<br />" + SetupManager.DeleteSetupFiles(deleteImages);


                        message += "<br />提示:任何页面首次访问将需要3-5秒钟才能打开,这是为了加速之后的访问,不是程序有问题(每次重启服务器都会进行加速)";

                        if (SetupManager.ErrorMessages.Count > 0)
                        {

                            message = message + "<br />升级过程中发生了" + SetupManager.ErrorMessages.Count + "个错误,需要您手动修正,具体请参见安装目录下的InstallLog.txt文件";

                            string errorMessages = "===================================================================\r\n";
                            errorMessages += "升级过程中发生了" + SetupManager.ErrorMessages.Count + "个错误,需要您手动修正以下错误\r\n";

                            int i = 1;
                            foreach (string m in SetupManager.ErrorMessages)
                            {
                                errorMessages += i + "." + m + "\r\n";
                                i++;
                            }
                            errorMessages += "\r\n最后请删除目录“/Images”\r\n";
                            errorMessages += "===================================================================\r\n";

                            SetupManager.CreateLog(errorMessages);
                        }
                    }
                    else
                    {
                        isError = "true";
                        isCompleted = 0;
                        //只要出错,就中止过程
                        Settings.Current.ProgressAccess = Max.Installs.Progress.Notset;
                    }


                }
                else if (!string.IsNullOrEmpty(p.Error))
                {
                    isError = "true";
                    isCompleted = 0;
                    Settings.Current.ProgressAccess = Max.Installs.Progress.Notset;
                }

                string json = "p = {'IsError':" + isError + ",'Error':'" + Globals.SafeJS(error) + "','message':'" + Globals.SafeJS(message) + "','Indx':" + indx + ",'Step':" + step + ",'Percent':" + percent + ",'IsCompleted':" + isCompleted + ",'title':'" + Globals.SafeJS(Settings.Current.ProgressAccess.Title) + "'};";
                Response.Write(json);
                Response.End();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 开始安装
        /// </summary>
        private void Setup()
        {
            int      stepIndex = 0;
            Settings setting   = Settings.Current;

            setting.RootPath = SiteInfo.Current.WebPath;
            string error = string.Empty;

            try
            {
                //解压文件
                stepIndex++;
                installWaiter.UpZip();

                ResetBar();

                //数据库操作  sql
                stepIndex++;
                SetupManager.InstallDatabase(delegate(int percent, string message)
                {
                    setting.ProgressAccess = new Progress("安装/更新数据库", percent, stepIndex);
                    InstallBarDelegate delegateInstallDb = new InstallBarDelegate(InstallDb);
                    installBars.BeginInvoke(delegateInstallDb);
                });

#if SQLITE
                if (Settings.Current.SetupMode == Max.Installs.SetupMode.New)
                {
                    error = SetupManager.SetDatabase();
                }
#endif

                ResetBar();

                //写入配置文件
                stepIndex++;
                ConfigConnectionString();
                SetupManager.AlterGolbals(SiteInfo.Current.WebPath + "\\");
#if SQLSERVER
                if (Settings.Current.SetupMode == Max.Installs.SetupMode.New)
                {
                    SetupManager.CreateAdministrator();//创建管理员
                }
#endif
                setting.ProgressAccess = new Progress("写入配置文件", 100, stepIndex);
                InstallBarDelegate delegateSetConfig = new InstallBarDelegate(SetConfig);
                installBars.BeginInvoke(delegateSetConfig);

                ResetBar();

                //特殊文件夹权限设置
                SetSpecialPurview();
                setting.ProgressAccess = new Progress("设置文件夹权限", 100, stepIndex);
                InstallBarDelegate delegateSetPurview = new InstallBarDelegate(SetPurview);
                installBars.BeginInvoke(delegateSetPurview);

                //完成
                InstallBarDelegate delegateInstallFinish = new InstallBarDelegate(InstallFinish);
                installBars.BeginInvoke(delegateInstallFinish);
            }
            catch (Exception ex)
            {
                Thread.CurrentThread.Abort();
                SetupManager.CreateLog(ex);
                MessageBox.Show(ex.Message, "bbsMax安装向导", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }