public static string MakeExcelOnlineSub(string xmlInput, DataTable dt) { string result = string.Empty; CExcelCSVOutput output = new CExcelCSVOutput(); try { //if (string.IsNullOrEmpty(xmlInput) || xmlInput.IndexOf(" FileName=\"") <= 0) //{ // result = output.CreateOutput("0", "1", "Error", "Input not have tag <FileName>", null); // return result; //} XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(xmlInput); if (xDoc.FirstChild != null && xDoc.FirstChild.Name == "InputValue") { XmlNode xNode = xDoc.FirstChild; //string fileName = xNode.Attributes["FileName"].Value; //string content64 = xNode.Attributes["FileStructContent"].Value; string fileName = String.Format("Template_InterfaceOrder_{0:ddMMyyyy_hhmmss}.xlsx", DateTime.Now); string samplePath = HttpRuntime.AppDomainAppPath + "_Template\\Excel"; byte[] bSampleFileContent = File.ReadAllBytes(samplePath + "\\Template_InterfaceOrder.xlsx"); string content64 = Convert.ToBase64String(bSampleFileContent); string contentJSon = "";//xNode.Attributes["FileJSonData"].Value; result = MakeInputFromJSonAndExcelFile(fileName, content64, contentJSon, dt); } else result = output.CreateOutput("0", "1", "Error", "Error.Invalid Input!!!", null); } catch (Exception ex) { result = output.CreateOutput("0", "1", "Error MakeExcelOnlineSub", ex.Message + ex.StackTrace, null); } return result; }
public static string ReadExcelOnline(string xmlInput) { string result = string.Empty; CExcelCSVOutput output = new CExcelCSVOutput(); try { if (string.IsNullOrEmpty(xmlInput) || xmlInput.IndexOf(" FileName=\"") <= 0) { result = output.CreateOutput("0", "1", "Error", "Input not have tag <FileName>", null); return(result); } XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(xmlInput); if (xDoc.FirstChild != null && xDoc.FirstChild.Name == "InputValue") { XmlNode xNode = xDoc.FirstChild; string fileName = xNode.Attributes["FileName"].Value; string content64 = xNode.Attributes["FileContent"].Value; string isReplaceSpecialString = "1"; if (xNode.Attributes["isReplaceSpecialString"] != null) { isReplaceSpecialString = xNode.Attributes["isReplaceSpecialString"].Value; } string tempPath = System.Configuration.ConfigurationManager.AppSettings["iMarkets.Service.Core.ExcelService.TempPath"]; if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath); } byte[] content = Convert.FromBase64String(content64); string extand = fileName.Substring(fileName.LastIndexOf('.')); fileName = fileName.Substring(0, fileName.LastIndexOf('.')); string fullFilePath = String.Format("{0}\\{1}{2:ddMMyyyy_hhmmssfff}{3}", tempPath, fileName, DateTime.Now, extand); FileStream fstream = File.Open(fullFilePath, FileMode.OpenOrCreate); fstream.Write(content, 0, content.Length); fstream.Flush(); fstream.Close(); //File.WriteAllBytes(fullFilePath, content); if (isReplaceSpecialString == "0") { result = BussinessWork(fullFilePath, false); } else { result = BussinessWork(fullFilePath); } } else { result = output.CreateOutput("0", "1", "Error", "Error.Invalid Input!!!", null); } } catch (Exception ex) { result = output.CreateOutput("0", "1", "ReadExcelOnlineError", ex.Message + ex.StackTrace, null); } return(result); }
public static string ReadExcelOnline(string xmlInput) { string result = string.Empty; CExcelCSVOutput output = new CExcelCSVOutput(); try { if (string.IsNullOrEmpty(xmlInput) || xmlInput.IndexOf(" FileName=\"") <= 0) { result = output.CreateOutput("0", "1", "Error", "Input not have tag <FileName>", null); return result; } XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(xmlInput); if (xDoc.FirstChild != null && xDoc.FirstChild.Name == "InputValue") { XmlNode xNode = xDoc.FirstChild; string fileName = xNode.Attributes["FileName"].Value; string content64 = xNode.Attributes["FileContent"].Value; string isReplaceSpecialString = "1"; if(xNode.Attributes["isReplaceSpecialString"] != null) isReplaceSpecialString = xNode.Attributes["isReplaceSpecialString"].Value; string tempPath = System.Configuration.ConfigurationManager.AppSettings["iMarkets.Service.Core.ExcelService.TempPath"]; if (!Directory.Exists(tempPath)) Directory.CreateDirectory(tempPath); byte[] content = Convert.FromBase64String(content64); string extand = fileName.Substring(fileName.LastIndexOf('.')); fileName = fileName.Substring(0, fileName.LastIndexOf('.')); string fullFilePath = String.Format("{0}\\{1}{2:ddMMyyyy_hhmmssfff}{3}", tempPath, fileName, DateTime.Now, extand); FileStream fstream = File.Open(fullFilePath, FileMode.OpenOrCreate); fstream.Write(content, 0, content.Length); fstream.Flush(); fstream.Close(); //File.WriteAllBytes(fullFilePath, content); if (isReplaceSpecialString == "0") result = BussinessWork(fullFilePath, false); else result = BussinessWork(fullFilePath); } else result = output.CreateOutput("0", "1", "Error", "Error.Invalid Input!!!", null); } catch (Exception ex) { result = output.CreateOutput("0", "1", "ReadExcelOnlineError", ex.Message + ex.StackTrace, null); } return result; }
private static string BussinessWork2Ex(string pathFile, DataSet contentExcel) { CExcelCSVOutput output = new CExcelCSVOutput(); string result = string.Empty; try { CMixExcel mixExcel = new CMixExcel(pathFile, true); result = output.CreateOutput2Ex(mixExcel, contentExcel); mixExcel.CloseStream(); //File.Delete(pathFile); } catch (Exception ex) { result = output.CreateOutput("0", "1", "Error BussinessWork2Ex", ex.Message + ex.StackTrace, null); } return(result); }
public static string MakeExcelOnline(string xmlInput) { string result = string.Empty; CExcelCSVOutput output = new CExcelCSVOutput(); try { if (string.IsNullOrEmpty(xmlInput) || xmlInput.IndexOf(" FileName=\"") <= 0) { result = output.CreateOutput("0", "1", "Error", "Input not have tag <FileName>", null); return(result); } XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(xmlInput); if (xDoc.FirstChild != null && xDoc.FirstChild.Name == "InputValue") { XmlNode xNode = xDoc.FirstChild; string fileName = xNode.Attributes["FileName"].Value; string content64 = xNode.Attributes["FileStructContent"].Value; string contentCSV = xNode.Attributes["FileCSVContent"].Value; try { contentCSV = System.Text.ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(contentCSV)); } catch { } string tempPath = System.Configuration.ConfigurationManager.AppSettings["iMarkets.Service.Core.ExcelService.TempPath"]; byte[] content = Convert.FromBase64String(content64); File.WriteAllBytes(tempPath + "\\" + fileName, content); DataSet ds = ConvertCVSToDataSet(contentCSV); result = BussinessWork2(tempPath + "\\" + fileName, ds); } else { result = output.CreateOutput("0", "1", "MakeExcelOnlineError", "Error.Invalid Input!!!", null); } } catch (Exception ex) { result = output.CreateOutput("0", "1", "MakeExcelOnlineError", ex.Message, null); } return(result); }
private static string BussinessWork(string pathFile, bool isReplaceSpecialString = true) { CExcelCSVOutput output = new CExcelCSVOutput(); string result = string.Empty; try { //FileInfo newFile = new FileInfo(pathFile); CMixExcel mixExcel = new CMixExcel(pathFile, false); result = output.CreateOutput("0", "0", "Success", "Success", mixExcel, isReplaceSpecialString); mixExcel.CloseStream(); File.Delete(pathFile); } catch (Exception ex) { result = output.CreateOutput("0", "1", " BussinessWork Error", ex.Message + ex.StackTrace, null); } return(result); }
public static string MakeExcelOnline(string xmlInput) { string result = string.Empty; CExcelCSVOutput output = new CExcelCSVOutput(); try { if (string.IsNullOrEmpty(xmlInput) || xmlInput.IndexOf(" FileName=\"") <= 0) { result = output.CreateOutput("0", "1", "Error", "Input not have tag <FileName>", null); return result; } XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(xmlInput); if (xDoc.FirstChild != null && xDoc.FirstChild.Name == "InputValue") { XmlNode xNode = xDoc.FirstChild; string fileName = xNode.Attributes["FileName"].Value; string content64 = xNode.Attributes["FileStructContent"].Value; string contentCSV = xNode.Attributes["FileCSVContent"].Value; try { contentCSV = System.Text.ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(contentCSV)); } catch { } string tempPath = System.Configuration.ConfigurationManager.AppSettings["iMarkets.Service.Core.ExcelService.TempPath"]; byte[] content = Convert.FromBase64String(content64); File.WriteAllBytes(tempPath + "\\" + fileName, content); DataSet ds = ConvertCVSToDataSet(contentCSV); result = BussinessWork2(tempPath + "\\" + fileName, ds); } else result = output.CreateOutput("0", "1", "MakeExcelOnlineError", "Error.Invalid Input!!!", null); } catch (Exception ex) { result = output.CreateOutput("0", "1", "MakeExcelOnlineError", ex.Message, null); } return result; }
public static string MakeExcelOnlineSub(string xmlInput, DataTable dt) { string result = string.Empty; CExcelCSVOutput output = new CExcelCSVOutput(); try { //if (string.IsNullOrEmpty(xmlInput) || xmlInput.IndexOf(" FileName=\"") <= 0) //{ // result = output.CreateOutput("0", "1", "Error", "Input not have tag <FileName>", null); // return result; //} XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(xmlInput); if (xDoc.FirstChild != null && xDoc.FirstChild.Name == "InputValue") { XmlNode xNode = xDoc.FirstChild; //string fileName = xNode.Attributes["FileName"].Value; //string content64 = xNode.Attributes["FileStructContent"].Value; string fileName = String.Format("Template_InterfaceOrder_{0:ddMMyyyy_hhmmss}.xlsx", DateTime.Now); string samplePath = HttpRuntime.AppDomainAppPath + "_Template\\Excel"; byte[] bSampleFileContent = File.ReadAllBytes(samplePath + "\\Template_InterfaceOrder.xlsx"); string content64 = Convert.ToBase64String(bSampleFileContent); string contentJSon = "";//xNode.Attributes["FileJSonData"].Value; result = MakeInputFromJSonAndExcelFile(fileName, content64, contentJSon, dt); } else { result = output.CreateOutput("0", "1", "Error", "Error.Invalid Input!!!", null); } } catch (Exception ex) { result = output.CreateOutput("0", "1", "Error MakeExcelOnlineSub", ex.Message + ex.StackTrace, null); } return(result); }
private static string BussinessWork2Ex(string pathFile, DataSet contentExcel) { CExcelCSVOutput output = new CExcelCSVOutput(); string result = string.Empty; try { CMixExcel mixExcel = new CMixExcel(pathFile, true); result = output.CreateOutput2Ex(mixExcel, contentExcel); mixExcel.CloseStream(); //File.Delete(pathFile); } catch (Exception ex) { result = output.CreateOutput("0", "1", "Error BussinessWork2Ex", ex.Message + ex.StackTrace, null); } return result; }
private static string BussinessWork(string pathFile,bool isReplaceSpecialString = true) { CExcelCSVOutput output = new CExcelCSVOutput(); string result = string.Empty; try { //FileInfo newFile = new FileInfo(pathFile); CMixExcel mixExcel = new CMixExcel(pathFile,false); result = output.CreateOutput("0", "0", "Success", "Success", mixExcel, isReplaceSpecialString); mixExcel.CloseStream(); File.Delete(pathFile); } catch (Exception ex) { result = output.CreateOutput("0", "1", " BussinessWork Error", ex.Message + ex.StackTrace, null); } return result; }