/// <summary> /// 生成数据文件发送 /// </summary> /// <param name="nowDateTime"></param> protected int UpdateData() { try { var emailHelper = new VPBLL.Email.BaseEmail(); int nEmailCount = emailHelper.SendEmail(); return nEmailCount; } catch (Exception error) { utils.WriteErrorLog(error.Message); return -1; } }
public void ProcessRequest(HttpContext context) { String act = ""; String resultMsg = ""; try { act = context.Request.Params["act"]; if (HttpContext.Current.Request.Cookies["UserID"] == null) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_Need_ReLogin, "登陆已失效,请重新登陆").ToMessage(); } else { int userId = Convert.ToInt32(HttpContext.Current.Request.Cookies["UserID"].Value); switch (act) { case "1": //GR_NewIV.aspx String refGRNumList = context.Request.Params["rgn"]; String refGRItemList = context.Request.Params["rgin"]; String invoiceNumber = context.Request.Params["ivn"]; String strInvoiceDate = context.Request.Params["ivd"]; String strTaxAmount = context.Request.Params["ivt"]; String strTotalAmount = context.Request.Params["iva"]; String strVendorRemark = context.Request.Params["vr"]; String poNumList = context.Request.Params["pn"]; String poINList = context.Request.Params["pin"]; String ivId_email = context.Request.Params["ivd"]; DateTime invoiceDate = new DateTime(); double taxAmount; double totalAmount; if (String.IsNullOrEmpty(invoiceNumber) || !(!String.IsNullOrEmpty(strInvoiceDate) && DateTime.TryParse(strInvoiceDate, out invoiceDate)) || !(!String.IsNullOrEmpty(strTaxAmount) && double.TryParse(strTaxAmount, out taxAmount)) || !(!String.IsNullOrEmpty(strTotalAmount) && double.TryParse(strTotalAmount, out totalAmount))) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.New_Invoice_Error_IVInformation_Wrong, "发票输入信息不正确").ToMessage(); break; } if (String.IsNullOrEmpty(refGRItemList) || String.IsNullOrEmpty(refGRItemList) || String.IsNullOrEmpty(poNumList) || String.IsNullOrEmpty(poINList) || refGRItemList.Split(',').Length != refGRItemList.Split(',').Length) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.New_Invoice_Error_GRInformation_Wrong, "收货信息错误").ToMessage(); break; } var result = new VPBLL.GR.GRHelper().createNewIV(userId, refGRNumList, refGRItemList, poNumList, poINList, invoiceNumber, invoiceDate, taxAmount, totalAmount, strVendorRemark); resultMsg = result.ToMessage(); logger.LogInfo(String.Format("NewIV(userId:{0}, refGRNumbers:'{1}', refGRItemNumber'{2}', invoiceNumber:{3}, invoiceDate:{4}) = {5}", userId, refGRNumList, refGRItemList, invoiceNumber, invoiceDate, resultMsg)); if (result.ResponseCode == 1) { try { String subject = "开发票超容差,请备注"; String vendorCode = new VPBLL.Users.UsersHelper().getUsersByID(userId).First().Username; String vendorName = new VPBLL.Vendor.VenderHelper().getABiVendorByCode(vendorCode).First().VendorName; String content = new VPBLL.GR.GRHelper().GetEmailContent(int.Parse(result.ResponseMessage), 3, userId, invoiceNumber, vendorCode, vendorName); List<KeyValuePair<String, String>> buyers = new VPBLL.Vendor.VenderHelper().getBuyerOfCompany(result.ResponseMessage, 3); if (buyers.Count > 0) { //var mh = new VPBLL.MailHelper(); //mh.EmainSend((from o in buyers select o.Value).ToArray(), content, subject); var be = new VPBLL.Email.BaseEmail(); newEmail = new VPBLL.Email.Email { Subject = subject, Content = content, DateCreated = DateTime.Now, DateModified = DateTime.Now, InvoiceID = Convert.ToInt32(ivId_email), IsSend = false }; newEmail.ToEmailAddresses = new List<string>(); foreach (var obj in (from o in buyers select o.Value).ToArray()) { newEmail.ToEmailAddresses.Add(obj); } be.RecordEmail(newEmail); } } catch (Exception ex) { logger.LogError(String.Format("开票超容差发送email失败"), ex); } } break; case "2": { VPBLL.BasePage bp = new VPBLL.BasePage(); if (bp.RoleID != 5) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_NoPermission, "用户无权限").ToMessage(); } else { String ivId = context.Request.Params["ivd"]; String payAmount = context.Request.Params["pa"]; String payDate = context.Request.Params["dp"]; String mdIV = context.Request.Params["in"]; resultMsg = new VPBLL.IV.IVHelper().updateInvoice(userId, int.Parse(ivId), mdIV, DateTime.Parse(payDate), double.Parse(payAmount)).ToMessage(); logger.LogInfo(String.Format("updateInvoice(invoiceId'{0}', PayDate'{1}', PayAmount'{2}'). UserID:{3}", ivId, payDate, payAmount, bp.UserID)); } } break; case "3": { VPBLL.BasePage bp = new VPBLL.BasePage(); if (bp.RoleID != 5) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_NoPermission, "用户无权限").ToMessage(); } else { string grNumber = context.Request.Params["gn"]; string grItemNumber = context.Request.Params["gin"]; int nRow = new VPBLL.GR.GRHelper().deleteGR(grNumber, grItemNumber, userId); resultMsg = String.Format("{0}&{1}", nRow > 0 ? 0 : -300, nRow.ToString()); logger.LogInfo(String.Format("deleteGR(userID={0}, grNumber={1}, grItemNumber={2}) = {3}", bp.UserID, grNumber, grItemNumber, nRow)); } } break; case "4": { VPBLL.BasePage bp = new VPBLL.BasePage(); if (bp.RoleID != 5) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_NoPermission, "用户无权限").ToMessage(); } else { string grNumber = context.Request.Params["pn"]; string grItemNumber = context.Request.Params["pin"]; int nRow = new VPBLL.PO.POHelper().deletePO(grNumber, grItemNumber, bp.UserID); resultMsg = String.Format("{0}&{1}", nRow > 0 ? 0 : -300, nRow.ToString()); logger.LogInfo(String.Format("deleteGR(userID={0}, poNumber={1}, poItemNumber={2}) = {3}", bp.UserID, grNumber, grItemNumber, nRow)); } } break; case "5": { VPBLL.BasePage bp = new VPBLL.BasePage(); if (bp.RoleID != 5) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_NoPermission, "用户无权限").ToMessage(); } else { string strgrinfo = context.Request.Params["gn"]; string strpoinfo = context.Request.Params["po"]; string gn = strgrinfo.Split(',')[0]; string gin = strgrinfo.Split(',')[1]; string pn = strpoinfo.Split(',')[0]; string pin = strpoinfo.Split(',')[1]; int nDelRow = new VPBLL.GR.GRHelper().deleteGRNew(gn, gin, pn, pin, userId); resultMsg = String.Format("{0}&{1}", nDelRow > 0 ? 0 : -300, nDelRow.ToString()); logger.LogInfo(String.Format("deleteGRNew(userID={0}, gn={1}, po={2}) = {3}", bp.UserID, strgrinfo, strpoinfo, nDelRow)); } } break; case "6": { VPBLL.BasePage bp = new VPBLL.BasePage(); if (bp.RoleID != 5) { resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.User_NoPermission, "用户无权限").ToMessage(); } else { string strTraceId = context.Request.Params["ti"]; int nRet = VPBLL.Trace.TraceHelper.RollbackTrace(int.Parse(strTraceId)); resultMsg = String.Format("{0}&{1}", nRet, nRet.ToString()); logger.LogInfo(String.Format("rollback(traceID={0}, userID={1}) = {2}", strTraceId, bp.UserID, nRet)); } } break; } } } catch (Exception ex) { logger.LogError(this, ex); resultMsg = new VPBLL.ResponseInfo(VPBLL.eResponseCode.SystemError, ex.Message).ToMessage();//"-550&未知错误"; } context.Response.ContentType = "text/plain"; context.Response.Write(resultMsg); }