Пример #1
0
        public void Execute(ProcessInfo process, PassState passInfo)
        {
            Dictionary <int, int> pages = new Dictionary <int, int>();

            pages.Add(1, 0);        // pages =0   hour =0
            pages.Add(6, 8);        // pages <5   hour =8
            pages.Add(21, 16);      // pages <=20 hour =16
            pages.Add(200, 24);     // pages >20  hour =24
            try
            {
                ProcessVariable doc       = process.GetVariableByName("Документ");
                ProcessVariable count     = process.GetVariableByName("Общее кол-во листов");
                ProcessVariable hours     = process.GetVariableByName("Срок исполнения задания");
                DVCard          _doc      = (DVCard)doc.Value;
                CardData        cardData  = process.Session.CardManager.GetCardData(new Guid(_doc.ID));
                RowData         row       = cardData.Sections[cardData.Type.Sections["СвойстваСтруктура"].Id].FirstRow;
                int             countPage = row.GetInt32("КоличествоЛистов").HasValue ? row.GetInt32("КоличествоЛистов").Value : 0;
                int             countApp  = row.GetInt32("ВПриложении").HasValue ? row.GetInt32("ВПриложении").Value : 0;
                count.Value = countPage + countApp;
                hours.Value = pages.Where(s => s.Key > (int)count.Value).Select(s => s.Value).Min();
                //var message=string.Format("Общее кол {0}, срок согласования {1} ч.", count.Value, hours.Value);

                //ListHours
                ProcessVariable listHours = process.GetVariableByName("ListHours");
                process.LogMessage("Кол" + listHours.Values.Count.ToString());
                process.LogMessage(listHours.GetType().Name);

                process.LogMessage("Кол listHours.VarEnumValues.Count" + listHours.VarEnumValues.Count.ToString());
                process.LogMessage("listHours.Values");
                for (int i = 0; i < listHours.Values.Count; i++)
                {
                    var value = listHours.Values[i];
                    process.LogMessage(value.GetType().Name);
                    process.LogMessage(value.Key.ToString());
                    process.LogMessage(value.Value.ToString());
                    //pages.Add((int)value.Key,(int)value.Value);
                }
                process.LogMessage("listHours.VarEnumValues");
                process.LogMessage(listHours.VarEnumValues.Keys.Count.ToString());
                //for (int i = 0; i < listHours.VarEnumValues.Count; i++)
                //{
                //	process.LogMessage(listHours.VarEnumValues[i].GetType().Name );
                //	process.LogMessage(listHours.VarEnumValues[i].NumValue.ToString());
                //	process.LogMessage(listHours.VarEnumValues[i].Value.ToString());
                //}
            }
            catch (Exception ex)
            {
                process.LogMessage("Ошибка выполнения скрипта:" + ex.Message);
            }
            return;
        }
Пример #2
0
        /// <summary>
        /// Инициализирует строку по данным карточки файла.
        /// </summary>
        /// <param name="Context">Объектный контекст.</param>
        /// <param name="FileCard">Данные карточки файла.</param>
        private void Initalize(ObjectContext Context, CardData FileCard)
        {
            RowData        FileCardMainInfoRow = FileCard.Sections[CardFile.MainInfo.ID].FirstRow;
            List <RowData> FileCardCategories  = FileCard.Sections[CardFile.Categories.ID].Rows.Where(row => !row.GetObject(CardFile.Categories.CategoryID).ToGuid().IsEmpty()).ToList();
            Guid           AuthorId            = FileCardMainInfoRow.GetGuid(CardFile.MainInfo.Author) ?? Guid.Empty;

            this.Name         = FileCardMainInfoRow.GetString(CardFile.MainInfo.FileName);
            this.Size         = (Decimal)FileCardMainInfoRow.GetInt32(CardFile.MainInfo.FileSize) / (Decimal)1024;
            this.Category     = FileCardCategories.Any() ? FileCardCategories.Select(row => row.GetString("Name")).Aggregate((a, b) => a + ";" + b) : String.Empty;
            this.Registrar    = AuthorId.IsEmpty() ? String.Empty : Context.GetEmployeeDisplay(AuthorId);
            this.RegistrarId  = AuthorId;
            this.CreationDate = FileCard.CreateDate;
        }
Пример #3
0
        /// <summary>
        /// Определение возраста прибора.
        /// </summary>
        public int GetAge()
        {
            int         Age             = 0;
            DateTime    LoadDate        = DateTime.MinValue;
            CardData    CurrentPassport = Card.CardScript.Session.CardManager.GetCardData(new Guid(this.DevicePassportID));
            SectionData Links           = CurrentPassport.Sections[CurrentPassport.Type.AllSections["CardReferences"].Id];

            foreach (RowData Link in Links.Rows)
            {
                if (Link.GetString("Description").IndexOf("Плановая дата отгрузки:") >= 0)
                {
                    CardData    LinkCard = Card.CardScript.Session.CardManager.GetCardData(new Guid(Link.GetString("Link")));
                    SectionData Devices  = LinkCard.Sections[SKB.Base.Ref.RefCompleteCard.Devices.ID];
                    foreach (RowData Row in Devices.Rows)
                    {
                        if ((Row.GetString(SKB.Base.Ref.RefCompleteCard.Devices.ContractSubjectId) == SKB.PaymentAndShipment.Cards.AccountCard.Item_Subject_Delivery) && (Row.GetString(SKB.Base.Ref.RefCompleteCard.Devices.DeviceNumberId) == this.DeviceItemID))
                        {
                            LoadDate = (DateTime)Row.GetDateTime(SKB.Base.Ref.RefCompleteCard.Devices.FactShipDate);
                        }
                    }
                }
            }

            if (LoadDate == DateTime.MinValue)
            {
                RowData DeviceYear = CurrentPassport.Sections[CurrentPassport.Type.AllSections["Properties"].Id].FindRow("@Name = '/Год прибора'");
                Age = DateTime.Today.Year - (int)DeviceYear.GetInt32("Value");
            }
            else
            {
                TimeSpan T = DateTime.Today - LoadDate;
                Age = (int)(T.Days / 365);
            }

            /*if (LoadDate.GetDateTime("Value") != null)
             * {
             *  TimeSpan T = DateTime.Today - ((DateTime)LoadDate.GetDateTime("Value"));
             *  Age = (int)(T.Days / 365);
             * }
             * else
             * {
             *  RowData DeviceYear = CurrentPassport.Sections[CurrentPassport.Type.AllSections["Properties"].Id].FindRow("@Name = '/Год прибора'");
             *  Age = DateTime.Today.Year - (int)DeviceYear.GetInt32("Value");
             * }*/
            return(Age);
        }
Пример #4
0
        /// <summary>
        /// Определение возраста изделия (количество лет с момента продажи/выпуска).
        /// </summary>
        public int GetAge()
        {
            int      Age             = 0;
            CardData CurrentPassport = CardScript.Session.CardManager.GetCardData(new Guid(this.WarePassportID));
            RowData  LoadDate        = CurrentPassport.Sections[CurrentPassport.Type.AllSections["Properties"].Id].FindRow("@Name = 'Дата отправки'");

            if (LoadDate.GetDateTime("Value") != null)
            {
                TimeSpan T = DateTime.Today - ((DateTime)LoadDate.GetDateTime("Value"));
                Age = (int)(T.Days / 365);
            }
            else
            {
                RowData DeviceYear = CurrentPassport.Sections[CurrentPassport.Type.AllSections["Properties"].Id].FindRow("@Name = '/Год прибора'");
                Age = DateTime.Today.Year - (int)DeviceYear.GetInt32("Value");
            }
            return(Age);
        }
 private static void SetRowEnumValue(this SectionData self,
                                     string fieldValue, string value)
 {
     if (!String.IsNullOrEmpty(value) && !RegexEngine.IsMatch(value, @"^\s+$"))
     {
         RowData        rd  = self.FindRow(string.Format("@Name='{0}'", fieldValue));
         SubSectionData ssd = rd.ChildSections[self.Card.Type.AllSections["EnumValues"].Id];
         RowData        srd = ssd.GetAllRows().ToList().Find(r => RegexEngine.IsMatch(r.GetString("ValueName"), value));
         srd = srd ?? ssd.GetAllRows().ToList().Find(r => RegexEngine.IsMatch(value, r.GetString("ValueName")));
         if (srd != null)
         {
             rd.SetInt32("Value", srd.GetInt32("ValueID"));
             rd.SetString("DisplayValue", srd.GetString("ValueName"));
         }
         else
         {
             logger.Warn("cardId='{0}'; {2}='{1}' value not found", self.Card.Id, value, fieldValue);
         }
     }
 }
Пример #6
0
        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();
        }
Пример #7
0
        /// <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();
        }
Пример #8
0
        /// <summary>
        /// Новый прибор.
        /// </summary>
        public Device(MyBaseCard Card, string DNID, string DTID, bool OA, bool R, bool C, bool V, bool WR, string A, string Com, string PL, bool W, string S, string WO)
        {
            this.Card    = Card;
            DeviceItemID = DNID;

            if (OA == false)
            {
                DevicePassportID  = DNID == "" ? "" : ApplicationCard.UniversalCard.GetItemPropertyValue(DNID.ToGuid(), "Паспорт прибора").ToString();
                DeviceNumber      = DNID == "" ? "" : ApplicationCard.UniversalCard.GetItemName(DNID.ToGuid());
                ShortDeviceNumber = DNID == "" ? "" : ApplicationCard.UniversalCard.GetItemPropertyValue(DNID.ToGuid(), "Номер прибора").ToString();
                string Year = DNID == "" ? "" : ApplicationCard.UniversalCard.GetItemPropertyValue(DNID.ToGuid(), "Год прибора").ToString();
                ShortDeviceNumber = ShortDeviceNumber.Length == 4 ? ShortDeviceNumber : ShortDeviceNumber + "/" + Year;
                RowData SpecConditions = Card.CardScript.Session.CardManager.GetCardData(new Guid(DevicePassportID)).Sections[CardOrd.Properties.ID].FindRow("@Name = 'Особые условия по СО и ГО'");
                SpecialConditions = SpecConditions.GetString("Value") != null?SpecConditions.GetString("Value") : "";
            }
            else
            {
                DevicePassportID = "";
                DeviceNumber     = "";
            }

            DeviceTypeID    = DTID == "" ? "" : DTID;
            DeviceType      = DTID == "" ? "" : ApplicationCard.UniversalCard.GetItemName(DTID.ToGuid());
            OnlyAccessories = OA;
            Repair          = R;
            Calibrate       = C;
            Verify          = V;
            WarrantyRepair  = WR;
            Wash            = W;
            Accessories     = A == "" ? "" : A;
            Comments        = Com == "" ? "" : Com;
            Services        = FormattingService(this.Repair, this.Calibrate, this.Verify);
            PackedListData  = PL == "" ? "" : PL;
            PackedListID    = "";
            Sensors         = S == "" ? "" : S;
            ServiceCardID   = WO;
            DeviceName      = this.DeviceNumber == "" ? "Комплектующие для " + this.DeviceType : this.DeviceType + " №" + this.ShortDeviceNumber;

            if (Sensors != "")
            {
                List <String> SelectedSensors = Sensors.Split(';').Where(s => !String.IsNullOrEmpty(s.Trim())).ToList();
                for (Int32 j = 0; j < SelectedSensors.Count; j++)
                {
                    String[] Sensor = SelectedSensors[j].Trim().Split(' ');
                    if (Sensor.Length >= 2)
                    {
                        RowData        CurrentDeviceRow      = GetDeviceRow(Sensor[1], Sensor[0]);
                        string         CurrentPassportId     = CurrentDeviceRow.ChildSections[0].FindRow("@Name = 'Паспорт прибора'").GetString("Value");
                        string         CurrentDeviceTypeID   = CurrentDeviceRow.ChildSections[0].FindRow("@Name = 'Наименование прибора'").GetString("Value");
                        string         CurrentDeviceTypeName = ApplicationCard.UniversalCard.GetItemName(CurrentDeviceTypeID);
                        AdditionalWare NewWare = new AdditionalWare(Card.CardScript, SelectedSensors[j], CurrentPassportId, CurrentDeviceRow.Id.ToString(), CurrentDeviceTypeID, CurrentDeviceTypeName);
                        AdditionalWaresList.Add(NewWare);
                    }
                }
            }

            if (ServiceCardID != "")
            {
                CardData ServiceCard = Card.CardScript.Session.CardManager.GetCardData(new Guid(ServiceCardID));
                RowData  Adjustment  = ServiceCard.Sections[RefServiceCard.Adjustment.ID].FirstRow;
                RowData  MainInfo    = ServiceCard.Sections[RefServiceCard.MainInfo.ID].FirstRow;
                this.VoidWarranty        = Adjustment.GetBoolean(RefServiceCard.Adjustment.VoidWarranty) == null ? false : (bool)Adjustment.GetBoolean(RefServiceCard.Adjustment.VoidWarranty);
                this.DoubleCost          = Adjustment.GetBoolean(RefServiceCard.Adjustment.DoubleCost) == null ? false : (bool)Adjustment.GetBoolean(RefServiceCard.Adjustment.DoubleCost);
                this.DescriptionOfReason = Adjustment.GetString(RefServiceCard.Adjustment.DescriptionOfReason) == null ? "" : Adjustment.GetString(RefServiceCard.Adjustment.DescriptionOfReason).ToString();
                this.RefusalToRepair     = (int)MainInfo.GetInt32(RefServiceCard.MainInfo.Status) == (int)RefServiceCard.MainInfo.State.Failure ? true : false;
            }
        }