Beispiel #1
0
        public void ReCalculate()
        {
            if (_newRow != null)
                return;
            // Calculate Totals by Activity and Day

            // Show header row of totals

            List<dev1_session> sessionData = Sessions.GetCurrentWeek();
            DateTime weekStart = Sessions.WeekStart;

            days = new Dictionary<string,DayEntry>();
            totals = new DayEntry();
            totals.isTotalRow = true;
            totals.ActivityName = "Total";
            totals.Activity = new EntityReference(null,null,null);
            totals.Activity.Name = "Total";

           

            foreach (dev1_session session in sessionData)
            {
                // Accumulate hours by Activity
                if (session.dev1_StartTime == null)
                    continue;
                int dayOfWeek = session.dev1_StartTime.GetDay()-OrganizationServiceProxy.OrganizationSettings.WeekStartDayCode.Value.Value;
                if (dayOfWeek < 0) dayOfWeek = 7 + dayOfWeek;
                string activity = session.dev1_ActivityId;

                if (days[activity] == null)
                {
                    DayEntry day = new DayEntry();
                    days[activity] = day;
                    day.Activity = new EntityReference(new Guid(session.dev1_ActivityId),null,null);
                    day.Activity.Name = session.activitypointer_subject;
                    day.RegardingObjectId = session.activitypointer_regardingobjectid;
                    
                    // Set the account name 
                    if (session.Account != null && day.Account == null)
                        day.Account = session.Account;

                    day.Activity.LogicalName = session.dev1_ActivityTypeName;
 
                }

                if (session.dev1_Duration != null)
                {
                    if (days[activity].Hours[dayOfWeek] == null)
                        days[activity].Hours[dayOfWeek] = 0;

                    days[activity].Hours[dayOfWeek] = days[activity].Hours[dayOfWeek] + session.dev1_Duration;

                    // Accumulate total hours
                    if (totals.Hours[dayOfWeek] == null)
                        totals.Hours[dayOfWeek] = 0;

                    totals.Hours[dayOfWeek] = totals.Hours[dayOfWeek] + session.dev1_Duration;
                }
            }

            // Flattern
            rows.Clear();
            rows.Add(totals);
            foreach (KeyValuePair<string,DayEntry> day in days)
            {
                day.Value.FlatternDays();
                rows.Add(day.Value);
            }
            totals.FlatternDays();

            SortData();
            Refresh();
        }
        public void ReCalculate()
        {
            // Calculate Totals by Activity and Day

            // Show header row of totals

            List<dev1_session> sessionData = sessions.GetCurrentWeek();
            DateTime weekStart = sessions.WeekStart;

            days = new Dictionary<string,DayEntry>();
            totals = new DayEntry();
            totals.isTotalRow = true;
            totals.ActivityName = "Total";
            totals.Activity = new EntityReference(null,null,null);
            totals.Activity.Name = "Total";
            foreach (dev1_session session in sessionData)
            {
                // Accumulate hours by Activity
                int dayOfWeek = session.dev1_StartTime.GetDay();
                string activity = session.dev1_ActivityId;

                if (days[activity] == null)
                {
                    DayEntry day = new DayEntry();
                    days[activity] = day;
                    day.Activity = new EntityReference(new Guid(session.dev1_ActivityId),null,null);

                    if (session.dev1_TaskId != null)
                        day.Activity.Name = session.dev1_TaskId.Name;
                    else if (session.dev1_LetterId !=null)
                        day.Activity.Name = session.dev1_LetterId.Name;
                    else if (session.dev1_EmailId !=null)
                        day.Activity.Name = session.dev1_EmailId.Name;
                    else if (session.dev1_PhoneCallId != null)
                        day.Activity.Name = session.dev1_PhoneCallId.Name;

                    day.Activity.LogicalName = session.dev1_ActivityTypeName;

                }

                if (session.dev1_Duration != null)
                {
                    if (days[activity].Hours[dayOfWeek] == null)
                        days[activity].Hours[dayOfWeek] = 0;

                    days[activity].Hours[dayOfWeek] = days[activity].Hours[dayOfWeek] + session.dev1_Duration;

                    // Accumulate total hours
                    if (totals.Hours[dayOfWeek] == null)
                        totals.Hours[dayOfWeek] = 0;

                    totals.Hours[dayOfWeek] = totals.Hours[dayOfWeek] + session.dev1_Duration;
                }
            }

            // Flattern
            rows.Clear();
            rows.Add(totals);
            foreach (KeyValuePair<string,DayEntry> day in days)
            {
                day.Value.FlatternDays();
                rows.Add(day.Value);
            }
            totals.FlatternDays();

            Refresh();
        }
Beispiel #3
0
        public void ReCalculate()
        {
            // Calculate Totals by Activity and Day

            // Show header row of totals

            List <dev1_session> sessionData = sessions.GetCurrentWeek();
            DateTime            weekStart   = sessions.WeekStart;

            days                 = new Dictionary <string, DayEntry>();
            totals               = new DayEntry();
            totals.isTotalRow    = true;
            totals.ActivityName  = "Total";
            totals.Activity      = new EntityReference(null, null, null);
            totals.Activity.Name = "Total";
            foreach (dev1_session session in sessionData)
            {
                // Accumulate hours by Activity
                int    dayOfWeek = session.dev1_StartTime.GetDay();
                string activity  = session.dev1_ActivityId;

                if (days[activity] == null)
                {
                    DayEntry day = new DayEntry();
                    days[activity] = day;
                    day.Activity   = new EntityReference(new Guid(session.dev1_ActivityId), null, null);



                    if (session.dev1_TaskId != null)
                    {
                        day.Activity.Name = session.dev1_TaskId.Name;
                    }
                    else if (session.dev1_LetterId != null)
                    {
                        day.Activity.Name = session.dev1_LetterId.Name;
                    }
                    else if (session.dev1_EmailId != null)
                    {
                        day.Activity.Name = session.dev1_EmailId.Name;
                    }
                    else if (session.dev1_PhoneCallId != null)
                    {
                        day.Activity.Name = session.dev1_PhoneCallId.Name;
                    }

                    day.Activity.LogicalName = session.dev1_ActivityTypeName;
                }

                if (session.dev1_Duration != null)
                {
                    if (days[activity].Hours[dayOfWeek] == null)
                    {
                        days[activity].Hours[dayOfWeek] = 0;
                    }

                    days[activity].Hours[dayOfWeek] = days[activity].Hours[dayOfWeek] + session.dev1_Duration;

                    // Accumulate total hours
                    if (totals.Hours[dayOfWeek] == null)
                    {
                        totals.Hours[dayOfWeek] = 0;
                    }

                    totals.Hours[dayOfWeek] = totals.Hours[dayOfWeek] + session.dev1_Duration;
                }
            }

            // Flattern
            rows.Clear();
            rows.Add(totals);
            foreach (KeyValuePair <string, DayEntry> day in days)
            {
                day.Value.FlatternDays();
                rows.Add(day.Value);
            }
            totals.FlatternDays();


            Refresh();
        }
        public void ReCalculate()
        {
            if (_newRow != null)
            {
                return;
            }
            // Calculate Totals by Activity and Day

            // Show header row of totals

            List <dev1_session> sessionData = Sessions.GetCurrentWeek();
            DateTime            weekStart   = Sessions.WeekStart;

            days                 = new Dictionary <string, DayEntry>();
            totals               = new DayEntry();
            totals.isTotalRow    = true;
            totals.ActivityName  = "Total";
            totals.Activity      = new EntityReference(null, null, null);
            totals.Activity.Name = "Total";



            foreach (dev1_session session in sessionData)
            {
                // Accumulate hours by Activity
                if (session.dev1_StartTime == null)
                {
                    continue;
                }
                int dayOfWeek = session.dev1_StartTime.GetDay() - OrganizationServiceProxy.OrganizationSettings.WeekStartDayCode.Value.Value;
                if (dayOfWeek < 0)
                {
                    dayOfWeek = 7 + dayOfWeek;
                }
                string activity = session.dev1_ActivityId;

                if (days[activity] == null)
                {
                    DayEntry day = new DayEntry();
                    days[activity]        = day;
                    day.Activity          = new EntityReference(new Guid(session.dev1_ActivityId), null, null);
                    day.Activity.Name     = session.activitypointer_subject;
                    day.RegardingObjectId = session.activitypointer_regardingobjectid;

                    // Set the account name
                    if (session.Account != null && day.Account == null)
                    {
                        day.Account = session.Account;
                    }

                    day.Activity.LogicalName = session.dev1_ActivityTypeName;
                }

                if (session.dev1_Duration != null)
                {
                    if (days[activity].Hours[dayOfWeek] == null)
                    {
                        days[activity].Hours[dayOfWeek] = 0;
                    }

                    days[activity].Hours[dayOfWeek] = days[activity].Hours[dayOfWeek] + session.dev1_Duration;

                    // Accumulate total hours
                    if (totals.Hours[dayOfWeek] == null)
                    {
                        totals.Hours[dayOfWeek] = 0;
                    }

                    totals.Hours[dayOfWeek] = totals.Hours[dayOfWeek] + session.dev1_Duration;
                }
            }

            // Flattern
            rows.Clear();
            rows.Add(totals);
            foreach (KeyValuePair <string, DayEntry> day in days)
            {
                day.Value.FlatternDays();
                rows.Add(day.Value);
            }
            totals.FlatternDays();

            SortData();
            Refresh();
        }