Пример #1
0
        public override EventCommandResult ExecuteCommand()
        {
            var result = new EventCommandResult();



            var dc = new DocumentGenerationController();
            //create a document with all parsed variables
            var document = dc.CreateDocument(this.customer, this.documentType, this.booking, this.bes);

            this.Event.Documents.Add(new Document
            {
                DocumentBLOB = document
            });


            if (booking != null)
            {
                this.Event.Documents.FirstOrDefault().DocumentName = "C" + customer.CustomerID + "B" + booking.BookingID +
                                                                     DateTime.Now.ToLongDateString() +
                                                                     documentType.ToString();
            }
            if (bes != null)
            {
                this.Event.Documents.FirstOrDefault().DocumentName = "C" + customer.CustomerID + "BE" + bes.BookingExtraSelectionID +
                                                                     DateTime.Now.ToLongDateString() +
                                                                     documentType.ToString();
            }

            //get that doc just created and add it to the event

            // this.Event.Documents.Add(document);


            if (!document.Equals(null) && !document.Equals(""))
            {
                result.ResultCode          = 200;
                result.CommandExecutedInfo = "DocumentOutCommand";
                result.ResultMessage       = "OK";
            }
            else
            {
                result.ResultCode          = 800;
                result.CommandExecutedInfo = "DocumentOutCommand";
                result.ResultMessage       = "Fail";
            }



            return(result);
        }
Пример #2
0
        public override EventCommandResult ExecuteCommand()
        {
            var result = new EventCommandResult();

            var dc = new DocumentGenerationController();

            IEnumerable <byte[]> theDocs = dc.GetAllFilesInADirectory(BundleDir);

            //attempt to pull all docs
            try
            {
                foreach (var doc in theDocs)
                {
                    var tempPdf = dc.ConvertWordBytesToPDFBytes(doc);



                    this.Event.Documents.Add(new Document
                    {
                        DocumentBLOB = tempPdf
                    });
                }
            }
            catch (Exception ex)
            {
                //generate email for error/write an error - provide a default document
                throw ex;
            }


            int i = 1;

            foreach (var doc in theDocs)
            {
                if (booking != null)
                {
                    this.Event.Documents.ElementAt(i - 1).DocumentName = "C" + customer.CustomerID + "B" + booking.BookingID +
                                                                         DateTime.Now.ToLongDateString() +
                                                                         documentType.ToString() + i.ToString();
                }
                if (bes != null)
                {
                    this.Event.Documents.ElementAt(i - 1).DocumentName = "C" + customer.CustomerID + "BE" + bes.BookingExtraSelectionID +
                                                                         DateTime.Now.ToLongDateString() +
                                                                         documentType.ToString() + i.ToString();
                }
                i++;
            }



            if (!this.Event.Documents.Equals(null) && this.Event.Documents.Any())
            {
                result.ResultCode          = 200;
                result.CommandExecutedInfo = "DocumentBundleCommand";
                result.ResultMessage       = "OK";
            }
            else
            {
                result.ResultCode          = 800;
                result.CommandExecutedInfo = "DocumentBundleCommand";
                result.ResultMessage       = "Fail";
            }



            return(result);
        }