예제 #1
0
        public String Generate(Int32?IdCustomer, Int32?IdAccount, Int32?IdMainItem)
        {
            UserName     = UserName.Replace(" ", "").Replace(".", "");
            CustomerName = CustomerName.Replace(" ", "").Replace(".", "");

            ReportDocument rpt = new ReportDocument();

            rpt.Load(this.ReportPath);
            rpt.FileName = this.ReportPath;
            CustomerName = CustomerName.Replace(@"\", "")
                           .Replace(@"/", "")
                           .Replace(@":", "")
                           .Replace(@"*", "")
                           .Replace(@"?", "")
                           .Replace("\"", "")
                           .Replace(@"<", "")
                           .Replace(@">", "")
                           .Replace(@"&", "")
                           .Replace(@"=", "");
            this.FilePath = this.FilePath + @"\" + UserName + @"\" + CustomerName;
            this.Url      = this.Url + @"/" + UserName + @"/" + CustomerName;
            if (!Directory.Exists(this.FilePath))
            {
                Directory.CreateDirectory(this.FilePath);
            }
            foreach (FileInfo file in new DirectoryInfo(this.FilePath).GetFiles())
            {
                file.Delete();
            }

            String FileNameNoPath = DateTime.Now.ToString("ddMMyyhhmmss");
            String FileName       = this.FilePath + @"\" + FileNameNoPath;
            List <Commons.Reports.FormulaReport> data = new List <Commons.Reports.FormulaReport>();

            Api.Client apiClient = new Api.Client(System.Configuration.ConfigurationManager.AppSettings["URLAPI"]);

            IRestResponse WSR = Task.Run(() => apiClient.getJArray("Reporte/Formula", "IdCustomer=" + IdCustomer
                                                                   + "&IdAccount=" + IdAccount
                                                                   + "&IdMainItem=" + IdMainItem)).Result;

            if (WSR.StatusCode == HttpStatusCode.OK)
            {
                data = JArray.Parse(WSR.Content).ToObject <List <Commons.Reports.FormulaReport> >();
            }
            DataSet ds = new DataSet();

            ds.Tables.Add(Data.ListToDataTable <Commons.Reports.FormulaReport>(data));
            ds.Tables[0].TableName = "ado";

            rpt.SetDataSource(ds);
            rpt.ParameterFields["Fecha_Inicial"].CurrentValues.Add(Data.CrParameterConvert(DateTime.Now));
            rpt.ParameterFields["Fecha_Final"].CurrentValues.Add(Data.CrParameterConvert(DateTime.Now));
            rpt.ParameterFields["Usuario"].CurrentValues.Add(Data.CrParameterConvert(UserName));
            rpt.ExportToDisk(ExportFormatType.PortableDocFormat, FileName + ".pdf");
            //rpt.ExportToDisk(ExportFormatType.Excel, FileName + ".xls");

            ExportOptions              exOpt   = new ExportOptions();
            ExcelFormatOptions         xlsOpt  = new ExcelFormatOptions();
            DiskFileDestinationOptions diskOpt = new DiskFileDestinationOptions();

            exOpt = rpt.ExportOptions;
            xlsOpt.ExcelUseConstantColumnWidth = false;
            xlsOpt.ExcelTabHasColumnHeadings   = true;
            exOpt.ExportFormatType             = ExportFormatType.Excel;
            exOpt.FormatOptions             = xlsOpt;
            exOpt.ExportDestinationType     = ExportDestinationType.DiskFile;
            diskOpt.DiskFileName            = FileName + ".xls";
            exOpt.DestinationOptions        = diskOpt;
            rpt.ExportOptions.FormatOptions = xlsOpt;
            rpt.Export();

            rpt.Close();
            rpt.Dispose();

            return(this.Url + @"/" + FileNameNoPath);
        }
        public String Generate(Int32?IdCustomer, Int32?IdAccount, DateTime?StartDate, DateTime?EndDate, String CustomerAddress,
                               String CustomerPhone, String CustomerCode, String CustomerNit, String CustomerLegalRepresentative, String ResolutionRate, DateTime?ResolutionDate,
                               DateTime?ExpirationDate, Boolean?GetTransmited, String FileHeaderList, String FileDetailList, Boolean UseFreeze)
        {
            UserName     = UserName.Replace(" ", "").Replace(".", "");
            CustomerName = CustomerName.Replace(" ", "").Replace(".", "");

            ReportDocument rpt = new ReportDocument();

            rpt.Load(this.ReportPath);
            rpt.FileName = this.ReportPath;
            CustomerName = CustomerName.Replace(@"\", "")
                           .Replace(@"/", "")
                           .Replace(@":", "")
                           .Replace(@"*", "")
                           .Replace(@"?", "")
                           .Replace("\"", "")
                           .Replace(@"<", "")
                           .Replace(@">", "")
                           .Replace(@"&", "")
                           .Replace(@"=", "");
            this.FilePath = this.FilePath + @"\" + UserName + @"\" + CustomerName;
            this.Url      = this.Url + @"/" + UserName + @"/" + CustomerName;
            if (!Directory.Exists(this.FilePath))
            {
                Directory.CreateDirectory(this.FilePath);
            }
            foreach (FileInfo file in new DirectoryInfo(this.FilePath).GetFiles())
            {
                file.Delete();
            }

            String FileNameNoPath = DateTime.Now.ToString("ddMMyyhhmmss");
            String FileName       = this.FilePath + @"\" + FileNameNoPath;
            List <Commons.Reports.SwornDeclarationOne> data = new List <Commons.Reports.SwornDeclarationOne>();
            DateTime start = (DateTime)StartDate;
            DateTime end   = (DateTime)EndDate;

            Api.Client apiClient = new Api.Client(System.Configuration.ConfigurationManager.AppSettings["URLAPI"]);

            IRestResponse WSR = Task.Run(() => apiClient.getJArray("Reporte/DeclaracionJuradaUno", "IdCustomer=" + IdCustomer
                                                                   + "&IdAccount=" + IdAccount
                                                                   + "&StartDate=" + start.ToString("yyy-MM-dd")
                                                                   + "&EndDate=" + end.ToString("yyy-MM-dd")
                                                                   + "&GetTransmited=" + GetTransmited
                                                                   + "&FileHeaderList=" + FileHeaderList
                                                                   + "&FileDetailList=" + FileDetailList
                                                                   + "&UseFreeze=" + UseFreeze)).Result;

            if (WSR.StatusCode == HttpStatusCode.OK)
            {
                data = JArray.Parse(WSR.Content).ToObject <List <Commons.Reports.SwornDeclarationOne> >();
            }
            DataSet ds = new DataSet();

            ds.Tables.Add(Data.ListToDataTable <Commons.Reports.SwornDeclarationOne>(data));
            ds.Tables[0].TableName = "ado";

            rpt.SetDataSource(ds);
            rpt.ParameterFields["@CustName"].CurrentValues.Add(Data.CrParameterConvert(CustomerNameShow));
            rpt.ParameterFields["@CustAddress"].CurrentValues.Add(Data.CrParameterConvert(CustomerAddress));
            rpt.ParameterFields["@CustPhone"].CurrentValues.Add(Data.CrParameterConvert(CustomerPhone));
            rpt.ParameterFields["@CustCode"].CurrentValues.Add(Data.CrParameterConvert(CustomerCode));
            rpt.ParameterFields["@CustNit"].CurrentValues.Add(Data.CrParameterConvert(CustomerNit));
            rpt.ParameterFields["@CustLegalRep"].CurrentValues.Add(Data.CrParameterConvert(CustomerLegalRepresentative));
            rpt.ParameterFields["@ResolutionRate"].CurrentValues.Add(Data.CrParameterConvert(ResolutionRate));
            rpt.ParameterFields["@ResolutionDate"].CurrentValues.Add(Data.CrParameterConvert(ResolutionDate));
            rpt.ParameterFields["@ExpirationDate"].CurrentValues.Add(Data.CrParameterConvert(ExpirationDate));
            rpt.ParameterFields["@EndDate"].CurrentValues.Add(Data.CrParameterConvert(EndDate));
            rpt.ParameterFields["@IsFrozen"].CurrentValues.Add(Data.CrParameterConvert(UseFreeze));
            rpt.ExportToDisk(ExportFormatType.PortableDocFormat, FileName + ".pdf");
            //rpt.ExportToDisk(ExportFormatType.Excel, FileName + ".xls");

            ExportOptions              exOpt   = new ExportOptions();
            ExcelFormatOptions         xlsOpt  = new ExcelFormatOptions();
            DiskFileDestinationOptions diskOpt = new DiskFileDestinationOptions();

            exOpt = rpt.ExportOptions;
            xlsOpt.ExcelUseConstantColumnWidth = false;
            xlsOpt.ExcelTabHasColumnHeadings   = true;
            exOpt.ExportFormatType             = ExportFormatType.Excel;
            exOpt.FormatOptions             = xlsOpt;
            exOpt.ExportDestinationType     = ExportDestinationType.DiskFile;
            diskOpt.DiskFileName            = FileName + ".xls";
            exOpt.DestinationOptions        = diskOpt;
            rpt.ExportOptions.FormatOptions = xlsOpt;
            rpt.Export();

            rpt.Close();
            rpt.Dispose();

            return(this.Url + @"/" + FileNameNoPath);
        }