Beispiel #1
0
        public bool SendNotificationAboutNewOrUpdatedWorkload(string uniqueName, int newOrUpdate)
        {
            EmailLogic clientEmail = new EmailLogic();

            // Mounting parameters and message.
            string ToName  = Util.GetUserAlias(uniqueName);
            string ToEmail = uniqueName;
            string Subject = "";

            StringBuilder StructureModified = new StringBuilder();

            StructureModified = EmailMessages.GetEmailMessageStructure();

            // Replacing the generic title by the customized.
            StructureModified.Replace("[MessageTitle]", "Hi " + ToName + ", we have news to you: ");

            if (newOrUpdate == 0) // new workload
            {
                Subject += "[ARDA] New workload available to you";

                // Replacing the generic subtitle by the customized.
                StructureModified.Replace("[MessageSubtitle]", "A new <strong>Workload</strong> was created and signed to you.");

                // Replacing the generic message body by the customized.
                StructureModified.Replace("[MessageBody]", "To see your new workload, please, click on the link bellow.");
            }
            else
            {
                Subject += "[ARDA] Existing workload has been updated";

                // Replacing the generic subtitle by the customized.
                StructureModified.Replace("[MessageSubtitle]", "A existent <strong>Workload</strong> signed to you was updated.");

                // Replacing the generic message body by the customized.
                StructureModified.Replace("[MessageBody]", "To see your workload updated, please, click on the link bellow.");
            }

            // Replacing the generic callout box.
            StructureModified.Replace("[MessageCallout]", "Dashboard (Kanban): <a href='/Dashboard/Index'>My workloads</a>");

            // Creating a object that will send the message.
            EmailLogic EmailObject = new EmailLogic();

            try
            {
                var EmailTask = EmailObject.SendEmailAsync(ToName, ToEmail, Subject, StructureModified.ToString());
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #2
0
        public bool SendNotificationOfNewUserByEmail(string uniqueName)
        {
            EmailLogic clientEmail = new EmailLogic();

            // Mounting parameters and message.
            var Configuration = new ConfigurationBuilder().AddJsonFile("secrets.json").Build();
            var admin         = Configuration["Email:Administrator"];

            string ToName  = "Arda Administrator";
            string ToEmail = admin;
            string Subject = "[ARDA] A new user has been logged @ Arda";

            StringBuilder StructureModified = new StringBuilder();

            StructureModified = EmailMessages.GetEmailMessageStructure();

            // Replacing the generic title by the customized.
            StructureModified.Replace("[MessageTitle]", "Hi " + ToName + ", someone requested access to the system");

            // Replacing the generic subtitle by the customized.
            StructureModified.Replace("[MessageSubtitle]", "Who did the request was <strong>" + uniqueName + "</strong>. If you deserve, can access 'Users' area and distribute the appropriated permissions.");

            // Replacing the generic message body by the customized.
            StructureModified.Replace("[MessageBody]", "Details about the request: </br></br><ul><li>Email: " + uniqueName + "</li><li>Date/time access: " + DateTime.Now + "</li></ul>");

            // Replacing the generic callout box.
            StructureModified.Replace("[MessageCallout]", "For more details about the request, send a message to <strong>[email protected]</strong>.");

            // Creating a object that will send the message.
            EmailLogic EmailObject = new EmailLogic();

            try
            {
                var EmailTask = EmailObject.SendEmailAsync(ToName, ToEmail, Subject, StructureModified.ToString());
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }