GenerateTemplate() public method

public GenerateTemplate ( int id, int templateType, string templateName ) : string
id int
templateType int
templateName string
return string
Esempio n. 1
0
        public void ShowTemplate(string fileName, int giftCertificateId)
        {
            // TODO: Make sure to use DI to get the template generator instance
               try
               {
                var template = new TemplateHelper(_unitofwork);
                string filePath = template.GenerateTemplate(giftCertificateId, 1, fileName); //here you have to send the name of the tempalte and the id of the giftcertificate

                Response.Clear();
                Response.ContentType = "application/text";
                Response.AddHeader("Content-Disposition", @"filename= " + fileName + ".docx");
                Response.TransmitFile(filePath);
                Response.End();
               }catch
               {

               }
        }
        public void ShowTemplate(string fileName, int giftCertificateId)
        {
            // TODO: Make sure to use DI to get the template generator instance
               try
               {
                var template = new TemplateHelper(_unitofwork,_log);
                string filePath = template.GenerateTemplate(giftCertificateId, 1, fileName); //here you have to send the name of the tempalte and the id of the giftcertificate

                Response.Clear();
                Response.ContentType = "application/text";
                Response.AddHeader("Content-Disposition", @"filename= " + fileName + ".docx");
                Response.TransmitFile(filePath);
                Response.End();
               }catch(Exception ex)
               {

               _log.Error(ex.Message.ToString(CultureInfo.InvariantCulture), ex.GetBaseException());
               //System.IO.File.AppendAllText(@"c:\temp\errors.txt", " ShowTemplate : " + ex.Message.ToString(CultureInfo.InvariantCulture));

               }
        }
Esempio n. 3
0
        //public ActionResult ShowLetterTemplates([DataSourceRequest] DataSourceRequest request)
        //{
        //    //return Json(_letterTemplateService.GetAllLetterTemplates().ToDataSourceResult(request));
        //}
        public void GenerateAgreementTemplate(int transporterID)
        {
            // TODO: Make sure to use DI to get the template generator instance

            var template = new TemplateHelper(_unitofwork);
            var filePath = template.GenerateTemplate(transporterID, 7, "FrameworkPurchaseContract"); //here you have to send the name of the tempalte and the id of the TransporterID

            var bidID = new int();
            var firstOrDefault = _bidWinnerService.Get(t => t.TransporterID == transporterID && t.Status == 1).FirstOrDefault();
            if (firstOrDefault != null)
            {
                bidID = firstOrDefault.BidID;
            }
            var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            var fileLen = Convert.ToInt32(fs.Length);
            var data = new byte[fileLen];
            fs.Read(data, 0, fileLen);
            fs.Close();

            var allPreviousDocs =
                _transporterAgreementVersionService.Get(t => t.TransporterID == transporterID);
            foreach (var agreementVersion in allPreviousDocs)
            {
                agreementVersion.Current = false;
                _transporterAgreementVersionService.EditTransporterAgreementVersion(agreementVersion);
            }

            var transporterAgreementVersion = new TransporterAgreementVersion
                {BidID = bidID, TransporterID = transporterID, AgreementDocxFile = data, IssueDate = DateTime.Now, Current = true};
            _transporterAgreementVersionService.AddTransporterAgreementVersion(transporterAgreementVersion);

            Response.Clear();
            Response.ContentType = "application/text";
            Response.AddHeader("Content-Disposition", @"filename= FrameworkPurchaseContract.docx");
            Response.TransmitFile(filePath);
            Response.End();
        }