Exemple #1
0
        public virtual void ExecuteScenario(Task CurrentTaskState)
        {
            string UserFirstName = CurrentTaskState.CreatedForFirstName;

            List <string> SuccessSvnRepositoryNames   = CurrentTaskState.UserRequests.Where(request => request.UserStatus != "ALREADY_EXISTS").Select(request => request.RepositoryName).ToList();
            string        RepositoryNamesConcatinated = "";

            foreach (var repositoryName in SuccessSvnRepositoryNames)
            {
                RepositoryNamesConcatinated += "”<b>" + repositoryName + "</b>” ";
            }


            List <string> ExistsSvnRepositoryNames          = CurrentTaskState.UserRequests.Where(request => request.UserStatus == "ALREADY_EXISTS").Select(request => request.RepositoryName).ToList();
            string        ExistsRepositoryNamesConcatinated = "";

            foreach (var repositoryName in ExistsSvnRepositoryNames)
            {
                ExistsRepositoryNamesConcatinated += "”<b>" + repositoryName + "</b>” ";
            }

            //only add note if the user exists on some of ther repos but not all of them.
            if (ExistsSvnRepositoryNames.Count > 0 && ExistsSvnRepositoryNames.Count < CurrentTaskState.UserRequests.Count)
            {
                NotificationBody = "Note:-<br> You Already Exist On The Following Repositories:-<br>{0}";
                NotificationBody = string.Format(NotificationBody, ExistsRepositoryNamesConcatinated);
            }
            else
            {
                NotificationBody = "";
            }

            List <string> repositoryPaths             = CurrentTaskState.UserRequests.Select(request => request.RepositoryFullPath.ToString()).ToList();
            string        RepositoryPathsConcatinated = "";

            foreach (var repositoryPath in repositoryPaths)
            {
                RepositoryPathsConcatinated += repositoryPath + "<br>";
            }

            string emailSender = "SvnBot";

            emailBody = string.Format(emailBody, UserFirstName, RepositoryNamesConcatinated, RepositoryPathsConcatinated, emailSender, NotificationBody);
            List <string> SendingTo = new List <string> {
                CurrentTaskState.CreatedForEmail
            };
            List <string> SendingCc = new List <string> {
                CurrentTaskState.CreatedByEmail
            };
            var EmailDetails = new EmailDTO
            {
                From         = emailSender + "@syngenta.org",
                To           = SendingTo,
                Cc           = SendingCc,
                Body         = emailBody,
                IsHtml       = "yes",
                Subject      = "Svn Access Response",
                MailPriority = ""
            };

            emailingService.SendEmail(EmailDetails);
        }