Beispiel #1
0
        public void CalendarItem_GetCalendarItem_InCache()
        {
            CalendarItem cachedItem = new CalendarItem();

            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                recorder.ExpectAndReturn(CalendarItem.Cache.ContainsKey(null), true);
                recorder.ExpectAndReturn(CalendarItem.Cache[null], cachedItem);
            }

            CalendarItem item = CalendarItem.GetCalendarItem(new DateTime(2008, 10, 6));
            Assert.AreSame(cachedItem, item);
        }
Beispiel #2
0
        /// <summary>
        /// Write date to container with style.
        /// </summary>
        /// <param name="writer">HtmlTextWriter.</param>
        /// <param name="dwt">Date.</param>
        /// <param name="Container">HtmlContainer.</param>
        /// <param name="fWriteTime">Write date(false) or time(true).</param>
        /// <param name="UserID">ID of user.</param>
        private void WriteDataTime(HtmlTextWriter writer,
            DayWorkTime dwt,
            String Container,
            bool fWriteTime,
            int? UserID)
        {
            CalendarItem calItem = new CalendarItem(dwt);
            String strValue = fWriteTime
                                  ? DateTimePresenter.GetTime(dwt.WorkTime)
                                  : dwt.Date.ToString("dd/MM");

            Color cellColor = new Color();
               if (UserID != null
                && dwt.WorkTime == TimeSpan.Zero
                && !calItem.IsWeekend)
            {
                WorkEvent workEvent = WorkEvent.GetCurrentEventOfDate((int) UserID, dwt.Date);

                if (workEvent != null)
                    switch (workEvent.EventType)
                    {
                        case WorkEventType.BusinessTrip:
                            strValue = "Trip";
                            cellColor = Color.LightSlateGray;
                            break;

                        case WorkEventType.Ill:
                            strValue = "Ill";
                            cellColor = Color.LightPink;
                            break;

                        case WorkEventType.TrustIll:
                            strValue = "Trust Ill";
                            cellColor = Color.LightPink;
                            break;

                        case WorkEventType.Vacation:
                            strValue = "Vacation";
                            cellColor = Color.LightYellow;
                            break;
                    }
            }

            if (calItem.IsWeekend)
                writer.WriteLine("<{0} class='weekend'>{1}</{0}>",
                                 Container,
                                 strValue);
            else
                writer.WriteLine("<{0} style='background-color: {1};' align='center'>{2}</{0}>",
                                 Container,
                                 cellColor.ToKnownColor(),
                                 strValue);
        }
Beispiel #3
0
        /// <summary>
        /// Returns calendar item for given date.
        /// </summary>
        /// <param name="date">Date.</param>
        /// <returns>Calendar item for given date.</returns>
        public static CalendarItem GetCalendarItem(DateTime date)
        {
            string key = GetCacheDateKey(date);

            if (Cache.ContainsKey(key))
            {
                return Cache[key];
            }
            else
            {
                CalendarDetails details = SiteProvider.Calendar.GetCalendarDetails(date);
                CalendarItem item = new CalendarItem();
                item.Date = date.Date;
                if ((date.DayOfWeek == DayOfWeek.Saturday) || (date.DayOfWeek == DayOfWeek.Sunday))
                { item.WorkTime = TimeSpan.Zero; }
                else
                { item.WorkTime = Globals.Settings.WorkTime.DefaultWorkTime; }
                if (details != null)
                {
                    item.m_ID = details.ID;
                    item.m_Date = details.Date;
                    item.m_WorkTime = details.WorkTime.TimeOfDay;
                    item.m_Comment = details.Comment;
                }
                Cache[key] = item;
                return item;
            }
        }
Beispiel #4
0
        private void FillInternalTable(HtmlTextWriter writer, PeriodOfficeStatistics officeStatistics)
        {
            for (var i = 0; i < officeStatistics.UserStatistics.Length; i++)
            {
                var userStatistic = officeStatistics.UserStatistics[i];
                if (i%2 == 0)
                    writer.WriteLine("<tr class='gridview-row'>");
                else
                    writer.WriteLine("<tr class='gridview-alternatingrow'>");

                foreach (var dayWorkTime in userStatistic.DayWorkTimes)
                {
                    var calendarItem = new CalendarItem(dayWorkTime);
                    var contentValue = DateTimePresenter.GetTime(dayWorkTime.WorkTime);

                    var cellColor = new Color();
                    if (dayWorkTime.WorkTime == TimeSpan.Zero && !calendarItem.IsWeekend)
                    {
                        WorkEvent workEvent = WorkEvent.GetCurrentEventOfDate((int) userStatistic.User.ID, dayWorkTime.Date);

                        if (workEvent != null)
                            switch (workEvent.EventType)
                            {
                                case WorkEventType.BusinessTrip:
                                    contentValue = "Trip";
                                    cellColor = Color.LightSlateGray;
                                    break;

                                case WorkEventType.Ill:
                                    contentValue = "Ill";
                                    cellColor = Color.LightPink;
                                    break;

                                case WorkEventType.TrustIll:
                                    contentValue = "Trust Ill";
                                    cellColor = Color.LightPink;
                                    break;

                                case WorkEventType.Vacation:
                                    contentValue = "Vacation";
                                    cellColor = Color.LightYellow;
                                    break;
                            }
                    }

                    if (calendarItem.IsWeekend)
                        writer.WriteLine("<td class='weekend statistic-table-internal-td'>{0}</td>", contentValue);
                    else
                        writer.WriteLine(
                            "<td class='statistic-table-internal-td' style='background-color: {0};' align='center'>{1}</td>",
                            cellColor.ToKnownColor(),
                            contentValue);
                }

                writer.WriteLine("<td class='statistic-table-internal-td'>{0}</td>",
                    DateTimePresenter.GetTime(userStatistic.TotalWorkTime));
                writer.WriteLine("<td class='statistic-table-internal-td'>{0}</td>",
                    DateTimePresenter.GetTime(userStatistic.RateTime));
                writer.WriteLine("<td class='statistic-table-internal-td'>{0}</td>",
                    DateTimePresenter.GetTime(userStatistic.RateTime - userStatistic.TotalWorkTime));
                writer.WriteLine("<td class='statistic-table-internal-td'>{0}</td>", GetDomainNameByUserStatistic(userStatistic));
                writer.WriteLine("</tr>");
            }
        }
Beispiel #5
0
        private void FillHeaderItems(HtmlTextWriter writer, PeriodOfficeStatistics officeStatistics)
        {
            foreach (var dayWorkTime in officeStatistics.UserStatistics[0].DayWorkTimes)
            {
                var calendarItem = new CalendarItem(dayWorkTime);
                var contentValue = dayWorkTime.Date.ToString("dd/MM");

                if (calendarItem.IsWeekend)
                    writer.WriteLine("<th class='weekend statistic-table-internal-th'>{0}</th>", contentValue);
                else
                    writer.WriteLine("<th class='statistic-table-internal-th'>{0}</th>", contentValue);
            }

            writer.WriteLine("<th class='statistic-table-internal-th'>{0}</th>", Resources.Strings.TotalTime);
            writer.WriteLine("<th class='statistic-table-internal-th'>{0}</th>", Resources.Strings.RateTime);
            writer.WriteLine("<th class='statistic-table-internal-th'>{0}</th>", Resources.Strings.DiffTime);
            writer.WriteLine("<th class='statistic-table-internal-th'>{0}</th>", Resources.Strings.DomainName);
        }