private void WinnerLotsSearch()
        {
            if ((Customers != null) && (Customers.Count > 0)) {
                SelectedCustomer = Customers[0];
            }

            if (Winners != null) Winners.Clear();
            if (SelectedCustomer == null) {
                MessageBox.Show("Выберите заказчика!", "Информация", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            IsWinnerLotsSearching = true;

            if ((mvm.lsProcessor != null) && (mvm.lsProcessor.isWorking()))
            {
                mvm.lsProcessor.Stop();
            }

            AllLotsSearched_delegete allLotsSearched_delegete = new AllLotsSearched_delegete(AllLotsSearched_proc);
            LotSearched_delegate lotSearched_delegate = new LotSearched_delegate(LotSearched__proc);
            mvm.lsProcessor = new LotsSearchProcessor(SelectedCustomer,
                                                      CustomerType_enum.Customer,
                                                      LawType_enum._44_94_223,
                                                      100,
                                                      100000000,
                                                      Convert.ToDateTime("2010.01.01"),
                                                      DateTime.Now,
                                                      lotSearched_delegate,
                                                      allLotsSearched_delegete
                                                      );
            mvm.lsProcessor.Operate();
        }
Пример #2
0
        public ResultType_enum FillWinners(Order order, InternetRequestEngine internetRequestEngine, 
                                           LotSearched_delegate lotSearched_delegate, out string winnerMessage)
        {
            isWinner = false;
            winnerMessage = "";
            HtmlAgilityPack.HtmlNode nodeTmp = null;
            try
            {
                switch (order.LawType.Name.Trim().ToLower())
                {
                    #region 44 Закон
                    case ("44"):
                        // Параметры лота
                        string _44lotName = order.Name;
                        long _44lotPrice = order.Price;
                        string _44lotPriceTypeName = order.OrderPriceType.Name;
                        string _44lotOrderHref = @"http://zakupki.gov.ru/epz/order/notice/zp44/view/common-info.html?regNumber=" + order.HrefId;
                        long _44lotDocumentPrice = 0;
                        string _44lotDocumentDateTime = "";

                        // Параметры победителя
                        string winnerName = "";
                        string winnerPhone = "";
                        string winnerEmail = "";

                        // Закупка
                        string numRegistr = "";

                        doc = internetRequestEngine.GetHtmlDoc(@"http://zakupki.gov.ru/epz/order/notice/ea44/view/supplier-results.html?regNumber=" + order.HrefId);
                        string checkMessage = "";
                        ResultType_enum resultTypeCheck = Globals.CheckDocResult(doc, out checkMessage);
                        if (resultTypeCheck != ResultType_enum.Done)
                        {
                            winnerMessage = checkMessage;
                            return resultTypeCheck;
                        }

                        text = "//div[@class=\"cardWrapper\"]";
                        text += "/div[@class=\"wrapper\"]";
                        text += "/div[@class=\"mainBox\"]";
                        text += "/div[@class=\"noticeTabBox\"]";
                        text += "/div[@class=\"noticeTabBoxWrapper\"]";
                        text += "/table";
                        text += "/tr";
                        text += "/td";
                        text += "/table[@class=\"noticeCardTableInBlock contractTable\"]";
                        text += "/tr";
                        text += "/td";
                        text += "/table[@class=\"contractTable displaytagTable\"]";
                        text += "/tbody";
                        text += "/tr";
                        text += "/td";

                        HtmlAgilityPack.HtmlNodeCollection atrCollection = doc.DocumentNode.SelectNodes(text);
                        // Возможно : Сведения о контракте из реестра контрактов отсутствуют
                        if ((atrCollection == null)/* &&
                            (doc.DocumentNode.InnerText.IndexOf("Сведения о контракте из реестра контрактов отсутствуют") > 0)*/)
                        {
                            return ResultType_enum.NotSearch;
                        }

                        int num = 1;
                        foreach (HtmlAgilityPack.HtmlNode atrNode in atrCollection)
                        {
                            switch (num)
                            {
                                case (1):
                                    numRegistr = ConvertNum(atrNode.InnerText.Trim());
                                    break;
                                case (4):
                                    if (atrNode.InnerText.Trim() != "")
                                    {
                                        string lotPriceStr = atrNode.InnerText.Trim().Replace(" ", "").ToLower();
                                        try
                                        {

                                            if (lotPriceStr.IndexOf(',') > -1)
                                            {
                                                _44lotDocumentPrice = Convert.ToInt64(lotPriceStr.Substring(0, lotPriceStr.IndexOf(',')));
                                            }
                                            else
                                            {
                                                if (lotPriceStr.IndexOf(' ') > -1)
                                                {
                                                    _44lotDocumentPrice = Convert.ToInt64(lotPriceStr.Substring(0, lotPriceStr.IndexOf(' ')));
                                                }
                                                else
                                                {
                                                    _44lotDocumentPrice = Convert.ToInt64(lotPriceStr);
                                                }
                                            }
                                        }
                                        catch
                                        {
                                            string sss = "ывавы";
                                        }
                                    }
                                    break;
                                case (5):
                                    if (atrNode.InnerText.Trim() != "")
                                    {
                                        _44lotDocumentDateTime = atrNode.InnerText.Trim();
                                        break;
                                    }
                                    break;
                                default:
                                    break;
                            }

                            num++;
                        }

                        // Номер реестровой записи
                        text = @"http://zakupki.gov.ru/epz/contract/contractCard/common-info.html?reestrNumber=" + numRegistr;
                        doc = internetRequestEngine.GetHtmlDoc(text);
                        resultTypeCheck = Globals.CheckDocResult(doc, out checkMessage);
                        if (resultTypeCheck != ResultType_enum.Done)
                        {
                            winnerMessage = checkMessage;
                            return resultTypeCheck;
                        }

                        text = "//div[@class=\"cardWrapper\"]";
                        text += "/div[@class=\"wrapper\"]";
                        text += "/div[@class=\"mainBox\"]";
                        text += "/div[@class=\"noticeTabBox\"]";
                        text += "/div[@class=\"noticeTabBoxWrapper\"]";
                        text += "/table[@class=\"cTdCenter\"]";
                        text += "/tbody";
                        text += "/tr";

                        HtmlAgilityPack.HtmlNodeCollection trCollection = doc.DocumentNode.SelectNodes(text);
                        if (trCollection == null)
                        {
                            return ResultType_enum.NotSearch;
                        }

                        num = 1;
                        int numTd = 1;

                        foreach (HtmlAgilityPack.HtmlNode trNode in trCollection)
                        {
                            if (num == 2)
                            {
                                foreach (HtmlAgilityPack.HtmlNode tdNode in trNode.ChildNodes)
                                {
                                    if (tdNode.Name == "td")
                                    {
                                        switch (numTd)
                                        {
                                            case (1):
                                                // Наименование организации
                                                winnerName = Globals.DecodeInternetSymbs(tdNode.InnerHtml.Trim().Replace("<br>", " "));
                                                isWinner = true;
                                                break;
                                            case (6):
                                                // Телефон, электронная почта
                                                string emailPhone = tdNode.InnerText.Trim();
                                                if (emailPhone.IndexOf('\n') > -1)
                                                {
                                                    winnerPhone = Globals.DecodeInternetSymbs(emailPhone.Substring(0, emailPhone.IndexOf('\n')).Trim());
                                                    winnerEmail = Globals.DecodeInternetSymbs(emailPhone.Substring(emailPhone.IndexOf('\n'), emailPhone.Length - emailPhone.IndexOf('\n')).Trim());
                                                }
                                                else
                                                {
                                                    winnerPhone = emailPhone;
                                                }
                                                break;
                                            default:
                                                break;
                                        }
                                        numTd++;
                                    }
                                }
                            }
                            num++;
                        }
                        if ((_44lotName != "") && (_44lotPrice != 0) && (_44lotPriceTypeName != ""))
                        {
                            Lot _44lot = new Lot();
                            _44lot.Order = order;
                            _44lot.Name = _44lotName;
                            if (_44lot.Name.Length > 400)
                            {
                                _44lot.Name = _44lot.Name.Substring(0, 398) + "..";
                            }

                            _44lot.Price = _44lotPrice;
                            // LotPriceType
                            LotPriceType lotPriceType = mvm.wc.LotPriceTypes.FirstOrDefault(m => m.Name.ToLower().Trim() == _44lotPriceTypeName.ToLower());
                            if (lotPriceType == null)
                            {
                                lotPriceType = new LotPriceType();
                                lotPriceType.Name = _44lotPriceTypeName;
                                mvm.wc.LotPriceTypes.Add(lotPriceType);
                                mvm.wc.SaveChanges();
                            }
                            _44lot.LotPriceType = lotPriceType;
                            _44lot.OrderHref = _44lotOrderHref;
                            _44lot.DocumentPrice = _44lotDocumentPrice;
                            _44lot.CreateDateTime = DateTime.Now;
                            try
                            {
                                if (_44lotDocumentDateTime.IndexOf('(') > -1)
                                {
                                    _44lot.DocumentDateTime = Convert.ToDateTime(_44lotDocumentDateTime.Substring(0, _44lotDocumentDateTime.IndexOf('(')).Trim());
                                }
                                else {
                                    _44lot.DocumentDateTime = Convert.ToDateTime(_44lotDocumentDateTime.Trim());
                                }

                            }
                            catch {
                                string sss = "аыв";
                            }

                            if (winnerName != "")
                            {
                                mvm.wc.Lots.Add(_44lot);
                                mvm.wc.SaveChanges();

                                Winner winner = new Winner();
                                winner.Name = winnerName;
                                winner.Phone = winnerPhone;
                                winner.Email = winnerEmail;
                                winner.Lot = _44lot;

                                mvm.wc.Winners.Add(winner);
                                mvm.wc.SaveChanges();

                                lotSearched_delegate(winner);
                            }
                        }

                        break;
                    #endregion
                    #region 223 Закон
                    case ("223"):
                        doc = internetRequestEngine.GetHtmlDoc(@"http://zakupki.gov.ru/223/purchase/public/purchase/info/protocols.html?noticeId=" + order.HrefId + @"&amp;epz=true");
                        resultTypeCheck = Globals.CheckDocResult(doc, out checkMessage);
                        if (resultTypeCheck != ResultType_enum.Done)
                        {
                            winnerMessage = checkMessage;
                            return resultTypeCheck;
                        }

                        // Поиск протоколов
                        text = "//div[@class=\"cardWrapper\"]";
                        text += "/div[@class=\"wrapper\"]";
                        text += "/div[@class=\"mainbox\"]";
                        text += "/div[@class=\"contentTabBox\"]";
                        text += "/div[@class=\"contentTabBoxBlock\"]";
                        text += "/div[@class=\"noticeTabBox \"]";
                        text += "/div[@class=\"noticeTabBoxWrapper\"]";
                        text += "/table";
                        text += "/tbody";
                        text += "/tr";

                        HtmlAgilityPack.HtmlNodeCollection trColl = doc.DocumentNode.SelectNodes(text);
                        // Страница не найдена
                        if (trColl == null) return ResultType_enum.NotSearch;

                        // Параметры победителя
                        winnerName = "";
                        winnerPhone = "";
                        winnerEmail = "";
                        // Поиск протоколов с победителем
                        foreach (HtmlAgilityPack.HtmlNode protocolNode in trColl)
                        {
                            text = ".//td[@class=\"descriptTenderTd\"]";
                            text += "/dl";
                            text += "/dt";
                            text += "/a";

                            HtmlAgilityPack.HtmlNode winnerProtocolNode = protocolNode.SelectSingleNode(text);
                            if (winnerProtocolNode == null) continue;

                            #region Решение комиссии
                            if ((winnerProtocolNode.InnerText.Trim().ToLower().IndexOf("протокол подведения итогов") > -1) ||
                                (winnerProtocolNode.InnerText.Trim().ToLower().IndexOf("подведению итогов") > -1) ||
                                (winnerProtocolNode.InnerText.Trim().ToLower().IndexOf("оценки и сопоставления заявок") > -1) ||
                                (winnerProtocolNode.InnerText.Trim().ToLower().IndexOf("победител") > -1) ||
                                (winnerProtocolNode.InnerText.Trim().ToLower().IndexOf("протокол основного этапа закупки") > -1) ||
                                (winnerProtocolNode.InnerText.Trim().ToLower().IndexOf("запрос предложений о цене договора") > -1))
                            {
                                string commissionDecisionMessage = "";
                                _223commissionDecision.Work(order, internetRequestEngine, winnerProtocolNode, lotSearched_delegate, out commissionDecisionMessage, out isWinner);

                            }
                            #endregion
                            #region Выбор победителя
                            if (winnerProtocolNode.InnerText.Trim().ToLower().IndexOf("протокол запроса котировок") > -1)
                            {
                                string winnerChoiceMessage = "";
                                // Доделать
                                _223winnerChoice.Work(order, internetRequestEngine, winnerProtocolNode, lotSearched_delegate, out winnerChoiceMessage, out isWinner);
                            }
                            #endregion
                        }

                        break;
                    #endregion
                    default:
                        return ResultType_enum.Done; // !!! Необходимо добавить 94 закон
                }

                if (!isWinner) return ResultType_enum.NotSearch; else return ResultType_enum.Done;
            }
            catch (Exception ex)
            {
                winnerMessage = ex.Message + '\n' + ex.StackTrace;
                return ResultType_enum.Error;
            }
        }
        public ResultType_enum Work(Order order, InternetRequestEngine internetRequestEngine,
                               HtmlAgilityPack.HtmlNode winnerProtocolNode, LotSearched_delegate lotSearched_delegate,
                               out string commissionDecisionMessage, out bool isWinner)
        {
            try
            {
                isWinner = false;
                commissionDecisionMessage = "";

                List<Lot> lotsTemp = new List<Lot>();
                List<Winner> winnersTemp = new List<Winner>();

                // Получаем ID протокола
                string protocolHref = winnerProtocolNode.Attributes["onclick"].Value;
                string protocolID = protocolHref.Substring(protocolHref.IndexOf("protocolInfoId=") + 15,
                    protocolHref.IndexOf("&purchaseId=") - (protocolHref.IndexOf("protocolInfoId=") + 15));

                text = @"http://zakupki.gov.ru/223/purchase/public/purchase/protocol/ip/application/comission-decision.html?noticeInfoId=&protocolInfoId=" + protocolID + "&mode=view";
                //text = @"http://zakupki.gov.ru/223/purchase/public/purchase/protocol/ip/application/comission-decision.html?noticeInfoId=716491&protocolInfoId=692914&mode=view";
                doc = internetRequestEngine.GetHtmlDoc(text);
                string checkMessage = "";
                ResultType_enum resultTypeCheck = Globals.CheckDocResult(doc, out checkMessage);
                if (resultTypeCheck != ResultType_enum.Done)
                {
                    commissionDecisionMessage = checkMessage;
                    return resultTypeCheck;
                }

                // Поиск лотов
                text = "//div[@class=\"cardWrapper\"]";
                text += "/div[@class=\"wrapper\"]";
                text += "/div[@class=\"mainbox\"]";
                text += "/div[@class=\"contentTabBoxBlock\"]";
                text += "/div[@class=\"noticeTabBox\"]";
                text += "/div[@class=\"noticeTabBoxWrapper\"]";
                text += "/div[@class=\"blue-border rootOfLot\"]";

                HtmlAgilityPack.HtmlNodeCollection lotsColl = doc.DocumentNode.SelectNodes(text);
                if (lotsColl == null) return ResultType_enum.NotSearch;

                string _223lotName = "";
                long _223lotPrice = 0;
                string _223lotPriceTypeName = "";
                long _223lotDocumentPrice = 0;
                string _223lotDocumentDate = "";

                Lot _223lot = null;
                Winner _223winner = null;
                int num = 1;

                // Обработка лотов
                int lotNum = 0;
                foreach (HtmlAgilityPack.HtmlNode lotNode in lotsColl)
                {
                    // Заполняем цену и валюту лота
                    _223lotName = "";
                    _223lotPrice = 0;
                    _223lotPriceTypeName = "";
                    _223lotDocumentPrice = 0;
                    _223lotDocumentDate = "";

                    _223lot = new Lot();
                    _223winner = new Winner();
                    _223winner.Lot = _223lot;

                    _223lot.Order = order;
                    _223lot.CreateDateTime = DateTime.Now;
                    _223lot.OrderHref = @"http://zakupki.gov.ru/223/purchase/public/purchase/info/common-info.html?noticeId=" + order.HrefId + "&epz=true";
                    lotsTemp.Add(_223lot);

                    // Получаем цену и валюту лота
                    text = ".//table";
                    text += "/tr[@class=\"mainExpand\"]";
                    text += "/td";
                    text += "/table[@class=\"outertable\"]";
                    text += "/tr";
                    HtmlAgilityPack.HtmlNodeCollection lotParamsColl = lotNode.SelectNodes(text);

                    if (lotParamsColl != null)
                    {
                        HtmlAgilityPack.HtmlNode lotParamPriceNode = lotParamsColl[1];
                        num = 1;
                        foreach (HtmlAgilityPack.HtmlNode tdNode in lotParamPriceNode.ChildNodes)
                        {
                            if (tdNode.Name != "td") continue;
                            if (num == 2)
                            {
                                string priceTypePriceLot = tdNode.InnerText.Trim();
                                if (priceTypePriceLot.IndexOf(' ') > -1)
                                {
                                    string _223lotPriceStr = Globals.DecodeInternetSymbs(priceTypePriceLot.Substring(0, priceTypePriceLot.IndexOf(' ')).Trim());
                                    if (_223lotPriceStr.IndexOf(',') > -1)
                                    {
                                        _223lotPrice = Convert.ToInt64(_223lotPriceStr.Substring(0, _223lotPriceStr.IndexOf(',')));
                                    }
                                    else
                                    {
                                        _223lotPrice = Convert.ToInt64(_223lotPriceStr);
                                    }
                                    //_223lotPrice = Convert.ToInt64(Globals.DecodeInternetSymbs(priceTypePriceLot.Substring(0, priceTypePriceLot.IndexOf(' ')).Trim()));
                                    _223lotPriceTypeName = Globals.DecodeInternetSymbs(priceTypePriceLot.Substring(priceTypePriceLot.IndexOf(' '), priceTypePriceLot.Length - priceTypePriceLot.IndexOf(' ')).Trim());
                                }

                                break;
                            }

                            num++;
                        }
                    }
                    else
                    {
                        text = ".//table[@class=\"outertable\"]";
                        text += "/tr";
                        lotParamsColl = lotNode.SelectNodes(text);

                        if (lotParamsColl != null)
                        {
                            int numTr = 1;
                            foreach (HtmlAgilityPack.HtmlNode trNode in lotParamsColl)
                            {
                                if (trNode.Name != "tr") continue;

                                int numTdParam = 1;
                                switch (numTr)
                                {
                                    case (1):
                                        numTdParam = 1;
                                        foreach (HtmlAgilityPack.HtmlNode tdNode in trNode.ChildNodes)
                                        {
                                            if (tdNode.Name != "td") continue;
                                            if (numTdParam == 1)
                                            {
                                                _223lotName = Globals.CutLotName(tdNode.InnerText.Trim());
                                                break;
                                            }
                                            numTdParam++;
                                        }
                                        break;
                                    case (2):
                                        numTdParam = 1;
                                        foreach (HtmlAgilityPack.HtmlNode tdNode in trNode.ChildNodes)
                                        {
                                            if (tdNode.Name != "td") continue;
                                            if (numTdParam == 2)
                                            {
                                                string priceTypePriceLot = tdNode.InnerText.Trim();
                                                if (priceTypePriceLot.IndexOf(' ') > -1)
                                                {
                                                    string _223lotPriceStr = Globals.DecodeInternetSymbs(priceTypePriceLot.Substring(0, priceTypePriceLot.IndexOf(' ')).Trim());
                                                    if (_223lotPriceStr.IndexOf(',') > -1)
                                                    {
                                                        _223lotPrice = Convert.ToInt64(_223lotPriceStr.Substring(0, _223lotPriceStr.IndexOf(',')));
                                                    }
                                                    else
                                                    {
                                                        _223lotPrice = Convert.ToInt64(_223lotPriceStr);
                                                    }
                                                    //_223lotPrice = Convert.ToInt64(Globals.DecodeInternetSymbs(priceTypePriceLot.Substring(0, priceTypePriceLot.IndexOf(' ')).Trim()));
                                                    _223lotPriceTypeName = Globals.DecodeInternetSymbs(priceTypePriceLot.Substring(priceTypePriceLot.IndexOf(' '), priceTypePriceLot.Length - priceTypePriceLot.IndexOf(' ')).Trim());
                                                    break;
                                                }
                                            }
                                            numTdParam++;
                                        }

                                        break;
                                    default:
                                        break;
                                }

                                numTr++;
                            }
                        }
                        else
                        {
                            return ResultType_enum.NotSearch;
                        }
                    }

                    if (_223lotName != "")
                    {
                        _223lot.Name = _223lotName;
                        if (_223lot.Name.Length > 400)
                        {
                            _223lot.Name = _223lot.Name.Substring(0, 398) + "..";
                        }
                    }

                    if ((_223lotPrice != 0) && (_223lotPriceTypeName != ""))
                    {
                        _223lot.Price = _223lotPrice;
                        LotPriceType lotPriceType = mvm.wc.LotPriceTypes.FirstOrDefault(m => m.Name.ToLower().Trim() == _223lotPriceTypeName.ToLower());
                        if (lotPriceType == null)
                        {
                            lotPriceType = new LotPriceType();
                            lotPriceType.Name = _223lotPriceTypeName;
                            mvm.wc.LotPriceTypes.Add(lotPriceType);
                            mvm.wc.SaveChanges();
                        }
                        _223lot.LotPriceType = lotPriceType;
                    }
                    else
                    {
                        // Не указана цена, берем следующий лот
                        continue;
                    }

                    // Получаем список участников
                    text = ".//table";
                    text += "/tr[@class=\"expandable-row\"]";
                    text += "/td";
                    text += "/div[@class=\"clientDemandWrapper\"]";
                    text += "/table[@class=\"outertable clientDemandTbl\"]";
                    text += "/tr";

                    HtmlAgilityPack.HtmlNodeCollection partnerWithHeaderColl = lotNode.SelectNodes(text);

                    // Поиск победителя среди участников
                    int tdnum = 1;
                    isWinner = false;
                    foreach (HtmlAgilityPack.HtmlNode partnerNode in partnerWithHeaderColl)
                    {
                        if (partnerNode.Attributes.Count > 0) continue;

                        tdnum = 1;
                        string nameTmp = "";
                        foreach (HtmlAgilityPack.HtmlNode tdNode in partnerNode.ChildNodes)
                        {
                            if (tdNode.Name != "td") continue;
                            if (tdnum == 2)
                            {
                                nameTmp = Globals.DecodeInternetSymbs(tdNode.InnerText.Trim());
                                nameTmp = Globals.CleanSpaces(nameTmp.Replace('\n', ' ').Replace('\t', ' '));
                            }

                            if (tdnum == 4)
                            {
                                if (tdNode.InnerText.Trim().ToLower() == "победитель")
                                {
                                    _223winner.Name = nameTmp;
                                    winnersTemp.Add(_223winner);
                                    isWinner = true;
                                }
                                break;
                            }
                            tdnum++;
                        }
                        if (isWinner) break;
                    }
                    lotNum++;
                }

                // Если лоты уже с заполненным именем, то не ищем имена
                bool allHasName = true;
                foreach (Lot lot in lotsTemp)
                {
                    if (lot.Name == "")
                    {
                        allHasName = false;
                        break;
                    }
                }

                // Если нет победителей, то не заполняем имена лотов
                bool hasWinners = false;
                foreach (Winner winner in winnersTemp)
                {
                    if (winner.Name != "")
                    {
                        hasWinners = true;
                        break;
                    }
                }

                // Заполняем имена лотов
                /*if ((!allHasName) && (hasWinners))
                {
                    if (lotsTemp.Count > 0)
                    {
                        text = @"http://zakupki.gov.ru/223/purchase/public/purchase/protocol/ip/application/list.html?noticeInfoId=&protocolInfoId=" + protocolID + @"&mode=view";
                        //text = @"http://zakupki.gov.ru/223/purchase/public/purchase/protocol/rkz/application/list.html?noticeInfoId=&protocolInfoId=1698215&mode=view";
                        doc = internetRequestEngine.GetHtmlDoc(text);
                        if (doc.DocumentNode.InnerText.IndexOf("Запрашиваемая страница временно недоступна") > -1)
                        {
                            //text = @"http://zakupki.gov.ru/223/purchase/public/purchase/protocol/ip/application/list.html?noticeInfoId=&protocolInfoId=" + protocolID + @"&mode=view";
                            text = @"http://zakupki.gov.ru/223/purchase/public/purchase/protocol/rkz/application/list.html?noticeInfoId=&protocolInfoId=1698215&mode=view";
                            doc = internetRequestEngine.GetHtmlDoc(text);
                        }

                        resultTypeCheck = Globals.CheckDocResult(doc, out checkMessage);
                        if (resultTypeCheck != ResultType_enum.Done)
                        {
                            commissionDecisionMessage = checkMessage;
                            return resultTypeCheck;
                        }

                        // Поиск имен лотов
                        text = "//div[@class=\"cardWrapper\"]";
                        text += "/div[@class=\"wrapper\"]";
                        text += "/div[@class=\"mainbox\"]";
                        text += "/div[@class=\"contentTabBoxBlock\"]";
                        text += "/div[@class=\"noticeTabBox\"]";
                        text += "/div[@class=\"clientDemandWrapper\"]";
                        text += "/table";
                        text += "/tr[@class=\"mainExpand\"]";
                        text += "/td[@class=\"descriptTenderTd\"]";
                        text += "/dt";

                        HtmlAgilityPack.HtmlNodeCollection lotNamesColl = doc.DocumentNode.SelectNodes(text);
                        if (lotNamesColl == null)
                        {
                            // Поиск имен лотов
                            text = "//div[@class=\"cardWrapper\"]";
                            text += "/div[@class=\"wrapper\"]";
                            text += "/div[@class=\"mainbox\"]";
                            text += "/div[@class=\"contentTabBox\"]";
                            text += "/div[@class=\"contentTabBoxBlock\"]";
                            text += "/div[@class=\"noticeTabBox\"]";
                            text += "/div[@class=\"noticeTabBoxWrapper\"]";
                            text += "/div[@class=\"clientDemandWrapper\"]";
                            text += "/table";
                            text += "/tr";
                            text += "/td";
                            text += "/table";
                            text += "/tr[@class=\"mainExpand\"]";
                            text += "/td[@class=\"descriptTenderTd\"]";

                            lotNamesColl = doc.DocumentNode.SelectNodes(text);
                            if (lotNamesColl == null) return ResultType_enum.NotSearch;
                        }

                        // Перебираем имена лотов
                        int lotNameNum = 0;
                        foreach (HtmlAgilityPack.HtmlNode lotNameNode in lotNamesColl)
                        {
                            try
                            {
                                lotsTemp[lotNameNum].Name = Globals.DecodeInternetSymbs(lotNameNode.InnerText.Trim());
                            }
                            catch
                            {
                                continue;
                            }
                            lotNameNum++;
                        }

                        // Поиск цены контракта и даты
                        // Перебираем лоты
                        text = "//div[@class=\"cardWrapper\"]";
                        text += "/div[@class=\"wrapper\"]";
                        text += "/div[@class=\"mainbox\"]";
                        text += "/div[@class=\"contentTabBoxBlock\"]";
                        text += "/div[@class=\"noticeTabBox\"]";
                        text += "/div[@class=\"clientDemandWrapper\"]";
                        text += "/table";
                        text += "/tr[@class=\"expandRow\"]";

                        HtmlAgilityPack.HtmlNodeCollection lotsPriceDateColl = doc.DocumentNode.SelectNodes(text);

                        if ((lotsPriceDateColl != null) && (lotsPriceDateColl.Count > 0))
                        {
                            int lotPriceDateNum = 0;
                            foreach (HtmlAgilityPack.HtmlNode lotPriceDateNode in lotsPriceDateColl)
                            {
                                text = ".//td";
                                text += "/div";
                                text += "/table";
                                text += "/tr";

                                HtmlAgilityPack.HtmlNodeCollection customersColl = lotPriceDateNode.SelectNodes(text);
                                if (customersColl != null)
                                {
                                    // Перебираем участников и ищем победителя
                                    bool itsWinner = false;
                                    foreach (HtmlAgilityPack.HtmlNode customerNode in customersColl)
                                    {
                                        if (customerNode.Attributes.Count > 0) continue;

                                        HtmlAgilityPack.HtmlNodeCollection customerAttributesColl = customerNode.SelectNodes(".//td");
                                        int attrNum = 1;
                                        foreach (HtmlAgilityPack.HtmlNode customerAttributeNode in customerAttributesColl)
                                        {
                                            if (customerAttributeNode.Name != "td") continue;
                                            switch (attrNum)
                                            {
                                                case (2):
                                                    string nameTmp = Globals.DecodeInternetSymbs(customerAttributeNode.InnerText.Trim());
                                                    if (nameTmp.IndexOf("Просмотреть заявку") > -1)
                                                    {
                                                        nameTmp = nameTmp.Substring(0, nameTmp.IndexOf("Просмотреть заявку")).Trim();
                                                    }
                                                    if (nameTmp == lotsTemp[lotPriceDateNum].Winner.Name)
                                                    {
                                                        itsWinner = true;
                                                    }
                                                    break;
                                                case (3):
                                                    if (customerAttributeNode.InnerText.Trim() != "")
                                                    {
                                                        _223lotDocumentDate = customerAttributeNode.InnerText.Trim();
                                                        break;
                                                    }
                                                    break;

                                                case (4):
                                                    if (customerAttributeNode.InnerText.Trim() != "")
                                                    {
                                                        string priceTypePriceLot = Globals.DecodeInternetSymbs(customerAttributeNode.InnerText.Trim());
                                                        if (priceTypePriceLot.IndexOf(' ') > -1)
                                                        {
                                                            _223lotDocumentPrice = Convert.ToInt64(Globals.DecodeInternetSymbs(priceTypePriceLot.Substring(0, priceTypePriceLot.IndexOf(' ')).Trim()));
                                                        }
                                                    }
                                                    break;
                                            }

                                            attrNum++;
                                        }
                                        if (itsWinner)
                                        {
                                            lotsTemp[lotPriceDateNum].DocumentPrice = _223lotDocumentPrice;
                                            if (_223lotDocumentDate.IndexOf('(') > -1)
                                            {
                                                lotsTemp[lotPriceDateNum].DocumentDateTime = Convert.ToDateTime(_223lotDocumentDate.Substring(0, _223lotDocumentDate.IndexOf('(')).Trim());
                                            }
                                            else
                                            {
                                                lotsTemp[lotPriceDateNum].DocumentDateTime = Convert.ToDateTime(_223lotDocumentDate.Trim());
                                            }
                                            break;
                                        }
                                        else
                                        {
                                            _223lotDocumentPrice = 0;
                                            _223lotDocumentDate = "";
                                        }
                                    }
                                }

                                lotPriceDateNum++;
                            }
                        }

                        // Заполняем заказ
                        foreach (Lot lotTmp in lotsTemp)
                        {
                            if (lotTmp.Name != "")
                            {
                                mvm.wc.Winners.Add(lotTmp.Winner);
                                mvm.wc.SaveChanges();

                                mvm.wc.Lots.Add(lotTmp);
                                mvm.wc.SaveChanges();

                                lotSearched_delegate(lotTmp);
                            }
                        }
                    }
                }
                else
                {*/
                    if (hasWinners)
                    {
                        foreach (Winner winnerTmp in winnersTemp)
                        {
                            if ((winnerTmp.Name != "") && (winnerTmp.Lot.Name != ""))
                            {
                                mvm.wc.Lots.Add(winnerTmp.Lot);
                                mvm.wc.SaveChanges();

                                mvm.wc.Winners.Add(winnerTmp);
                                mvm.wc.SaveChanges();

                                lotSearched_delegate(winnerTmp);
                            }
                        }
                    }
                //}

                return ResultType_enum.Done;
            }
            catch (Exception ex)
            {
                isWinner = false;
                commissionDecisionMessage = ex.Message + '\n' + ex.StackTrace;
                return ResultType_enum.Error;
            }
        }