} // doIt /// <summary> /// Send No Guarantee EMail /// </summary> /// <param name="A_Asset_ID">asset</param> /// <param name="R_MailText_ID">mail to send</param> /// <param name="trxName">trx</param> /// <returns>message - delivery errors start with **</returns> private String SendNoGuaranteeMail(int A_Asset_ID, int R_MailText_ID, Trx trxName) { MAsset asset = new MAsset(GetCtx(), A_Asset_ID, trxName); if (asset.GetAD_User_ID() == 0) { return("** No Asset User"); } VAdvantage.Model.MUser user = new VAdvantage.Model.MUser(GetCtx(), asset.GetAD_User_ID(), Get_Trx()); if (user.GetEMail() == null || user.GetEMail().Length == 0) { return("** No Asset User Email"); } if (_MailText == null || _MailText.GetR_MailText_ID() != R_MailText_ID) { _MailText = new VAdvantage.Model.MMailText(GetCtx(), R_MailText_ID, Get_Trx()); } if (_MailText.GetMailHeader() == null || _MailText.GetMailHeader().Length == 0) { return("** No Subject"); } // Create Mail EMail email = _client.CreateEMail(user.GetEMail(), user.GetName(), null, null); if (email == null) { return("** Invalid: " + user.GetEMail()); } _MailText.SetPO(user); _MailText.SetPO(asset); String message = _MailText.GetMailText(true); if (_MailText.IsHtml()) { email.SetMessageHTML(_MailText.GetMailHeader(), message); } else { email.SetSubject(_MailText.GetMailHeader()); email.SetMessageText(message); } String msg = email.Send(); new MUserMail(_MailText, asset.GetAD_User_ID(), email).Save(); if (!EMail.SENT_OK.Equals(msg)) { return("** Not delivered: " + user.GetEMail() + " - " + msg); } // return(user.GetEMail()); } // sendNoGuaranteeMail
/// <summary> /// 保存 /// </summary> private void Save() { int id = Utils.GetInt(Utils.GetQueryStringValue("id")); BFinance bll = new BFinance(); MAsset model = id > 0 ? bll.GetAsset(id) : new MAsset(); string msg = string.Empty; if (GetPageVal(model, ref msg)) { PageResponse(UtilsCommons.AjaxReturnJson((id > 0 ? bll.UpdAsset(model) : bll.AddAsset(model)) ? "1" : "-1", model.Id > 0 ? "修改失败!" : "保存失败!")); } else { PageResponse(UtilsCommons.AjaxReturnJson("-1", msg)); } }
/// <summary> /// 获取页面数据 /// </summary> /// <param name="model">固定资产实体</param> /// <param name="msg">返回验证结果</param> /// <returns></returns> private bool GetPageVal(MAsset model, ref string msg) { if (model != null) { //资产ID model.AssetCode = Utils.InputText(Utils.GetFormValue(txt_Id.ClientID)); msg += model.AssetCode.Length > 0 ? string.Empty : "编号不能为空!<br/>"; //资产名称 model.AssetName = Utils.InputText(Utils.GetFormValue(txt_Name.ClientID)); msg += model.AssetName.Length > 0 ? string.Empty : "资产名称不能为空!<br/>"; //购买时间 model.BuyTime = Utils.GetDateTime(txt_purchaseDate.Text); msg += model.BuyTime != DateTime.MinValue ? string.Empty : "请填写正确的购买时间!<br/>"; //部门名称 model.Department = Utils.GetFormValue(SelectSection1.SelectNameClient); //使用部门 model.DepartmentId = Utils.GetInt(Utils.GetFormValue(SelectSection1.SelectIDClient)); msg += model.DepartmentId > 0 && model.Department.Length > 0 ? string.Empty : "请选择部门!<br/>"; //原有价值 model.BuyPrice = Utils.GetDecimal(Utils.GetFormValue(txt_cost.ClientID)); msg += model.BuyPrice > 0 ? string.Empty : "原始价值不能为空!<br/>"; //折旧年限 model.DepreciableLife = Utils.GetDecimal(Utils.GetFormValue(txt_depreciationDateY.ClientID)); msg += model.DepreciableLife > 0 ? string.Empty : "折旧年限不能为空!<br/>"; model.Admin = Utils.GetFormValue(SellsSelect1.SellsNameClient); model.AdminId = Utils.GetFormValue(SellsSelect1.SellsIDClient); model.AdminDeptId = Utils.GetInt(Utils.GetFormValue("AdminDeptID")); //公司编号 model.CompanyId = CurrentUserCompanyID; //操作时间 model.IssueTime = DateTime.Now; //操作人 model.OperatorId = SiteUserInfo.UserId; model.Operator = SiteUserInfo.Name; //备注 model.Remark = Utils.InputText(Utils.GetFormValue(txt_Remark.ClientID)); return(msg.Length <= 0); } else { return(false); } }
} // sendNoGuaranteeMail /// <summary> /// Deliver Asset /// </summary> /// <param name="A_Asset_ID">asset</param> /// <returns>message - delivery errors start with **</returns> private String DeliverIt(int A_Asset_ID) { log.Fine("A_Asset_ID=" + A_Asset_ID); long start = CommonFunctions.CurrentTimeMillis(); // MAsset asset = new MAsset(GetCtx(), A_Asset_ID, Get_Trx()); if (asset.GetAD_User_ID() == 0) { return("** No Asset User"); } VAdvantage.Model.MUser user = new VAdvantage.Model.MUser(GetCtx(), asset.GetAD_User_ID(), Get_Trx()); if (user.GetEMail() == null || user.GetEMail().Length == 0) { return("** No Asset User Email"); } if (asset.GetProductR_MailText_ID() == 0) { return("** Product Mail Text"); } if (_MailText == null || _MailText.GetR_MailText_ID() != asset.GetProductR_MailText_ID()) { _MailText = new VAdvantage.Model.MMailText(GetCtx(), asset.GetProductR_MailText_ID(), Get_Trx()); } if (_MailText.GetMailHeader() == null || _MailText.GetMailHeader().Length == 0) { return("** No Subject"); } // Create Mail EMail email = _client.CreateEMail(user.GetEMail(), user.GetName(), null, null); if (email == null || !email.IsValid()) { asset.SetHelp(asset.GetHelp() + " - Invalid EMail"); asset.SetIsActive(false); return("** Invalid EMail: " + user.GetEMail() + " - " + email); } if (_client.IsSmtpAuthorization()) { email.CreateAuthenticator(_client.GetRequestUser(), _client.GetRequestUserPW()); } _MailText.SetUser(user); _MailText.SetPO(asset); String message = _MailText.GetMailText(true); if (_MailText.IsHtml() || _AttachAsset) { email.SetMessageHTML(_MailText.GetMailHeader(), message); } else { email.SetSubject(_MailText.GetMailHeader()); email.SetMessageText(message); } if (_AttachAsset) { MProductDownload[] pdls = asset.GetProductDownloads(); if (pdls != null) { foreach (MProductDownload element in pdls) { //URL url = element.getDownloadURL(m_client.getDocumentDir()); Url url = element.GetDownloadURL(_client.GetDocumentDir()); if (url != null) { email.AddAttachment(url.Value); } } } else { log.Warning("No DowloadURL for A_Asset_ID=" + A_Asset_ID); } } String msg = email.Send(); new MUserMail(_MailText, asset.GetAD_User_ID(), email).Save(); if (!EMail.SENT_OK.Equals(msg)) { return("** Not delivered: " + user.GetEMail() + " - " + msg); } MAssetDelivery ad = asset.ConfirmDelivery(email, user.GetAD_User_ID()); ad.Save(); asset.Save(); // log.Fine((CommonFunctions.CurrentTimeMillis() - start) + " ms"); // success return(user.GetEMail() + " - " + asset.GetProductVersionNo()); }