/// <summary>
/// Send E-Mails to Colleagues regarding open vacation days
/// </summary>
        private void OnVacationLiability()
        {
            DateTime reportDate = timeFunctions.MonthEnd(timeFunctions.MonthEnd(MonthlySalaryDate));


            CreateEmployeeSalaryOverview    salaryOverview  = new CreateEmployeeSalaryOverview(null, new DateTime(reportDate.Year, 1, 1), reportDate);
            List <EmployeesMonthlyPayments> monthlyPayments = salaryOverview.GetMonthlyPayments(reportDate.Month);

            foreach (EmployeesMonthlyPayments payment in monthlyPayments)
            {
                EmployeesForTravelExpenses employee = dbAccess.FindEmployeeById(payment.EmployeeForTravelExpensesId);
                if (employee == null)
                {
                    continue;
                }
                EmployeePaymentDetail salarydetail = dbAccess.GetLatestSalary(payment.EmployeeForTravelExpensesId);

                // do not send emails to people whos contract expire
                if (salarydetail.LastPayment != null && salarydetail.LastPayment == reportDate)
                {
                    continue;
                }

                // Send Email

                SendEmailClass sendEmail = new SendEmailClass();
                sendEmail.Subject   = "Urlaub / Vacation ";
                sendEmail.ToAddress = employee.EmailAddress;

                StringBuilder germanText = new StringBuilder();
                germanText.Append($"Liebe(r) {employee.FirstName},{Environment.NewLine}{Environment.NewLine}");
                germanText.Append("Wie einmal im Jahr üblich, bitte ich dich mir mitzuteilen, wieviele Urlaubstage zum Jahresende noch offen sein werden. Falls du deinen kompletten Urlaub genommen hast, kannst du diese E-Mail ignorieren." + Environment.NewLine + Environment.NewLine);
                germanText.Append($"Solltest du im Laufe des Jahres {reportDate.Year} bei QuantCo angefangen haben, errechnen sich die Urlaubstage nach der Formel 28 / 12 * Anzahl Monate bei QuantCo (Ergebnis bitte aufrunden).");
                germanText.Append(Environment.NewLine + Environment.NewLine + "Vielen Dank für deine Unterstützung." + Environment.NewLine + Environment.NewLine);
                StringBuilder englishText = new StringBuilder();
                englishText.Append($"Dear {employee.FirstName},{Environment.NewLine}{Environment.NewLine}");
                englishText.Append("As usual once a year, I would like to ask you to tell me how many vacation days are left for this calendar year. Should you have taken all your vacation you can ignore this email." + Environment.NewLine + Environment.NewLine);
                englishText.Append($"In case you have joined QuantCo in {reportDate.Year} you can calculate the number of vacation days using the formula: 28 / 12 * number of months with QuantCo (result can be rounded up).");
                englishText.Append(Environment.NewLine + Environment.NewLine + "Thank you for your support." + Environment.NewLine + Environment.NewLine);

                sendEmail.Body = $"{germanText.ToString()}{englishText.ToString()}" +
                                 $"{System.Environment.NewLine} {System.Environment.NewLine} Mit freundlichen Grüßen / Best regards {System.Environment.NewLine} {System.Environment.NewLine} Franz";

                bool success = true;

                if (employee.FirstName.Contains("Sabrina") || employee.FirstName.Contains("Franz"))
                {
                    success = sendEmail.SendEmailToServer();
                }

                if (!success)
                {
                    NotificationRequest.Raise(new Notification()
                    {
                        Title   = "QuantCo Deutschland GmbH",
                        Content = $"Das Email an {sendEmail.ToAddress} konnte nicht gesendet werden"
                    });
                }
            }
        }
        public override void OnNavigatedTo(NavigationContext navigationContext)
        {
            base.OnNavigatedTo(navigationContext);

            // run CreateEmployeeSalaryOverview
            DateTime startDate = new DateTime(DateTime.Now.Year, 1, 1);
            DateTime endDate   = new DateTime(DateTime.Now.Year, 12, 31);

            createOverView = new CreateEmployeeSalaryOverview(null, startDate, endDate);

            StartButtonContent = $"Datei erstellen";
        }
        private void OnStartOverview()
        {
            // set PeriodTo to end of Month

            PeriodTo = dateFunctions.MonthEnd(PeriodTo);
            CreateEmployeeSalaryOverview createOverview = new CreateEmployeeSalaryOverview(null, PeriodFrom.Date, PeriodTo.Date);

            overviews = createOverview.GetSalaryOverview();

            if (SortByOffice)
            {
                overviews = overviews.OrderBy(s => s.OfficeLocation).ThenBy(s => s.EmployeeName).ToList();
            }



            // create JsonFile
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            settings.MissingMemberHandling = MissingMemberHandling.Ignore;

            string jsonContent = JsonConvert.SerializeObject(overviews, settings);

            string jsonfile = $"C:\\Users\\Public\\Documents\\Json.json";

            System.IO.File.WriteAllText(jsonfile, jsonContent);

            //TypeReportSource source = new TypeReportSource();
            //source.TypeName = typeof(AccountingHelper.Reporting.AnnualSalarySummary).AssemblyQualifiedName;
            //source.Parameters.Add("Source", jsonfile);
            //source.Parameters.Add("DataSelector", string.Empty);

            //ViewerParameter parameter = new ViewerParameter();
            //parameter.typeReportSource = source;

            //eventAggregator.GetEvent<ViewerParameterEvent>().Publish(parameter);

            var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            // set any deviceInfo settings if necessary
            var deviceInfo = new System.Collections.Hashtable();


            var reportSource = new Telerik.Reporting.TypeReportSource();

            // reportName is the Assembly Qualified Name of the report
            reportSource.TypeName = typeof(AccountingHelper.Reporting.AnnualSalarySummary).AssemblyQualifiedName;


            // Pass parameter value with the Report Source if necessary
            reportSource.Parameters.Add("Source", jsonfile);
            reportSource.Parameters.Add("DataSelector", string.Empty);

            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);
            jsonfile = jsonfile.Replace(".json", ".pdf");


            using (System.IO.FileStream fs = new System.IO.FileStream(jsonfile, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }

            SelectedFilename = jsonfile;

            result = reportProcessor.RenderReport("XLSX", reportSource, deviceInfo);
            string excelFileName = $"C:\\Users\\Public\\Documents\\gehaltsuebersicht.xlsx";

            using (System.IO.FileStream fs = new System.IO.FileStream(excelFileName, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }
        }
        private void OnPayrollCost()
        {
            //TypeReportSource source = new TypeReportSource();
            //source.TypeName = typeof(AccountingHelper.Reporting.MonthlySalary).AssemblyQualifiedName;

            //source.Parameters.Add("EndDate", reportDate);
            //source.Parameters.Add("StartDate", new DateTime(reportDate.Year, reportDate.Month, 1));
            //source.Parameters.Add("MonthYear", $"{reportDate: MMMM yyyy}");


            // new Version of MonthlySalary
            DateTime reportDate = timeFunctions.MonthEnd(timeFunctions.MonthEnd(MonthlySalaryDate));

            CreateEmployeeSalaryOverview    salaryOverview  = new CreateEmployeeSalaryOverview(null, new DateTime(reportDate.Year, 1, 1), reportDate);
            List <EmployeesMonthlyPayments> monthlyPayments = salaryOverview.GetMonthlyPayments(reportDate.Month);

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            settings.MissingMemberHandling = MissingMemberHandling.Ignore;

            string jsonContent = JsonConvert.SerializeObject(monthlyPayments, settings);

            string jsonfile = $"C:\\Users\\Public\\Documents\\MonthlyOverview.json";

            System.IO.File.WriteAllText(jsonfile, jsonContent);
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

            // set any deviceInfo settings if necessary
            var deviceInfo = new System.Collections.Hashtable();


            var reportSource = new Telerik.Reporting.TypeReportSource();

            // reportName is the Assembly Qualified Name of the report
            reportSource.TypeName = typeof(AccountingHelper.Reporting.MonthlySalaryOverview).AssemblyQualifiedName;


            // Pass parameter value with the Report Source if necessary
            reportSource.Parameters.Add("Source", jsonfile);
            reportSource.Parameters.Add("DataSelector", string.Empty);

            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("XLSX", reportSource, deviceInfo);

            string xlsxFile = jsonfile.Replace("json", "xlsx");

            using (System.IO.FileStream fs = new System.IO.FileStream(xlsxFile, System.IO.FileMode.Create))
            {
                fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            }

            ConfirmationRequest.Raise(new Confirmation()
            {
                Content = $"Es wurde eine Excel-Datei ({xlsxFile}) erstellt" + Environment.NewLine + Environment.NewLine + "Soll die Excel-Datei als E-Mail verschickt werden?",
                Title   = "QuantCo Deutschland GmbH"
            }, response =>
            {
                if (response.Confirmed)
                {
                    // send E-mail to Property 'CEOto'
                    SendEmailToCEO(xlsxFile);
                }
            });

            ViewerParameter parameter = new ViewerParameter()
            {
                typeReportSource = reportSource
            };

            eventAggregator.GetEvent <ViewerParameterEvent>().Publish(parameter);
        }