Exemplo n.º 1
0
 /// <summary>
 /// 启动运动按钮选中事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ckbAllowMovement_CheckedChanged(object sender, EventArgs e)
 {
     Global.IsAllowMove = this.ckbAllowMovement.Checked;
     Global.AllowMove();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 加载当前项目信息
        /// </summary>
        private bool LoadProduct()
        {
            try
            {
                var productName = this.cbbProductName.SelectedItem.ToString();

                if (MoveExecute.LoadSettings(productName))
                {
                    Log.GetInstance().NormalWrite("重新加载项目配置文件配置成功。");
                }
                else
                {
                    Log.GetInstance().ErrorWrite("重新加载项目配置文件配置失败。");
                    this.lastProductName = null;
                    this.cbbProductName.SelectedIndex = -1;
                    return(false);
                }

                var currentProductPath = Path.Combine(this.productPath, productName);
                var fileName           = Global.IsExistFileBySuffixName(currentProductPath, ".bin");

                if (fileName == "")
                {
                    Log.GetInstance().ErrorWrite(string.Format("目录 '{0}' 下没有找到该项目的bin文件,切换项目失败。", currentProductPath));
                    this.lastProductName = null;;
                    this.cbbProductName.SelectedIndex = -1;
                    return(false);
                }

                ///
                ///设置Recipe
                ///
                var           tasks = new List <Task>();
                CmdResultCode cmdRes;
                bool          f = false;

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

                    tasks.Add(Task.Factory.StartNew(() =>
                    {
                        cmdRes = IIXExecute.SetRecipe(iixServer, Path.Combine(currentProductPath, fileName));

                        if (cmdRes != CmdResultCode.Success)
                        {
                            f = false;
                        }
                    }));
                }

                Task.WaitAll(tasks.ToArray());

                if (!f)
                {
                    Log.GetInstance().ErrorWrite(string.Format("切换项目失败,原因:设置Recipe失败。"));
                    this.lastProductName = null;
                    this.cbbProductName.SelectedIndex = -1;
                    return(false);
                }

                //修改配置文件中当前项目名
                IniFile.IniWriteValue("Product", "ProductName", productName, Global.ConfigPath);
                this.lastProductName = productName;

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

                return(false);
            }
        }