示例#1
0
        /// <summary>
        /// 修改License
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLicenseFile_Click(object sender, EventArgs e)
        {
            try
            {
                using (OpenFileDialog dialog = new OpenFileDialog())
                {
                    if (!string.IsNullOrWhiteSpace(this.txtLicenseFile.Text))
                    {
                        string fileDir = Path.GetDirectoryName(this.txtLicenseFile.Text);
                        if (Directory.Exists(fileDir))
                        {
                            dialog.InitialDirectory = fileDir;
                        }
                        dialog.FileName = Path.GetFileName(this.txtLicenseFile.Text);
                    }
                    dialog.Title    = "Select License file.";
                    dialog.Filter   = string.Format("key pack file(*.{0})|*.{0}", "keys");
                    dialog.Filter  += string.Format("|{0} file(*.{0})|*.{0}", "key");
                    dialog.Filter  += "|All file(*.*)|*.*";
                    dialog.FileName = Path.GetFileName(this.txtLicenseFile.Text);
                    if (dialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    this.txtLicenseFile.Text = dialog.FileName;

                    if (MessageBox.Show("确定更新License吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        var tasks = new List <Task>();

                        foreach (var iixServer in Global.ListIIXSerevr)
                        {
                            if (iixServer.IsEnable == false)
                            {
                                continue;
                            }

                            tasks.Add(Task.Factory.StartNew(() =>
                            {
                                IIXExecute.UpdateLicense(iixServer, dialog.FileName);
                            }));
                        }

                        Task.WaitAll(tasks.ToArray());
                    }
                }
            }
            catch (Exception ex)
            {
                Log.GetInstance().ErrorWrite("系统错误,请查询日志文件检查。");
                Log.WriterExceptionLog(ex.ToString());
            }
        }