public void FillDiagramm(List <ClientData> sourceClientData) //fill resdiagramm with elements&links of currentdiagramm { foreach (Elements item in sourceClientData[_index].Current.Elements) { item.AddParentId(sourceClientData[_index].Current.Links); Elements element = new Elements(item); //element.AddParentId(sourceClientData[_index].Current.Links); sourceClientData[_index].Result.Elements.Add(element); //переделать через джоб } foreach (Links item in sourceClientData[_index].Current.Links) { Links link = new Links(item); sourceClientData[_index].Result.Links.Add(link); //переделать через джоб } foreach (Elements item in sourceClientData[_index].Current.Elements) { SubjectElements subjects = new SubjectElements(item.Id, sourceClientData[_index].Current.Elements); RecoderInfo.AddSubjectElements(subjects); Startup.subjTest.Add(subjects); //test } }
public void AddSubjectElements(SubjectElements subjectsElement) { SourceSubjects.Add(subjectsElement); }
public void MigrationFull(List <ClientData> sourceClientData, string id, int indexElement) { sourceClientData[_index].Result.Elements[indexElement].Name = sourceClientData[_index].Integration.Elements[0].Name; sourceClientData[_index].Result.Elements[indexElement].OldId = sourceClientData[_index].Integration.Elements[0].Id; sourceClientData[_index].Result.Elements[indexElement].OldCode = sourceClientData[_index].Integration.Elements[0].OldCode; List <Elements> sourceMigrationElements = new List <Elements>(); List <Links> sourceMigrationLinks = new List <Links>(); var diff = Int32.Parse(sourceClientData[_index].Result.Elements[indexElement].Level) - 1; var indexMigrationElement = 0; var lastIdElements = 0; Position position = new Position(sourceClientData[_index].Result.Elements[indexElement].Level, sourceClientData[_index].Result.Elements[indexElement].Number); //clear subjects of choose elements if (RecoderInfo.SourceSubjects.Find((x) => x.ParentId == sourceClientData[_index].Result.Elements[indexElement].Id) != null) { foreach (var item in RecoderInfo.SourceSubjects.Find((x) => x.ParentId == sourceClientData[_index].Result.Elements[indexElement].Id).SubjectId) { Elements elementToRemove = sourceClientData[_index].Result.Elements.Find((x) => x.Id == item); sourceClientData[_index].Result.Elements.Remove(elementToRemove); List <int> indexLinkToDel = new List <int>(); var countLinks = 0; foreach (Links link in sourceClientData[_index].Result.Links) { if (link.Afe2 == elementToRemove.Id && link.Afe1 == elementToRemove.ParentId || link.Afe3 == elementToRemove.Id && link.Afe1 == elementToRemove.ParentId) { //Links linkToRemove = link; //sourceClientData[_index].Result.Links.Remove(linkToRemove); indexLinkToDel.Add(countLinks); } countLinks++; } foreach (var index in indexLinkToDel) { //Links removeLink = new Links(sourceClientData[_index].Result.Links[index]); //sourceClientData[_index].Result.Links.Remove(removeLink); //sourceClientData[_index].Result.Links.Remove(sourceClientData[_index].Result.Links[index]); sourceClientData[_index].Result.Links[index].Afe1 = "0"; sourceClientData[_index].Result.Links[index].Afe2 = "0"; sourceClientData[_index].Result.Links[index].Afe3 = "0"; } } } foreach (Elements item in sourceClientData[_index].Result.Elements) //find lastId { if (Int32.Parse(item.Id) > lastIdElements) { lastIdElements = Int32.Parse(item.Id); } } if (position.Number - 1 > 0) //check left elements { RecoderInfo.CreateStructDiagrammInfo(position, sourceClientData[_index].Result.Elements); //create info left struct foreach (Elements item in sourceClientData[_index].Integration.Elements) //create source_elements4migration { if (item != sourceClientData[_index].Integration.Elements[0]) { Elements element = new Elements(item); element.Level = (Int32.Parse(element.Level) + diff).ToString(); element.Id = (++lastIdElements).ToString(); sourceMigrationElements.Add(element); indexMigrationElement++; } } foreach (Elements item in sourceMigrationElements) //migration elements { if (RecoderInfo.LeftStructDiagramm.Find((x) => x.Level == item.Level) != null) { item.Number = (Int32.Parse(item.Number) + RecoderInfo.LeftStructDiagramm.Find((x) => x.Level == item.Level).LastNumber).ToString(); //RecoderInfo.LeftStructDiagramm.Find((x) => x.Level == item.Level).LastNumber = Int32.Parse(item.Number); } Job.AddElement(sourceClientData, Job.Types[2], item); } foreach (Links item in sourceClientData[_index].Integration.Links) //migration links { Links link = new Links(item); if (sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe1 && x.OldId != x.Id) != null) { link.Afe1 = sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe1 && x.OldId != x.Id).Id; } if (sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe2 && x.OldId != x.Id) != null) { link.Afe2 = sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe2 && x.OldId != x.Id).Id; } if (sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe3 && x.OldId != x.Id) != null) { link.Afe3 = sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe3 && x.OldId != x.Id).Id; } sourceClientData[_index].Result.Links.Add(link); } foreach (string item in sourceClientData[_index].Integration.DcmpElements) //migration integr dcpm { var value = item; sourceClientData[_index].Result.DcmpElements.Add(value); } for (int i = 0; i < sourceClientData[_index].Result.DcmpElements.Count; i++) //recode dcmp { if (sourceClientData[_index].Result.Elements.Find((x) => x.OldCode == sourceClientData[_index].Result.DcmpElements[i] && (x.OldCode != ("z" + x.Level + x.Number) && x.OldCode != ("z" + x.Level + "." + x.Number))) != null) { Elements element = new Elements(sourceClientData[_index].Result.Elements.Find((x) => x.OldCode == sourceClientData[_index].Result.DcmpElements[i] && (x.OldCode != ("z" + x.Level + x.Number) && x.OldCode != ("z" + x.Level + "." + x.Number)))); if (Int32.Parse(element.Number) > 9) { sourceClientData[_index].Result.DcmpElements[i] = "z" + element.Level + "." + element.Number; } else { sourceClientData[_index].Result.DcmpElements[i] = "z" + element.Level + element.Number; } } } List <SubjectElements> sourceSubjects = new List <SubjectElements>(); foreach (Elements item in sourceClientData[_index].Current.Elements) { if (item.Level == sourceClientData[_index].Result.Elements[indexElement].Level && Int32.Parse(item.Number) > Int32.Parse(sourceClientData[_index].Result.Elements[indexElement].Number)) { SubjectElements subjects = new SubjectElements(item.Id, sourceClientData[_index].Current.Elements); if (subjects.SubjectId.Count > 0) { sourceSubjects.Add(subjects); //Startup.subjTest.Add(subjects); } } } RecoderInfo.CreateIntegrationStructDiagramm(sourceClientData[_index].Integration.Elements); position.Level = Int32.Parse(sourceClientData[_index].Result.Elements[indexElement].Level); position.Number = Int32.Parse(sourceClientData[_index].Result.Elements[indexElement].Number); var point = true; while (point == true) { if (sourceClientData[_index].Result.Elements.Find((x) => x.Level == position.Level.ToString() && x.Number == (position.Number + 1).ToString()) != null) { Elements element = sourceClientData[_index].Result.Elements.Find((x) => x.Level == position.Level.ToString() && x.Number == (position.Number + 1).ToString()); if (sourceSubjects.Find((x) => x.ParentId == element.Id && x.SubjectId.Count > 0) != null) { foreach (var item in sourceSubjects.Find((x) => x.ParentId == element.Id).SubjectId) { Elements subjElement = sourceClientData[_index].Result.Elements.Find((x) => x.Id == item); sourceClientData[_index].Result.Elements.Find((x) => x.Id == item).Number = (RecoderInfo.ForRightStructDiagramm.Find((x) => x.Level == subjElement.Level).Numbers.Count + Int32.Parse(subjElement.Number)).ToString(); } } position.Number++; } else { point = false; } } var _dcmp = "z" + sourceClientData[_index].Result.Elements[indexElement].Level + sourceClientData[_index].Result.Elements[indexElement].Number; sourceClientData[_index].Result.DcmpElements.Add(_dcmp); foreach (string item in sourceClientData[_index].Current.DcmpElements) { var value = item; /* * if (sourceClientData[_index].Result.Elements.Find((x) => x.OldCode == value) != null) * { * Elements element = new Elements(sourceClientData[_index].Result.Elements.Find((x) => x.OldCode == value)); * var code = "z" + element.Level; * if (Int32.Parse(element.Number) > 9) * { * code += "." + element.Number; * } * else * code += element.Number; * if (element.OldCode != code) * { * value = code; * } * }*/ sourceClientData[_index].Result.DcmpElements.Add(value); } var count = 0; List <int> indexLinkToDelete = new List <int>(); foreach (var item in sourceClientData[_index].Result.Links) { var countCopy = 0; foreach (var linkCopyCheck in sourceClientData[_index].Result.Links) { if (item.Afe1 == linkCopyCheck.Afe1 && item.Afe2 == linkCopyCheck.Afe2 && item.Afe3 == linkCopyCheck.Afe3 && item.Type == linkCopyCheck.Type && count != countCopy) { indexLinkToDelete.Add(countCopy); } countCopy++; } count++; } } else { MigrationFirstNumberSubjectNull(sourceClientData, id, indexElement); } }
public void MigrationFirstNumberSubjectNull(List <ClientData> sourceClientData, string id, int indexElement) { sourceClientData[_index].Result.Elements[indexElement].Name = sourceClientData[_index].Integration.Elements[0].Name; sourceClientData[_index].Result.Elements[indexElement].OldId = sourceClientData[_index].Integration.Elements[0].Id; sourceClientData[_index].Result.Elements[indexElement].OldCode = sourceClientData[_index].Integration.Elements[0].OldCode; List <Elements> sourceMigrationElements = new List <Elements>(); List <Links> sourceMigrationLinks = new List <Links>(); var diff = Int32.Parse(sourceClientData[_index].Result.Elements[indexElement].Level) - 1; var indexMigrationElement = 0; var lastIdElements = 0; //clear subjects of choose elements if (RecoderInfo.SourceSubjects.Find((x) => x.ParentId == sourceClientData[_index].Result.Elements[indexElement].Id) != null) { foreach (var item in RecoderInfo.SourceSubjects.Find((x) => x.ParentId == sourceClientData[_index].Result.Elements[indexElement].Id).SubjectId) { Elements elementToRemove = sourceClientData[_index].Result.Elements.Find((x) => x.Id == item); sourceClientData[_index].Result.Elements.Remove(elementToRemove); List <int> indexLinkToDel = new List <int>(); var countLinks = 0; foreach (Links link in sourceClientData[_index].Result.Links) { if ((link.Afe2 == elementToRemove.Id && link.Afe1 == elementToRemove.ParentId) || (link.Afe3 == elementToRemove.Id && link.Afe1 == elementToRemove.ParentId)) { //Links linkToRemove = link; //sourceClientData[_index].Result.Links.Remove(linkToRemove); indexLinkToDel.Add(countLinks); } countLinks++; } foreach (var index in indexLinkToDel) { //Links removeLink = sourceClientData[_index].Result.Links[index]; //sourceClientData[_index].Result.Links.Remove(removeLink); //sourceClientData[_index].Result.Links.Remove(sourceClientData[_index].Result.Links[index]); sourceClientData[_index].Result.Links[index].Afe1 = "0"; sourceClientData[_index].Result.Links[index].Afe2 = "0"; sourceClientData[_index].Result.Links[index].Afe3 = "0"; } } } foreach (Elements item in sourceClientData[_index].Result.Elements) { if (Int32.Parse(item.Id) > lastIdElements) { lastIdElements = Int32.Parse(item.Id); } } var count = 0; foreach (Elements item in sourceClientData[_index].Integration.Elements) { if (count > 0) { Elements element = new Elements(item); element.Level = (Int32.Parse(element.Level) + diff).ToString(); element.Id = (++lastIdElements).ToString(); sourceMigrationElements.Add(element); indexMigrationElement++; } count++; } foreach (Elements item in sourceMigrationElements) { Job.AddElement(sourceClientData, Job.Types[2], item); } foreach (Links item in sourceClientData[_index].Integration.Links) { Links link = new Links(item); if (sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe1 && x.OldId != x.Id) != null) { link.Afe1 = sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe1 && x.OldId != x.Id).Id; } if (sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe2 && x.OldId != x.Id) != null) { link.Afe2 = sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe2 && x.OldId != x.Id).Id; } if (sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe3 && x.OldId != x.Id) != null) { link.Afe3 = sourceClientData[_index].Result.Elements.Find((x) => x.OldId == link.Afe3 && x.OldId != x.Id).Id; } sourceClientData[_index].Result.Links.Add(link); } foreach (string item in sourceClientData[_index].Integration.DcmpElements) { var value = item; sourceClientData[_index].Result.DcmpElements.Add(value); } for (int i = 0; i < sourceClientData[_index].Result.DcmpElements.Count; i++) { if (sourceClientData[_index].Result.Elements.Find((x) => x.OldCode == sourceClientData[_index].Result.DcmpElements[i] && (x.OldCode != ("z" + x.Level + x.Number) && x.OldCode != ("z" + x.Level + "." + x.Number))) != null) { Elements element = new Elements(sourceClientData[_index].Result.Elements.Find((x) => x.OldCode == sourceClientData[_index].Result.DcmpElements[i] && (x.OldCode != ("z" + x.Level + x.Number) && x.OldCode != ("z" + x.Level + "." + x.Number)))); if (Int32.Parse(element.Number) > 9) { sourceClientData[_index].Result.DcmpElements[i] = "z" + element.Level + "." + element.Number; } else { sourceClientData[_index].Result.DcmpElements[i] = "z" + element.Level + element.Number; } } } var _dcmp = "z" + sourceClientData[_index].Result.Elements[indexElement].Level + sourceClientData[_index].Result.Elements[indexElement].Number; sourceClientData[_index].Result.DcmpElements.Add(_dcmp); foreach (string item in sourceClientData[_index].Current.DcmpElements) { var value = item; sourceClientData[_index].Result.DcmpElements.Add(value); } List <SubjectElements> sourceSubjects = new List <SubjectElements>(); foreach (Elements item in sourceClientData[_index].Current.Elements) { if (item.Level == sourceClientData[_index].Result.Elements[indexElement].Level && Int32.Parse(item.Number) > Int32.Parse(sourceClientData[_index].Result.Elements[indexElement].Number)) { SubjectElements subjects = new SubjectElements(item.Id, sourceClientData[_index].Current.Elements); if (subjects.SubjectId.Count > 0) { sourceSubjects.Add(subjects); //Startup.subjTest.Add(subjects); } } } count = 0; List <int> indexLinkToDelete = new List <int>(); foreach (var item in sourceClientData[_index].Result.Links) { var countCopy = 0; foreach (var linkCopyCheck in sourceClientData[_index].Result.Links) { if (item.Afe1 == linkCopyCheck.Afe1 && item.Afe2 == linkCopyCheck.Afe2 && item.Afe3 == linkCopyCheck.Afe3 && item.Type == linkCopyCheck.Type && count != countCopy) { indexLinkToDelete.Add(countCopy); } countCopy++; } count++; } /* * foreach (var index in indexLinkToDelete) * { * //sourceClientData[_index].Result.Links.Remove(sourceClientData[_index].Result.Links[index]); * //sourceClientData[_index].Result.Links[index].Afe1 = "0"; * //sourceClientData[_index].Result.Links[index].Afe2 = "0"; * sourceClientData[_index].Result.Links[index].Afe3 = "0"; * } * * count = 0; * indexLinkToDelete.Clear(); * foreach (var item in sourceClientData[_index].Result.Links) * { * if (item.Afe1 == "0" && item.Afe2 == "0") * { * indexLinkToDelete.Add(count); * } * count++; * } * foreach (var item in indexLinkToDelete) * { * Links linkToDelete = sourceClientData[_index].Result.Links[item]; * sourceClientData[_index].Result.Links.Remove(linkToDelete); * }*/ }