public static bool SendMailNotification(string OrderCode, string UserCode) { bool retuenValue = false; /*Oftenly We Write a mail service Separately by inserting all data into one table as if status * of Mailnotification table isPending then we send mail*/ try { using (var db = new Entities()) { MailNotification mailNotification = new MailNotification(); mailNotification.UserCode = UserCode; mailNotification.Status = "Pending"; mailNotification.OrderCode = OrderCode; mailNotification.MailDate = DateTime.UtcNow;; mailNotification.Message = GetmessageAsperStatus(OrderCode); retuenValue = true; db.MailNotifications.Add(mailNotification); db.SaveChanges(); } } catch (Exception ex) { SaveException(ex); } return(retuenValue); }
public bool EnqueueMailNotification(MailNotification mailNotification) { bool result = false; string notification = JsonConvert.SerializeObject(mailNotification); string queueName = ConfigurationManager.AppSettings["azure-queue-mailnotification"]; QueueManager.InsertMessage(notification, queueName); result = true; return(result); }
private MailNotification ProsesMailNotificationBody(MASTER_DATA_APPROVAL data) { var bodyMail = new StringBuilder(); var rc = new MailNotification(); var userCreatorInfo = _poaBll.GetUserById(data.CREATED_BY); var webRootUrl = ConfigurationManager.AppSettings["WebRootUrl"]; var page = _pageBLL.GetPageByID(data.PAGE_ID); rc.Subject = "Master Data " + page.MENU_NAME + " Approval Status is " + EnumHelper.GetDescription(data.STATUS_ID); bodyMail.Append("Dear Team,<br />"); bodyMail.Append("Kindly be informed, " + rc.Subject + ". <br />"); bodyMail.Append(BuildBodyMail(data, webRootUrl)); var controllerList = _poaBll.GetMasterApprovers(); rc.Body = bodyMail.ToString(); if (data.STATUS_ID == Enums.DocumentStatus.WaitingForMasterApprover) { foreach (var user in controllerList) { rc.To.Add(user.EMAIL); } rc.IsCCExist = true; rc.CC.Add(userCreatorInfo.EMAIL); } else { foreach (var user in controllerList) { rc.IsCCExist = true; rc.CC.Add(user.EMAIL); } rc.To.Add(userCreatorInfo.EMAIL); } return(rc); }
public void Setup() { _address = new IpsAddress(); _address.Address = new List <string> { "*****@*****.**" }; _message = new IpsMessage(); _message.Message = "testMessage"; _message.Subject = "testSubject"; _sender = new MailNotification(); }
public DTO_UserModify() { TicketId = -1; Code = "TK00000000-0"; Status = Enums.TicketStatus.open; CategoryName = ""; Notifications = new MailNotification(); Messages = null; Errors = Enums.TicketEditUserErrors.none; IsReadOnly = true; IsBehalf = false; isOwner = false; }
public List <MailNotification> getMailInfo(string AcName, string Appno) { List <MailNotification> Mailinf = new List <MailNotification>(); try { con = Utility.Util.Connection("DBEntities"); string result = ""; SqlCommand cmd = new SqlCommand("SP_Mail_Content", con); con.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ActionN", AcName); result = cmd.ExecuteNonQuery().ToString(); if (result.Equals(null)) { return(null); } SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { MailNotification MailItems = new MailNotification(); MailItems.Subject = ds.Tables[0].Rows[i]["Subject"].ToString(); MailItems.Message = ds.Tables[0].Rows[i]["Message"].ToString(); MailItems.MailAppNo = MailItems.Message.Replace("<AppNo>", Appno); Mailinf.Add(MailItems); } } catch (Exception ex) { ex.Message.ToString(); } finally { con.Close(); } return(Mailinf); }
public IHttpActionResult AssignmentEnd([FromBody] MailNotification mailNotification) { try { var client = new RestClient(_assignmentApi); var request = new RestRequest("getbyid"); request.AddParameter("id", mailNotification.AssignmentId); var response = client.ExecuteGetTaskAsync(request).GetAwaiter().GetResult(); var assignment = Deserialize(response.Content); SendMail(assignment, null, mailNotification.userId); return(Ok()); } catch (Exception ex) { Log.Write(ex); return(InternalServerError()); } }
private string SendInvitations(ApiUser hdUser, string recipients, string topic, string url) { Guid organizationId = hdUser.OrganizationId; int departmentId = hdUser.DepartmentId; int userId = hdUser.UserId; string Email = hdUser.LoginEmail; string userName = hdUser.FullName; string department = hdUser.DepartmentName; List <int> intUserIds = new List <int>(); string[] emails = recipients.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray(); recipients = ""; foreach (string email in emails) { if (!Utils.IsValidEmail(email)) { continue; } recipients += email + ";"; } if (string.IsNullOrWhiteSpace(recipients)) { throw new HttpError(HttpStatusCode.NotFound, "Incorrect Email(s)"); } string subject = topic; string from = "\"" + userName + " - " + department + "\"<" + Email + ">"; if (!string.IsNullOrWhiteSpace(recipients)) { try { string body = "Hi! You got " + topic + ".\n Please open this url to start chat: " + url + $". Or click <a href=\"{url}\" target=\"_blank\">{url}</a>"; MailNotification _mail_notification = new MailNotification(organizationId, departmentId, userId, from, recipients, subject, body); string _return_string = _mail_notification.Commit(true); } catch { throw new HttpError(HttpStatusCode.NotFound, "Email error."); } } else { throw new HttpError(HttpStatusCode.NotFound, "No recepients selected."); } return("OK"); }
private MailNotification ProcessEmailQuotaNotification(QUOTA_MONITORING data, out Pbck1Dto pbck1Data, List <string> goodTypeList) { var bodyMail = new StringBuilder(); var rc = new MailNotification(); var toUserIdList = data.QUOTA_MONITORING_DETAIL.Where(x => x.ROLE_ID != (int)Core.Enums.UserRole.Controller).Select(x => x.USER).ToList(); var ccControllerIdList = data.QUOTA_MONITORING_DETAIL.Where(x => x.ROLE_ID == (int)Core.Enums.UserRole.Controller).Select(x => x.USER).ToList(); var webRootUrl = ConfigurationManager.AppSettings["WebRootUrl"]; if (data.EX_GROUP_TYPE == (int)Core.Enums.ExGoodsType.HasilTembakau) { pbck1Data = _pbck1BLL.GetPbck1CompletedDocumentByPlantAndSubmissionDate(data.SUPPLIER_WERKS, data.SUPPLIER_NPPBKC_ID, DateTime.Now, data.NPPBKC_ID, goodTypeList).LastOrDefault(); } else { pbck1Data = _pbck1BLL.GetPbck1CompletedDocumentByExternalAndSubmissionDate(data.SUPPLIER_WERKS, data.SUPPLIER_NPPBKC_ID, DateTime.Now, data.NPPBKC_ID, goodTypeList).LastOrDefault(); } rc.Subject = "PBCK-1 Quota is currently below " + data.WARNING_LEVEL + "% of Approved Qty."; bodyMail.Append("Dear Team,<br />"); bodyMail.Append("Kindly be informed, " + rc.Subject + ". <br />"); bodyMail.Append(BuildBodyMailForQuotaNotification(pbck1Data, webRootUrl, data)); rc.To.AddRange(toUserIdList.Select(x => x.EMAIL).ToList()); rc.Body = bodyMail.ToString(); foreach (var controller in ccControllerIdList) { rc.IsCCExist = true; rc.CC.Add(controller.EMAIL); } return(rc); }
public void ProcessMailSessionNotification(string message) { try { // Obtenemos la notificacion de la queue: notifications MailNotification pushNotification = JsonConvert.DeserializeObject <MailNotification>(message); mailManager.SendAsync(pushNotification.EMail); // Encolamos la notificacion al topic de service bus // para que tambien llegue en tiempo real dynamic data = pushNotification.notificacion; sbmanager.SendMessageToSessionQueue(data, pushNotification.notificacion.IdUser, pushNotification.notificacion.Label).GetAwaiter().GetResult();; } catch (Exception e) { var messageException = telemetry.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name); telemetry.Critical(messageException); } }
public JsonResult Notify(int id) { try { MailNotification mNotif = new MailNotification(); mNotif.SourceMail = "*****@*****.**"; mNotif.TargetMail = "*****@*****.**"; //SMSNotification mNotif = new SMSNotification(); //mNotif.Phone = "05462948416"; Notification notification = new Notification(mNotif); notification.Message = "Message"; var currentTarget = _repoWrapper.Targets.GetById(id); Notifications ntfs = new Notifications(); ntfs.TargetID = currentTarget.ID; ntfs.UserId = 1; ntfs.TargetContact = mNotif.TargetMail; if (currentTarget.State) { ntfs.Message = "Target is working!"; } else { ntfs.Message = "Target is Stopped!"; } _repoWrapper.Notifications.Insert(ntfs); notification.Notify(); return(Json(ntfs)); } catch (Exception ex) { return(Json(-1)); } }
static void Main(string[] args) { Database database = new Database(); FileWriter fileWriter = new FileWriter(); Notification notification; bool isABadThingUsingAnimalsForSendingMessages = true; if (isABadThingUsingAnimalsForSendingMessages) { notification = new MailNotification(); } else { notification = new PidgeonNotification(); } WorkingRobot workingRobot = new WorkingRobot(database, fileWriter, notification); workingRobot.Work(); }
public void ProcessMailNotification(string message, Dictionary <string, int> UserPriority) { try { // Obtenemos la notificacion de la queue: notifications MailNotification pushNotification = JsonConvert.DeserializeObject <MailNotification>(message); mailManager.SendAsync(pushNotification.EMail); //Aumentamos la prioridad del usuario int Priority = AddUserIfNotExist(UserPriority, pushNotification.notificacion.IdUser); // Encolamos la notificacion al topic de service bus // para que tambien llegue en tiempo real dynamic data = pushNotification.notificacion; sbmanager.SendMessageAsync(Priority, data, pushNotification.notificacion.IdUser, pushNotification.notificacion.Label); } catch (Exception e) { var messageException = telemetry.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name); telemetry.Critical(messageException); } }
private void MyToastTask() { var newNotification = new MailNotification() { Title = "Vacation Request", Sender = "Mohamed Magdy", Content = "I would like to request for vacation from 20 / 12 / 2015 to 30 / 12 / 2015............." }; var configuration = new NotificationConfiguration(new TimeSpan(0, 0, 5), null, null, "MailNotificationTemplate", NotificationFlowDirection.RightBottom); for (; ;) { App.Current?.Dispatcher?.Invoke(() => { _dailogService.ShowNotificationWindow(newNotification, configuration); }); Thread.Sleep(4 * 1000); } }
private MailNotification ProcessEmailQuotaNotification(List <InvalidBrandByCk5ForEmail> invalidCk5List) { var bodyMail = new StringBuilder(); var rc = new MailNotification(); var toList = new List <String>(); rc.IsDataExist = false; List <ZAIDM_EX_BRAND> brandDeactivated = new List <ZAIDM_EX_BRAND>(); foreach (var invalidCk5 in invalidCk5List) { toList.AddRange(invalidCk5.userTo.Where(x => x.EMAIL != "").Select(x => x.EMAIL).ToList()); } rc.Subject = "Brands Never used on any CK-5 (export) in the last 5 months."; bodyMail.Append("Dear Team,<br />"); bodyMail.Append("Kindly be informed, brands below are Never used on any CK-5 (export) in the last 5 months. <br />"); bodyMail.Append(BuildBodyMailForQuotaNotification(invalidCk5List)); rc.To.AddRange(toList.Distinct()); rc.Body = bodyMail.ToString(); foreach (var controller in invalidCk5List.FirstOrDefault().userCc) { rc.IsCCExist = true; rc.CC.Add(controller.EMAIL); } if (rc.Body.Contains("</td>")) { rc.IsDataExist = true; } return(rc); }
internal static object SendInvoice(ApiUser hdUser, string invoice_id, string recipients, bool isPDFOnly = false) { Guid organizationId = hdUser.OrganizationId; int departmentId = hdUser.DepartmentId; int userId = hdUser.UserId; string Email = hdUser.LoginEmail; string userName = hdUser.FullName; string department = hdUser.DepartmentName; Models.Invoice invoice = GetInvoice(organizationId, departmentId, invoice_id, false); int AccountId = invoice.AccountId; List <int> intUserIds = new List <int>(); string[] emails = recipients.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray(); recipients = ""; invoice.recipients = AccountUsers.GetAccountUsers(organizationId, departmentId, invoice.AccountId); foreach (string email in emails) { if (!Utils.IsValidEmail(email)) { continue; } bool isAccountingContact = true; int userID = 0; string new_email = ""; AccountUser user = invoice.recipients.Find(r => r.Email.ToLower() == email.ToLower()); if (user != null) { isAccountingContact = user.AccountingContact; userID = user.Id; new_email = user.Email; } else { userId = bigWebApps.bigWebDesk.Data.Accounts.InsertUserIntoAccount(hdUser.OrganizationId, hdUser.DepartmentId, AccountId, email, 0, false); new_email = email; isAccountingContact = false; } if (!isAccountingContact) { bigWebApps.bigWebDesk.Data.Accounts.UpdateAccountContact(hdUser.OrganizationId, hdUser.DepartmentId, AccountId, userID, true); } recipients += new_email + ";"; } int ProjectId = invoice.ProjectId; int invoiceID = invoice.Id.Value; string subject = invoice.Customer + " | Invoice #" + invoiceID; string from = "\"" + userName + " - " + department + "\"<" + Email + ">"; if (!string.IsNullOrWhiteSpace(recipients)) { Instance_Config instanceConfig = new Models.Instance_Config(hdUser); string currency = string.IsNullOrWhiteSpace(instanceConfig.Currency) ? "$" : instanceConfig.Currency; try { string filename = "Invoice-" + invoiceID.ToString() + ".pdf"; string logoURL = string.Empty; string logoImageUrl = Files.GetOrganizationLargeLogoUrl(organizationId); if (!String.IsNullOrEmpty(logoImageUrl)) { logoURL = logoImageUrl; } logoImageUrl = Files.GetInstanceLargeLogoUrl(hdUser.InstanceId); if (!String.IsNullOrEmpty(logoImageUrl)) { logoURL = logoImageUrl; } byte[] pdfBytes = null; string body = ""; try { pdfBytes = bigWebApps.bigWebDesk.Data.Invoice.ExportPDF(organizationId, hdUser.InstanceId, departmentId, userId, invoiceID, "https://app.sherpadesk.com", currency, instanceConfig.Names.tech.a, instanceConfig.Names.ticket.a, instanceConfig.ProjectTracking, instanceConfig.Names.user.a, instanceConfig.QBUseQBInvoiceNumber, logoURL); if (isPDFOnly) { var sfile = new System.IO.MemoryStream(pdfBytes); return(new BWA.bigWebDesk.Api.Services.FilesService.FileResult(sfile, "application/pdf", filename)); } body = bigWebApps.bigWebDesk.Data.Invoice.ExportHtml(organizationId, hdUser.InstanceId, departmentId, userId, invoiceID, "https://app.sherpadesk.com", currency, instanceConfig.Names.tech.a, instanceConfig.Names.ticket.a, instanceConfig.ProjectTracking, instanceConfig.Names.user.a, instanceConfig.QBUseQBInvoiceNumber); } catch { throw new HttpError(HttpStatusCode.NotFound, "Cannot create invoice with provided data."); } MailNotification _mail_notification = new MailNotification(organizationId, departmentId, userId, from, recipients, subject, body); if (pdfBytes != null) { bigWebApps.bigWebDesk.Data.FileItem[] _files = new bigWebApps.bigWebDesk.Data.FileItem[1]; _files[0] = new bigWebApps.bigWebDesk.Data.FileItem(0, filename, pdfBytes.Length, DateTime.Now, string.Empty, pdfBytes); _mail_notification.AttachedFiles = _files; } string _return_string = _mail_notification.Commit(true); } catch { throw new HttpError(HttpStatusCode.NotFound, "Email error."); } } else { throw new HttpError(HttpStatusCode.NotFound, "No recepients selected."); } return(invoice); }