Пример #1
0
        public static void ImportPrometric()
        {
            PrometricSpider.DownloadAllExams();
            var files     = GetFiles(PrometricSpider.ExamFolder);
            var parser    = new PageParser();
            var fileCount = files.Count();
            var i         = 0;

            foreach (var file in files)
            {
                WriteStatus("Обработка вендоров", Providers.PrometricExamType, i++, fileCount);


                var exams = parser.ParseExams(File.ReadAllText(file));

                if (exams.IsEmpty())
                {
                    continue;
                }
                var match    = Regex.Match(file, @"client(.*?)program");
                var clientID = int.Parse(match.Groups[1].Value);
                if (!ProviderConst.PrometricVendorIDList.ContainsKey(clientID))
                {
                    continue;
                }
                var vendorID   = ProviderConst.PrometricVendorIDList[clientID];
                var examType   = Providers.PrometricExamType;
                var providerId = Providers.Prometric;

                var providerExams = exams.Where(pe =>
                                                pe.Languages.Intersect(ProviderConst.GetPrometricLanguages()).Any());
                ImportExams(providerExams, vendorID, examType, providerId);
            }
        }
Пример #2
0
        public static void ImportExams(IEnumerable <ProviderExam> providerExams,
                                       int vendorID, string examType, int providerId)
        {
            var context = new SpecialistDataContext(PioneerConnectionString);

            foreach (var providerExam in providerExams)
            {
                var exam = context.Exams
                           .FirstOrDefault(e => e.Exam_TC == providerExam.Number);
                if (exam != null)
                {
                    exam.LastChangeDate = DateTime.Now;
                }
                else
                {
                    exam = new Exam {
                        Exam_TC        = providerExam.Number,
                        ExamName       = providerExam.Name,
                        ExamType       = examType,
                        Vendor_ID      = vendorID,
                        LastChangeDate = DateTime.Now
                    };
                    context.Exams.InsertOnSubmit(exam);
                }

                if (!exam.ProviderPrice.HasValue || examType == exam.ExamType)

                /*	if (exam.ExamProviders.All(e => e.Provider_ID != providerId)) {
                 *              exam.ExamProviders.Add(
                 *                      new ExamProvider {
                 *                              Provider_ID = providerId,
                 *                              LastChanger_TC = Employees.Specweb,
                 *                              InputDate = DateTime.Now,
                 *                              Employee_TC = Employees.Specweb,
                 *                              LastChangeDate = DateTime.Now
                 *                      });
                 *      }*/
                /*|| (vendorID == ProviderConst.OracleId && examType == Providers.VueExamType)*/ {
                    exam.ProviderPrice = providerExam.Price;
                    exam.Available     = true;
                    exam.Languages     = providerExam.Languages.Where(l =>
                                                                      ProviderConst.GetPrometricLanguages().Contains(l))
                                         .JoinWith(",");
                }
            }
            context.SubmitChanges();
        }