コード例 #1
0
        public ProtocolW(Protocol protocol)
        {
            this.Id = protocol.Id;
            this.RequestId = protocol.Id;
            this.IssuedDate = protocol.IssuedDate.ToLocalTime();
            this.TesterMKB = protocol.TesterMKB;
            this.TesterFZH = protocol.TesterFZH;
            this.LabLeader = protocol.LabLeader;

            this.ProtocolResults = protocol.ProtocolResults;
            this.Request = protocol.Request;
            this.ProtocolsRemarksA = protocol.ProtocolsRemarks.Where(pr => pr.AcredetationLevel.Level.Trim() == AcreditationLevels.Acredited).ToList();
            this.ProtocolsRemarksB = protocol.ProtocolsRemarks.Where(pr => pr.AcredetationLevel.Level.Trim() == AcreditationLevels.NotAcredited).ToList();
        }
コード例 #2
0
        public void GenerateProtocolReport(Protocol protocol, Request request)
        {
            var protocolRequest = request ?? protocol.Request;
            var diaryNumber = protocolRequest.Diary.Number;
            //We need to identify if there will be more than 1 protocol (one for A and one for B)
            var acreditedProducts = protocolRequest.Diary.Products.Where(p => p.ProductTests.Any(pt => pt.Test.AcredetationLevel.Level.Trim() == AcreditationLevels.Acredited));

            var notAcreditedProducts = protocolRequest.Diary.Products.Where(p => p.ProductTests.Any(pt => pt.Test.AcredetationLevel.Level.Trim() == AcreditationLevels.NotAcredited));

            if (acreditedProducts.Count() > 0)
            {
                WriteProtocolReport(protocol, diaryNumber, "A", acreditedProducts, protocolRequest);
            }

            if (notAcreditedProducts.Count() > 0)
            {
                WriteProtocolReport(protocol, diaryNumber, "B", notAcreditedProducts, protocolRequest);
            }
        }
コード例 #3
0
        public Protocol ToBase()
        {
            var protocol = new Protocol();

            protocol.Id = this.Id;
            protocol.RequestId = this.RequestId;
            protocol.IssuedDate = this.IssuedDate;
            protocol.TesterMKB = this.TesterMKB;
            protocol.TesterFZH = this.TesterFZH;
            protocol.LabLeader = this.LabLeader;

            protocol.ProtocolResults = this.ProtocolResults;
            protocol.Request = this.Request;
            protocol.ProtocolsRemarks = this.ProtocolsRemarksA.Union(this.ProtocolsRemarksB).ToList();

            return protocol;
        }
コード例 #4
0
 public void GeneratePorotocolReport(Protocol protocol, Request request = null)
 {
     var filesRep = new FilesRepository();
     filesRep.GenerateProtocolReport(protocol, request);
 }
コード例 #5
0
        private void WriteProtocolReport(Protocol protocol, int diaryNumber, string category, IEnumerable<Product> products, Request request)
        {
            var model = new ReportModel();

            model.ReportParameters.Add("AcredetationLevel", category);

            model.ReportParameters.Add("ProtocolNumber", category + diaryNumber);
            model.ReportParameters.Add("ProtocolIssuedDate", protocol.IssuedDate);

            model.ReportParameters.Add("Products", products);
            //var methods = products.SelectMany(p => p.ProductTests.Where(pt => pt.Test.AcredetationLevel.Level.Trim() == category).Select(pt => pt.Test.TestMethods)).Distinct();
            var methods = products.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 = products.OrderBy(p => p.Number).Select(p => p.Quantity);
            model.ReportParameters.Add("Quantities", quantities);

            var protocolResults = protocol.ProtocolResults.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("Contractor", request.Diary.Contractor);
            model.ReportParameters.Add("Client", request.Diary.Client.Name);
            model.ReportParameters.Add("LetterNumber", request.Diary.LetterNumber);
            model.ReportParameters.Add("LetterDate", request.Diary.LetterDate);
            model.ReportParameters.Add("RequestDate", request.Date.ToLocalTime());
            model.ReportParameters.Add("LabLeader", protocol.LabLeader);
            model.ReportParameters.Add("TesterMKB", protocol.TesterMKB);
            model.ReportParameters.Add("TesterFZH", protocol.TesterFZH);

            var remarks = protocol.ProtocolsRemarks.Where(r => r.AcredetationLevel.Level.Trim() == category);
            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(diaryNumber);

            var fileProps = GetFileProperties(diaryNumber, 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();
        }