public string ExecuteAction(string ClientKey, string inputValue) { inputValue = CXML.HtmlDecode(inputValue); DataSet ds = new CCoreDao().ExecuteAction(ClientKey, inputValue); return(CDataParser.DataSetToCSV(ds)); }
public string GetContextData(string ClientKey, string inputValue) { inputValue = CXML.HtmlDecode(inputValue); CLogManager.WritePL("GetContextData", "End write response"); DataSet ds = new CCoreDao().GetContextData(ClientKey, inputValue); CLogManager.WritePL("GetContextData", "End write response"); return(CDataParser.DataSetToCSV(ds)); }
public CApplicationMessage SendReport(string ClientKey, string inputValue) { try { inputValue = CXML.HtmlDecode(inputValue); byte[] reportContent = GetReportPdf(inputValue); CApplicationMessage message = SendReportViaEmail(inputValue, reportContent, "", null); return(message); } catch (Exception ex) { return(new CApplicationMessage() { Result = 0, Name = ex.Message, Description = ex.Message, Code = "ERROR" }); } }
public CApplicationMessage SendGCN(string ClientKey, string inputValue) { try { inputValue = CXML.HtmlDecode(inputValue); string attachmentFileName = CXML.GetXmlNodeValue(inputValue, "RequestParams/@FileNumber"); string refno = CXML.GetXmlNodeValue(inputValue, "RequestParams/@RefNo"); string authenticateInput = CXML.Query(inputValue, "/InputValue"); //Lay noi dung file attach //byte[] attachmentContent = null; byte[] reportContent = null; CApplicationMessage sendResult = null; string KHEmail = CXML.GetXmlNodeValue(inputValue, "RequestParams/@Email"); string localInputValue = string.Format("<RequestParams Email=\"{0}\" Context=\"{1}\" />", KHEmail, "KHACHHANG_GCN"); if (!string.IsNullOrEmpty(refno)) { FileInfo attachInfo = new FileInfo(Path.Combine(ConfigurationManager.AppSettings["FWS.VnAccounting.AttachmentFolder"], refno + ".pdf")); if (attachInfo.Exists) { try { reportContent = File.ReadAllBytes(attachInfo.FullName); sendResult = SendReportViaEmail(localInputValue, reportContent, "", null); } catch (Exception ex) { return(new CApplicationMessage() { Result = 0, Name = ex.Message, Description = ex.Message, Code = "ERROR" }); } } else //Neu file khong ton tai thì tự xuất từ report { sendResult = ExportAndSendGCN_TBGT(ClientKey, inputValue); //return new CApplicationMessage() { Result = 0, Name = "Không tìm thấy file " + attachmentFileName, Description = "Không tìm thấy file " + attachmentFileName, Code = "ERROR" }; } } else { sendResult = ExportAndSendGCN_TBGT(ClientKey, inputValue); } /* * //Lay TBGT * List<CTransactions> transactions = GetAllAvailableTBGTPdf(ClientKey, inputValue); * * //Zip file * List<byte[]> zipList = ZipFiels(transactions); * * //attachmentFileName danh cho file scan yeu cau, nhung chua duoc duyet nen chuyen qua cho tbgt * if (zipList != null && zipList.Count > 0) * { * attachmentFileName = "TBGT.zip"; * attachmentContent = zipList[0]; * } * else * { * attachmentFileName = ""; * attachmentContent = null; * } * CApplicationMessage sendResult = SendReportViaEmail(localInputValue, reportContent, attachmentFileName, attachmentContent); * //neu gui thanh cong thi gui tiep cac tbgt khac (neu co nhieu hon 10 tbgt) * if (sendResult.IsSuccessfull) * { * if (zipList != null && zipList.Count >= 1) * { * for (int i = 1; i < zipList.Count; i++) * { * attachmentFileName = "TBGT.zip"; * attachmentContent = zipList[i]; * CApplicationMessage result = SendReportViaEmail(localInputValue, null, attachmentFileName, attachmentContent); * } * * } * } */ if (sendResult.IsSuccessfull) { //Neu send thanh cong thi luu thoi gian gui lai localInputValue = "<RequestParams RefType=\"21\" Context=\"TOOL\" Function=\"Transaction_Asset\" Action=\"UpdateGCNEmail\" ID=\"{0}\" SoDonNhan=\"{1}\" SendGCNEmail=\"{2}\" SendGCNDateTime=\"{3}\"/>"; string transID = CXML.GetXmlNodeValue(inputValue, "RequestParams/@ID"); string number = CXML.GetXmlNodeValue(inputValue, "RequestParams/@SoNhanDon"); localInputValue = authenticateInput + string.Format(localInputValue, transID, number, KHEmail, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string result = new FWS.VnAccounting.Service.Data.Core.Class.CCoreService().ExecuteAction(ClientKey, localInputValue); //List<CApplicationMessage> mess = CDataParser.FromCSV<CApplicationMessage>(result, 1); //if (mess != null && mess.Count > 0) return mess[0]; //return null; } return(sendResult); } catch (Exception ex) { return(new CApplicationMessage() { Result = 0, Name = ex.Message, Description = ex.Message, Code = "ERROR" }); } }
public CApplicationMessage UpdateAndSendReport(string ClientKey, string inputValue) { inputValue = CXML.HtmlDecode(inputValue); // B1. Update Ngay thang nhan xuong db // B2. Lay file Pdf report // B3. Gui Email // B4. Update trang thai gui email // /* * <InputValue UserID="1" /> * <RequestParams Action="" ReceiveResponseDateTime="" ObjectID="" ObjectEmail="" WarranterEmail="" /> * <RequestParams Context="" RegisTransRefNo="" ViewID="" ViewerID="" RefNo="" ObjectID=""/> * */ // Update ngay thang xuong db string localInputValue = inputValue; localInputValue = CXML.Query(inputValue, "InputValue,RequestParams[1]"); string actionResult = new Core.CoreService().ExecuteAction(ClientKey, localInputValue); string Action = CXML.GetXmlNodeValue(localInputValue, "RequestParams/@Action"); bool isSendCSGT = false; string booleanStr = CXML.GetXmlNodeValue(localInputValue, "RequestParams/@IsSendCSGT"); bool.TryParse(booleanStr, out isSendCSGT); booleanStr = CXML.GetXmlNodeValue(localInputValue, "RequestParams/@IsSendKH"); bool isSendKH = false; bool.TryParse(booleanStr, out isSendKH); // Lay file pdf string reportInputValue = CXML.Query(inputValue, "InputValue,RequestParams[2]"); byte[] reportContent = null;// GetReportPdf(reportInputValue); string reportContext = CXML.GetXmlNodeValue(reportInputValue, "RequestParams/@Context"); string regisTransRefNo = CXML.GetXmlNodeValue(reportInputValue, "RequestParams/@RegisTransRefNo"); string viewerID = CXML.GetXmlNodeValue(reportInputValue, "RequestParams/@ViewerID"); //string booleanStr= CXML.GetXmlNodeValue(reportInputValue, "RequestParams/@IsSendCSGT"); // gui email //localInputValue = CXML.Query(inputValue, "InputValue,RequestParams[1]"); string CAEmail = "", KHEmail = ""; CApplicationMessage sendResult = null; int countSuccessCA = 0, countFailCA = 0, countSuccessKH = 0, countFailKH = 0; if (Action.ToUpper() == "UPDATE_REQUEST") { // Truong hop in rieng thi gui moi don mot email // - Goi ham Init de tao ra TBGT: Function= Transaction_TBGT_CreateData // - Goi ham lay list TBGT '<InputValue UserID="14" /><RequestParams RefType="22" Level="0" RegisTransRefNo="1153900217"/>' // - Xuat // Goi ham tao Report reportInputValue = CXML.AddXmlAttribute(reportInputValue, "RequestParams", "Function", "Transaction_TBGT_CreateData"); actionResult = new FWS.VnAccounting.Service.Data.Core.Class.CCoreService().ExecuteAction(ClientKey, reportInputValue); CApplicationMessage mess = CDataParser.FromCSV <CApplicationMessage>(actionResult, 0)[0]; if (!mess.IsSuccessfull) { return(mess); } //Goi ham lay danh sach report can gui email int level = 0; if (reportContext.ToUpper() == "COMBINE") { level = 1; } string getReportlistInput = CXML.Query(inputValue, "InputValue"); getReportlistInput += string.Format("<RequestParams Function=\"GetTransaction_Asset\" RefType=\"22\" Level=\"{0}\" RegisTransRefNo=\"{1}\"/>", level, regisTransRefNo); actionResult = new FWS.VnAccounting.Service.Data.Core.Class.CCoreService().GetContextData(ClientKey, getReportlistInput); List <CTransactions> transactions = CDataParser.FromCSV <CTransactions>(actionResult, 1); if (transactions == null || transactions.Count == 0) { return(new CApplicationMessage() { Description = "Không có dữ liệu để gửi" }); } for (int i = 0; i < transactions.Count; i++) { //Xuat bao cao pdf reportInputValue = CXML.Query(inputValue, "InputValue"); reportInputValue += string.Format("<RequestParams ID=\"{0}\" Context=\"{4}\" RefNo=\"{1}\" RegisTransRefNo=\"{2}\" ViewerID=\"{3}\" IncludeSign=\"1\"/>", transactions[i].ID, transactions[i].RefNo, transactions[i].RegisTransRefNo, viewerID, reportContext); reportContent = GetReportPdf(reportInputValue); //duyet qua tung bao cao de xuat bao cao va chay du lieu CAEmail = CXML.GetXmlNodeValue(localInputValue, "RequestParams/@ObjectEmail"); if (!string.IsNullOrEmpty(CAEmail) && isSendCSGT) { string sendmainInput = string.Format("<RequestParams Email=\"{0}\" Context=\"{1}\" />", CAEmail, "CONGAN"); sendResult = SendReportViaEmail(sendmainInput, reportContent, "", null); // neu gui mail cho CA thanh cong thi moi gui toi KH if (sendResult.IsSuccessfull) { countSuccessCA++; } else { countFailCA++; } } //Bo chuc nang gui email den KH KHEmail = CXML.GetXmlNodeValue(localInputValue, "RequestParams/@WarranterEmail"); if (!string.IsNullOrEmpty(KHEmail) && isSendKH) { string sendmainInput = string.Format("<RequestParams Email=\"{0}\" Context=\"{1}\" />", KHEmail, "KHACHHANG"); sendResult = SendReportViaEmail(sendmainInput, reportContent, "", null); if (sendResult.IsSuccessfull) { countSuccessKH++; } else { countFailKH++; } } //Neu gui thanh cong va co gui den CSGT thi cap nhat lai email if (isSendCSGT && countSuccessCA > 0) { getReportlistInput = CXML.Query(inputValue, "InputValue"); getReportlistInput += string.Format("<RequestParams Function=\"Transaction_Asset\" Action=\"UPDATE_REQUEST\" RefType=\"22\" ID=\"{0}\" RefNo=\"{1}\" RegisTransRefNo=\"{2}\"/>", transactions[i].ID, transactions[i].RefNo, transactions[i].RegisTransRefNo); actionResult = new FWS.VnAccounting.Service.Data.Core.Class.CCoreService().ExecuteAction(ClientKey, getReportlistInput); // gui email thanh cong thi update lai thoi gian gui mail } } } else if (Action.ToUpper() == "UPDATE_RESPONSE") { reportInputValue = CXML.AddXmlAttribute(reportInputValue, "RequestParams", "IncludeSign", "1"); reportContent = GetReportPdf(reportInputValue); KHEmail = CXML.GetXmlNodeValue(localInputValue, "RequestParams/@WarranterEmail"); string ResponseStatus = CXML.GetXmlNodeValue(localInputValue, "RequestParams/@ResponseStatus"); if (ResponseStatus == "0") { localInputValue = string.Format("<RequestParams Email=\"{0}\" Context=\"{1}\" />", KHEmail, "PHANHOI_CAPNHAT"); sendResult = SendReportViaEmail(localInputValue, reportContent, "", null); if (sendResult.IsSuccessfull) { countSuccessKH++; } else { countFailKH++; } } else if (ResponseStatus == "1") { localInputValue = string.Format("<RequestParams Email=\"{0}\" Context=\"{1}\" />", KHEmail, "PHANHOI_TUCHOI"); sendResult = SendReportViaEmail(localInputValue, reportContent, "", null); if (sendResult.IsSuccessfull) { countSuccessKH++; } else { countFailKH++; } } } else if (Action == "UPDATE_SENDTHONGBAOPHI") { reportInputValue = CXML.AddXmlAttribute(reportInputValue, "RequestParams", "IncludeSign", "1"); reportContent = GetReportPdf(reportInputValue); KHEmail = CXML.GetXmlNodeValue(localInputValue, "RequestParams/@Email"); localInputValue = string.Format("<RequestParams Email=\"{0}\" Context=\"{1}\" />", KHEmail, "THONGBAO_PHI"); sendResult = SendReportViaEmail(localInputValue, reportContent, "", null); if (sendResult.IsSuccessfull) { countSuccessKH++; } else { countFailKH++; } } string message = ""; if (countSuccessCA > 0) { message += string.Format("Gửi thành công {0} email tới {1}\n", countSuccessCA, CAEmail); } if (countFailCA > 0) { message += string.Format("{0} email tới {1} bị lỗi\n", countFailCA, CAEmail); } if (countSuccessKH > 0) { message += string.Format("Gửi thành công {0} email tới {1}\n", countSuccessKH, KHEmail); } if (countFailKH > 0) { message += string.Format("{0} email tới {1} bị lỗi\n", countFailKH, KHEmail); } if (message.EndsWith("\n")) { message = message.Remove(message.Length - 1); } // update ket qua gui email xuong db //localInputValue = localInputValue = CXML.Query(inputValue, "InputValue"); //if (sendResult.IsSuccessfull) //{ //} //new Core.CoreService().ExecuteAction(ClientKey, localInputValue); //return string.Format("Code;Name;Description;Result\n{0};{1};{2};{3}","OK",message,message,1); return(new CApplicationMessage() { Result = 1, Name = message, Description = message, Code = "OK" }); //return CApplicationMessage.ToCSV<CApplicationMessage>( //return new CApplicationMessage() { Result = 1, Name = "OK", Description = "Success", Code = "OK" }; }