private void CreateeMailsForTerminAndParticipant(List<Guid> TypIDListToSelect, String FileName) { Termin[] TerminEntries = Data.DbServer3.WordUp.Termine.Find_ForSpecificTypIDs (TypIDListToSelect, DateTime.Now.AddDays(-1)); Dictionary<Person, List<String>> SendList = new Dictionary<Person, List<string>>(); foreach (Termin TerminEntry in TerminEntries) { String TerminID = TerminEntry.Id.ToString(); List<Object> ObjectsToPrint = DataWrapper.Instance.CreateTreeForTerminData(TerminEntry, "ProfisPart"); String TargetDirectory = Path.GetDirectoryName(FileName); if (!Directory.Exists(TargetDirectory)) Directory.CreateDirectory(TargetDirectory); String CreatedFileNameAndDescription; PersonZuTermin[] InvolvedPersonen = Data.DbServer3.WordUp.PersonenZuTerminen.Collection .Where(sel => sel.WordUpId == Data.DbServer3.WordUp.WordUpIDGuid && sel.TermineId == TerminEntry.Id && TypIDListToSelect.Contains((Guid) sel.PersonenTypId)).ToArray(); ProjektZuTermin[] InvolvedProjekte = Data.DbServer3.WordUp.ProjekteZuTerminen.Collection .Where(sel => sel.Projekt.WordUpRootId == Data.DbServer3.WordUp.WordUpIDGuid && sel.TermineId == TerminEntry.Id).ToArray(); if((InvolvedPersonen.Length > 0) || (InvolvedProjekte.Length > 0)) { XAMLPrintoutDefinitions.PrintFileCards PrintHandler = new XAMLPrintoutDefinitions.PrintFileCards(); CreatedFileNameAndDescription = PrintHandler.PrintTermine(ObjectsToPrint, TargetDirectory); } else { TerminPrint Helper = new TerminPrint(TerminEntry); CreatedFileNameAndDescription = ";" + Helper.DescriptionElements; } foreach (PersonZuTermin personZuTermin in Data.DbServer3.WordUp.PersonenZuTerminen.Collection .Where(sel => sel.WordUpId == Data.DbServer3.WordUp.WordUpIDGuid && sel.TermineId == TerminEntry.Id && Data.DbServer3.WordUp.Typen.AllTypIDsForBetreuer .Contains((Guid)sel.PersonenTypId)).ToArray()) { if (SendList.ContainsKey(personZuTermin.Person)) SendList[personZuTermin.Person].Add(CreatedFileNameAndDescription); else SendList[personZuTermin.Person] = new List<string>() {CreatedFileNameAndDescription}; } } SmtpClient MailClient = new SmtpClient(WMB.SecureData.StandardSMTPServer); MailClient.Credentials = new NetworkCredential(WMB.SecureData.StandardSMTPUser, WMB.SecureData.StandardSMTPPassword); MailClient.DeliveryMethod = SmtpDeliveryMethod.Network; String Receiver = SelectReceiver(); foreach (Person staffPerson in SendList.Keys) { StringBuilder Result = new StringBuilder(); // Result.AppendLine("<html>"); // Result.AppendLine(CommonHTMLHeader); // Result.AppendLine("<body>"); Result.AppendLine("Hallo Brigitte!"); Result.AppendLine(String.Empty); Result.AppendLine("Diese Mail gehört an die folgende Adresse gesendet:"); Result.AppendLine(String.Empty); Result.AppendLine(String.Empty); Result.AppendLine("<h3>" + staffPerson.EMail + "</h3>"); Result.AppendLine(String.Empty); Result.AppendLine(String.Empty); Result.AppendLine("<H3>Hallo " + staffPerson.VorName + "!</H3>"); Result.AppendLine(String.Empty); Result.AppendLine("<p>Diese Mail enthält die nächsten Termine, soweit sie Dich betreffen.</p>"); Result.AppendLine("<p>Beiliegend (Attachment) schicke ich dir zu manchen Terminen noch " + "detaillierte Infos, die du zur Terminvorbereitung benötigst.</p>"); Result.AppendLine(String.Empty); Result.AppendLine("<h3>lg Brigitte</h3>"); Result.AppendLine(String.Empty); Result.AppendLine("<h3>Hier noch die demnächst stattfindenden Termine:</h3>"); Result.AppendLine(String.Empty); List<Attachment> Attachments = new List<Attachment>(); Result.AppendLine("<table border=\"1\">"); Result.AppendLine("<tr><th>Att.</th><th>Wann</th><th>Was</th><th>Wo</th><th>Details</th></tr>"); foreach (String fileNameAndDescription in SendList[staffPerson]) { Result.AppendLine("<tr>"); String[] Elements = fileNameAndDescription.Split(';'); String[] EinzelElemente = Elements[1].Split('\t'); String AttachmentAvailable = "-"; if (!String.IsNullOrEmpty(Elements[0])) { Attachments.Add(new Attachment(Elements[0].Replace(".xps", ".pdf"))); AttachmentAvailable = "ja"; } Result.AppendLine("<td>" + AttachmentAvailable + "</td>"); foreach (String EinzelElement in EinzelElemente) { Result.AppendLine("<td>" + EinzelElement + "</td>"); } Result.AppendLine("</tr>"); } Result.AppendLine("</table>"); // Result.Append("</body></html>"); MailMessage BasicMail = new MailMessage(WMB.SecureData.StandardSMTPUser, ((String.IsNullOrEmpty(Receiver)) ? staffPerson.EMail : Receiver)); BasicMail.IsBodyHtml = true; BasicMail.BodyEncoding = Encoding.UTF8; BasicMail.HeadersEncoding = Encoding.UTF8; BasicMail.SubjectEncoding = Encoding.UTF8; BasicMail.Subject = "word up!23-Termindaten für die nächsten Termine"; BasicMail.Body = "<p>" + Result.ToString().Replace("\r\n", "</br>") + "</p>"; //.Replace ("\r\n", "</br>"); foreach (Attachment Att in Attachments) { BasicMail.Attachments.Add(Att); } MailClient.Send(BasicMail); BasicMail.Dispose(); } return; }
public String CreateMultiProjectProjectFolder(DbEntities.dbserver3.wordup.rows.Projekt[] ProjectsToCreate, String TargetDirectory, String Description, String FileNameElement = "") { //String ProjectFolderBaseDirectory = Basics.Instance.ProjektMaterialDirectory; //String OrteFolderBaseDirectory = Basics.Instance.OrtsMaterialDirectory; String FileName = String.Empty; if (String.IsNullOrEmpty(FileNameElement)) FileName = Path.Combine(TargetDirectory, "ProjektMappe_" + DateTime.Now.ToString("yyyy-MMM-dd_HH_mm") + ".pdf"); else FileName = Path.Combine(TargetDirectory, WMB.Basics.ConvertToCorrectFileNameElement(FileNameElement) + ".pdf"); Guid OldOrteID = Guid.Empty; List<Object> ResultetObjectsToPrint = new List<Object>(); foreach (DbEntities.dbserver3.wordup.rows.Projekt projectEntry in ProjectsToCreate) { PlanungPrint planungPrint = new PlanungPrint(projectEntry) { PageBreakAllowedBefore = true }; ResultetObjectsToPrint.Add(planungPrint); planungPrint.MaximalWMUValue = Data.DbServer3.WordUp.Projekte.WMUDistribution.Keys.Max(); planungPrint.MaximalWSPLakateValue = Data.DbServer3.WordUp.Projekte.WSPlakateDistribution.Keys.Max(); planungPrint.MaximalWertigkeitValue = Data.DbServer3.WordUp.Projekte.WertigkeitValueDistribution.Keys.Max(); ResultetObjectsToPrint.Add(new HeadLinePrint("Bemerkungen:", "SubSubSub")); foreach (Aktivitaet aktivitaet in projectEntry.Aktivitaeten) { ResultetObjectsToPrint.Add(new AktivitaetenPrint(aktivitaet) { }); } ResultetObjectsToPrint.Add(new HeadLinePrint("Ideen", "SubSubSub")); foreach (WSPlakat wsPlakat in projectEntry.WSPlakate) { ResultetObjectsToPrint.Add(new IdeePrint(wsPlakat) {} ); } foreach (ProjektZuTermin projektZuTermin in Data.DbServer3.WordUp.ProjekteZuTerminen.Find_By_ProjekteId(projectEntry.Id) ) { TerminPrint TerminRoot = new TerminPrint(projektZuTermin.Termin); ResultetObjectsToPrint.Add(TerminRoot); bool firstTeam = true; bool firstVertreter = true; foreach (PersonZuTermin PersonZuTerminEntry in Data.DbServer3.WordUp.PersonenZuTerminen .FindOrLoad_ActivePersonenZuTerminen(projektZuTermin.Termin.Id) .Where(sel => Data.DbServer3.WordUp.Typen.AllTypIDsForBetreuer.Contains((Guid)sel.PersonenTypId))) { if (firstTeam) { ResultetObjectsToPrint.Add(new HeadLinePrint("Betreuer", "Sub") { PageBreakAllowedBefore = true, BorderPadding = new Thickness(40, 10, 0, 0) }); firstTeam = false; } TeamPersonPrint TeamPerson = new TeamPersonPrint(PersonZuTerminEntry); TeamPerson.BorderPadding = new Thickness(40, 0, 0, 0); ResultetObjectsToPrint.Add(TeamPerson); } foreach (PersonZuTermin PersonZuTerminEntry in Data.DbServer3.WordUp.PersonenZuTerminen .FindOrLoad_ActivePersonenZuTerminen(projektZuTermin.Termin.Id) .Where(sel => Data.DbServer3.WordUp.Typen.AllTypIDsForVertreter.Contains((Guid)sel.PersonenTypId))) { if (firstVertreter) { ResultetObjectsToPrint.Add(new HeadLinePrint("VertreterInnen", "Sub") { PageBreakAllowedBefore = true, BorderPadding = new Thickness(40, 10, 0, 0) }); firstVertreter = false; } VertreterPersonPrint VertreterPerson = new VertreterPersonPrint(PersonZuTerminEntry); VertreterPerson.BorderPadding = new Thickness(40, 0, 0, 0); ResultetObjectsToPrint.Add(VertreterPerson); } } if (projectEntry.Ort.Id != OldOrteID) { OldOrteID = projectEntry.Ort.Id; ResultetObjectsToPrint.AddRange(DataWrapper.Instance.CreateTreeForOrtePictures (projectEntry)); } } XAMLPrintoutDefinitions.PrintFileCards PicturePrintHandler = new XAMLPrintoutDefinitions.PrintFileCards(); return PicturePrintHandler.PrintProjektMapData(ResultetObjectsToPrint, FileName, Description); }
public List<Object> CreateTreeForTerminData(Termin TerminEntry, String SecurityGroup) { List<Object> CollectionOfClassesToPrint = new List<object>(); String TerminID = TerminEntry.Id.ToString(); TerminPrint TerminRoot = new TerminPrint(TerminEntry); CollectionOfClassesToPrint.Add(TerminRoot); bool firstTeam = true; bool firstVertreter = true; bool firstProjekt = true; foreach (PersonZuTermin PersonZuTerminEntry in Data.DbServer3.WordUp.PersonenZuTerminen .FindOrLoad_ActivePersonenZuTerminen(TerminEntry.Id) .Where(sel => Data.DbServer3.WordUp.Typen.AllTypIDsForBetreuer.Contains((Guid) sel.PersonenTypId))) { if (firstTeam) { CollectionOfClassesToPrint.Add(new HeadLinePrint("Betreuer", "Sub") {PageBreakAllowedBefore = true, BorderPadding = new Thickness(40, 10, 0, 0)}); firstTeam = false; } TeamPersonPrint TeamPerson = new TeamPersonPrint(PersonZuTerminEntry); TeamPerson.BorderPadding = new Thickness(40, 0, 0, 0); CollectionOfClassesToPrint.Add(TeamPerson); } foreach (PersonZuTermin PersonZuTerminEntry in Data.DbServer3.WordUp.PersonenZuTerminen .FindOrLoad_ActivePersonenZuTerminen(TerminEntry.Id) .Where(sel => Data.DbServer3.WordUp.Typen.AllTypIDsForVertreter.Contains((Guid)sel.PersonenTypId))) { if (firstVertreter) { CollectionOfClassesToPrint.Add(new HeadLinePrint("VertreterInnen", "Sub") {PageBreakAllowedBefore = true, BorderPadding = new Thickness(40, 10, 0, 0)}); firstVertreter = false; } VertreterPersonPrint VertreterPerson = new VertreterPersonPrint(PersonZuTerminEntry); VertreterPerson.BorderPadding = new Thickness(40, 0, 0, 0); CollectionOfClassesToPrint.Add(VertreterPerson); } foreach (ProjektZuTermin projektZuTerminEntry in Data.DbServer3.WordUp.ProjekteZuTerminen.Collection .Where(sel => sel.TermineId == TerminEntry.Id && sel.Projekt.WordUpRootId == Data.DbServer3.WordUp.WordUpIDGuid)) { if (firstProjekt) { CollectionOfClassesToPrint.Add( new HeadLinePrint("Zu behandelnde Planungen/Projekte bei diesem Termin", "Sub") { PageBreakAllowedBefore = true, BorderPadding = new Thickness(40, 10, 0, 0) }); } CreateAllForOneProjectToPrint(Basics.DataSelection.Planungen, CollectionOfClassesToPrint, projektZuTerminEntry.Projekt, ref firstProjekt, true, true, false, true, SecurityGroup); } return CollectionOfClassesToPrint; }