Ejemplo n.º 1
0
        private static void  InitUpdate()
        {
            #region 工管中心MD5验证

            string          ErrMsg           = string.Empty;
            Logger          log              = new Logger(Path.Combine(Directory.GetCurrentDirectory(), "Log"));
            CaijiCommHelper _CaijiCommHelper = new CaijiCommHelper(log);
            if (!GetMD5(_CaijiCommHelper.GetECode(Convert.ToString(ConfigurationManager.ConfigurationManager.AppSettings["Machinecode"])), out ErrMsg))
            {
            }
            else
            {
            }


            #endregion
        }
Ejemplo n.º 2
0
        private void InitUpdate()
        {
            SetThreadControlEnabled(btnLogin, false);
            if (_CaijiCommHelper.TestServerConnection())
            {
                bNetWorkIsConnected = true;
            }
            else
            {
                bNetWorkIsConnected = false;
            }

            SetThreadControlText(btnLogin, "更新");
ChangSYS:

            SetThreadControlText(lblUpdateStatus, "初始化连接服务器.....");
            if (bNetWorkIsConnected)
            {
                JZUpgrade.UpdateHelperClient uhc = new JZUpgrade.UpdateHelperClient("5");
                if (!uhc.IsNewest())
                {
                    DataTable dt   = uhc.GetNewUpdate();
                    bool      flag = false;
                    try
                    {
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                SetThreadControlText(lblUpdateStatus, "正在获取更新...");
                                String subFolder = uhc.GetSubFolder(dt.Rows[i]["FileType"].ToString());
                                String path      = Path.Combine(Application.StartupPath, "update\\" + subFolder);
                                if (!Directory.Exists(path))
                                {
                                    Directory.CreateDirectory(path);
                                }
                                String file  = Path.Combine(path, dt.Rows[i]["FileName"].ToString());
                                byte[] bytes = uhc.GetUpdateFileByID(new Guid(dt.Rows[i]["ID"].ToString()));
                                SetThreadControlText(lblUpdateStatus, "正在保存更新...");
                                if (bytes != null)
                                {
                                    File.WriteAllBytes(file, bytes);
                                    uhc.SaveUpdateInfo(dt.Rows[i]["ID"].ToString(), dt.Rows[i]["FileName"].ToString(),
                                                       dt.Rows[i]["FileType"].ToString(),
                                                       System.Convert.ToDateTime(dt.Rows[i]["CreatedServerTime"]).ToString("yyyy-MM-dd HH:mm:ss.fff"));
                                }
                                if (i == dt.Rows.Count - 1)
                                {
                                    SetThreadControlText(lblUpdateStatus, "更新文件获取成功!");
                                }
                            }

                            SetThreadControlText(lblUpdateStatus, "获取更新完毕");

                            flag = true;
                        }
                        else
                        {
                            SetThreadControlText(lblUpdateStatus, "获取更新完毕");

                            flag = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        _Log.WriteLog(ex.StackTrace, false, true);
                    }
                    timerUpdate.Enabled             = false;
                    PICUpdateStatus.BackgroundImage = Properties.Resources.dot_green;
                    IsUpdate = false;
                    if (flag == true)
                    {
                        SetThreadControlText(lblUpdateStatus, "请点击更新按钮开始更新");
                        SetThreadControlEnabled(btnLogin, true);
                        IsUpdate = true;
                    }
                    else
                    {
                        PICUpdateStatus.BackgroundImage = Properties.Resources.dot_red;
                        SetThreadControlText(lblUpdateStatus, "更新失败,请和管理员联系");
                        IsUpdate = false;
                    }
                }
                else
                {
                    #region 工管中心MD5验证

                    SetThreadControlText(lblUpdateStatus, "工管中心文件验证.....");
                    if (_CaijiCommHelper.GetIsRemotCheck())
                    {
                        string ErrMsg = string.Empty;
                        if (!GetMD5(_CaijiCommHelper.GetECode(_Module.SpecialSetting.MachineCode), out ErrMsg))
                        {
                            MessageBox.Show(ErrMsg, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                            SetThreadControlText(lblUpdateStatus, "系统验证失败,请联系管理员!");
                            return;
                        }
                        else
                        {
                            _Log.WriteLog("系统验证成功", false, false);
                        }
                    }
                    #endregion

                    SetThreadControlText(btnLogin, "登陆");
                    SetThreadControlEnabled(btnLogin, true);
                    IsUpdate = false;
                    PICUpdateStatus.Image = Kingrocket.CJ.Components.Properties.Resources.dot_green;
                    SetThreadControlText(lblUpdateStatus, "当前是最新版本");
                }
            }
            else
            {
                ChangAddress();
                if (bNetWorkIsConnected)
                {
                    goto ChangSYS;
                }
                else
                {
                    SetThreadControlEnabled(btnLogin, true);
                    SetThreadControlText(btnLogin, "登陆");
                    Yqun.Common.ContextCache.ApplicationContext.Current.ISLocalService = true;
                    SetThreadControlText(lblUpdateStatus, "网络连接失败,转到本地登录,请联系管理员");
                    Yqun.Common.ContextCache.ApplicationContext.Current.ISLocalService = true;
                }
            }
        }