/// <summary> /// получает запись доп. изделия в универсальном справочнике. /// </summary> /// <param name="GotNumber">Заводской номер.</param> /// <param name="Device">Наименование изделия.</param> public RowData GetDeviceRow(String GotNumber, String Device) { String Number = null, Year = null; if (GotNumber.Contains("/")) { Year = GotNumber.Split('/')[1]; Number = GotNumber.Split('/')[0]; } else { Number = GotNumber; } SectionData Items = ApplicationCard.UniversalCard.Sections[RefUniversal.Item.ID]; SectionQuery Query = Card.CardScript.Session.CreateSectionQuery(); Query.ConditionGroup.Operation = ConditionGroupOperation.And; Query.ConditionGroup.Conditions.AddNew("Name", FieldType.Unistring, ConditionOperation.Contains, String.Format("{0} № {1}/{2}", Device, Number, Year)); RowDataCollection Found = Items.FindRows(Query.GetXml()); return(Found.Count == 1 ? Found[0] : null); }
private void UpdateEmployeeManager(RowData employeeDocsvision, CardData refStaffData, string employeeChief) { if (employeeChief == null) { // logger.Info("Руководитель сотрудника не найден."); return; } SectionQuery sectionQueryEmployee = Session.CreateSectionQuery(); sectionQueryEmployee.ConditionGroup.Conditions.AddNew(RefStaff.Employees.IDCode, FieldType.Unistring, ConditionOperation.Equals, employeeChief); RowDataCollection employeeCollection = refStaffData.Sections[RefStaff.Employees.ID].FindRows(sectionQueryEmployee.GetXml()); if (employeeCollection != null && employeeCollection.Count > 0) { employeeDocsvision[RefStaff.Units.Manager] = employeeCollection[0].Id; //logger.Info("Руководитель сотрудника обновлен."); } /*else * { * logger.Info("Руководитель сотрудника не найден."); * * } */ }
private async Task <SectionQueryResutl> QuerySection(SectionQuery query, int offsetInExam) { var result = new List <QuestionDto>(); var questionsQuery = query.Section.Reference.Collection(_questionCollectionName).Offset(query.Offset); var remain = query.Limit; QuerySnapshot questionsSnapshot = await questionsQuery.GetSnapshotAsync(); foreach (DocumentSnapshot documentSnapshot in questionsSnapshot.Documents) { offsetInExam++; var entity = documentSnapshot.ConvertTo <Question>(); if (query.SearchText.IsNotNullOrEmpty() && (entity.Analysis?.Contains(query.SearchText) != true) && !entity.Title.Contains(query.SearchText) && !entity.Options.Any(x => (x.Name.Contains(query.SearchText) || (x.AnswerText.IsNotNullOrEmpty() && x.AnswerText.Contains(query.SearchText))))) { continue; } var dto = entity.To <QuestionDto>(); dto.ExamId = query.ExamId; dto.SectionName = query.Section.Name; dto.SectionId = query.Section.Reference.Id; remain--; result.Add(dto); } return(new SectionQueryResutl { OffsetInExam = offsetInExam, Items = result }); }
private static string GetSectionSearchQuery(UserSession Session, string fieldName, string fieldValue, FieldType fieldType = FieldType.Unistring, ConditionOperation conditionOperation = ConditionOperation.Equals) { SectionQuery query = Session.CreateSectionQuery(); query.ConditionGroup.Conditions.AddNew(fieldName, fieldType, conditionOperation, fieldValue); return(query.GetXml(null, true)); }
public static RowData GetEmployeeRowDataByAccount(string account) { account = BuildAccountDomain(account); SectionQuery query = Session.CreateSectionQuery(); query.ConditionGroup.Conditions.AddNew("AccountName", FieldType.Unistring, ConditionOperation.Equals, account); RowData rdEmployee = SessionManager.SecStaffEmployees.FindRows(query.GetXml())[0]; return(rdEmployee); }
/// <summary> /// Инициализирует папку заданными значениями. /// </summary> /// <param name="Device">Прибор.</param> /// <param name="CodeID">ID кода СКБ.</param> /// <param name="CodeName">Отобразаемое значение кода СКБ.</param> /// <param name="DocumentID">ID документа.</param> /// <param name="DocumentName">Название документа.</param> /// <param name="FolderID">ID папки.</param> public DocumentsFolder(Folder ParentFolder, CardData Document, SavedSearchGroup SearchGroup, SavedView View, FolderCard FolderCard) { this.ParentFolder = ParentFolder; this.Document = Document; DocumentID = Document.Id; SectionData Properties = Document.Sections[CardOrd.Properties.ID]; DocumentType = Properties.FindRow("@Name = '" + RefPropertiesCD.Requisities.FileType + "'").GetString("Value"); RowData Code = Properties.FindRow("@Name = '" + RefPropertiesCD.Requisities.Code + "'"); CodeID = Code.GetGuid("Value").Value; CodeName = Code.GetString("DisplayValue"); RowData Applicable = Properties.FindRow("@Name = '" + RefPropertiesCD.Requisities.Applicable + "'"); Applicability = Applicable.GetString("DisplayValue"); RowData Name = Properties.FindRow("@Name = '" + RefPropertiesCD.Requisities.DocumentName + "'"); string ShortType = DocumentType == "СД - Спецификация (не платы)" || DocumentType == "СП - Спецификация платы" ? "" : DocumentType.Remove(DocumentType.IndexOf(" - ")); DocumentName = CodeName + " " + ShortType + " " + Name.GetString("Value"); Folder = FolderCard.CreateFolder(ParentFolder.Id, DocumentName); Folder.Type = FolderTypes.Virtual; if (!SearchGroup.Queries.Any(row => row.Name == DocumentName)) { SearchQuery Query = FolderCard.Session.CreateSearchQuery(); CardTypeQuery CardType = Query.AttributiveSearch.CardTypeQueries.AddNew(CardOrd.ID); SectionQuery Section = CardType.SectionQueries.AddNew(CardOrd.MainInfo.ID); Section.Operation = SectionQueryOperation.And; Section.ConditionGroup.Operation = ConditionGroupOperation.And; Section.ConditionGroup.Conditions.AddNew(CardOrd.MainInfo.Type, FieldType.RefId, ConditionOperation.Equals, MyHelper.RefType_CD); Section = CardType.SectionQueries.AddNew(CardOrd.Properties.ID); Section.Operation = SectionQueryOperation.And; Section.ConditionGroup.Operation = ConditionGroupOperation.And; Section.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Value, FieldType.Unistring, ConditionOperation.Equals, DocumentType); Section.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Name, FieldType.Unistring, ConditionOperation.Equals, RefPropertiesCD.Requisities.FileType); Section = CardType.SectionQueries.AddNew(CardOrd.Properties.ID); Section.Operation = SectionQueryOperation.And; Section.ConditionGroup.Operation = ConditionGroupOperation.And; Section.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Value, FieldType.RefId, ConditionOperation.Equals, CodeID); Section.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Name, FieldType.Unistring, ConditionOperation.Equals, RefPropertiesCD.Requisities.Code); Query.Limit = 0; SearchGroup.Queries.AddNew(DocumentName).Import(Query); } SavedSearchQuery SavedQuery = SearchGroup.Queries.First(row => row.Name == DocumentName); Folder.RefId = SavedQuery.Id; Folder.CurrentViewId = View.Id; Folder.DefaultViewId = View.Id; }
private bool SearchEmployeeTest(CardData refStaffData, string code) { SectionQuery sectionQueryTest = Session.CreateSectionQuery(); sectionQueryTest.ConditionGroup.Conditions.AddNew(RefStaff.Employees.IDCode, FieldType.Unistring, ConditionOperation.Equals, code); RowDataCollection employeeCollection = refStaffData.Sections[RefStaff.Employees.ID].FindRows(sectionQueryTest.GetXml()); return(employeeCollection.Count > 0); }
//im private RowData GetExistObject(Guid mode, string alias, string value) private RowDataCollection GetExistObject(Guid mode, string alias, string value) { if (string.IsNullOrEmpty(alias) || string.IsNullOrEmpty(value) || mode == null || mode == Guid.Empty) { return(null); } try { CardData refStaffData = Session.CardManager.GetDictionaryData(RefStaff.ID); SectionData unitsSection = null; if (mode == RefStaff.Employees.ID) { unitsSection = refStaffData.Sections[RefStaff.Employees.ID]; } else if (mode == RefStaff.Units.ID) { unitsSection = refStaffData.Sections[RefStaff.Units.ID]; } else if (mode == RefStaff.Positions.ID) { unitsSection = refStaffData.Sections[RefStaff.Positions.ID]; } if (unitsSection == null) { return(null); } SectionQuery sectionQuery = Session.CreateSectionQuery(); sectionQuery.ConditionGroup.Conditions.AddNew(alias, FieldType.Unistring, ConditionOperation.Equals, value); RowDataCollection employeeCollection = unitsSection.FindRows(sectionQuery.GetXml()); if (employeeCollection != null && employeeCollection.Count > 0) { //im return employeeCollection[0]; return(employeeCollection); } } catch (Exception ex) { return(null); } return(null); }
public async Task <QueryResult <Section> > GetSections(SectionQuery queryObj) { var result = new QueryResult <Section>(); var query = GetSectionAsQueryable(); query = query.ApplySectionFilter(queryObj); if (queryObj.IncludeSchedule) { query = query.Select(s => IncludeOnlyCurrentSemesterSchedule(s)); } result.TotalItems = await query.CountAsync(); result.Items = await query.ToListAsync(); return(result); }
/// <summary> /// Перечень прибора и всех доп. изделий. /// </summary> /*public ArrayList FindAllDevices() * { * ArrayList DevicesList = new ArrayList(); * string Device = Card.GetControlValue(RefServiceCard.MainInfo.DeviceCardID) == null ? "" : * Card.GetControlValue(RefServiceCard.MainInfo.DeviceCardID).ToString(); * this.Card.WriteLog("Прибор: " + Device); * DevicesList.Add(Device); * * GridView Grid_AdditionalWaresList = Card.ICardControl.GetGridView(RefServiceCard.AdditionalWaresList.Alias); * ITableControl Table_AdditionalWaresList = Card.ICardControl.FindPropertyItem<ITableControl>(RefServiceCard.AdditionalWaresList.Alias); * this.Card.WriteLog("Ищем датчики. Кол-во: " + Table_AdditionalWaresList.RowCount.ToString()); * for (int i = 0; i < Table_AdditionalWaresList.RowCount; i++) * { * Device = UniversalCard.GetItemPropertyValue(new Guid(Table_AdditionalWaresList[i][RefServiceCard.AdditionalWaresList.WaresNumberID].ToString()), "Паспорт прибора").ToString(); * //DeviceName = UniversalCard.GetItemPropertyValue(Table_AdditionalWaresList[i][RefServiceCard.AdditionalWaresList.WaresNumberID].ToGuid(), "Наименование прибора").ToString(); * //if (!DevicesList.Contains(DeviceName)) * DevicesList.Add(Device); * this.Card.WriteLog("Датчик: " + Device); * } * return DevicesList; * }*/ private void TReplacement_ButtonPressed(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (!this.TReplacement.Properties.ReadOnly) { Guid DevicePassportTypeID = new Guid("{42826E25-AD0E-4D9C-8B18-CD88E6796972}"); // Тип - "Паспорт прибора" Guid DevicePassportFolderID = new Guid("{DDE96A16-438B-46DB-AC70-B477769E2124}"); // Папка - "[01] ПАСПОРТА ПРИБОРОВ" SearchQuery searchQuery = Card.CardScript.Session.CreateSearchQuery(); searchQuery.CombineResults = ConditionGroupOperation.And; CardTypeQuery typeQuery = searchQuery.AttributiveSearch.CardTypeQueries.AddNew(CardOrd.ID); SectionQuery sectionQuery = typeQuery.SectionQueries.AddNew(CardOrd.MainInfo.ID); sectionQuery.Operation = SectionQueryOperation.And; sectionQuery.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery.ConditionGroup.Conditions.AddNew("Type", FieldType.RefId, ConditionOperation.Equals, DevicePassportTypeID); sectionQuery = typeQuery.SectionQueries.AddNew(CardOrd.Properties.ID); sectionQuery.Operation = SectionQueryOperation.And; sectionQuery.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Name, FieldType.String, ConditionOperation.Equals, "Состояние прибора"); sectionQuery.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Value, FieldType.Int, ConditionOperation.Equals, 3); sectionQuery = typeQuery.SectionQueries.AddNew(CardOrd.Properties.ID); sectionQuery.Operation = SectionQueryOperation.And; sectionQuery.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Name, FieldType.String, ConditionOperation.Equals, "Прибор"); sectionQuery.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Value, FieldType.RefId, ConditionOperation.Equals, new Guid(DeviceType)); // Получение текста запроса searchQuery.Limit = 0; string query = searchQuery.GetXml(); Guid result = Card.CardScript.CardFrame.CardHost.SelectCard("Выберите паспорт изделия для замены:", DevicePassportFolderID, query); if (!result.Equals(Guid.Empty)) { ReplacementID = result.ToString(); Replacement = Card.CardScript.Session.CardManager.GetCardData(new Guid(ReplacementID)).Description; this.TReplacement.Text = Replacement; } } }
private void UpdateEmployeePosition(RowData employeeDocsvision, CardData refStaffData, string titleId, string title) { SectionData positionSection = refStaffData.Sections[RefStaff.Positions.ID]; SectionQuery sectionQueryPosition = Session.CreateSectionQuery(); // Добавление условия поиска по дате создания документа sectionQueryPosition.ConditionGroup.Conditions.AddNew(RefStaff.Positions.Name, FieldType.Unistring, ConditionOperation.Equals, title); RowDataCollection positionCollection = positionSection.FindRows(sectionQueryPosition.GetXml()); if (positionCollection.Count > 0) { //logger.Info("Должность сотрудника обновлена"); employeeDocsvision[RefStaff.Employees.Position] = positionCollection[0].Id; } else { //logger.Info("Создана новая должность. Должность сотрудника обновлена"); employeeDocsvision[RefStaff.Employees.Position] = AddPositionManual(title, titleId); } }
public static Boolean CheckDuplication(UserSession Session, String CheckName) { logger.Info("checkName='{0}'", CheckName); String[] CheckNameParts = CheckName.Split('\t'); if (CheckNameParts.Length == 2) { return(Directory.Exists(Path.Combine(ArchivePath, MyHelper.RemoveInvalidFileNameChars(CheckNameParts[0]), MyHelper.RemoveInvalidFileNameChars(CheckNameParts[1])))); } else if (CheckNameParts.Length == 3) { return(Directory.Exists(Path.Combine(ArchivePath, MyHelper.RemoveInvalidFileNameChars(CheckNameParts[0]), MyHelper.RemoveInvalidFileNameChars(CheckNameParts[1]), MyHelper.RemoveInvalidFileNameChars(CheckNameParts[2])))); } else if (CheckName.Contains("Админ")) { logger.Info("Big files permission"); return(false); } else { CardData UniversalCard = Session.CardManager.GetDictionaryData(RefUniversal.ID); SectionQuery Query_Section = UniversalCard.Session.CreateSectionQuery(); Query_Section.ConditionGroup.Conditions.AddNew(RefUniversal.Item.Name, FieldType.Unistring, ConditionOperation.StartsWith, CheckName); RowDataCollection FoundItems = UniversalCard.Sections[RefUniversal.Item.ID].FindRows(Query_Section.GetXml(null, true)); if (FoundItems.Count > 0) { logger.Info("Запись найдена"); logger.Info("Идентификатор: " + FoundItems[0].Id); return(true); } logger.Info("Запись не найдена"); return(false); } }
private void Button_Click(Object sender, EventArgs e) { if (sender == Button_Start) { if (Parties.Any()) { SearchQuery Query_Search = Session.CreateSearchQuery(); Query_Search.Limit = 0; Query_Search.CombineResults = ConditionGroupOperation.Or; CardTypeQuery Query_CardType = Query_Search.AttributiveSearch.CardTypeQueries.AddNew(CardOrd.ID); SectionQuery Query_Section = Query_CardType.SectionQueries.AddNew(CardOrd.MainInfo.ID); Query_Section.Operation = SectionQueryOperation.And; Query_Section.ConditionGroup.Operation = ConditionGroupOperation.And; Query_Section.ConditionGroup.Conditions.AddNew(CardOrd.MainInfo.Type, FieldType.RefId, ConditionOperation.Equals, MyHelper.RefType_ListofDocs); Query_Section = Query_CardType.SectionQueries.AddNew(CardOrd.Properties.ID); Query_Section.Operation = SectionQueryOperation.And; Query_Section.ConditionGroup.Operation = ConditionGroupOperation.And; Query_Section.ConditionGroup.Conditions.AddNew(CardOrd.Properties.Name, FieldType.Unistring, ConditionOperation.Equals, RefPropertiesListOfDocs.Requisities.Party); ConditionGroup Query_ConditionGroup = Query_Section.ConditionGroup.ConditionGroups.AddNew(); Query_ConditionGroup.Operation = ConditionGroupOperation.Or; foreach (SelectionItem Party in Parties) { Condition Query_Condition = Query_ConditionGroup.Conditions.AddNew(CardOrd.Properties.Value, FieldType.RefId, ConditionOperation.Equals, Party.Id); Query_Condition.FieldSubtype = FieldSubtype.Universal; Query_Condition.FieldSubtypeId = MyHelper.RefItem_Party; } CardDataCollection ListOfDocsDatas = Session.CardManager.FindCards(Query_Search.GetXml()); if (ListOfDocsDatas.Count > 0) { List <Guid> WrongPartyIds = ListOfDocsDatas.Select(card => card.Sections[CardOrd.Properties.ID].GetPropertyValue(RefPropertiesListOfDocs.Requisities.Party).ToGuid()) .Where(g => !g.IsEmpty()).Distinct().ToList(); List <String> WrongPartyNames = WrongPartyIds.Select(WrongPartyId => Edit_Parties.SelectedItems.FirstOrDefault(item => item.ObjectId == WrongPartyId)) .Where(item => !item.IsNull()).Select(item => "«" + item.DisplayValue + "»").ToList(); if (WrongPartyNames.Any()) { if (WrongPartyNames.Count == 1) { MyMessageBox.Show("Партия " + WrongPartyNames[0] + " уже запущена в производство." + Environment.NewLine + "Удалите её из списка!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MyMessageBox.Show("Партии " + WrongPartyNames.Aggregate((a, b) => a + ", " + b) + " уже запущены в производство." + Environment.NewLine + "Удалите их из списка!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } DialogResult = DialogResult.None; } } } else { MyMessageBox.Show("Не выбрано ни одной партии!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); DialogResult = DialogResult.None; } } else { DialogResult = DialogResult.None; } }
internal SectionQueryInfo(SectionQuery sq, short shapeid, int numrows) { this.SectionQuery = sq; this.ShapeID = shapeid; this.RowCount = numrows; }
/// <summary> /// Осуществляет обновление доработки в Паспорте прибора на основании данных Конструктора справочников /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BindImprov_Click(object sender, EventArgs e) { if (this.TypeName.Text == "") { MessageBox.Show("Укажите тип прибора!"); return; } if (this.DocName.Text == "") { MessageBox.Show("Укажите документ-основание!"); return; } StatusStrip.Items["StatusText"].Text = "Процесс начат..."; StatusStrip.Update(); // Получение записи справочника ремонтных работ и доработок //ObjectContext Context = Session.CreateContext(); // Получение справочника "Ремонтные работы и доработки" //IBaseUniversalService baseUniversalService = Context.GetService<IBaseUniversalService>(); //BaseUniversal baseUniversal = Context.GetObject<BaseUniversal>(RefBaseUniversal.ID); CardData baseUniversal = Session.CardManager.GetCardData(new Guid("{4538149D-1FC7-4D41-A104-890342C6B4F8}")); if (!baseUniversal.Sections[new Guid("{A1DCE6C1-DB96-4666-B418-5A075CDB02C9}")].GetAllRows().Any(r => r.Id == new Guid("{43A6DA44-899C-47D8-9567-2185E05D8524}"))) { StatusStrip.Items["StatusText"].Text = "Ошибка! Не найден справочник ремонтных работ и доработок..."; StatusStrip.Update(); return; } // Поиск записей справочника SearchQuery searchQuery = Session.CreateSearchQuery(); searchQuery.CombineResults = ConditionGroupOperation.And; CardTypeQuery typeQuery = searchQuery.AttributiveSearch.CardTypeQueries.AddNew(DocsVision.BackOffice.CardLib.CardDefs.CardBaseUniversalItem.ID); SectionQuery sectionQuery = typeQuery.SectionQueries.AddNew(DocsVision.BackOffice.CardLib.CardDefs.CardBaseUniversalItem.System.ID); sectionQuery.Operation = SectionQueryOperation.And; sectionQuery.ConditionGroup.Operation = ConditionGroupOperation.And; ConditionGroup ConditionGroup = sectionQuery.ConditionGroup.ConditionGroups.AddNew(); ConditionGroup.Operation = ConditionGroupOperation.And; ConditionGroup.Conditions.AddNew(DocsVision.BackOffice.CardLib.CardDefs.CardBaseUniversalItem.System.Kind, FieldType.RefId, ConditionOperation.Equals, new Guid("{F4650B71-B131-41D2-AAFA-8DA1101ACA52}")); SectionQuery sectionQuery2 = typeQuery.SectionQueries.AddNew(new Guid("{3F9F3C1D-1CF1-4E71-BBE4-31D6AAD94EF7}")); sectionQuery2.Operation = SectionQueryOperation.And; sectionQuery2.ConditionGroup.Operation = ConditionGroupOperation.And; ConditionGroup ConditionGroup2 = sectionQuery2.ConditionGroup.ConditionGroups.AddNew(); ConditionGroup2.Operation = ConditionGroupOperation.And; ConditionGroup2.Conditions.AddNew("BaseDocument", FieldType.RefId, ConditionOperation.Equals, Document.Id); ConditionGroup2.Conditions.AddNew("Status", FieldType.Int, ConditionOperation.Equals, 0); SectionQuery sectionQuery3 = typeQuery.SectionQueries.AddNew(new Guid("{E6DB53B7-7677-4978-8562-6B17917516A6}")); sectionQuery3.Operation = SectionQueryOperation.And; sectionQuery3.ConditionGroup.Operation = ConditionGroupOperation.And; ConditionGroup ConditionGroup3 = sectionQuery3.ConditionGroup.ConditionGroups.AddNew(); ConditionGroup3.Operation = ConditionGroupOperation.And; ConditionGroup3.Conditions.AddNew("DeviceID", FieldType.RefId, ConditionOperation.Equals, DeviceType.Id); searchQuery.Limit = 0; string query = searchQuery.GetXml(); CardDataCollection CardBaseUniversalItems = Session.CardManager.FindCards(query); CardData ItemCard = null; RowData ItemRow = null; if (CardBaseUniversalItems.Count() == 0) { StatusStrip.Items["StatusText"].Text = "Ошибка! Не найдена соответствующая карточка ремонтных работ и доработок..."; StatusStrip.Update(); return; } if (CardBaseUniversalItems.Count() > 1) { StatusStrip.Items["StatusText"].Text = "Ошибка! Найдено несколько подходящих карточек ремонтных работ и доработок..."; StatusStrip.Update(); return; } if (CardBaseUniversalItems.Count() == 1) { ItemCard = CardBaseUniversalItems.First(); RowData ItemType = baseUniversal.Sections[new Guid("{A1DCE6C1-DB96-4666-B418-5A075CDB02C9}")].GetAllRows().First(r => r.Id == new Guid("{43A6DA44-899C-47D8-9567-2185E05D8524}")); ItemRow = ItemType.ChildSections[new Guid("{1B1A44FB-1FB1-4876-83AA-95AD38907E24}")].Rows.First(r => (Guid)r.GetGuid("ItemCard") == ItemCard.Id); if (ItemRow.IsNull()) { StatusStrip.Items["StatusText"].Text = "Ошибка! Не найдена соответствующая запись справочника ремонтных работ и доработок..."; StatusStrip.Update(); return; } else { StatusStrip.Items["StatusText"].Text = "Запись найдена: " + ItemRow.GetString("Name") + "..."; StatusStrip.Update(); } } Guid DevicePassportTypeID = new Guid("{42826E25-AD0E-4D9C-8B18-CD88E6796972}"); CardData CardTypeDictionary = Session.CardManager.GetDictionaryData(RefTypes.ID); SectionData DocumentTypes = CardTypeDictionary.Sections[RefTypes.DocumentTypes.ID]; RowData DevicePassportType = DocumentTypes.GetRow(DevicePassportTypeID); RowDataCollection DevicePassportProperties = DevicePassportType.ChildSections[RefTypes.Properties.ID].Rows; SearchQuery searchQuery2 = Session.CreateSearchQuery(); searchQuery2.CombineResults = ConditionGroupOperation.And; CardTypeQuery typeQuery2 = searchQuery2.AttributiveSearch.CardTypeQueries.AddNew(CardOrd.ID); SectionQuery sectionQuery4 = typeQuery2.SectionQueries.AddNew(CardOrd.MainInfo.ID); sectionQuery4.Operation = SectionQueryOperation.And; sectionQuery4.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery4.ConditionGroup.Conditions.AddNew("Type", FieldType.RefId, ConditionOperation.Equals, DevicePassportTypeID); sectionQuery4 = typeQuery2.SectionQueries.AddNew(CardOrd.Properties.ID); sectionQuery4.Operation = SectionQueryOperation.And; sectionQuery4.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery4.ConditionGroup.Conditions.AddNew("Name", FieldType.String, ConditionOperation.Equals, "Прибор"); sectionQuery4.ConditionGroup.Conditions.AddNew("Value", FieldType.RefId, ConditionOperation.Equals, DeviceType.Id); sectionQuery4 = typeQuery2.SectionQueries.AddNew(CardOrd.SelectedValues.ID); sectionQuery4.Operation = SectionQueryOperation.And; sectionQuery4.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery4.ConditionGroup.Conditions.AddNew("SelectedValue", FieldType.RefCardId, ConditionOperation.Equals, Document.Id); // Получение текста запроса searchQuery2.Limit = 0; string query2 = searchQuery2.GetXml(); Console.WriteLine(query2); Console.ReadLine(); CardDataCollection coll = Session.CardManager.FindCards(query2); Clear(); StatusStrip.Items["StatusText"].Text = "Найдено паспортов: " + coll.Count.ToString() + "..."; StatusStrip.Update(); int i = 0; for (i = 0; i < coll.Count; i++) { CardData Card = coll[i]; Card.ForceUnlock(); StatusStrip.Items["StatusText"].Text = i.ToString() + " из " + coll.Count + ". " + Card.Description; StatusStrip.Update(); SectionData Properties = Card.Sections[CardOrd.Properties.ID]; RowDataCollection DocumentCol = Properties.FindRow("@Name = 'Документ'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowData DocumentRow = DocumentCol.First(r => new Guid(r.GetString("SelectedValue")).Equals(Document.Id)); if (DocumentRow != null) { RowDataCollection Assembly = Properties.FindRow("@Name = 'Сборочный узел'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection RepareItem = Properties.FindRow("@Name = 'Запись справочника ремонтных работ и доработок'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Indication = Properties.FindRow("@Name = 'Указание'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Check = Properties.FindRow("@Name = 'Выполнено'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection CheckDate = Properties.FindRow("@Name = 'Дата выполнения'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Comments = Properties.FindRow("@Name = 'Комментарии'").ChildSections[CardOrd.SelectedValues.ID].Rows; if (DocumentCol.Count != Assembly.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (Assembly.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = Assembly.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != RepareItem.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (RepareItem.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = RepareItem.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != Indication.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (Indication.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = Indication.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != Check.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (Check.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = Check.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != CheckDate.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (CheckDate.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = CheckDate.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != Comments.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (Comments.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = Comments.AddNew(); NewRow.SetInt32("Order", Order); } } } int CurrentOrder = (int)DocumentRow.GetInt32("Order"); RepareItem.First(r => r.GetInt32("Order") == CurrentOrder).SetGuid("SelectedValue", ItemRow.Id); if (!ItemCard.Sections[new Guid("{3F9F3C1D-1CF1-4E71-BBE4-31D6AAD94EF7}")].FirstRow.GetGuid("AssemblyUnit").IsNull()) { Assembly.First(r => r.GetInt32("Order") == CurrentOrder).SetGuid("SelectedValue", (Guid)ItemCard.Sections[new Guid("{3F9F3C1D-1CF1-4E71-BBE4-31D6AAD94EF7}")].FirstRow.GetGuid("AssemblyUnit")); } if (!ItemRow.GetString("Description").IsNull()) { Indication.First(r => r.GetInt32("Order") == CurrentOrder).SetString("SelectedValue", ItemRow.GetString("Description")); } } Clear(); } StatusStrip.Items["StatusText"].Text = i.ToString() + " карточек успешно обработано."; StatusStrip.Update(); }
private void CheckDocument_Click(object sender, EventArgs e) { // //object activateParam = new object[] { "{E568490B-D73A-46BD-ADE1-54A0D9CA27D4}" }; //Host = (ICardHost)CardHost.CreateInstance(Session); //Guid result = Host.SelectCard("Выберите докумнт-основание для доработки:", activateParam); if (this.DocName.Text == "") { MessageBox.Show("Укажите номер Разрешения!"); } else { //Guid ResolutionTypeID = new Guid("{0051EE5E-C387-40DF-87D6-66160EB3395E}"); //CardData CardTypeDictionary = Session.CardManager.GetDictionaryData(RefTypes.ID); //SectionData DocumentTypes = CardTypeDictionary.Sections[RefTypes.DocumentTypes.ID]; //RowData ResolutionType = DocumentTypes.GetRow(ResolutionTypeID); //RowDataCollection ResolutionProperties = ResolutionType.ChildSections[new Guid("{752CCD78-111E-4F4C-9BB0-3933856EF44A}")].Rows; SearchQuery searchQuery = Session.CreateSearchQuery(); searchQuery.CombineResults = ConditionGroupOperation.And; CardTypeQuery typeQuery = searchQuery.AttributiveSearch.CardTypeQueries.AddNew(new Guid("{0051EE5E-C387-40DF-87D6-66160EB3395E}")); SectionQuery sectionQuery = typeQuery.SectionQueries.AddNew(new Guid("{752CCD78-111E-4F4C-9BB0-3933856EF44A}")); sectionQuery.Operation = SectionQueryOperation.And; sectionQuery.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery.ConditionGroup.Conditions.AddNew("Number", FieldType.String, ConditionOperation.Equals, this.DocName.Text); // Получение текста запроса searchQuery.Limit = 0; string query = searchQuery.GetXml(); Console.WriteLine(query); Console.ReadLine(); CardDataCollection coll = Session.CardManager.FindCards(query); Clear(); if (coll.Count == 0) { SearchQuery searchQuery2 = Session.CreateSearchQuery(); CardTypeQuery typeQuery2 = searchQuery2.AttributiveSearch.CardTypeQueries.AddNew(CardOrd.ID); SectionQuery sectionQuery4 = typeQuery2.SectionQueries.AddNew(CardOrd.MainInfo.ID); sectionQuery4.Operation = SectionQueryOperation.And; sectionQuery4.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery4.ConditionGroup.Conditions.AddNew("Type", FieldType.RefId, ConditionOperation.Equals, new Guid("{66A8D7CC-5804-4237-9D13-B3897EF18CEC}")); sectionQuery4 = typeQuery2.SectionQueries.AddNew(CardOrd.Properties.ID); sectionQuery4.Operation = SectionQueryOperation.And; sectionQuery4.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery4.ConditionGroup.Conditions.AddNew("Name", FieldType.String, ConditionOperation.Equals, "Номер разрешения"); sectionQuery4.ConditionGroup.Conditions.AddNew("Value", FieldType.String, ConditionOperation.Equals, this.DocName.Text); // Получение текста запроса searchQuery2.Limit = 0; string query2 = searchQuery2.GetXml(); Console.WriteLine(query2); Console.ReadLine(); CardDataCollection coll2 = Session.CardManager.FindCards(query2); Clear(); if (coll2.Count == 0) { MessageBox.Show("Разрешение с указанным номером не найдено!"); } else { Document = coll2[0]; this.DocName.Text = Document.Description; this.DocName.Enabled = false; } } else { Document = coll[0]; this.DocName.Text = Document.Description; this.DocName.Enabled = false; } } }
private void AddImprov_Click(object sender, EventArgs e) { RowData PartyRow = null; CardData UniversalDictionary = Session.CardManager.GetCardData(new Guid("{B2A438B7-8BB3-4B13-AF6E-F2F8996E148B}")); List <RowData> PartyItemRows = new List <RowData>(); RowDataCollection PartyRowsCollection; if (!Document.Sections.Any(r => r.Id == new Guid("{A8F93D97-496B-4675-B520-058B919146B7}"))) { PartyRowsCollection = Document.Sections[new Guid("{5B6B407E-3D72-49E7-97D9-8E1E028C7274}")].Rows.First(r => r.GetString("Name") == "Партия").ChildSections[new Guid("{E6F5105F-8BD8-4500-9780-60D7C1402DDB}")].Rows; foreach (RowData CurrentRow in PartyRowsCollection) { PartyItemRows.Add(UniversalDictionary.GetItemRow((Guid)CurrentRow.GetGuid("SelectedValue"))); } } else { PartyRowsCollection = Document.Sections[new Guid("{A8F93D97-496B-4675-B520-058B919146B7}")].Rows; foreach (RowData CurrentRow in PartyRowsCollection) { PartyItemRows.Add(UniversalDictionary.GetItemRow((Guid)CurrentRow.GetGuid("PartyId"))); } } //List<RowData> PartyItemRows = PartyRowsCollection.Select(r => UniversalDictionary.GetItemRow((Guid)r.GetGuid("Id"))).ToList(); if (PartyItemRows.Any(r => UniversalDictionary.GetItemPropertyValue(r.Id, "Наименование прибора").ToGuid() == DeviceType.Id)) { PartyRow = PartyItemRows.FirstOrDefault(r => UniversalDictionary.GetItemPropertyValue(r.Id, "Наименование прибора").ToGuid() == DeviceType.Id); } else { StatusStrip.Items["StatusText"].Text = "Ошибка! В Разрешении не указана партия для текущего прибора."; StatusStrip.Update(); switch (MessageBox.Show("Внести доработку во все приборы в эксплуатации?", "Ошибка", MessageBoxButtons.YesNo)) { case DialogResult.Yes: StatusStrip.Items["StatusText"].Text = "Продолжение работы..."; StatusStrip.Update(); break; case DialogResult.No: return; break; } } List <Guid> ImprovPartiesGuid = new List <Guid>(); if (!PartyRow.IsNull()) { RowData PartyDicType = UniversalDictionary.Sections[new Guid("{5E3ED23A-2B5E-47F2-887C-E154ACEAFB97}")].Rows.First(r => r.GetString("Name") == "Справочник партий"); IEnumerable <RowData> AllParties = PartyDicType.ChildSections[new Guid("{DD20BF9B-90F8-4D9A-9553-5B5F17AD724E}")].Rows.Where(r => (UniversalDictionary.GetItemPropertyValue(r.Id, "Наименование прибора").ToGuid() == DeviceType.Id) && (!UniversalDictionary.GetItemPropertyValue(r.Id, "Год начала выпуска").IsNull())); PartyComparer PC = new PartyComparer(); List <RowData> ImprovParties = AllParties.Where(r => PC.Compare(r.GetString("Name"), PartyRow.GetString("Name")) == 1).ToList(); foreach (RowData CurrentParty in ImprovParties) { ImprovPartiesGuid.Add(CurrentParty.Id); } } CardData baseUniversal = Session.CardManager.GetCardData(new Guid("{4538149D-1FC7-4D41-A104-890342C6B4F8}")); if (!baseUniversal.Sections[new Guid("{A1DCE6C1-DB96-4666-B418-5A075CDB02C9}")].GetAllRows().Any(r => r.Id == new Guid("{43A6DA44-899C-47D8-9567-2185E05D8524}"))) { StatusStrip.Items["StatusText"].Text = "Ошибка! Не найден справочник ремонтных работ и доработок..."; StatusStrip.Update(); return; } // Поиск записей справочника SearchQuery searchQuery = Session.CreateSearchQuery(); searchQuery.CombineResults = ConditionGroupOperation.And; CardTypeQuery typeQuery = searchQuery.AttributiveSearch.CardTypeQueries.AddNew(DocsVision.BackOffice.CardLib.CardDefs.CardBaseUniversalItem.ID); SectionQuery sectionQuery = typeQuery.SectionQueries.AddNew(DocsVision.BackOffice.CardLib.CardDefs.CardBaseUniversalItem.System.ID); sectionQuery.Operation = SectionQueryOperation.And; sectionQuery.ConditionGroup.Operation = ConditionGroupOperation.And; ConditionGroup ConditionGroup = sectionQuery.ConditionGroup.ConditionGroups.AddNew(); ConditionGroup.Operation = ConditionGroupOperation.And; ConditionGroup.Conditions.AddNew(DocsVision.BackOffice.CardLib.CardDefs.CardBaseUniversalItem.System.Kind, FieldType.RefId, ConditionOperation.Equals, new Guid("{F4650B71-B131-41D2-AAFA-8DA1101ACA52}")); SectionQuery sectionQuery2 = typeQuery.SectionQueries.AddNew(new Guid("{3F9F3C1D-1CF1-4E71-BBE4-31D6AAD94EF7}")); sectionQuery2.Operation = SectionQueryOperation.And; sectionQuery2.ConditionGroup.Operation = ConditionGroupOperation.And; ConditionGroup ConditionGroup2 = sectionQuery2.ConditionGroup.ConditionGroups.AddNew(); ConditionGroup2.Operation = ConditionGroupOperation.And; ConditionGroup2.Conditions.AddNew("BaseDocument", FieldType.RefId, ConditionOperation.Equals, Document.Id); ConditionGroup2.Conditions.AddNew("Status", FieldType.Int, ConditionOperation.Equals, 0); SectionQuery sectionQuery3 = typeQuery.SectionQueries.AddNew(new Guid("{E6DB53B7-7677-4978-8562-6B17917516A6}")); sectionQuery3.Operation = SectionQueryOperation.And; sectionQuery3.ConditionGroup.Operation = ConditionGroupOperation.And; ConditionGroup ConditionGroup3 = sectionQuery3.ConditionGroup.ConditionGroups.AddNew(); ConditionGroup3.Operation = ConditionGroupOperation.And; ConditionGroup3.Conditions.AddNew("DeviceID", FieldType.RefId, ConditionOperation.Equals, DeviceType.Id); searchQuery.Limit = 0; string query = searchQuery.GetXml(); CardDataCollection CardBaseUniversalItems = Session.CardManager.FindCards(query); CardData ItemCard = null; RowData ItemRow = null; if (CardBaseUniversalItems.Count() == 0) { StatusStrip.Items["StatusText"].Text = "Ошибка! Не найдена соответствующая карточка ремонтных работ и доработок..."; StatusStrip.Update(); return; } if (CardBaseUniversalItems.Count() > 1) { StatusStrip.Items["StatusText"].Text = "Ошибка! Найдено несколько подходящих карточек ремонтных работ и доработок..."; StatusStrip.Update(); return; } if (CardBaseUniversalItems.Count() == 1) { ItemCard = CardBaseUniversalItems.First(); RowData ItemType = baseUniversal.Sections[new Guid("{A1DCE6C1-DB96-4666-B418-5A075CDB02C9}")].GetAllRows().First(r => r.Id == new Guid("{43A6DA44-899C-47D8-9567-2185E05D8524}")); ItemRow = ItemType.ChildSections[new Guid("{1B1A44FB-1FB1-4876-83AA-95AD38907E24}")].Rows.First(r => (Guid)r.GetGuid("ItemCard") == ItemCard.Id); if (ItemRow.IsNull()) { StatusStrip.Items["StatusText"].Text = "Ошибка! Не найдена соответствующая запись справочника ремонтных работ и доработок..."; StatusStrip.Update(); return; } else { StatusStrip.Items["StatusText"].Text = "Запись найдена: " + ItemRow.GetString("Name") + "..."; StatusStrip.Update(); } } Guid DevicePassportTypeID = new Guid("{42826E25-AD0E-4D9C-8B18-CD88E6796972}"); CardData CardTypeDictionary = Session.CardManager.GetDictionaryData(RefTypes.ID); SectionData DocumentTypes = CardTypeDictionary.Sections[RefTypes.DocumentTypes.ID]; RowData DevicePassportType = DocumentTypes.GetRow(DevicePassportTypeID); RowDataCollection DevicePassportProperties = DevicePassportType.ChildSections[RefTypes.Properties.ID].Rows; SearchQuery searchQuery2 = Session.CreateSearchQuery(); searchQuery2.CombineResults = ConditionGroupOperation.And; CardTypeQuery typeQuery2 = searchQuery2.AttributiveSearch.CardTypeQueries.AddNew(CardOrd.ID); SectionQuery sectionQuery4 = typeQuery2.SectionQueries.AddNew(CardOrd.MainInfo.ID); sectionQuery4.Operation = SectionQueryOperation.And; sectionQuery4.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery4.ConditionGroup.Conditions.AddNew("Type", FieldType.RefId, ConditionOperation.Equals, DevicePassportTypeID); sectionQuery4 = typeQuery2.SectionQueries.AddNew(CardOrd.Properties.ID); sectionQuery4.Operation = SectionQueryOperation.And; sectionQuery4.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery4.ConditionGroup.Conditions.AddNew("Name", FieldType.String, ConditionOperation.Equals, "Прибор"); sectionQuery4.ConditionGroup.Conditions.AddNew("Value", FieldType.RefId, ConditionOperation.Equals, DeviceType.Id); if (ImprovPartiesGuid.Count != 0) { sectionQuery4 = typeQuery2.SectionQueries.AddNew(CardOrd.Properties.ID); sectionQuery4.Operation = SectionQueryOperation.And; sectionQuery4.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery4.ConditionGroup.Conditions.AddNew("Name", FieldType.String, ConditionOperation.Equals, "№ партии"); ConditionGroup PartyGroup = sectionQuery4.ConditionGroup.ConditionGroups.AddNew(); PartyGroup.Operation = ConditionGroupOperation.Or; for (int j = 0; j < ImprovPartiesGuid.Count; j++) { PartyGroup.Conditions.AddNew("Value", FieldType.RefId, ConditionOperation.OneOf, ImprovPartiesGuid.ToArray()[j]); } } else { sectionQuery4 = typeQuery2.SectionQueries.AddNew(CardOrd.Properties.ID); sectionQuery4.Operation = SectionQueryOperation.And; sectionQuery4.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery4.ConditionGroup.Conditions.AddNew("Name", FieldType.String, ConditionOperation.Equals, "Состояние прибора"); sectionQuery4.ConditionGroup.Conditions.AddNew("Value", FieldType.RefId, ConditionOperation.OneOf, new int[] { 5, 6 }); } // Получение текста запроса searchQuery2.Limit = 0; string query2 = searchQuery2.GetXml(); Console.WriteLine(query2); Console.ReadLine(); CardDataCollection coll = Session.CardManager.FindCards(query2); Clear(); StatusStrip.Items["StatusText"].Text = "Найдено паспортов: " + coll.Count.ToString() + "..."; StatusStrip.Update(); int i = 0; for (i = 0; i < coll.Count; i++) { CardData Card = coll[i]; Card.ForceUnlock(); StatusStrip.Items["StatusText"].Text = i.ToString() + " из " + coll.Count + ". " + Card.Description; StatusStrip.Update(); SectionData Properties = Card.Sections[CardOrd.Properties.ID]; RowDataCollection DocumentCol = Properties.FindRow("@Name = 'Документ'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Assembly = Properties.FindRow("@Name = 'Сборочный узел'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection RepareItem = Properties.FindRow("@Name = 'Запись справочника ремонтных работ и доработок'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Indication = Properties.FindRow("@Name = 'Указание'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Check = Properties.FindRow("@Name = 'Выполнено'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection CheckDate = Properties.FindRow("@Name = 'Дата выполнения'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Comments = Properties.FindRow("@Name = 'Комментарии'").ChildSections[CardOrd.SelectedValues.ID].Rows; if (DocumentCol.Count != Assembly.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (Assembly.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = Assembly.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != RepareItem.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (RepareItem.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = RepareItem.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != Indication.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (Indication.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = Indication.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != Check.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (Check.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = Check.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != CheckDate.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (CheckDate.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = CheckDate.AddNew(); NewRow.SetInt32("Order", Order); } } } if (DocumentCol.Count != Comments.Count) { foreach (RowData Doc in DocumentCol) { int Order = (int)Doc.GetInt32("Order"); if (Comments.FirstOrDefault(r => r.GetInt32("Order") == Order).IsNull()) { RowData NewRow = Comments.AddNew(); NewRow.SetInt32("Order", Order); } } } if (!DocumentCol.Any(r => r.GetGuid("SelectedValue") == Document.Id)) { int CurrentOrder = DocumentCol.Count + 1; RowData NewRow2 = DocumentCol.AddNew(); NewRow2.SetInt32("Order", CurrentOrder); NewRow2.SetGuid("SelectedValue", Document.Id); NewRow2 = RepareItem.AddNew(); NewRow2.SetInt32("Order", CurrentOrder); NewRow2.SetGuid("SelectedValue", ItemRow.Id); NewRow2 = Assembly.AddNew(); NewRow2.SetInt32("Order", CurrentOrder); if (!ItemCard.Sections[new Guid("{3F9F3C1D-1CF1-4E71-BBE4-31D6AAD94EF7}")].FirstRow.GetGuid("AssemblyUnit").IsNull()) { NewRow2.SetGuid("SelectedValue", (Guid)ItemCard.Sections[new Guid("{3F9F3C1D-1CF1-4E71-BBE4-31D6AAD94EF7}")].FirstRow.GetGuid("AssemblyUnit")); } NewRow2 = Indication.AddNew(); NewRow2.SetInt32("Order", CurrentOrder); if (!ItemCard.Sections[new Guid("{3F9F3C1D-1CF1-4E71-BBE4-31D6AAD94EF7}")].FirstRow.GetGuid("Instructions").IsNull()) { NewRow2.SetGuid("SelectedValue", (Guid)ItemCard.Sections[new Guid("{3F9F3C1D-1CF1-4E71-BBE4-31D6AAD94EF7}")].FirstRow.GetGuid("Instructions")); } NewRow2 = Check.AddNew(); NewRow2.SetInt32("Order", CurrentOrder); NewRow2 = CheckDate.AddNew(); NewRow2.SetInt32("Order", CurrentOrder); NewRow2 = Comments.AddNew(); NewRow2.SetInt32("Order", CurrentOrder); } Clear(); } StatusStrip.Items["StatusText"].Text = i.ToString() + " карточек успешно обработано."; StatusStrip.Update(); }
//public string UpdateDepartment(string unitId, string unit, string unitFull, string ownerId, string chief, string curator) public object UpdateDepartment(string unitId, string unit, string unitFull, string ownerId, string chief, string curator) { if (string.IsNullOrEmpty(unit)) { //logger.Info(string.Format(LogEmptyInfo, "Unit")); //return string.Format(LogEmptyInfo, "Unit"); return(true); } CardData refStaffData = Session.CardManager.GetDictionaryData(RefStaff.ID); SectionData unitsSection = refStaffData.Sections[RefStaff.Units.ID]; //im RowData department = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, unitId); RowDataCollection departmentColl = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, unitId); RowData department = null; try{ department = departmentColl[0]; } catch {} if (department == null) { return(AddDepartment(unitId, unit, unitFull, ownerId, chief, curator)); } refStaffData.BeginUpdate(); //Родитель if (ownerId == unitId) { return(true); } var existedParentDepartmentCode = department.ParentRow[RefStaff.Units.Code]; if (!(existedParentDepartmentCode == null && ownerId == null) && !ownerId.Equals(existedParentDepartmentCode)) { SectionQuery sectionQueryParentDepartment = Session.CreateSectionQuery(); sectionQueryParentDepartment.ConditionGroup.Conditions.AddNew(RefStaff.Units.Code, FieldType.Unistring, ConditionOperation.Equals, ownerId); RowDataCollection departmentParentCollection = unitsSection.FindRows(sectionQueryParentDepartment.GetXml()); if (departmentParentCollection != null && departmentParentCollection.Count > 0) { department.Move(departmentParentCollection[0].Id, Guid.Empty); } } refStaffData.EndUpdate(); refStaffData.BeginUpdate(); try{ var isFirstLoad = ConfigurationManager.AppSettings["FirstLoad"]; if (isFirstLoad == "1") { department[RefStaff.Units.Name] = unit; department[RefStaff.Units.FullName] = unitFull; } else { department[RefStaff.Units.Name] = unit; department[RefStaff.Units.FullName] = unitFull; } department[RefStaff.Units.Code] = unitId; //Руководитель подразделения if (chief != string.Empty) { try{ UpdateDepartmentChief(department, refStaffData, chief); } catch { refStaffData.EndUpdate(); return("Руководитель не найден."); } } //Куратор подразделения if (curator != string.Empty) { try{ UpdateDepartmentCurator(department, refStaffData, curator); } catch { refStaffData.EndUpdate(); return("Куратор не найден."); } } refStaffData.EndUpdate(); //return "Департамент обновлен"; return(true); } catch { return("Ошибка при попытке обновить подразделение. Необходимо перезапустить сервис!"); } }
private void DeleteImprov_Click(object sender, EventArgs e) { if (this.TypeName.Text == "") { MessageBox.Show("Укажите тип прибора!"); return; } if (this.DocName.Text == "") { MessageBox.Show("Укажите документ-основание!"); return; } StatusStrip.Items["StatusText"].Text = "Процесс начат..."; StatusStrip.Update(); Guid DevicePassportTypeID = new Guid("{42826E25-AD0E-4D9C-8B18-CD88E6796972}"); CardData CardTypeDictionary = Session.CardManager.GetDictionaryData(RefTypes.ID); SectionData DocumentTypes = CardTypeDictionary.Sections[RefTypes.DocumentTypes.ID]; RowData DevicePassportType = DocumentTypes.GetRow(DevicePassportTypeID); RowDataCollection DevicePassportProperties = DevicePassportType.ChildSections[RefTypes.Properties.ID].Rows; SearchQuery searchQuery = Session.CreateSearchQuery(); searchQuery.CombineResults = ConditionGroupOperation.And; CardTypeQuery typeQuery = searchQuery.AttributiveSearch.CardTypeQueries.AddNew(CardOrd.ID); SectionQuery sectionQuery = typeQuery.SectionQueries.AddNew(CardOrd.MainInfo.ID); sectionQuery.Operation = SectionQueryOperation.And; sectionQuery.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery.ConditionGroup.Conditions.AddNew("Type", FieldType.RefId, ConditionOperation.Equals, DevicePassportTypeID); sectionQuery = typeQuery.SectionQueries.AddNew(CardOrd.Properties.ID); sectionQuery.Operation = SectionQueryOperation.And; sectionQuery.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery.ConditionGroup.Conditions.AddNew("Name", FieldType.String, ConditionOperation.Equals, "Прибор"); sectionQuery.ConditionGroup.Conditions.AddNew("Value", FieldType.RefId, ConditionOperation.Equals, DeviceType.Id); sectionQuery = typeQuery.SectionQueries.AddNew(CardOrd.SelectedValues.ID); sectionQuery.Operation = SectionQueryOperation.And; sectionQuery.ConditionGroup.Operation = ConditionGroupOperation.And; sectionQuery.ConditionGroup.Conditions.AddNew("SelectedValue", FieldType.RefCardId, ConditionOperation.Equals, Document.Id); // Получение текста запроса searchQuery.Limit = 0; string query = searchQuery.GetXml(); Console.WriteLine(query); Console.ReadLine(); CardDataCollection coll = Session.CardManager.FindCards(query); Clear(); StatusStrip.Items["StatusText"].Text = "Найдено паспортов: " + coll.Count.ToString() + "..."; StatusStrip.Update(); int i = 0; for (i = 0; i < coll.Count; i++) { CardData Card = coll[i]; Card.ForceUnlock(); StatusStrip.Items["StatusText"].Text = i.ToString() + " из " + coll.Count + ". " + Card.Description; StatusStrip.Update(); SectionData Properties = Card.Sections[CardOrd.Properties.ID]; RowDataCollection DocumentCol = Properties.FindRow("@Name = 'Документ'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowData DocumentRow = DocumentCol.First(r => new Guid(r.GetString("SelectedValue")).Equals(Document.Id)); if (DocumentRow != null) { int Order = (int)DocumentRow.GetInt32("Order"); RowDataCollection Assembly = Properties.FindRow("@Name = 'Сборочный узел'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection RepareItem = Properties.FindRow("@Name = 'Запись справочника ремонтных работ и доработок'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Indication = Properties.FindRow("@Name = 'Указание'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Check = Properties.FindRow("@Name = 'Выполнено'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection CheckDate = Properties.FindRow("@Name = 'Дата выполнения'").ChildSections[CardOrd.SelectedValues.ID].Rows; RowDataCollection Comments = Properties.FindRow("@Name = 'Комментарии'").ChildSections[CardOrd.SelectedValues.ID].Rows; if (Assembly.FirstOrDefault(r => r.GetInt32("Order") == Order) != null) { Assembly.Remove(Assembly.First(r => r.GetInt32("Order") == Order).Id); } if (RepareItem.FirstOrDefault(r => r.GetInt32("Order") == Order) != null) { RepareItem.Remove(RepareItem.First(r => r.GetInt32("Order") == Order).Id); } if (Indication.FirstOrDefault(r => r.GetInt32("Order") == Order) != null) { Indication.Remove(Indication.First(r => r.GetInt32("Order") == Order).Id); } if (Check.FirstOrDefault(r => r.GetInt32("Order") == Order) != null) { Check.Remove(Check.First(r => r.GetInt32("Order") == Order).Id); } if (CheckDate.FirstOrDefault(r => r.GetInt32("Order") == Order) != null) { CheckDate.Remove(CheckDate.First(r => r.GetInt32("Order") == Order).Id); } if (Comments.FirstOrDefault(r => r.GetInt32("Order") == Order) != null) { Comments.Remove(Comments.First(r => r.GetInt32("Order") == Order).Id); } DocumentCol.Remove(DocumentRow.Id); } Clear(); } StatusStrip.Items["StatusText"].Text = i.ToString() + " карточек успешно обработано."; StatusStrip.Update(); }
public static IQueryable <Section> ApplySectionFilter(this IQueryable <Section> query, SectionQuery queryObj) { if (queryObj.DepartmentId.HasValue) { query = query.Where(s => s.Curriculum.DepartmentId == queryObj.DepartmentId); } if (!queryObj.IncludeInactive) { query = query.Where(s => s.IsActive); } return(query); }
public async Task <LoadMoreResult <QuestionDto> > GetQuestions(string examId, LoadMoreQuery query) { var examDocRef = db.Collection(_examCollectionName).Document(examId); var examSnapshot = await examDocRef.GetSnapshotAsync(); ParameterChecker.Against <FileNotFoundException>(examSnapshot.Exists == false, $"Exam {examSnapshot.Id} does not exist!"); var exam = examSnapshot.ConvertTo <Exam>(); var sections = new List <Section>(); Query allSectionsQuery = db.Collection(_examCollectionName).Document(examId).Collection(_sectionCollectionName); QuerySnapshot allCitiesQuerySnapshot = await allSectionsQuery.GetSnapshotAsync(); foreach (DocumentSnapshot documentSnapshot in allCitiesQuerySnapshot.Documents) { var section = documentSnapshot.ConvertTo <Section>(); sections.Add(section); } var remain = query.Limit; var dtos = new List <QuestionDto>(); var currentIndex = 0; var offsetInExam = query.Offset; for (int i = 0; i < sections.Count; i++) { var section = sections[i]; if (currentIndex < query.Offset) { if (currentIndex + section.NumberOfQuestions < query.Offset) { currentIndex += section.NumberOfQuestions; offsetInExam += query.Offset; continue; } else { var offsetInSection = query.Offset - currentIndex; var sectionQuery = new SectionQuery { ExamId = exam.Reference.Id, Section = section, Offset = offsetInSection, Limit = remain, SearchText = query.SearchText }; var queryResult = await QuerySection(sectionQuery, offsetInExam); offsetInExam = queryResult.OffsetInExam; if (queryResult.Items.Any()) { dtos.AddRange(queryResult.Items); remain -= queryResult.Items.Count; } } } else { var sectionQuery = new SectionQuery { ExamId = exam.Reference.Id, Section = section, Offset = 0, Limit = remain, SearchText = query.SearchText }; var queryResult = await QuerySection(sectionQuery, offsetInExam); offsetInExam = queryResult.OffsetInExam; if (queryResult.Items.Any()) { dtos.AddRange(queryResult.Items); remain -= queryResult.Items.Count; } } if (remain == 0) { break; } } return(new LoadMoreResult <QuestionDto>(offsetInExam < exam.NumberOfQuestions, offsetInExam, dtos)); }