Exemple #1
0
        private static void GenerateLoaclFileReport(string clientName, string[] clients, ClientOrganizationInfos missingMappingsReport, ClientOrganizationInfos multiplMappingsReport)
        {
            var basePath = $@"{Constants.BaseDestinationPath}\{clientName}\";
            var sb = new StringBuilder();


            if (missingMappingsReport.Any())
            {
                var filePath = basePath + "Missing Mapping Report.txt";
                sb.Append("Clients:\n");
                foreach (var client in clients)
                {
                    sb.Append(client + "\n");
                }
                sb.Append("\n\n");
                missingMappingsReport.OrganizationInfos = missingMappingsReport.OrganizationInfos
                    .OrderBy(c => c.Level)
                    .ThenBy(c => c.Name).ToList();

                sb.AppendFormat("{0, -10}{1, -50}{2,-50}", "Level", "Organization Name", "Parent Name");
                foreach (var clientOrganizationInfo in missingMappingsReport.OrganizationInfos)
                {
                    if (clientOrganizationInfo.Level > 3)
                    {
                        sb.AppendFormat("{0, -10}{1, -50}{2,-50}", clientOrganizationInfo.Level, clientOrganizationInfo.Name, clientOrganizationInfo.ParentName);
                    }
                    else
                    {
                        sb.AppendFormat("{0, -10}{1, -50}", clientOrganizationInfo.Level, clientOrganizationInfo.Name);
                    }
                    sb.Append("\n");
                }
                File.WriteAllText(filePath, sb.ToString());

            }
            if (multiplMappingsReport.Any())
            {

                missingMappingsReport.OrganizationInfos = missingMappingsReport.OrganizationInfos.OrderBy(c => c.Level).ThenBy(c => c.Name).ToList();

            }


        }
Exemple #2
0
        private static void GenerateEmailReport(string[] clients, ClientOrganizationInfos missingMappingsReport, ClientOrganizationInfos multiplMappingsReport)
        {
            var sendSuccessNotice = true;
            var mailManager = new MailManager(Constants.Resources.SmtpFrom, Constants.Resources.SmtpServer,
                    Constants.Resources.SmtpUserId, Constants.Resources.SmtpPassword);

            if (missingMappingsReport.Any())
            {
                sendSuccessNotice = false;
                missingMappingsReport.OrganizationInfos = missingMappingsReport.OrganizationInfos.OrderBy(c => c.Level).ThenBy(c => c.Name).ToList();
                mailManager.SendMailFromTemplate(MailManager.MailTemplateTypes.MissingOrganizations, Constants.Resources.SmtpTo,
                    "Failed!", new { Clients = clients, Report = missingMappingsReport });


            }
            if (multiplMappingsReport.Any())
            {
                sendSuccessNotice = false;
                missingMappingsReport.OrganizationInfos = missingMappingsReport.OrganizationInfos.OrderBy(c => c.Level).ThenBy(c => c.Name).ToList();
                mailManager.SendMailFromTemplate(MailManager.MailTemplateTypes.MultipleOrganizatonMatches, Constants.Resources.SmtpTo,
                   "Failed!", new { Clients = clients, Report = multiplMappingsReport });
            }

            if (sendSuccessNotice)
            {

                mailManager.SendMailFromTemplate(MailManager.MailTemplateTypes.Success, Constants.Resources.SmtpTo,
                    "Success!", new { Clients = clients });
            }
        }
Exemple #3
0
        private static void GenerateTextReport(string[] clients, ClientOrganizationInfos missingMappingsReport, ClientOrganizationInfos multipleOrganizationMappings)
        {

            try
            {
                if (missingMappingsReport.Any())
                {

                    missingMappingsReport.OrganizationInfos = missingMappingsReport.OrganizationInfos.OrderBy(c => c.Level).ThenBy(c => c.Name).ToList();
                    var model = new { Report = missingMappingsReport, Clients = clients };
                    var body = MailManager.GenerateEmailBody(MailManager.MailTemplateTypes.MissingOrganizations, "Failed", model);
                    using (var sw = new StreamWriter(@"c:\temp\missingReport.txt"))
                    {
                        sw.Write(body);
                        sw.Flush();
                    }


                }
                if (multipleOrganizationMappings.Any())
                {

                    missingMappingsReport.OrganizationInfos = missingMappingsReport.OrganizationInfos.OrderBy(c => c.Level).ThenBy(c => c.Name).ToList();
                    var model = new { Report = missingMappingsReport, Clients = clients };
                    var body = MailManager.GenerateEmailBody(MailManager.MailTemplateTypes.MultipleOrganizatonMatches, "Failed", model);
                    using (var sw = new StreamWriter(@"c:\temp\multipleOrganizationMappings.txt"))
                    {
                        sw.Write(body);
                        sw.Flush();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }


        }