ActionResultBase IGet.Get(WebPanelItemCollection saveCollection) { if (saveCollection.CollectionType == typeof(SubDomainItem) && this is IWebPanelObjectActions.ISubDomainActions.ISubDomainGet) { return(((IWebPanelObjectActions.ISubDomainActions.ISubDomainGet) this).Get(saveCollection)); } else if (saveCollection.CollectionType == typeof(DomainItem) && this is IWebPanelObjectActions.IDomainActions.IDomainGet) { return(((IWebPanelObjectActions.IDomainActions.IDomainGet) this).Get(saveCollection)); } throw new ArgumentException("Not Supported object type!"); }
/// <summary> /// Метод получает главный домен /// </summary> /// <returns></returns> /* DomainItem GetMainDomain() * { * DomainItem MainDomain = null; * cPanel_ActionResult result = new cPanel_ActionResult(); * result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) => * { * if (nodeList != null) * { * string mainDomain = nodeList[0]["result"].InnerText; * if (!string.IsNullOrEmpty(mainDomain)) * { * MainDomain = new DomainItem(mainDomain); * return ActionResultCode.Success; * } * } * return ActionResultCode.Error_EmptyServerAnswer; * }); * result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("print", "", APIVersion.v1, new CommandArgs("arg-0", "$CPDATA{'DNS'}")), this.Account.WebSession)); * return MainDomain; * }*/ /// <summary> /// Метод получает главный домен альтернативным способ /// </summary> /// <returns></returns> DomainItem GetMainDomain() { DomainItem MainDomain = null; WebPanelItemCollection domainCollection = new WebPanelItemCollection(typeof(WebPanelItems.DomainItem)); if (((IWebPanelObjectActions.IDomainActions.IDomainGet) this).Get(domainCollection) && domainCollection.Count > 0) { if (domainCollection[0] != null && domainCollection[0].ExtViewData != null && domainCollection[0].ExtViewData["rootdomain"] != null) { MainDomain = new DomainItem(domainCollection[0].ExtViewData["rootdomain"]); } } return(MainDomain); }
ActionResultBase IDomainGet.Get(WebPanelItemCollection saveCollection) { DirectAdmin_ActionResult result = new DirectAdmin_ActionResult(); result.DataTextProccessor = new DirectAdmin_ActionResult.DataTextHandler((InputText) => { foreach (KeyValuePair <string, string> domainNow in StrHelpClass.ToKeyValueURLString(InputText, true)) { saveCollection.Add(new DirectAdmin_Domain(domainNow.Key, StrHelpClass.ToNameValueURLString(domainNow.Value))); } return(ActionResultCode.Success); }); result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_ADDITIONAL_DOMAINS", ""), this.Account.WebSession)); return(result); }
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); }
/// <summary> /// Метод получает все поддомены для указанного поддомена /// </summary> ActionResultBase GetAllAdditionalDomains(DomainItem domain, WebPanelItemCollection SubDomainList) { DirectAdmin_ActionResult result = new DirectAdmin_ActionResult(); result.DataTextProccessor = new DirectAdmin_ActionResult.DataTextHandler((InputText) => { foreach (KeyValuePair <string, string> domainNow in StrHelpClass.ToKeyValueURLString(InputText, true)) { SubDomainList.Add(new SubDomainItem(domain.Name, domainNow.Value)); } return(ActionResultCode.Success); }); CommandArgs arg = new CommandArgs("domain", domain.Name); result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("CMD_API_SUBDOMAINS", "", arg), this.Account.WebSession)); return(result); }
ActionResultBase IDomainGet.Get(WebPanelItemCollection saveCollection) { cPanel_ActionResult result = new cPanel_ActionResult(); result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) => { if (nodeList != null) { foreach (XmlNode node in nodeList) { saveCollection.Add(new cPanel_Domain(node)); } } return(ActionResultCode.Success); }); result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("AddonDomain", "listaddondomains"), this.Account.WebSession)); return(result); }
ActionResultBase ISubDomainGet.Get(WebPanelItemCollection saveCollection) { DirectAdmin_ActionResult result = new DirectAdmin_ActionResult(); WebPanelItemCollection AdditionDomains = new WebPanelItemCollection(typeof(DomainItem)); result = (DirectAdmin_ActionResult)((IWebPanelObjectActions.IDomainActions.IDomainGet) this).Get(AdditionDomains); if (result) { foreach (DomainItem domain in AdditionDomains) { if (!string.IsNullOrEmpty(domain.ExtViewData["subdomain"]) && domain.ExtViewData["subdomain"] != "0") { GetAllAdditionalDomains(domain, saveCollection); } } } return(result); }
ActionResultBase BatchDomainTools.IWebPanelObjectActions.ISubDomainActions.ISubDomainGet.Get(WebPanelItemCollection saveCollection) { cPanel_ActionResult result = new cPanel_ActionResult(); DomainItem mainDomain = GetMainDomain(); //if(mainDomain==null) // mainDomain = GetMainDomainAlternative(); result.DataNodeProccessor = new cPanel_ActionResult.DataNodeHandler((nodeList) => { if (nodeList != null) { foreach (XmlNode node in nodeList) { cPanel_SubDomain subDomain = new cPanel_SubDomain(node); if (mainDomain != null && !subDomain.RootDomain.Equals(mainDomain.Name, StringComparison.InvariantCultureIgnoreCase) || mainDomain == null) { saveCollection.Add(subDomain); } } return(ActionResultCode.Success); } return(ActionResultCode.Error_InvalidServerAnswer); }); result.ExecuteQuery(WebNetCommunication.BuildGetRequest(BuildCommandQuery("SubDomain", "listsubdomains"), this.Account.WebSession)); return(result); }
public ActionsTaskForm(ActionsType _actionsType, WebPanelItemCollection ItemsToProcess, Type _workType, WebPanelOptionData.IOptionData ExtOptions) { InitializeComponent(); this.actionsType = _actionsType; if (this.actionsType == ActionsType.Add) { this.ActionBackGroundWorker = new WebPanelActionsTask.ActionAddTask(); this.TaskTypePict.Image = global::BatchDomainTools.Properties.Resources.AddTaskIcon; this.Text = "Добавления новых объектов"; this.desription = new Dictionary <string, string>() { { "Укажите объекты для добавления", "Каждый добавляемый объект должен начинаться с новой строки" }, { "Вы можете указать параметры для добавляемых объектов", "По умолчанию используются стандартные параметры для панели" },// из настроек программы"}, { "Все готово, можно начинать процесс добавления", "Нажмите кнопку старта для начала процесса добавления" } }; } else { if (this.actionsType == ActionsType.Edit) { this.ActionBackGroundWorker = new WebPanelActionsTask.ActionEditTask(); this.TaskTypePict.Image = global::BatchDomainTools.Properties.Resources.EditTaskIcon; this.Text = "Редактирование выделенных объектов"; this.desription = new Dictionary <string, string>() { { "Укажите объекты для редактирования", "Каждый редактируемый объект должен начинаться с новой строки" }, { "Измените параметры для редактируемых объектов", "По умолчанию используются стандартные параметры для панели" }, { "Все готово, можно начинать процесс редактирования", "Нажмите кнопку старта для начала процесса редактирования" } }; } else if (this.actionsType == ActionsType.Remove) { this.ActionBackGroundWorker = new WebPanelActionsTask.ActionRemoveTask(); this.TaskTypePict.Image = global::BatchDomainTools.Properties.Resources.DeleteTaskIcon; this.Text = "Удаление выделенных объектов"; this.desription = new Dictionary <string, string>() { { "Укажите объекты для удаления", "Каждый удаляемый объект должен начинаться с новой строки" }, { "Измените параметры удаления объектов", "По умолчанию будут использованны параметры из настроек программы" }, { "Можно начинать процесс удаления", "Для начала процесса удаления нажмите на кнопку старта" } }; } } if (ExtOptions == null) { this.tablessControl1.TabPages.Remove(this.PropertyChangeTabPage); this.desription.Remove(this.desription.ElementAt(1).Key); } else { this.PropertyData = ExtOptions; this.OptionsGrid.SelectedObject = this.PropertyData; this.OptionsGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(OprionsGrid_PropertyValueChanged); } this.tablessControl1.SelectedIndexChanged += new EventHandler(tablessControl1_SelectedIndexChanged); this.ActionBackGroundWorker.ProgressChanged += new ProgressChangedEventHandler(bgWorker_ProgressChanged); this.ActionBackGroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(ActionBackGroundWorker_RunWorkerCompleted); this.workType = _workType; this.panel3.Paint += new PaintEventHandler((_sender, _e) => { ControlPaint.DrawBorder(_e.Graphics, _e.ClipRectangle, Color.Transparent, 0, ButtonBorderStyle.None, Color.FromArgb(223, 223, 223), 1, ButtonBorderStyle.Solid, Color.Transparent, 0, ButtonBorderStyle.None, Color.Transparent, 0, ButtonBorderStyle.None); }); this.panel2.Paint += new PaintEventHandler((__sender, __e) => { ControlPaint.DrawBorder(__e.Graphics, __e.ClipRectangle, Color.Transparent, 0, ButtonBorderStyle.None, Color.Transparent, 0, ButtonBorderStyle.Solid, Color.Transparent, 0, ButtonBorderStyle.None, Color.FromArgb(223, 223, 223), 1, ButtonBorderStyle.Solid); }); this.TitleLabel.Text = desription.ElementAt(this.tablessControl1.SelectedIndex).Key; this.Desriptionlabel.Text = desription.ElementAt(this.tablessControl1.SelectedIndex).Value; if (ItemsToProcess != null) { this.DomaintBox.Lines = ItemsToProcess.ToStringArray(); } }
/// <summary> /// Создает экземпляр ActionsExecuteForm для изменения переданных элементов /// </summary> public ActionsTaskForm(WebPanelItemCollection ItemsToProcess, WebPanelOptionData.IOptionData EditOptions) : this(ActionsType.Edit, ItemsToProcess, ItemsToProcess.CollectionType, EditOptions) { }
/// <summary> /// Создает экземпляр ActionsExecuteForm для удаления переданных элементов /// </summary> public ActionsTaskForm(WebPanelItemCollection ItemsToProcess) : this(ActionsType.Remove, ItemsToProcess, ItemsToProcess.CollectionType, null) { }