public SuiteCRMViewModel Convert(project project)
 {
     return(new SuiteCRMViewModel
     {
         Id = project.id,
         Name = project.name,
         Description = project.description,
         CreationDateTime = project.date_entered.HasValue ? (DateTime?)CRMHelper.SetSiteTimeZone(this.services, project.date_entered.Value) : null,
         ModifiedDateTime = project.date_modified.HasValue ? (DateTime?)CRMHelper.SetSiteTimeZone(this.services, project.date_modified.Value) : null,
     });
 }
        private CommentsViewModel.CRMCommentViewModel Convert(CRMCommentPartRecord record, IEnumerable <IUser> users)
        {
            var output = new CommentsViewModel.CRMCommentViewModel
            {
                IsEmail        = record.IsEmail,
                Subject        = record.Subject,
                BCC            = record.BCC,
                CC             = record.CC,
                CommentDateUtc = record.CommentDateUtc,
                CommentText    = record.CommentText,
                IsHtml         = record.IsHtml,
                User           = users.FirstOrDefault(c => c.Id == record.User.Id)
            };

            if (output.CommentDateUtc.HasValue && output.CommentDateUtc.Value.Kind == DateTimeKind.Utc)
            {
                output.CommentDateUtc = CRMHelper.SetSiteTimeZone(services, output.CommentDateUtc.Value);
            }

            return(output);
        }
Exemple #3
0
        protected void FillStatusTimes(TicketViewModel model, TicketPart part, IEnumerable <StatusRecordViewModel> statusRecords)
        {
            CommonPart commonPart = part.As <CommonPart>();
            List <KeyValuePair <int, DateTime> > output = new List <KeyValuePair <int, DateTime> >();

            // creation time
            if (commonPart != null && commonPart.CreatedUtc.HasValue)
            {
                output.Add(new KeyValuePair <int, DateTime>(StatusRecord.NewStatus, CRMHelper.SetSiteTimeZone(this.orchardServices.WorkContext, commonPart.CreatedUtc.Value)));
            }

            var statusTimes = part.StatusTimes;

            foreach (var item in statusTimes)
            {
                var statusRecord = statusRecords.FirstOrDefault(c => c.Id == item.Key);
                if (statusRecord == null)
                {
                    continue;
                }

                int?statusTypeId = statusRecord.StatusTypeId.HasValue?
                                   statusRecord.StatusTypeId.Value:
                                   statusRecords
                                   .Where(c => c.OrderId <= statusRecord.OrderId && c.StatusTypeId.HasValue)
                                   .Select(c => c.StatusTypeId)
                                   .OrderByDescending(c => c)
                                   .FirstOrDefault();

                statusTypeId = statusTypeId ?? StatusRecord.NewStatus;
                output.Add(new KeyValuePair <int, DateTime>(statusTypeId.Value, CRMHelper.SetSiteTimeZone(this.orchardServices.WorkContext, item.Value)));
            }

            model.StatusTimes.Clear();
            model.StatusTimes.AddRange(output.OrderBy(c => c.Value));
        }
Exemple #4
0
        protected DriverResult GanttChartDisplay(MilestonePart part, dynamic shapeHelper)
        {
            List <DriverResult> shapes = new List <DriverResult>();

            EditMilestoneViewModel model = this.Convert(part);

            shapes.Add(ContentShape("Parts_Milestone_Data", () => shapeHelper.Parts_Milestone_Data(Model: model)));

            var memberShapes = this.GetMilestoneMembers(part.Id, "GanttChart", false).ToList();

            memberShapes.ForEach(c =>
            {
                ContentItem contentItem = c.ContentItem;
                TicketPart ticket       = contentItem.As <TicketPart>();
                c.StatusId = ticket.Record.StatusRecord != null ? (int?)ticket.Record.StatusRecord.Id : null;
            });

            dynamic ticketsModel = new ExpandoObject();

            ticketsModel.Milestone = model;

            List <dynamic> months = new List <dynamic>();

            List <DateTime> daysInDateTime = new List <DateTime>();

            // List of days in milestone
            if (model.Start.HasValue && model.End.HasValue && model.Start.Value < model.End.Value)
            {
                for (var day = model.Start.Value.Date; day <= model.End.Value.Date; day = day.AddDays(1))
                {
                    daysInDateTime.Add(CRMHelper.SetSiteTimeZone(this.services.WorkContext, day));
                }
            }

            var monthNames = new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };

            var monthsInDayTime = daysInDateTime.GroupBy(c => new { c.Year, c.Month });

            foreach (var item in monthsInDayTime)
            {
                List <string> days  = new List <string>();
                dynamic       month = new ExpandoObject();
                month.Month = item.Key.Month;
                month.Year  = item.Key.Year;
                month.Name  = T(monthNames[item.Key.Month - 1]).Text;
                months.Add(month);

                foreach (var day in item)
                {
                    daysInDateTime.Add(day);
                    days.Add(day.ToString("yyyy-MM-dd"));
                }

                month.Days = days;
            }

            ticketsModel.Months = months;
            ticketsModel.Items  = memberShapes;
            ticketsModel.Today  = CRMHelper.SetSiteTimeZone(this.services.WorkContext, DateTime.UtcNow).ToString("yyyy-MM-dd");

            // we want to represent the tickets in a table where there is a column for each status.
            var statusRecords = this.basicDataService.GetStatusRecords().ToList();

            statusRecords.Insert(0, new StatusRecord {
                Id = 0, OrderId = 0, Name = T("No Status").Text
            });
            ticketsModel.StatusRecords = statusRecords;

            shapes.Add(ContentShape("Parts_Milestone_GanttChart", () => shapeHelper.Parts_Milestone_GanttChart(Model: JsonConvert.SerializeObject(ticketsModel))));

            return(this.Combined(shapes.ToArray()));
        }