コード例 #1
0
        public RequestW(Request request)
        {
            this.Id = request.Id;
            this.DiaryId = request.DiaryId;
            this.Date = request.Date;
            this.AcceptedBy = request.AcceptedBy;
            this.IsAccepted = request.IsAccepted;
            this.TestingPeriod = request.TestingPeriod;

            this.Diary = request.Diary;
            this.User = request.User;
            this.Protocols = request.Protocols;
        }
コード例 #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 void GeneratePorotocolReport(Protocol protocol, Request request = null)
 {
     var filesRep = new FilesRepository();
     filesRep.GenerateProtocolReport(protocol, request);
 }
コード例 #4
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();
        }
コード例 #5
0
        public Request ToBase()
        {
            Request request = new Request();

            request.Id = this.Id;
            request.DiaryId = this.DiaryId;
            request.Date = this.Date;
            request.AcceptedBy = this.AcceptedBy;
            request.IsAccepted = this.IsAccepted;
            request.TestingPeriod = this.TestingPeriod;

            request.Diary = this.Diary;
            request.User = this.User;
            request.Protocols = this.Protocols;

            return request;
        }
コード例 #6
0
        public string GenerateRequest(Guid diaryId, int testingPeriod)
        {
            if(db.Diaries.Any(x => x.Id == diaryId))
            {
                Request request = new Request();
                request.Id = Guid.NewGuid();
                var date = DateTime.Now.ToUniversalTime();
                request.Date = date;
                request.DiaryId = diaryId;
                request.TestingPeriod = testingPeriod;

                try
                {
                    db.Requests.Add(request);
                    var filesRepository = new FilesRepository();
                    string charGenerated = filesRepository.GenerateRequestListReport(diaryId, date, testingPeriod);
                    db.SaveChanges();

                    return charGenerated;
                }
                catch(Exception ex)
                {
                    Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                }
            }

            return string.Empty;
        }