示例#1
0
        public static byte[] Render(bool vastScale,
                                    DateTime curDate,
                                    DateTime startDate,
                                    int[] users,
                                    ObjectTypes[] objectTypes,
                                    List <KeyValuePair <int, int> > highlightedItems,
                                    bool generateDataXml,
                                    string styleFilePath,
                                    int portionX,
                                    int portionY,
                                    int itemsPerPage,
                                    int pageNumber)
        {
            startDate = startDate.AddDays((vastScale ? 7 : 21) * portionX);
            DateTime finishDate = startDate.AddDays(vastScale ? 7 : 21);

            portionX = 0;

            GanttView gantt = CreateGanttView(startDate, vastScale, ConvertDayOfWeek(PortalConfig.PortalFirstDayOfWeek), HeaderItemHeight, ItemHeight);

            if (portionY >= 0)
            {
                #region Add data
                foreach (int userId in users)
                {
                    Element spanElement = gantt.CreateSpanElement(null, null, null);

                    DataTable table = Calendar.GetResourceUtilization(userId, curDate, startDate, finishDate, new ArrayList(objectTypes), highlightedItems, true, true, true, false);
                    table.AcceptChanges();

                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        DataRow row = table.Rows[i];

                        if (row.RowState != DataRowState.Deleted)
                        {
                            DateTime          intervalStart  = (DateTime)row["Start"];
                            DateTime          intervalFinish = ((DateTime)row["Finish"]);
                            Calendar.TimeType timeType       = (Calendar.TimeType)row["Type"];
                            bool highlight = (bool)row["Highlight"];

                            gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, timeType.ToString(), null);
                            if (highlight)
                            {
                                gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, "Highlight", null);
                            }
                        }
                    }
                }

                #endregion
            }

            return(GanttManager.Render(gantt, generateDataXml, styleFilePath, portionX, portionY, PortionWidth, users.Length * ItemHeight, itemsPerPage, pageNumber));
        }
示例#2
0
        private static Element AddInterval2(GanttView gantt, Element parent, DateTime?start, DateTime?finish, string id, string type, string tag)
        {
            Element child = null;

            if (start != null && finish != null)
            {
                child = gantt.CreateIntervalElement(parent, start.Value, finish.Value, id, type, tag);
                if (type == "Summary")
                {
                    gantt.CreatePointElement(child, start.Value, null, type + "Start", tag);
                    gantt.CreatePointElement(child, finish.Value, null, type + "Finish", tag);
                }
            }
            else
            {
                if (start != null)
                {
                    child = gantt.CreatePointElement(parent, start.Value, id, type + "Start", tag);
                }
                if (finish != null)
                {
                    child = gantt.CreatePointElement(parent, finish.Value, id, type + "Finish", tag);
                }
            }

            return(child);
        }
示例#3
0
        public static byte[] RenderLegendItem(string styleFilePath, string type)
        {
            byte[] ret = null;

            DateTime  startDate = DateTime.Now.Date;
            GanttView gantt     = CreateGanttView(startDate, false, DayOfWeek.Monday, 0, ItemHeight);

            Element spanElement = gantt.CreateSpanElement(null, null, null);

            DateTime intervalStart  = startDate.AddHours(12);
            DateTime intervalFinish = intervalStart.AddDays(2);

            gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, type, null);

            #region Render

            using (MemoryStream stream = new MemoryStream())
            {
                gantt.LoadStyleSheetFromFile(styleFilePath);
                gantt.ApplyStyleSheet();

                gantt.RenderPortion(new Point(0, 0), new Size(24 * 3, Convert.ToInt32(ItemHeight)), 0, 0, ImageFormat.Png, stream);

                ret = stream.ToArray();
            }

            #endregion

            return(ret);
        }
示例#4
0
        public static byte[] RenderLegendItem(string styleFilePath, GanttItem item, bool completed)
        {
            byte[] ret = null;

            DateTime  startDate = DateTime.Now.Date;
            GanttView gantt     = CreateGanttView(startDate, DayOfWeek.Monday, 0, ItemHeight);

            Element spanElement = gantt.CreateSpanElement(null, null, null);

            DateTime pointDate      = startDate.AddHours(36);
            DateTime intervalStart  = startDate.AddHours(12);
            DateTime intervalFinish = intervalStart.AddDays(2);

            string tag = completed ? "Completed" : "";

            switch (item)
            {
            case GanttItem.PointStart:
                gantt.CreatePointElement(spanElement, pointDate, null, "Start", tag);
                break;

            case GanttItem.PointFinish:
                gantt.CreatePointElement(spanElement, pointDate, null, "Finish", tag);
                break;

            case GanttItem.PointActualStart:
                gantt.CreatePointElement(spanElement, pointDate, null, "ActualStart", tag);
                break;

            case GanttItem.PointActualFinish:
                gantt.CreatePointElement(spanElement, pointDate, null, "ActualFinish", tag);
                break;

            case GanttItem.Interval:
                gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, null, tag);
                break;

            case GanttItem.IntervalActual:
                gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, "Actual", tag);
                break;

            case GanttItem.IntervalProgress:
                gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, "Progress", tag);
                break;

            case GanttItem.IntervalSummary:
            case GanttItem.IntervalProject:
                Element interval = gantt.CreateIntervalElement(spanElement, intervalStart, intervalFinish, null, "Summary", tag);
                gantt.CreatePointElement(interval, intervalStart, null, "SummaryStart", tag);
                gantt.CreatePointElement(interval, intervalFinish, null, "SummaryFinish", tag);
                break;

            case GanttItem.PointMilestone:
                AddMilestone(gantt, spanElement, pointDate, null, null, tag);
                break;

            case GanttItem.PointMilestoneBasePlanRight:
                AddMilestone(gantt, spanElement, intervalStart, intervalFinish, null, tag);
                break;

            case GanttItem.PointMilestoneBasePlanLeft:
                AddMilestone(gantt, spanElement, intervalFinish, intervalStart, null, tag);
                break;
            }

            #region Render

            using (MemoryStream stream = new MemoryStream())
            {
                gantt.LoadStyleSheetFromFile(styleFilePath);
                gantt.ApplyStyleSheet();

                gantt.RenderPortion(new Point(0, 0), new Size(24 * 3, Convert.ToInt32(ItemHeight)), 0, 0, ImageFormat.Png, stream);

                ret = stream.ToArray();
            }

            #endregion

            return(ret);
        }