/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="xmlDocument"></param> /// <returns></returns> public static AbstractTaskManager Bind(XmlDocument xmlDocument) { XmlNodeList xmlStepInfos = xmlDocument.GetElementsByTagName("stepInfo"); AbstractTaskManager tm = new AbstractTaskManager(); tm.StepInfos = new List <StepInfo>(); foreach (XmlNode xmlStepInfo in xmlStepInfos) { StepInfo si = new StepInfo(xmlStepInfo.Attributes.GetNamedItem("title").Value) { GetActionInfo = new ActionInfo { ActionName = xmlStepInfo.Attributes.GetNamedItem("action").Value, ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value, AreaName = xmlStepInfo.Attributes.GetNamedItem("area").Value }, PostActionInfo = new ActionInfo { ActionName = xmlStepInfo.Attributes.GetNamedItem("action").Value, ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value, AreaName = xmlStepInfo.Attributes.GetNamedItem("area").Value } }; tm.StepInfos.Add(si); } tm.currentStepInfo = tm.StepInfos.First(); return(tm); }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="xmlDocument"></param> /// <returns></returns> public static AbstractTaskManager Bind(XmlDocument xmlDocument) { XmlNodeList xmlStepInfos = xmlDocument.GetElementsByTagName("stepInfo"); AbstractTaskManager tm = new AbstractTaskManager(); tm.StepInfos = new List<StepInfo>(); foreach (XmlNode xmlStepInfo in xmlStepInfos) { StepInfo si = new StepInfo(xmlStepInfo.Attributes.GetNamedItem("title").Value) { GetActionInfo = new ActionInfo { ActionName = xmlStepInfo.Attributes.GetNamedItem("action").Value, ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value, AreaName = xmlStepInfo.Attributes.GetNamedItem("area").Value }, PostActionInfo = new ActionInfo { ActionName = xmlStepInfo.Attributes.GetNamedItem("action").Value, ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value, AreaName = xmlStepInfo.Attributes.GetNamedItem("area").Value } }; tm.StepInfos.Add(si); } tm.currentStepInfo = tm.StepInfos.First(); return tm; }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param>NA</param> public void GoToNext() { this.currentStepInfo.SetStatus(StepStatus.success); StepInfo temp = this.currentStepInfo; this.currentStepInfo = this.Next(); }
public CreateTaskmanager() { MaxStepId = 0; Root = new StepInfo("ROOT") { Id = GenerateStepId() }; }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="index"></param> public void SetCurrent(int index) { currentStepInfo = StepInfos.ElementAt(index); currentStepInfo.SetStatus(StepStatus.inProgress); for (int i = index + 1; i < StepInfos.Count(); i++) { StepInfos.ElementAt(i).SetStatus(StepStatus.none); } }
public bool IsEquals(StepInfo stepInfo) { if (this.Id.Equals(stepInfo.Id)) { return(true); } else { return(false); } }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="stepinfo"></param> public void RemoveExecutedStep(StepInfo stepinfo) { if (TaskInfos == null) { TaskInfos = new List <StepInfo>(); } else { if (TaskInfos.Contains(stepinfo)) { TaskInfos.Remove(stepinfo); } prevStepInfo = TaskInfos.Last(); } }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="stepinfo"></param> public void AddExecutedStep(StepInfo stepinfo) { prevStepInfo = stepinfo; if (TaskInfos == null) TaskInfos = new List<StepInfo>(); if (TaskInfos.Count > 0) { if (TaskInfos.Select(p => p.title.Equals(stepinfo.title)).First()) { StepInfo tempStep = TaskInfos.Where(p => p.title.Equals(stepinfo.title)).First(); TaskInfos.Remove(tempStep); } } TaskInfos.Add(stepinfo); }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="stepinfo"></param> public void AddExecutedStep(StepInfo stepinfo) { prevStepInfo = stepinfo; if (TaskInfos == null) { TaskInfos = new List <StepInfo>(); } if (TaskInfos.Count > 0) { if (TaskInfos.Select(p => p.title.Equals(stepinfo.title)).First()) { StepInfo tempStep = TaskInfos.Where(p => p.title.Equals(stepinfo.title)).First(); TaskInfos.Remove(tempStep); } } TaskInfos.Add(stepinfo); }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param>NA</param> public void GoToPrev() { StepInfo temp = this.currentStepInfo; this.currentStepInfo = this.Prev(); }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="stepInfo"></param> public void SetCurrent(StepInfo stepInfo) { currentStepInfo = stepInfo; currentStepInfo.SetStatus(StepStatus.inProgress); }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="stepInfo"></param> /// <returns></returns> public int GetIndex(StepInfo stepInfo) { return this.StepInfos.IndexOf(stepInfo); }
private List<StepInfo> UpdateStepsBasedOnUsage(BaseUsage usage, StepInfo currentSelected, string parentXpath) { // genertae action, controller base on usage string actionName = ""; string childName = ""; if (usage is MetadataPackageUsage) { actionName = "SetMetadataPackageInstanze"; childName = ((MetadataPackageUsage)usage).MetadataPackage.Name; } else { actionName = "SetMetadataCompoundAttributeInstanze"; if (usage is MetadataNestedAttributeUsage) childName = ((MetadataNestedAttributeUsage)usage).Member.Name; if (usage is MetadataAttributeUsage) childName = ((MetadataAttributeUsage)usage).MetadataAttribute.Name; } List<StepInfo> list = new List<StepInfo>(); List<StepModelHelper> stepHelperModelList = (List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER]; if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) { XDocument xMetadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; var x = XmlUtility.GetXElementByXPath(parentXpath, xMetadata); if (x != null && !x.Name.Equals("null")) { StepInfo current = currentSelected; IEnumerable<XElement> xelements = x.Elements(); if (xelements.Count() > 0) { int counter = 0; foreach (XElement element in xelements) { counter++; string title = counter.ToString(); if (current.Children.Where(s => s.title.Equals(title)).Count() == 0) { long id = Convert.ToInt64((element.Attribute("roleId")).Value.ToString()); StepInfo s = new StepInfo(title) { Id = TaskManager.GenerateStepId(), Parent = current, IsInstanze = true, //GetActionInfo = new ActionInfo //{ // ActionName = actionName, // ControllerName = "CreateSetMetadataPackage", // AreaName = "DCM" //}, //PostActionInfo = new ActionInfo //{ // ActionName = actionName, // ControllerName = "CreateSetMetadataPackage", // AreaName = "DCM" //} }; string xPath = parentXpath + "//" + childName.Replace(" ", string.Empty) + "[" + counter + "]"; s.Children = GetChildrenStepsUpdated(usage, s, xPath); list.Add(s); if (TaskManager.Root.Children.Where(z => z.Id.Equals(s.Id)).Count() == 0) { StepModelHelper parent = GetStepModelhelper(current.Id); StepModelHelper newStepModelHelper = new StepModelHelper(s.Id, counter, usage, xPath, parent); stepHelperModelList.Add(newStepModelHelper); } }//end if }//end foreach }//end if } } return list; }
private List<StepInfo> GetChildrenStepsUpdated(BaseUsage usage, StepInfo parent, string parentXpath) { List<StepInfo> childrenSteps = new List<StepInfo>(); List<BaseUsage> childrenUsages = UsageHelper.GetCompoundChildrens(usage); List<StepModelHelper> stepHelperModelList = (List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER]; foreach (BaseUsage u in childrenUsages) { string label = u.Label.Replace(" ", string.Empty); string xPath = parentXpath + "//" + label + "[1]"; bool complex = false; string actionName = ""; if (u is MetadataPackageUsage) { actionName = "SetMetadataPackage"; } else { actionName = "SetMetadataCompoundAttribute"; if (u is MetadataAttributeUsage) { MetadataAttributeUsage mau = (MetadataAttributeUsage)u; if (mau.MetadataAttribute.Self is MetadataCompoundAttribute) complex = true; } if (u is MetadataNestedAttributeUsage) { MetadataNestedAttributeUsage mau = (MetadataNestedAttributeUsage)u; if (mau.Member.Self is MetadataCompoundAttribute) complex = true; } } if (complex) { StepInfo s = new StepInfo(u.Label) { Id = TaskManager.GenerateStepId(), Parent = parent, IsInstanze = false, //GetActionInfo = new ActionInfo //{ // ActionName = actionName, // ControllerName = "CreateSetMetadataPackage", // AreaName = "DCM" //}, //PostActionInfo = new ActionInfo //{ // ActionName = actionName, // ControllerName = "CreateSetMetadataPackage", // AreaName = "DCM" //} }; s.Children = UpdateStepsBasedOnUsage(u, s, xPath).ToList(); childrenSteps.Add(s); if (TaskManager.Root.Children.Where(z => z.title.Equals(s.title)).Count() == 0) { StepModelHelper p = GetStepModelhelper(parent.Id); stepHelperModelList.Add(new StepModelHelper(s.Id, 1, u, xPath, p)); } } } return childrenSteps; }
public ActionResult AddComplexUsage(int parentStepId, int number) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; //TaskManager.SetCurrent(TaskManager.Get(parentStepId)); long metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]); int position = number + 1; StepModelHelper parentStepModelHelper = GetStepModelhelper(parentStepId); BaseUsage u = LoadUsage(parentStepModelHelper.Usage); //Create new step StepInfo newStep = new StepInfo(UsageHelper.GetNameOfType(u)) { Id = TaskManager.GenerateStepId(), parentTitle = parentStepModelHelper.Model.StepInfo.title, Parent = parentStepModelHelper.Model.StepInfo, IsInstanze = true, }; string xPath = parentStepModelHelper.XPath + "//" + UsageHelper.GetNameOfType(u) + "[" + position + "]"; // add to parent stepId parentStepModelHelper.Model.StepInfo.Children.Add(newStep); TaskManager.StepInfos.Add(newStep); // create Model AbstractMetadataStepModel model = null; if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage) { model = MetadataCompoundAttributeModel.ConvertToModel(parentStepModelHelper.Usage, number); model.Number = position; ((MetadataCompoundAttributeModel)model).ConvertMetadataAttributeModels(LoadUsage(parentStepModelHelper.Usage), metadataStructureId, newStep.Id); //Update metadata xml //add step to metadataxml AddCompoundAttributeToXml(model.Source, model.Number, parentStepModelHelper.XPath); } if (u is MetadataPackageUsage) { model = MetadataPackageModel.Convert(parentStepModelHelper.Usage, number); model.Number = position; ((MetadataPackageModel)model).ConvertMetadataAttributeModels(LoadUsage(parentStepModelHelper.Usage), metadataStructureId, newStep.Id); //Update metadata xml //add step to metadataxml AddPackageToXml(model.Source, model.Number, parentStepModelHelper.XPath); } // create StepModel for new step StepModelHelper newStepModelhelper = new StepModelHelper { StepId = newStep.Id, Usage = parentStepModelHelper.Usage, Number = position, Model = model, XPath = xPath, Level = parentStepModelHelper.Level+1, Activated = true }; newStep.Children = GetChildrenSteps(u, newStep, xPath, newStepModelhelper); newStepModelhelper.Model.StepInfo = newStep; newStepModelhelper = getChildModelsHelper(newStepModelhelper); // add stepmodel to dictionary AddStepModelhelper(newStepModelhelper); //add stepModel to parentStepModel parentStepModelHelper.Childrens.Insert(newStepModelhelper.Number - 1, newStepModelhelper); //update childrens of the parent step based on number for (int i = 0; i < parentStepModelHelper.Childrens.Count; i++) { StepModelHelper smh = parentStepModelHelper.Childrens.ElementAt(i); smh.Number = i + 1; } // add step to parent and update title of steps //parentStepModelHelper.Model.StepInfo.Children.Insert(newStepModelhelper.Number - 1, newStep); for (int i = 0; i < parentStepModelHelper.Model.StepInfo.Children.Count; i++) { StepInfo si = parentStepModelHelper.Model.StepInfo.Children.ElementAt(i); si.title = (i + 1).ToString(); } //// load InstanzB for parentmodel parentStepModelHelper.Model.ConvertInstance((XDocument)(TaskManager.Bus[CreateTaskmanager.METADATA_XML]), parentStepModelHelper.XPath); if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage) { return PartialView("_metadataCompoundAttributeView", parentStepModelHelper); } if (u is MetadataPackageUsage) { return PartialView("_metadataCompoundAttributeView", parentStepModelHelper); } return null; }
private int countSteps(StepInfo step) { int i = 0; if (step.Children.Count > 0) { i = step.Children.Count; foreach (StepInfo s in step.Children) { i += countSteps(s); } } return i; }
/// <summary> /// Remove stepInfo from parent stepInfo /// /// </summary> /// <param name="parent">parent step</param> /// <param name="index">position of the stepinfo in children</param> /// <returns></returns> public StepInfo Remove(StepInfo parent, int index) { try { parent.Children.RemoveAt(index); for (int i = index; i < parent.Children.Count; i++) { int position = i + 1; parent.Children.ElementAt(i).title = position.ToString(); } } catch (Exception ex) { } return parent; }
/// <summary> /// find last step from step /// </summary> /// <param name="stepInfo"></param> /// <returns></returns> public StepInfo Last(StepInfo stepInfo) { return findLast(stepInfo); }
public bool IsRoot(StepInfo stepInfo) { if (stepInfo.Id.Equals(this.Root.Id)) return true; else return false; }
public bool IsCurrent(StepInfo stepInfo) { if (this.currentStepInfo.Id.Equals(stepInfo.Id)) return true; else return false; }
public bool IsChildExpand(StepInfo stepInfo) { if (stepInfo.Children.Count > 0) { foreach (StepInfo child in stepInfo.Children) { if (child.Expand == true) return true; } } return false; }
public bool IsChildCurrent(StepInfo stepInfo) { if(IsCurrent(stepInfo)) { return true; } if (stepInfo.Children.Count > 0) { foreach (StepInfo child in stepInfo.Children) { if(IsChildCurrent(child) ==true) return true; } } return false; }
private void AdvanceTaskManagerBasedOnExistingMetadata(long MetadataStructureId) { TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"]; MetadataStructureManager metadataStructureManager = new MetadataStructureManager(); List<MetadataPackageUsage> metadataPackageList = metadataStructureManager.GetEffectivePackages(MetadataStructureId).ToList(); List<StepModelHelper> stepModelHelperList = new List<StepModelHelper>(); if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_STEP_MODEL_HELPER)) { TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER] = stepModelHelperList; } else { TaskManager.Bus.Add(CreateTaskmanager.METADATA_STEP_MODEL_HELPER, stepModelHelperList); } TaskManager.StepInfos = new List<StepInfo>(); foreach (MetadataPackageUsage mpu in metadataPackageList) { //only add none optional usages StepInfo si = new StepInfo(mpu.Label) { Id = TaskManager.GenerateStepId(), parentTitle = mpu.MetadataPackage.Name, Parent = TaskManager.Root, IsInstanze = false, }; TaskManager.StepInfos.Add(si); StepModelHelper stepModelHelper = new StepModelHelper(si.Id, 1, mpu, "Metadata//" + mpu.Label.Replace(" ", string.Empty) + "[1]", null); stepModelHelperList.Add(stepModelHelper); si = LoadStepsBasedOnUsage(mpu, si, "Metadata//" + mpu.Label.Replace(" ", string.Empty) + "[1]", stepModelHelper); TaskManager.Root.Children.Add(si); TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER] = stepModelHelperList; } TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER] = stepModelHelperList; Session["CreateDatasetTaskmanager"] = TaskManager; }
private StepInfo findLast(StepInfo stepInfo) { if (stepInfo.Children.Count == 0) return stepInfo; else return findLast(stepInfo.Children.Last()); }
private List<StepInfo> GetChildrenStepsFromMetadata(BaseUsage usage, StepInfo parent, string parentXpath, StepModelHelper parentStepModelHelper) { List<StepInfo> childrenSteps = new List<StepInfo>(); List<BaseUsage> childrenUsages = UsageHelper.GetCompoundChildrens(usage); List<StepModelHelper> stepHelperModelList = (List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER]; if (childrenUsages.Count > 0) { foreach (BaseUsage u in childrenUsages) { int number = 1;//childrenUsages.IndexOf(u) + 1; string xPath = parentXpath + "//" + u.Label.Replace(" ", string.Empty) + "[" + number + "]"; bool complex = false; string actionName = ""; string attrName = ""; if (u is MetadataPackageUsage) { actionName = "SetMetadataPackage"; } else { actionName = "SetMetadataCompoundAttribute"; if (u is MetadataAttributeUsage) { MetadataAttributeUsage mau = (MetadataAttributeUsage)u; if (mau.MetadataAttribute.Self is MetadataCompoundAttribute) { complex = true; attrName = mau.MetadataAttribute.Self.Name; } } if (u is MetadataNestedAttributeUsage) { MetadataNestedAttributeUsage mau = (MetadataNestedAttributeUsage)u; if (mau.Member.Self is MetadataCompoundAttribute) { complex = true; attrName = mau.Member.Self.Name; } } } if (complex) { StepInfo s = new StepInfo(u.Label) { Id = TaskManager.GenerateStepId(), parentTitle = attrName, Parent = parent, IsInstanze = false, GetActionInfo = new ActionInfo { ActionName = actionName, ControllerName = "CreateSetMetadataPackage", AreaName = "DCM" }, PostActionInfo = new ActionInfo { ActionName = actionName, ControllerName = "CreateSetMetadataPackage", AreaName = "DCM" } }; //only not optional if (TaskManager.StepInfos.Where(z => z.Id.Equals(s.Id)).Count() == 0) { StepModelHelper newStepModelHelper = new StepModelHelper(s.Id, 1, u, xPath, parentStepModelHelper); stepHelperModelList.Add(newStepModelHelper); s = LoadStepsBasedOnUsage(u, s, xPath, newStepModelHelper); childrenSteps.Add(s); } } //} } } return childrenSteps; }
private StepInfo findNext(StepInfo child) { StepInfo parent = child.Parent; int index = parent.Children.IndexOf(child); if (index + 1 < parent.Children.Count) { // return next child return parent.Children.ElementAt(index + 1); } else { if (IsRoot(parent)) return new StepInfo(""); else { return findNext(parent); } } }
private StepInfo LoadStepsBasedOnUsage(BaseUsage usage, StepInfo current, string parentXpath, StepModelHelper parent) { // genertae action, controller base on usage string actionName = ""; string childName = ""; int min = usage.MinCardinality; if (usage is MetadataPackageUsage) { actionName = "SetMetadataPackageInstanze"; childName = ((MetadataPackageUsage)usage).MetadataPackage.Name; } else { actionName = "SetMetadataCompoundAttributeInstanze"; if (usage is MetadataNestedAttributeUsage) childName = ((MetadataNestedAttributeUsage)usage).Member.Name; if (usage is MetadataAttributeUsage) childName = ((MetadataAttributeUsage)usage).MetadataAttribute.Name; } List<StepInfo> list = new List<StepInfo>(); List<StepModelHelper> stepHelperModelList = (List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER]; if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML)) { XDocument xMetadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML]; //var x = new XElement("null"); XElement parentXElement = new XElement("tmp"); Dictionary<string, string> keyValueDic = new Dictionary<string, string>(); keyValueDic.Add("id", usage.Id.ToString()); if (usage is MetadataPackageUsage) { keyValueDic.Add("type", BExIS.Xml.Helpers.XmlNodeType.MetadataPackageUsage.ToString()); //elements = XmlUtility.GetXElementsByAttribute(usage.Label, keyValueDic, xMetadata).ToList(); parentXElement = XmlUtility.GetXElementByXPath(parent.XPath, xMetadata); } else { keyValueDic.Add("type", BExIS.Xml.Helpers.XmlNodeType.MetadataAttributeUsage.ToString()); //elements = XmlUtility.GetXElementsByAttribute(usage.Label, keyValueDic, xMetadata, parentXpath).ToList(); parentXElement = XmlUtility.GetXElementByXPath(parent.XPath, xMetadata); } //foreach (var x in elements) //{ XElement x = parentXElement; if (x != null && !x.Name.Equals("null")) { IEnumerable<XElement> xelements = x.Elements(); if (xelements.Count() > 0) { int counter = 0; XElement last = null; foreach (XElement element in xelements) { // if the last has not the same name reset count if (last != null && !last.Name.Equals(element.Name)) { counter = 0; } last = element; counter++; string title = counter.ToString(); //usage.Label+" (" + counter + ")"; long id = Convert.ToInt64((element.Attribute("roleId")).Value.ToString()); StepInfo s = new StepInfo(title) { Id = TaskManager.GenerateStepId(), Parent = current, IsInstanze = true, HasContent = UsageHelper.HasUsagesWithSimpleType(usage), //GetActionInfo = new ActionInfo //{ // ActionName = actionName, // ControllerName = "CreateSetMetadataPackage", // AreaName = "DCM" //}, //PostActionInfo = new ActionInfo //{ // ActionName = actionName, // ControllerName = "CreateSetMetadataPackage", // AreaName = "DCM" //} }; string xPath = parentXpath + "//" + childName.Replace(" ", string.Empty) + "[" + counter + "]"; if (TaskManager.Root.Children.Where(z => z.title.Equals(title)).Count() == 0) { StepModelHelper newStepModelHelper = new StepModelHelper(s.Id, counter, usage, xPath, parent); stepHelperModelList.Add(newStepModelHelper); s.Children = GetChildrenStepsFromMetadata(usage, s, xPath, newStepModelHelper); current.Children.Add(s); } } } } //} //TaskManager.AddToBus(CreateDatasetTaskmanager.METADATAPACKAGE_IDS, MetadataPackageDic); } return current; }
private StepInfo findNextInstanze(StepInfo child) { //if (child.IsInstanze) //{ StepInfo parent = child.Parent; int index = parent.Children.IndexOf(child); if (index + 1 < parent.Children.Count) { // return next child return parent.Children.ElementAt(index + 1); } else { if (IsRoot(parent)) return new StepInfo(""); else { return findNextInstanze(parent); } } //} //else //{ // return findNextInstanze(child.Parent); //} }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="stepInfo"></param> /// <returns></returns> public int GetIndex(StepInfo stepInfo) { return(this.StepInfos.IndexOf(stepInfo)); }
private StepInfo findPrevInstanze(StepInfo child) { StepInfo parent = child.Parent; int index = parent.Children.IndexOf(child); if (IsRoot(parent)) { if (index > 0) return Last(parent.Children.ElementAt(index - 1)); else return new StepInfo(""); } else { if (!parent.IsInstanze) return findPrevInstanze(parent); if (index > 0) return parent.Children.ElementAt(index - 1); else return parent; } }
private StepInfo get(StepInfo parent, int id) { foreach (StepInfo child in parent.Children) { if (child.Id.Equals(id)) return child; if (child.Children.Count > 0) { StepInfo s = get(child, id); if(s !=null) return s; } } return null; }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="stepinfo"></param> public void RemoveExecutedStep(StepInfo stepinfo) { if (TaskInfos == null) TaskInfos = new List<StepInfo>(); else { if (TaskInfos.Contains(stepinfo)) TaskInfos.Remove(stepinfo); prevStepInfo = TaskInfos.Last(); } }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="xmlDocument"></param> /// <returns></returns> public static CreateTaskmanager Bind(XmlDocument xmlDocument) { XmlNodeList xmlStepInfos = xmlDocument.GetElementsByTagName("stepInfo"); CreateTaskmanager tm = new CreateTaskmanager(); tm.StepInfos = new List<StepInfo>(); foreach (XmlNode xmlStepInfo in xmlStepInfos) { StepInfo si = new StepInfo(xmlStepInfo.Attributes.GetNamedItem("title").Value) { Id = tm.GenerateStepId(), Parent = tm.Root, IsInstanze = true, HasContent = true, GetActionInfo = new ActionInfo { ActionName = xmlStepInfo.Attributes.GetNamedItem("action").Value, ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value, AreaName = xmlStepInfo.Attributes.GetNamedItem("area").Value }, PostActionInfo = new ActionInfo { ActionName = xmlStepInfo.Attributes.GetNamedItem("action").Value, ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value, AreaName = xmlStepInfo.Attributes.GetNamedItem("area").Value } }; tm.StepInfos.Add(si); tm.Root.Children.Add(si); } tm.currentStepInfo = tm.Root.Children.First(); return tm; }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <returns></returns> //public StepInfo Prev() //{ // this.prevStepInfo = findPrev(this.currentStepInfo); // return this.prevStepInfo; //} //public StepInfo Next() //{ // if (this.currentStepInfo.Children.Count > 0) // { // return this.currentStepInfo.Children.First(); // } // else // { // return findNext(this.currentStepInfo); // } //} private StepInfo findPrev(StepInfo child) { StepInfo parent = child.Parent; int index = parent.Children.IndexOf(child); if (IsRoot(parent)) { if (index > 0) return Last(parent.Children.ElementAt(index - 1)); else return new StepInfo(""); } else { if (index > 0) { StepInfo pStep = parent.Children.ElementAt(index - 1); if (pStep.Children.Count == 0) return pStep; else return findLast(pStep); } else return parent; } }
public int GetX(StepInfo step, int position) { StepInfo parent = step.Parent; if (IsRoot(parent)) { int stepIndex = parent.Children.IndexOf(step); for (int i = 0; i < stepIndex; i++) { position += countSteps(parent.Children.ElementAt(i))+1; } } else { position += parent.Children.IndexOf(step) + 1; position = GetX(parent, position); } return position; }