public string Update(string InputValue) { string strInputValue = CreatePara(InputValue); CApplicationMessage message = service.UpdateItem(strInputValue); return(CJson.SerializeObject(message)); }
public string UpdateRoleByGroupID(string groupID, string listRole) { string InputValue = CXmlPara.CreatePara(new CPara[] { new CPara("GroupID", groupID) }, ""); InputValue += listRole; CApplicationMessage message = service.UpdateUserGroupInterfaceFunction(InputValue); return(message.IsSuccessfull + "|" + message.Description); }
private CApplicationMessage SendReportViaEmail(string inputValue, byte[] pdfFile, string otherAttachName, byte[] otherAttachContent) { // gui mail cho KH, CA // lay thong tin email tu input // lay thong tin noi dung mail // lay thong tin noi dung // lay file pdf export // gui mail voi file pdf attach string email = ""; string subject = ""; string body = ""; string attacthFileName = ""; byte[] attacthFileContent = null; email = CXML.GetXmlNodeValue(inputValue, "RequestParams/@Email"); CApplicationMessage message = new CApplicationMessage(); try { string fileContent = GetEmailTemplate(inputValue); GetEmailContentFromTemplate(fileContent, out subject, out body); attacthFileName = "ThongBao.pdf"; attacthFileContent = pdfFile;// GetReportPdf(inputValue); if (attacthFileContent == null && otherAttachContent != null) { attacthFileName = otherAttachName; attacthFileContent = otherAttachContent; otherAttachName = ""; otherAttachContent = null; } string sendResult = CServiceReference.Callcenter.SendMail(email, "", "", subject, body, attacthFileName, attacthFileContent, otherAttachName, otherAttachContent, "", null); if (sendResult.StartsWith("00")) { message.Result = 1; message.Description = sendResult; } else { message.Description = sendResult; } return(message); } catch (Exception ex) { message.Description = ex.Message; message.Result = null; return(message); } }
public string Update(string InputValue) { InventoryService service = new InventoryService(); CApplicationMessage message = service.UpdateInventoryUnit(InputValue); StringBuilder ret = new StringBuilder(); ret.Append("{"); ret.AppendFormat("ID:'{0}',\n", message.ID); ret.AppendFormat("Code:'{0}',\n", message.Code); ret.AppendFormat("Name:'{0}'\n", message.Name); ret.Append("}"); return(ret.ToString()); }
public string UpdateItem(int userID, string session, string funcPara) { //string pInput = string.Format("<InputValue UserID=\"{0}\" Session=\"{1}\" {2}/>", userID, session, funcPara); string InputValue = CXmlPara.CreatePara(funcPara); CApplicationMessage message = service.UpdateCustomerGroup(InputValue); StringBuilder ret = new StringBuilder(); ret.Append("{"); ret.AppendFormat("Code:'{0}',\n", message.Code); ret.AppendFormat("Name:'{0}'\n", message.Name); ret.Append("}"); return(ret.ToString()); }
public string Update(string InputValue) { string strInputValue = CreatePara(InputValue); StringBuilder ret = new StringBuilder(); CApplicationMessage message = service.UpdateItem(strInputValue); if (message != null) { ret.Append("{"); ret.AppendFormat("ID:'{0}',\n", message.ID); ret.AppendFormat("Code:'{0}',\n", message.Code); ret.AppendFormat("Name:'{0}'\n", message.Name); ret.Append("}"); } return(ret.ToString()); }
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" }); } }
private CApplicationMessage ExportAndSendGCN_TBGT(string ClientKey, string inputValue) { byte[] attachmentContent = null; string attachmentFileName = ""; byte[] reportContent = GetReportPdf(inputValue); //Lay TBGT List <CTransactions> transactions = GetAllAvailableTBGTPdf(ClientKey, inputValue); //Zip file List <byte[]> zipList = ZipFiels(transactions); string KHEmail = CXML.GetXmlNodeValue(inputValue, "RequestParams/@Email"); string localInputValue = string.Format("<RequestParams Email=\"{0}\" Context=\"{1}\" />", KHEmail, "KHACHHANG_GCN"); //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); } } } return(sendResult); }
public string UpdateItem(string funcPara) { //string pInput = string.Format("<InputValue UserID=\"{0}\" Session=\"{1}\" {2}/>", userID, session, inputValue); string InputValue = CXmlPara.CreatePara(funcPara); CApplicationMessage message = service.UpdateInventoryStock(InputValue); StringBuilder ret = new StringBuilder(); ret.Append("{"); try { ret.AppendFormat("Code:'{0}',\n", message.Code); ret.AppendFormat("Name:'{0}'\n", message.Name); } catch (Exception ex) { } ret.Append("}"); return(ret.ToString()); }
public string SendReport(string ClientKey, string InputValue) { try { CApplicationMessage result = new CMessageToCustomer().SendReport(ClientKey, InputValue); List <CApplicationMessage> list = new List <CApplicationMessage>(); list.Add(result); return(CApplicationMessage.ToCSV <CApplicationMessage>(list)); } catch (Exception ex) { CLogManager.WriteSL("SendReport", ex.ToString()); List <CApplicationMessage> list = new List <CApplicationMessage>(); list.Add(new CApplicationMessage() { Name = "", Description = ex.Message, Result = 0 }); return(CApplicationMessage.ToCSV <CApplicationMessage>(list)); } }
public string UpdateItem(int userID, string session, string funcPara) { //string pInput = string.Format("<InputValue UserID=\"{0}\" Session=\"{1}\" {2}/>", userID, session, funcPara); string InputValue = CXmlPara.CreatePara(funcPara); CApplicationMessage message = service.UpdateAccount(InputValue); StringBuilder ret = new StringBuilder(); try { ret.Append("{"); ret.AppendFormat("Code:'{0}',\n", message.Code); ret.AppendFormat("Name:'{0}',\n", message.Name); ret.AppendFormat("Result:'{0}'\n", message.Result); ret.Append("}"); } catch (Exception ex) { CLogManager.Write("ChartAccountUI:UpdateItem", ex.ToString(), "Account"); } return(ret.ToString()); }
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" }; }
public string UpdateTransaction(string input) { CApplicationMessage message = GLS.UpdateTransaction(input); return(CJson.SerializeObject(message)); }
public string UpdateAsset(string InputValue) { CApplicationMessage message = service.UpdateAsset(InputValue); return(CJson.SerializeObject(message)); }