Esempio n. 1
0
 public ExcelHelperForDLRReports(string username, string downloadpath, string downloadurl)
 {
     zip       = new ZipFile();
     i         = 0;
     dpd       = new DownloadPathDetails(downloadpath, downloadurl);
     _username = username;
     _filename = username;
 }
Esempio n. 2
0
 public ConvertToCSV(string savepath, string username, string downloadpathurl)
 {
     _filename        = username;
     _filenamepostfix = 1;
     _username        = username;
     _savepath        = savepath;
     zip      = new ZipFile();
     dpd      = new DownloadPathDetails(_savepath, downloadpathurl);
     _zippath = _savepath + username + ".zip";
 }
Esempio n. 3
0
        public string[] ToExcel(DataSet dsInput, string filename, string downloadpath, string downloadurl)
        {
            try
            {
                ____logconfig.Log_Write(____logconfig.LogLevel.INFO, 188, "ExcelHelperForDLR:ToExcel()::Function starts here.");
                dpd = new DownloadPathDetails(downloadpath, downloadurl);
                //sample path: "D:\\Websites\\http\\dbsmsapiorg\\downloads.vivaconnect.in\\download\\DLR\\"
                //sample url : "http://downloads.vivaconnect.in/download/DLR/"
                System.IO.Directory.CreateDirectory(@dpd.Path);
                if (File.Exists(dpd.Path + filename))
                {
                    File.Delete(dpd.Path + filename);
                }

                GetExcelXml(dsInput, filename);
                string fullpath = dpd.Path + filename;

                string zipPath = fullpath.Substring(0, fullpath.Length - 4);
                using (ZipFile zip = new ZipFile())
                {
                    ZipEntry zip_entry = zip.AddFile(zipPath + ".xls");
                    zip_entry.FileName = filename;
                    zip.Save(zipPath + ".zip");
                }
                if (File.Exists(dpd.Path + filename))
                {
                    File.Delete(dpd.Path + filename);
                }

                FileInfo f    = new FileInfo(zipPath + ".zip");
                string[] file = new string[3];
                file[0] = f.Name;
                file[1] = dpd.Url + f.Name;
                if (f.Length > (1024 * 1024))
                {
                    float fl = ((float)(f.Length) / (float)(1024 * 1024));
                    file[2] = Math.Round(fl, MidpointRounding.ToEven).ToString() + "MB";
                }
                else
                {
                    float fl = ((float)(f.Length) / (float)(1024));
                    file[2] = Math.Round(fl, MidpointRounding.ToEven).ToString() + "KB";
                }
                return(file);
            }
            catch (Exception exc)
            {
                //new Logs("exportexcel.txt").asyncWrite(exc.Message.ToString());
                ____logconfig.Error_Write(____logconfig.LogLevel.EXC, 229, exc.Message.ToString(), "ExcelHelperForDLR");
                return(null);
            }
        }