示例#1
0
 protected virtual void ActionResultCode_ErrorBasic(ActionResultBase result)
 {
     OnProgressChanged(ErrorMessage + result.ErrorMessage, ViewStatus.Error);
     if (result.ActionCode == ActionResultCode.Error_AuthError)
     {
         this.CancelAsync();
     }
 }
示例#2
0
 protected virtual void PrepareData()
 {
     if (this.PropertyData is WebPanelOptionData.ISPmanager_DomainOption)
     {
         BatchDomainTools.WebPanelOptionData.ISPmanager_DomainOption options = this.PropertyData as WebPanelOptionData.ISPmanager_DomainOption;
         if (options.IPAddrs == null || options.IPAddrs.Length == 0)
         {
             try
             {
                 options.IPAddrs = new string[] {
                     System.Net.Dns.GetHostAddresses(WebPanelAccount.AccountManager.SelectAccount.PanelAddr.DnsSafeHost)[0].ToString()
                 };
             }
             catch (Exception ex)
             {
                 this.ReportProgress(0, string.Format("[MCOLOR:Red]Не удалось получить основной IP адрес для веб-панели ISPmanager:{0}[/MCOLOR]", ex.Message));
                 this.CancelAsync();
                 return;
             }
         }
     }
     if (this is ActionEditTask || this is ActionRemoveTask)
     {
         IWebPanelBasicActions.IGet           GetInstance    = WebPanelAccount.AccountManager.SelectAccount.WebPanelAPI;
         WebPanelItems.WebPanelItemCollection TempCollection = new BatchDomainTools.WebPanelItems.WebPanelItemCollection(this.Quenu.CollectionType);
         ActionResultBase result = GetInstance.Get(TempCollection);
         if (!result)
         {
             this.ReportProgress(0,
                                 String.Format("[MCOLOR:Red]Не удалось получить список для сопоставления объектов: {0}[/MCOLOR]", result.ErrorMessage));
             this.CancelAsync();
             return;
         }
         if (TempCollection.Count == 0)
         {
             this.ReportProgress(0, "[MCOLOR:Red]В хостинг панели нет указанных объектов .[/MCOLOR]");
             this.CancelAsync();
             return;
         }
         for (int iNeddle = 0; iNeddle < this.Quenu.Count; iNeddle++)
         {
             for (int iHaystack = 0; iHaystack < TempCollection.Count; iHaystack++)
             {
                 if (this.Quenu[iNeddle].Equals(TempCollection[iHaystack]))
                 {
                     this.Quenu[iNeddle] = TempCollection[iHaystack];
                     TempCollection.RemoveAt(iHaystack);
                     break;
                 }
             }
         }
     }
 }
 private void ActionResultCode_Error_ServerTimeout(ActionResultBase result, WebPanelItems.WebPanelItemBase item)
 {
     OnProgressChanged(result.ErrorMessage + ".Проверяем был удален или нет.", ViewStatus.ErrorNotCritical);
     if (!GetInstance.Exist(item))
     {
         base.ActionResultCode_Success(result);
     }
     else
     {
         OnProgressChanged("Объект не был удален, пробуем еще раз.", ViewStatus.ErrorNotCritical);
         this.CurrentIndex--;
     }
 }
示例#4
0
        private T ProcessAction <T>(IAction action) where T : ActionResultBase
        {
            ActionResultBase result = action.Process(GameState, Config);

            if (result.IsDead)
            {
                StartFromBeginning();
            }

            if (result is T)
            {
                return((T)result);
            }

            throw new InvalidCastException(String.Format("Invalid action processor for {0}", action));
        }
        protected override void OnDoWork2(System.ComponentModel.DoWorkEventArgs e)
        {
            ActionResultBase       result        = null;
            WebPanelItemCollection TopDomainList = null;

            if (this.Quenu.CollectionType == typeof(SubDomainItem))
            {
                this.ReportProgress(0, "Получаем список основных доменов.");
                TopDomainList = new WebPanelItemCollection(typeof(DomainItem));
                if (!(result = this.GetInstance.Get(TopDomainList)))
                {
                    this.ReportProgress(0, string.Format("[MCOLOR:Red]Не удалось получить список основных доменов:{0}[/MCOLOR]", result.ErrorMessage));
                    this.CancelAsync();
                    return;
                }
                if (TopDomainList.Count == 0)
                {
                    this.ReportProgress(0, "[MCOLOR:Red]Не обнаруженно основных доменов. Невозможно добавит поддомены не имея основных доменов.[/MCOLOR]");
                    this.CancelAsync();
                    return;
                }
            }
            for (this.CurrentIndex = 0; this.CurrentIndex < base.Quenu.Count; this.CurrentIndex++)
            {
                if (base.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
                WebPanelItems.WebPanelItemBase workObject = this.Quenu[this.CurrentIndex];
                OnProgressChanged("", ViewStatus.Select);
                if (TopDomainList != null)
                {
                    workObject = WebPanelItems.SubDomainItem.FindAndMake(workObject.Name, TopDomainList);
                    if (workObject == null)
                    {
                        OnProgressChanged("Не возможно добавить поддомен, поскольку не найден основной домен.", ViewStatus.Error);
                        continue;
                    }
                }
                result = AddInstance.Add(workObject, base.PropertyData);
                base.ProcessResult(result, workObject);
                TimeOut();
            }
            this.ReportProgress(100);
        }
        public void HealAction_Heal_DecreaseCoins()
        {
            GameState state = new GameState();

            state.CurrentPlayer = new Player();
            state.CurrentPlayer.Initialize(10, 20, 10, 10);

            IAction healAction = new HealAction();

            Assert.AreEqual(healAction.CanApply(state, config), true);

            ActionResultBase actionResult = healAction.Process(state, config);

            Assert.AreEqual(actionResult.IsSeccessful, true);

            Assert.AreEqual(state.CurrentPlayer.Coins, 0);
            Assert.AreEqual(state.CurrentPlayer.Health, 20);
        }
示例#7
0
 /// <summary>
 /// Метод обрабатывает результат выполнеия оцерации над объектом из очереди
 /// </summary>
 /// <param name="result"></param>
 protected void ProcessResult(ActionResultBase result, WebPanelItems.WebPanelItemBase item)
 {
     if (ResultDelegates.ContainsKey(result.ActionCode))
     {
         ResultDelegates[result.ActionCode](result, item);
     }
     else
     {
         if (result)
         {
             this.ActionResultCode_Success(result);
         }
         else
         {
             this.ActionResultCode_ErrorBasic(result);
         }
     }
 }
示例#8
0
 protected virtual void ActionResultCode_Success(ActionResultBase result)
 {
     OnProgressChanged(this.SuccessMessage, ViewStatus.Success);
     this.Quenu.RemoveAt(this.CurrentIndex);
     this.CurrentIndex--;
 }
 /// <summary>
 /// Метод вызывается при попытки добавить объект, который уже есть в панели управления
 /// </summary>
 private void ActionResultCode_Error_ObjectAlreadyExist(ActionResultBase result, WebPanelItems.WebPanelItemBase item)
 {
     OnProgressChanged("Уже добавлен!", ViewStatus.ErrorNotCritical);
     base.ActionResultCode_Success(result);
 }