Esempio n. 1
0
        private async Task SendNotificationsForMembers(List <MembersWithEditionPeriodDays> membersWithNotificationRange, Project project, string subjectName)
        {
            if (membersWithNotificationRange.Any())
            {
                foreach (var memberNotifRange in membersWithNotificationRange)
                {
                    var dayOrDays = project.NotificationDay == 1 ? "day" : "days";

                    var linkToCreateTEntry = $"https://time.coral.team:1593/calendar/week;date={NotificationPeriodFirstDay.Month}-{NotificationPeriodFirstDay.Day}-{NotificationPeriodFirstDay.Year}";

                    var dateFormatShort = new GetDateFormat().GetDateFormaDotNetShortById(memberNotifRange.Member.DateFormatId);
                    //var dateRangeShort = $"{NotificationPeriodFirstDay.ToString(dateFormatShort, CultureInfo.InvariantCulture)} - {NotificationPeriodLastDay.ToString(dateFormatShort, CultureInfo.InvariantCulture)}";

                    var editionDaysFormat      = "<b>" + string.Join(", </b><b>", memberNotifRange.EditionPeriodDays.Select(x => x.ToString(dateFormatShort, CultureInfo.InvariantCulture))) + "</b>";
                    var emailSenderSimpleModel = new EmailSenderSimpleModel
                    {
                        Subject   = $"Reminder to fill time entry {memberNotifRange.Member.User.Email} by {subjectName} Settigs",
                        ToEmail   = memberNotifRange.Member.User.Email,
                        EmailText = $@"<p>Hello, {memberNotifRange.Member.FullName}!<br>
                        <p>This is a friendly reminder.
                        <p>That you haven’t filled your Time Entries on <b>{project.Name}</b> project.<br> 
                        <p>for the next last work <b>{project.NotificationDay}</b> {dayOrDays}: {editionDaysFormat}. 
                        <p><a href=""{linkToCreateTEntry}"">Would you like to enter your time now?</a><br><br>
                        <p>Best wishes, <a href=""mailto:[email protected]"">CoralTime Team!</a>"
                    };

                    await EmailSenderSimple(_configuration, emailSenderSimpleModel);
                }
            }
        }
        private Row CreateTotalHeadersRow(string value, SharedStringTablePart shareStringPart, PropertyInfo prop, Row commonEntityRow)
        {
            var cell = new Cell();

            if (prop.PropertyType == typeof(DateTime))
            {
                var dateFormat = new GetDateFormat().GetDateFormaDotNetById(DateFormatId);
                value = DateTime.Parse(value).ToString(dateFormat, CultureInfo.InvariantCulture);
            }

            value = UpdateTimeFormatForValue(prop, value);
            value = UpdateProjectNameToUpperCase(prop, value);
            value = ConcatHeaderNameWithValue(prop, value);
            if (prop.Name == InternalProperties.TimeEntryName.ToString() && GroupById == (int)Constants.ReportsGroupBy.None)
            {
                value = string.Empty;
            }

            cell = GetCellValue(shareStringPart, value, cell);

            SetCellStyleForHeaders(prop, cell);

            commonEntityRow.Append(cell);

            AddEmptyCellsBeforCellTotalActualTime(prop, commonEntityRow);

            return(commonEntityRow);
        }
Esempio n. 3
0
        private string CreateEmailTextForEmailByProjectSettings(string baseUrl, MemberWithProjecsNotifications memberWithProjecsNotifications)
        {
            var sbEmailText = new StringBuilder($"<p>Hello, {memberWithProjecsNotifications.MemberFullName}!<br><p>This is a friendly reminder, that you haven’t entered your Time Entries on ");

            if (memberWithProjecsNotifications.ProjectsWithDatesEditing.Count > 1)
            {
                sbEmailText.Append("the following projects:<br>");
            }

            var dateFormatShort = new GetDateFormat().GetDateFormaDotNetShortById(memberWithProjecsNotifications.MemberDateFormatId);

            var indexCurrentProject = 0;

            foreach (var project in memberWithProjecsNotifications.ProjectsWithDatesEditing)
            {
                var dayOrDays = project.EditionDays.EditionDays.Length > 1 ? "days" : "day";

                if (memberWithProjecsNotifications.ProjectsWithDatesEditing.Count > 1)
                {
                    sbEmailText.Append($"{++indexCurrentProject}. ");
                }

                var editionDaysFormat = string.Join(", </b><b>",
                                                    project.EditionDays.EditionDays.Select(x => x.ToString(dateFormatShort, CultureInfo.InvariantCulture)));
                var sbEditionDaysFormat = new StringBuilder($"<b>{editionDaysFormat}</b>");

                sbEmailText.Append($"<b>{project.ProjectWithDatesEditing.Name}</b> project for <b>{project.EditionDays.EditionDays.Length}</b> work{dayOrDays}: {sbEditionDaysFormat}.<br>");
            }

            sbEmailText.Append($"<p><a href=\"{baseUrl}/calendar/\">Would you like to enter your time now?</a><br><p>Best wishes, <a href=\"mailto:[email protected]\">CoralTime Team!</a>");

            return(sbEmailText.ToString());
        }
        private async Task SendNotificationsForMembers(List <Member> membersByDayOfWeekAndHours, Project project, string subjectName)
        {
            if (membersByDayOfWeekAndHours.Any())
            {
                foreach (var member in membersByDayOfWeekAndHours)
                {
                    var dayOrDays = project.NotificationDay == 1 ? "day" : "days";

                    var linkToCreateTEntry = $"https://time.coral.team:1593/calendar/week;date={NotificationPeriodFirstDay.Month}-{NotificationPeriodFirstDay.Day}-{NotificationPeriodFirstDay.Year}";
                    var linkCallBackMain   = "https://time.coral.team:1593/";

                    var dateFormatShort = new GetDateFormat().GetDateFormaDotNetShortById(member.DateFormatId);
                    var dateRangeShort  = $"{NotificationPeriodFirstDay.ToString(dateFormatShort, CultureInfo.InvariantCulture)} - {NotificationPeriodLastDay.ToString(dateFormatShort, CultureInfo.InvariantCulture)}";

                    var emailSenderSimpleModel = new EmailSenderSimpleModel
                    {
                        Subject   = $"Reminder to fill time entry {member.User.Email} by {subjectName} Settigs",
                        ToEmail   = member.User.Email,
                        EmailText = $@"<p>Hello, {member.FullName}!<br>
                        <p>This is a friendly reminder that you haven’t filled your time entries for the last work <b>{project.NotificationDay}</b> {dayOrDays}:<br>
                        <p>({dateRangeShort}) on <b>{project.Name}</b> project.<br>
                        <p>Would you like to enter your time now? <a href=""{linkToCreateTEntry}"">Just click here to open CoralTime</a><br><br>
                        <p>Best wishes, <a href=""mailto:[email protected]"">CoralTime Team!</a>"
                    };

                    await EmailSenderSimple(_configuration, emailSenderSimpleModel);
                }
            }
        }
Esempio n. 5
0
        private string GetValueForPeriodCell()
        {
            var dateFormat = new GetDateFormat().GetDateFormaDotNetById(DateFormatId);
            //value = DateTime.Parse(value).ToString(dateFormat, );
            var valueForPeriodCell = "Period: " + DateFrom.ToString(dateFormat, CultureInfo.InvariantCulture) + " - " + DateTo.ToString(dateFormat, CultureInfo.InvariantCulture);

            return(valueForPeriodCell);
        }
Esempio n. 6
0
 private string UpdateDateFormatForValue(string valueSingleFromProp, PropertyInfo prop)
 {
     if (prop.PropertyType == typeof(DateTime))
     {
         var dateFormat = new GetDateFormat().GetDateFormaDotNetById(DateFormatId);
         valueSingleFromProp = DateTime.Parse(valueSingleFromProp).ToString(dateFormat, CultureInfo.InvariantCulture);
     }
     return(valueSingleFromProp);
 }
        private string UpdateDateFormat(PropertyInfo prop, string value)
        {
            if (prop.PropertyType == typeof(DateTime))
            {
                var dateFormat = new GetDateFormat().GetDateFormaDotNetById(DateFormatId);
                value = DateTime.Parse(value).ToString(dateFormat);
            }

            return(value);
        }
        public static string UpdateDateFormat(DateTime?dateTime, int?dateFormatId)
        {
            if (dateTime != null)
            {
                var dateFormat          = new GetDateFormat().GetDateFormaDotNetById(dateFormatId ?? 0);
                var valueSingleFromProp = ((DateTime)dateTime).ToString(dateFormat, CultureInfo.InvariantCulture);

                return(valueSingleFromProp);
            }

            return(null);
        }
Esempio n. 9
0
        private PDFCell GetPeriodPDFCell()
        {
            var dateFormat = new GetDateFormat().GetDateFormaDotNetById(DateFormatId);

            var pdfCell = new PDFCell
            {
                NameDefault = "PeriodName",
                NameDisplay = "Period: ",
                Value       = DateFrom.ToString(dateFormat) + " - " + DateTo.ToString(dateFormat),
            };

            return(pdfCell);
        }
        private Row[] CreateEntityRows(IEnumerable <ReportsGridItemsView> nestedEntities, SharedStringTablePart shareStringPart)
        {
            var nestedEntityRows = new Row[nestedEntities.Count()];

            #region Nested entity rows.

            var index = 0;
            foreach (var item in nestedEntities)
            {
                var row = new Row();

                foreach (var prop in PropsEntityRows)
                {
                    if (!IsPropByDefaultGrouping(prop.Name))
                    {
                        var cell  = new Cell();
                        var value = (prop.GetValue(item, null) ?? string.Empty).ToString();

                        cell.StyleIndex = 0;

                        if (prop.PropertyType == typeof(DateTime))
                        {
                            var dateFormat = new GetDateFormat().GetDateFormaDotNetById(DateFormatId);
                            value = DateTime.Parse(value).ToString(dateFormat);
                        }

                        if (prop.Name == InternalProperties.ActualTime.ToString() ||
                            prop.Name == InternalProperties.EstimatedTime.ToString() ||
                            prop.Name == InternalProperties.TimeFrom.ToString() ||
                            prop.Name == InternalProperties.TimeTo.ToString())
                        {
                            var time = TimeSpan.FromSeconds(Int32.Parse(value));
                            value = time.ToString(@"hh\:mm");
                        }

                        if (prop.Name == InternalProperties.TotalActualTime.ToString() ||
                            prop.Name == InternalProperties.TotalEstimatedTime.ToString())
                        {
                            cell            = GetCellValue(shareStringPart, value, cell);
                            cell.StyleIndex = 5;
                        }
                        else if (prop.Name == InternalProperties.TaskName.ToString() ||
                                 prop.Name == InternalProperties.Description.ToString())
                        {
                            cell            = GetCellValue(shareStringPart, value, cell);
                            cell.StyleIndex = 6;
                        }
                        else
                        {
                            cell = GetCellValue(shareStringPart, value, cell);
                        }

                        row.Append(cell);
                    }
                }

                nestedEntityRows[index++] = row;
            }

            #endregion

            return(nestedEntityRows);
        }
Esempio n. 11
0
        private Row[] CreateRowsEntityValues(IEnumerable <ReportsGridItemsView> valueListFromProp, SharedStringTablePart shareStringPart)
        {
            var rowsEntityValues = new Row[valueListFromProp.Count()];

            var index = 0;

            foreach (var item in valueListFromProp)
            {
                var row = new Row();

                foreach (var prop in PropsEntityHeadersAndRows)
                {
                    if (!IsPropByDefaultGrouping(prop.Name))
                    {
                        var cell  = new Cell();
                        var value = (prop.GetValue(item, null) ?? string.Empty).ToString();

                        cell.StyleIndex = 1;

                        if (prop.PropertyType == typeof(DateTime))
                        {
                            var dateFormat = new GetDateFormat().GetDateFormaDotNetById(DateFormatId);
                            value = DateTime.Parse(value).ToString(dateFormat, CultureInfo.InvariantCulture);
                        }

                        if (prop.Name == InternalProperties.ActualTime.ToString() ||
                            prop.Name == InternalProperties.EstimatedTime.ToString() ||
                            prop.Name == InternalProperties.TimeFrom.ToString() ||
                            prop.Name == InternalProperties.TimeTo.ToString())
                        {
                            var time = TimeSpan.FromSeconds(Int32.Parse(value));
                            if (time.TotalHours == 0)
                            {
                                value = string.Empty;
                            }
                            else
                            {
                                value = time.ToString(@"hh\:mm");
                            }
                        }

                        if (prop.Name == InternalProperties.TotalActualTime.ToString() ||
                            prop.Name == InternalProperties.TotalEstimatedTime.ToString())
                        {
                            cell            = GetCellValue(shareStringPart, value, cell);
                            cell.StyleIndex = 6;
                        }

                        if (prop.Name == InternalProperties.TaskName.ToString() ||
                            prop.Name == InternalProperties.Description.ToString())
                        {
                            cell            = GetCellValue(shareStringPart, value, cell);
                            cell.StyleIndex = 5;
                        }
                        else
                        {
                            cell = GetCellValue(shareStringPart, value, cell);
                        }

                        row.Append(cell);
                    }

                    row.Append(new Row());
                }

                rowsEntityValues[index++] = row;
            }

            return(rowsEntityValues);
        }