public ActionResult Edit(ArchivedDiaryW adiary)
        {
            if (ModelState.IsValid)
            {
                _rep.Edit(adiary);
                return(RedirectToAction("Index", "Diary"));
            }

            return(View(adiary));
        }
示例#2
0
        //Archived shit
        public void RegenerateProtocolReport(ArchivedDiaryW adiary)
        {
            var acreditedProducts    = adiary.ArchivedProducts.Where(p => p.ArchivedProductTests.Any(apt => apt.TestAcredetationLevel.Trim() == AcreditationLevels.Acredited));
            var notAcreditedProducts = adiary.ArchivedProducts.Where(p => p.ArchivedProductTests.Any(apt => apt.TestAcredetationLevel.Trim() == AcreditationLevels.NotAcredited));

            if (acreditedProducts.Count() > 0)
            {
                RewriteProtocolReport(adiary, "A", acreditedProducts);
            }

            if (notAcreditedProducts.Count() > 0)
            {
                RewriteProtocolReport(adiary, "B", notAcreditedProducts);
            }
        }
        public ActionResponse RegenerateArchivedProtocol(ArchivedDiaryW adiary)
        {
            var response = new ActionResponse();

            try
            {
                _filesRepo.RegenerateProtocolReport(adiary);

                response.IsSuccess  = true;
                response.SuccessMsg = "Успешно опресняване на архивирания протокол!";
            }
            catch (Exception exc)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(exc);
                response.Error = ErrorFactory.UnableToRefreshArchivedProtocol;
            }

            return(response);
        }
示例#4
0
        public void Edit(ArchivedDiaryW adiary)
        {
            var archivedDiary = Db.ArchivedDiaries.Single(ad => ad.Id == adiary.Id);

            archivedDiary.Number                     = adiary.Number;
            archivedDiary.LetterNumber               = adiary.LetterNumber;
            archivedDiary.LetterDate                 = adiary.LetterDate.ToUniversalTime();
            archivedDiary.AcceptanceDateAndTime      = adiary.AcceptanceDateAndTime;
            archivedDiary.Contractor                 = adiary.Contractor;
            archivedDiary.Client                     = adiary.Client;
            archivedDiary.ClientMobile               = adiary.ClientMobile;
            archivedDiary.Comment                    = adiary.Comment;
            archivedDiary.RequestDate                = adiary.RequestDate.ToUniversalTime();
            archivedDiary.RequestAcceptedBy          = adiary.RequestAcceptedBy;
            archivedDiary.ProtocolIssuedDate         = adiary.ProtocolIssuedDate;
            archivedDiary.ProtocolTester             = adiary.ProtocolTester;
            archivedDiary.ProtocolLabLeader          = adiary.ProtocolLabLeader;
            archivedDiary.Remark                     = adiary.Remark;
            archivedDiary.RequestTestingPeriod       = adiary.RequestTestingPeriod;
            archivedDiary.AcreditationRegisteredDate = adiary.AcreditationRegisteredDate;
            archivedDiary.AcreditationValidDate      = adiary.AcreditationValidToDate;

            Db.SaveChanges();
        }
示例#5
0
        private void RewriteProtocolReport(ArchivedDiaryW adiary, string category, IEnumerable <ArchivedProduct> products)
        {
            var model = new ReportModel();

            model.ReportParameters.Add("AcredetationLevel", category);
            model.ReportParameters.Add("ProtocolNumber", category + adiary.Number);
            model.ReportParameters.Add("ProtocolIssuedDate", adiary.ProtocolIssuedDate);

            var convertedProducts = new List <Product>();
            var productConverter  = new ProductConverter();

            foreach (var pr in products)
            {
                var product = productConverter.ConvertFromArchived(pr);
                convertedProducts.Add(product);
            }

            model.ReportParameters.Add("Products", convertedProducts);
            var methods = convertedProducts.SelectMany(p => p.ProductTests.Where(pt => pt.Test.AcredetationLevel.Level.Trim() == category)
                                                       .Select(pt => new MethodsModel()
            {
                TestName = pt.Test.Name, TestMethod = pt.TestMethod.Method
            })).ToList().Distinct();

            model.ReportParameters.Add("Methods", methods);
            var quantities = convertedProducts.OrderBy(p => p.Number).Select(p => p.Quantity);

            model.ReportParameters.Add("Quantities", quantities);

            var protocolResultsConverter = new ProtocolResultsConverter();
            var theProtocolResults       = adiary.ArchivedProtocolResults.Select(apr => protocolResultsConverter.ConvertFromArchived(apr));

            var protocolResults = theProtocolResults.Where(pr => pr.ProductTest.Test.AcredetationLevel.Level.Trim() == category)
                                  .OrderBy(x => x.ProductTest.Product.Number).ThenBy(x => x.ProductTest.Test.Name).ThenBy(x => x.ResultNumber);

            model.ReportParameters.Add("ProtocolResults", protocolResults);

            model.ReportParameters.Add("category", category);
            model.ReportParameters.Add("AcreditationRegisteredDate", adiary.AcreditationRegisteredDate);
            model.ReportParameters.Add("AcreditationValidToDate", adiary.AcreditationValidToDate);
            model.ReportParameters.Add("Contractor", adiary.Contractor);
            model.ReportParameters.Add("Client", adiary.Client);
            model.ReportParameters.Add("LetterNumber", adiary.LetterNumber);
            model.ReportParameters.Add("LetterDate", adiary.LetterDate);
            model.ReportParameters.Add("RequestDate", adiary.RequestDate.ToLocalTime());
            model.ReportParameters.Add("LabLeader", adiary.ProtocolLabLeader);
            model.ReportParameters.Add("Tester", adiary.ProtocolTester);

            var remarksConverter = new RemarksConverter();
            var remarks          = adiary.ArchivedProtocolRemarks.Where(r => r.AcredetationLevel.Trim() == category)
                                   .Select(r => new ProtocolsRemark()
            {
                Remark = remarksConverter.ConvertFromArchived(r),
                Number = r.Number
            });

            model.ReportParameters.Add("Remarks", remarks);

            if (category == "A")
            {
                string acredetationString = @"АКРЕДИТИРАНА СЪГЛАСНО БДС EN ISO/IEC 17025:2006
СЕРТИФИКАТ №55 ЛИ ОТ 08.04.2015 г./ ИА „БСА”
С ВАЛИДНОСТ НА АКРЕДИТАЦИЯТА ДО 31.03.2016 г.
";
                model.ReportParameters.Add("AcredetationString", acredetationString);
            }

            var report = new ProtocolReport(model);
            var data   = report.GenerateReport();

            CheckAndGenerateDirectories(adiary.Number);

            var fileProps = GetFileProperties(adiary.Number, FileNames.Protocol, category);

            if (File.Exists(fileProps.FullPath))
            {
                string newDestination = fileProps.FullPath.Substring(0, fileProps.FullPath.Length - 5) + "_" + DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss") + ".docx";
                File.Move(fileProps.FullPath, newDestination);
            }

            var file = File.Create(fileProps.FullPath);

            file.Write(data, 0, data.Length);
            file.Close();
        }