Exemplo n.º 1
0
        public string CreateContract(ModelViewContrat obj)
        {
            var NegocioOrden    = new BusinessOrder();
            var NegocioCliente  = new BusinessClient();
            var NegocioContrato = new BusinessContrat();
            var objAlerta       = new BusinessNotification();
            var Cliente         = NegocioCliente.GetByClientID(obj.NumbClient);

            SpreadsheetInfo.SetLicense("EQU2-3K5L-UZDC-SDYN");
            string        Origin = GlobalConfiguration.MabeAttachmentsLocal + "FormatoContrato.xlsx";
            List <string> result = obj.EMails.Split(new char[] { ';' }).ToList();

            ExcelFile      ef = ExcelFile.Load(Origin);
            ExcelWorksheet ws = ef.Worksheets[0];

            ws.Cells["N15"].Value = obj.Folio;
            //ws.Cells["L7"].Value = obj.ODS;
            ws.Cells["M20"].Value  = obj.Period;
            ws.Cells["M21"].Value  = obj.StartDate;
            ws.Cells["T21"].Value  = obj.EndDate;
            ws.Cells["M30"].Value  = obj.NumbClient;
            ws.Cells["M31"].Value  = Cliente.FirstName + " " + Cliente.LastName.ToUpper();
            ws.Cells["M32"].Value  = Cliente.StreetAddress;
            ws.Cells["M33"].Value  = Cliente.BoroughAddress;
            ws.Cells["M34"].Value  = Cliente.MunicipalityAddress;
            ws.Cells["M35"].Value  = Cliente.PostalCodeAddress;
            ws.Cells["M36"].Value  = obj.Town;
            ws.Cells["M37"].Value  = Cliente.PhoneNumber1;
            ws.Cells["M38"].Value  = obj.Totals;
            ws.Cells["M48"].Value  = obj.Model;
            ws.Cells["M49"].Value  = obj.Description;
            ws.Cells["M50"].Value  = obj.Serie;
            ws.Cells["R145"].Value = obj.Town;
            ws.Cells["V145"].Value = DateTime.Today.ToString("yyyyMMdd");


            string file    = "ContratoPoliza" + obj.Folio + ".pdf";
            string quotion = "Polizas_" + DateTime.Today.ToString("yyyyMMdd");
            string Destiny = GlobalConfiguration.MabeAttachmentsLocal + quotion + "/" + file;

            string Cotizaciones = new DirectoryInfo(GlobalConfiguration.MabeAttachmentsLocal).ToString() + quotion;

            if (!(Directory.Exists(Cotizaciones)))
            {
                Directory.CreateDirectory(Cotizaciones);
            }
            ef.Save(Destiny);
            string URL      = GlobalConfiguration.urlRequest + "Content/Attachments/" + quotion + "/" + file;
            var    orden    = NegocioOrden.GetByOrderID(obj.FK_OrderID);
            var    Contrato = NegocioContrato.GetByOrderFolio(orden.PK_OrderID, obj.Folio);

            if (obj.EMails != "")
            {
                if (Contrato == null)
                {
                    Contrato = NegocioContrato.Insert(orden.PK_OrderID, obj.Folio, URL);
                }
                else
                {
                    Contrato.Fk_OrderID = orden.PK_OrderID;
                    Contrato.Folio      = obj.Folio;
                    Contrato.Ruta       = URL;
                    NegocioContrato.Update(Contrato);
                }
                string sb = File.ReadAllText(GlobalConfiguration.LocateBodyMail + "MailContratoPoliza.txt");

                sb = sb.Replace("#%Nombre%#", Cliente.FirstName + " " + Cliente.LastName);
                sb = sb.Replace("#%Folio%#", obj.Folio);
                sb = sb.Replace("#%Modelo%#", obj.Model);
                sb = sb.Replace("#%Descripcion%#", obj.Description.ToUpper());
                sb = sb.Replace("#%Serie%#", obj.Serie);
                sb = sb.Replace("#%Compra%#", DateTime.Today.ToString("dd/MM/yyyy"));

                objAlerta.SendMailExchange(GlobalConfiguration.exchangeUserCotiza, GlobalConfiguration.exchangePwdCotiza, result, "Contrato Póliza", sb.ToString(), Destiny);
            }
            else
            {
                string Tipo     = "Poliza";
                var    EnvioSMS = SendNotification(obj.PhoneNumber, Tipo, URL);

                return(EnvioSMS);
            }

            return(URL);
        }
Exemplo n.º 2
0
 public static string CreateContrat(ModelViewContrat obj)
 {
     return(new BusinessPolicy().CreateContract(obj));
 }