public void SendInform(byte type, ModelView.MessageModel inform, Configuration configuration, string homaTitle) { switch (type) { case (byte)Enums.UserInformType.SMS: MessageComponenet.Instance.SMSFacade.SendSms(configuration.SMSAccountId, configuration.SMSAccountUserName, configuration.SMSAccountPassword, inform.Mobile, inform.SMSBody); break; case (byte)Enums.UserInformType.Email: if ( !MessageComponenet.Instance.MailFacade.SendMail(configuration.MailHost, configuration.MailPassword, configuration.MailUserName, configuration.MailFrom, configuration.MailPort, homaTitle, configuration.EnableSSL, inform.Email, inform.EmailTitle, inform.EmailBody)) { throw new Exception("مشکلی در ارسال ایمیل وجود دارد"); } break; case (byte)Enums.UserInformType.Both: try { if ( !MessageComponenet.Instance.MailFacade.SendMail(configuration.MailHost, configuration.MailPassword, configuration.MailUserName, configuration.MailFrom, configuration.MailPort, homaTitle, configuration.EnableSSL, inform.Email, inform.EmailTitle, inform.EmailBody)) { throw new Exception("مشکلی در ارسال ایمیل وجود دارد"); } } catch { } try { MessageComponenet.Instance.SMSFacade.SendSms(configuration.SMSAccountId, configuration.SMSAccountUserName, configuration.SMSAccountPassword, inform.Mobile, inform.SMSBody); } catch { } break; } }
public ActionResult UpdateList(FormCollection collection) { try { var list = new List <User>(); var firstOrDefault = collection.AllKeys.FirstOrDefault(s => s.Equals("ModelId")); if (!string.IsNullOrEmpty(collection[firstOrDefault])) { var strings = collection[firstOrDefault].Split(','); foreach (var key in strings) { if (string.IsNullOrEmpty(key)) { continue; } var status = collection["Status-" + key.ToGuid()].ToByte(); var oldstatus = collection["oldstatus-" + key.ToGuid()].ToByte(); var oldChair = String.IsNullOrEmpty(collection["OldChairId-" + key.ToGuid()]) ? (Guid?)null : collection["OldChairId-" + key.ToGuid()].ToGuid(); var chair = String.IsNullOrEmpty(collection["ChairId-" + key.ToGuid()]) ? (Guid?)null : collection["ChairId-" + key.ToGuid()].ToGuid(); if (oldstatus != status || oldChair != chair) { list.Add(new User() { Id = key.ToGuid(), Status = oldstatus != status ? status : oldstatus, ChairId = oldChair != chair ? chair : oldChair }); } } } var userFacade = CongressComponent.Instance.BaseInfoComponents.UserFacade; if (userFacade.UpdateList(this.Homa.Id, list)) { ShowMessage(Resources.Common.UpdateSuccessMessage, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Succeed); if (list.All(x => x.Status != (byte)Enums.UserStatus.PayConfirm) || !this.Homa.Configuration.AllowUserPrintCard) { return(Content("true")); } var homaFacade = CongressComponent.Instance.BaseInfoComponents.HomaFacade; var @where = userFacade.Where(x => x.Id.In(list.Select(i => i.Id))); foreach (var keyValuePair in list.Where(x => x.Status == (byte)Enums.UserStatus.PayConfirm)) { try { if (this.Homa.Configuration.UserRegisterInformType == (byte?)Enums.UserInformType.Email || this.Homa.Configuration.UserRegisterInformType == (byte?)Enums.UserInformType.Both) { var user = @where.FirstOrDefault(x => x.Id == keyValuePair.Id); if (user == null) { continue; } var data = StringUtils.Encrypt(keyValuePair.Id + "," + this.Homa.Id); var value = user.PaymentTypeId.HasValue ? user.PaymentType.Title : this.Homa.Configuration.CartTypeEmptyValue; var messageModel = new ModelView.MessageModel { Email = user.EnterpriseNode.Email, EmailBody = "<a href=\"http://" + Request.Url.Authority + Radyn.Web.Mvc.UI.Application.CurrentApplicationPath + "/Congress/ReportPanel/EmailPrintUserCard?value=" + data + "\" style=\"font-size: 30px;font-weight: bold;color: green\">" + Resources.Congress.ClickForViewAndDownloadyourCard + "</a>", EmailTitle = string.Format(Resources.Congress.Card + "{0}" + " " + "{1}", value ?? "", this.Homa.CongressTitle), SendEmail = true }; homaFacade.SendInform(this.Homa, (byte)Enums.UserInformType.Email, messageModel); } } catch { } } return(Content("true")); } ShowMessage(Resources.Common.ErrorInEdit, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error); return(Content("false")); } catch (Exception exception) { ShowExceptionMessage(exception); return(Content("false")); } }