Ejemplo n.º 1
0
        private void RenderWeeklySummary(HtmlTextWriter output)
        {
            if (attendance.Count == 0)
            {
                return;
            }

            int entryIndex = 0;

            // Variable to hold the current working entry
            DojoAttendanceEntry entry = attendance[entryIndex];

            // Variable to hold first and last class dates to start and stop the loop
            DojoAttendanceEntry lastEntry = attendance[attendance.Count - 1];

            // Variables for holding the first date of each week
            DateTime currentFirstDayOfWeek  = DateManipulator.FirstOfWeek(entry.Class.ClassStart);
            DateTime previousFirstDayOfWeek = currentFirstDayOfWeek - TimeSpan.FromDays(7);

            // Set hit counters to -1 to inform loop on first run
            int beginnerHits = 0;
            int mudanshaHits = 0;
            int yudanshaHits = 0;
            int totalHits    = 0;

            while (entry != lastEntry)
            {
                while (entry.Class.ClassStart > currentFirstDayOfWeek)
                {
                    // Increment Counters
                    totalHits++;

                    if (entry.Rank.ID == 1)
                    {
                        beginnerHits++;
                    }
                    if (entry.Rank.IsMudansha)
                    {
                        mudanshaHits++;
                    }
                    if (entry.Rank.IsYudansha)
                    {
                        yudanshaHits++;
                    }

                    entryIndex++;

                    if (entryIndex < attendance.Count)
                    {
                        entry = attendance[entryIndex];
                    }
                    else
                    {
                        break;
                    }
                }

                renderWeeklySummary(output, this.DefaultRowCssClass,
                                    currentFirstDayOfWeek,
                                    DateManipulator.LastOfWeek(currentFirstDayOfWeek),
                                    beginnerHits, mudanshaHits, yudanshaHits, totalHits);

                // Reset Counters
                beginnerHits = 0;
                mudanshaHits = 0;
                yudanshaHits = 0;
                totalHits    = 0;

                currentFirstDayOfWeek  = previousFirstDayOfWeek;
                previousFirstDayOfWeek = currentFirstDayOfWeek - TimeSpan.FromDays(7);
            }
        }
Ejemplo n.º 2
0
        private void RenderView(HtmlTextWriter output, bool showWeeklyIndex)
        {
            // Variables for holding the days of a week
            DateTime currentIndexDate = DateTime.MinValue;
            DateTime lastIndexDate    = DateTime.MinValue;

            bool   rowflag = false;
            string rowCssClass;

            //
            // Render Records
            //
            foreach (DojoAttendanceEntry entry in attendance)
            {
                #region Render Indexing

                // Render Week Headers
                if (showWeeklyIndex)
                {
                    // Set the first and last day of week for the current entry
                    currentIndexDate = DateManipulator.FirstOfWeek(entry.Class.ClassStart);

                    if (lastIndexDate != currentIndexDate)
                    {
                        output.WriteFullBeginTag("tr");
                        output.WriteBeginTag("td");
                        output.WriteAttribute("class", indexRowCssClass);
                        output.WriteAttribute("colspan", "8");
                        output.Write(HtmlTextWriter.TagRightChar);
                        output.Write(currentIndexDate.ToLongDateString());
                        output.Write(" - ");
                        output.Write(DateManipulator.LastOfWeek(currentIndexDate).ToLongDateString());
                        output.WriteEndTag("td");
                        output.WriteEndTag("tr");

                        lastIndexDate = currentIndexDate;
                    }
                }
                else
                {
                    currentIndexDate = entry.Class.ClassStart.Date;

                    if (currentIndexDate != lastIndexDate)
                    {
                        output.WriteFullBeginTag("tr");
                        output.WriteBeginTag("td");
                        output.WriteAttribute("valign", "top");
                        output.WriteAttribute("colspan", "4");
                        output.WriteAttribute("class", indexRowCssClass);
                        output.Write(HtmlTextWriter.TagRightChar);
                        output.Write(currentIndexDate.ToLongDateString());
                        output.WriteEndTag("td");
                        output.WriteEndTag("tr");

                        lastIndexDate = currentIndexDate;
                    }
                }

                #endregion

                // Flip Rowstate
                if (rowflag)
                {
                    rowCssClass = this.defaultRowCssClass;
                }
                else
                {
                    rowCssClass = this.alternateRowCssClass;
                }
                rowflag = !rowflag;

                renderEntry(output, rowCssClass, entry);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void RenderContent(HtmlTextWriter output)
        {
            EnsureChildControls();

            DojoAttendanceEntryFlags[] options = new DojoAttendanceEntryFlags[]
            {
                DojoAttendanceEntryFlags.Class,
                DojoAttendanceEntryFlags.Member,
                DojoAttendanceEntryFlags.Rank,
                DojoAttendanceEntryFlags.MemberPrivateContact
            };

            DojoAttendanceEntryManager m = new DojoAttendanceEntryManager();

            StringBuilder whereQuery = new StringBuilder();

            if (ddMembers.SelectedItem.Value != "-1")
            {
                whereQuery.Append("MemberID=");
                whereQuery.Append(ddMembers.SelectedItem.Value);
            }

            if (ddClassDefinitions.SelectedItem.Value != "-1")
            {
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }

                if (ddClassDefinitions.SelectedItem.Value == "0")
                {
                    whereQuery.Append("ParentDefinitionID=null");
                }
                else
                {
                    whereQuery.Append("ParentDefinitionID=");
                    whereQuery.Append(ddClassDefinitions.SelectedItem.Value);
                }
            }

            if (ddInstructors.SelectedItem.Value != "-1")
            {
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }

                whereQuery.Append("kitTessen_Classes.InstructorID=");
                whereQuery.Append(ddInstructors.SelectedItem.Value);
            }

            switch (ddSearchMode.SelectedItem.Text)
            {
            case "Today":                                       // today
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(LocalTime.Date);
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(LocalTime.Date.AddDays(1));
                whereQuery.Append("#)");
                break;

            case "This Month":
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date));
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date).AddMonths(1));
                whereQuery.Append("#)");
                break;

            case "Last Month":
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(DateManipulator.SubtractMonths(LocalTime.Date, 1));
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date));
                whereQuery.Append("#)");
                break;

            case "This Week":
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date));
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).AddDays(1));
                whereQuery.Append("#)");
                break;

            case "Last Week":
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(7)));
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(6)));
                whereQuery.Append("#)");
                break;
            }

            attendance =
                m.GetCollection(whereQuery.ToString(), "ClassStart DESC", options);

            switch (ddView.SelectedItem.Value)
            {
            case "default":
                RenderView(output, false);
                break;

            case "weekly":
                RenderView(output, true);
                break;

            case "weeklysummary":
                RenderWeeklySummary(output);
                break;
            }
        }
Ejemplo n.º 4
0
        protected override void Render(HtmlTextWriter output)
        {
            #region Test for Errors

            if (clip == null)
            {
                RenderException(output, "The requested content could not be found.");
                return;
            }

            if (!adminView)
            {
                if (!clip.ParentCatalog.Enabled)
                {
                    RenderException(output, "The content's requested catalog is disabled.");
                    return;
                }

                if (clip.ExpirationDate < DateTime.Now)
                {
                    RenderException(output, "The requested content is expired.");
                    return;
                }

                if (clip.PublishDate > DateTime.Now)
                {
                    RenderException(output, "The requested content is awaiting publishing.");
                    return;
                }
            }

            #endregion

            #region Editor Rendering

            if (userEditor != null && userEditor.Visible)
            //if (caEditor != null && caEditor.Visible)
            //if (ftbEditor != null && ftbEditor.Visible)
            {
                output.Write("<div style=\"margin-bottom:5px\">Title:</div><div style=\"margin-bottom:5px\">");
                tbTitle.RenderControl(output);
                output.Write("</div><div style=\"margin-bottom:5px\">Description:</div><div style=\"margin-bottom:5px\">");
                tbDescription.RenderControl(output);
                output.Write("</div><div style=\"margin-bottom:5px\">");
                userEditor.RenderControl(output);
                //ftbEditor.RenderControl(output);
                output.Write("</div><div>");
                btSave.RenderControl(output);
                output.Write("&nbsp;");
                btCancel.RenderControl(output);
                output.Write("</div>");
                return;
            }

            #endregion

            #region Content Rendering

            if (_contentOnly)
            {
                // Resolve home references! Whahoo!
                output.Write(clip.Body.Replace("=\"~", Page.ResolveUrl("~")));

                // Display Edit Link
                if (btEdit != null && btEdit.Visible)
                {
                    output.Write("<br>");
                    btEdit.RenderControl(output);
                }

                return;
            }

            #endregion

            // Compile Clip
            Amns.GreyFox.Content.Support.ContentBuilder b = new Amns.GreyFox.Content.Support.ContentBuilder(clip);
            b.Compile();

            this.renderTextTag(output, _titleCssClass, "h3", clip.Title);

            if (clip.Authors.Count != 0)
            {
                output.WriteBeginTag("h4");
                if (_contributorsCssClass != "")
                {
                    output.WriteAttribute("class", _contributorsCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                for (int i = 0; i < clip.Authors.Count; i++)
                {
                    output.Write(clip.Authors[i].Contact.ConstructName("P F L S"));
                    if (i + 1 < clip.Authors.Count)
                    {
                        output.Write(", ");
                    }
                }
                output.WriteEndTag("h4");

                // Output Dates
                this.renderTextTag(output, _publishDateCssClass, "h5", clip.PublishDate.ToString("MMMM yyyy"));
            }

            output.WriteBeginTag("div");
            if (_bodyCssClass != string.Empty)
            {
                output.WriteAttribute("class", _bodyCssClass);
            }
            output.Write(HtmlTextWriter.TagRightChar);

            #region Reference, Administrator and Additional Side Panels

            output.WriteBeginTag("div");
            output.WriteAttribute("style", "float:right;");
            output.Write(HtmlTextWriter.TagRightChar);

            #region Reference Panel

            if (clip.References.Count != 0)
            {
                output.WriteBeginTag("table");
                output.WriteAttribute("border", "0");
                output.WriteAttribute("cellPadding", "5");
                output.WriteAttribute("cellSpacing", "0");
                output.WriteAttribute("width", "150px");
                if (_referenceTableCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _referenceTableCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteFullBeginTag("tr");
                output.WriteBeginTag("td");
                if (_referenceTitleCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _referenceTitleCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write("References");
                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                foreach (DbContentClip reference in clip.References)
                {
                    output.WriteFullBeginTag("tr");
                    output.WriteFullBeginTag("td");
                    output.WriteBeginTag("a");
                    if (reference.OverrideUrl != string.Empty)
                    {
                        output.WriteAttribute("href", reference.OverrideUrl);
                    }
                    else
                    {
                        output.WriteAttribute("href", Page.ResolveUrl(string.Format(_linkFormat, reference.ID)));
                    }
                    if (reference.MenuTooltip != string.Empty)
                    {
                        output.WriteAttribute("title", reference.MenuTooltip);
                    }
                    output.Write(HtmlTextWriter.TagRightChar);
                    output.Write(reference.Title);
                    output.WriteEndTag("a");
                    output.WriteEndTag("td");
                    output.WriteEndTag("tr");
                }
                output.WriteEndTag("table");
            }

            #endregion

            #region Administration Panel

            if (btEdit != null && btEdit.Visible)
            {
                output.WriteBeginTag("table");
                output.WriteAttribute("border", "0");
                output.WriteAttribute("cellPadding", "5");
                output.WriteAttribute("cellSpacing", "0");
                output.WriteAttribute("width", "150px");
                if (_referenceTableCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _referenceTableCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteFullBeginTag("tr");
                output.WriteBeginTag("td");
                if (_referenceTitleCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _referenceTitleCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write("Administration");
                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                btEdit.RenderControl(output);
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                #region Hit Counter Display

                // TODO: Finish Counter
                int totalHits  = 0;
                int uniqueHits = 0;

                DbContentHitManager    hm   = new DbContentHitManager();
                DbContentHitCollection hits = hm.GetCollection("RequestContentID=" + clip.ID.ToString(), "RequestDate", null);

                totalHits = hits.Count;

                // =================================================
                // BAR GRAPH
                // =================================================

                DateTime now = DateTime.Now;

                DateTime weekStart6 = DateManipulator.FirstOfWeek(now);
                DateTime weekStart5 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(7)));
                DateTime weekStart4 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(14)));
                DateTime weekStart3 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(21)));
                DateTime weekStart2 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(28)));
                DateTime weekStart1 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(35)));

                int[] weekCounts = new int[6];

                // Count Unique Hits
                foreach (DbContentHit hit in hits)
                {
                    if (hit.IsUnique)
                    {
                        if (hit.RequestDate > weekStart1 & hit.RequestDate < weekStart2)
                        {
                            weekCounts[0]++;
                        }
                        if (hit.RequestDate > weekStart2 & hit.RequestDate < weekStart3)
                        {
                            weekCounts[1]++;
                        }
                        if (hit.RequestDate > weekStart3 & hit.RequestDate < weekStart4)
                        {
                            weekCounts[2]++;
                        }
                        if (hit.RequestDate > weekStart4 & hit.RequestDate < weekStart5)
                        {
                            weekCounts[3]++;
                        }
                        if (hit.RequestDate > weekStart5 & hit.RequestDate < weekStart6)
                        {
                            weekCounts[4]++;
                        }
                        if (hit.RequestDate > weekStart6)
                        {
                            weekCounts[5]++;
                        }

                        uniqueHits++;
                    }
                }

                int graphWidth   = 138;
                int graphHeight  = 100;
                int graphPadding = 1;
                int plotWidth    = graphWidth - (graphPadding * 2);
                int plotHeight   = graphHeight - (graphPadding * 2);
                int maxBarHeight = plotHeight;
                int minBarHeight = 20;
                int barMargin    = 2;
                int barWidth     = 21;

                // Find Highest Count
                int maxCount = 0;
                for (int i = 0; i < weekCounts.Length; i++)
                {
                    if (weekCounts[i] > maxCount)
                    {
                        maxCount = weekCounts[i];
                    }
                }

                // Find Height per Unit
                double pixelUnit = Convert.ToDouble(maxBarHeight) / Convert.ToDouble(maxCount);

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.Write("<strong>Hits:</strong>");
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");

                output.WriteFullBeginTag("style");
                output.WriteLine("#vertgraph { width : " + graphWidth.ToString() + "px; " +
                                 "height: " + graphHeight.ToString() + "px; " +
                                 "position: relative; " +
                                 "padding: " + graphPadding.ToString() + "px; " +
                                 "background: #aaaaaa; }");
                output.WriteLine("#vertgraph .graph-area { width: " + plotWidth.ToString() + "px; " +
                                 "height: " + plotHeight.ToString() + "px; " +
                                 "padding: 0; " +
                                 "margin: 0; " +
                                 "position: relative; " +
                                 "overflow: hidden; } ");
                output.WriteLine("#vertgraph ul { width: " + plotWidth.ToString() + "px; " +
                                 "height: " + plotHeight.ToString() + "px; " +
                                 "margin: 0; " +
                                 "padding: 0; " +
                                 "position: absolute; " +
                                 "bottom: 0; " +
                                 "list-style-type: none; }");
                output.Write("#vertgraph ul li { position: absolute; " +
                             "width: " + barWidth.ToString() + "px; " +
                             "height: " + maxBarHeight.ToString() + "px; " +
                             "bottom: 0; " +
                             "padding 0; " +
                             "margin 0; " +
                             "background: no-repeat; " +
                             "writing-mode:tb-rl; " +
                             "text-align: center; " +
                             "font-size: xx-small; " +
                             //					"font-weight: bold; " +
                             "vertical-align: middle; " +
                             "color: white; }");
                output.WriteLine("#vertgraph li.week1 { background: #999999; left: 0px; }");
                output.WriteLine("#vertgraph li.week2 { background: #888888; left: " + ((barMargin + barWidth) * 1).ToString() + "px; }");
                output.WriteLine("#vertgraph li.week3 { background: #777777; left: " + ((barMargin + barWidth) * 2).ToString() + "px; }");
                output.WriteLine("#vertgraph li.week4 { background: #666666; left: " + ((barMargin + barWidth) * 3).ToString() + "px; }");
                output.WriteLine("#vertgraph li.week5 { background: #555555; left: " + ((barMargin + barWidth) * 4).ToString() + "px; }");
                output.WriteLine("#vertgraph li.week6 { background: #444444; left: " + ((barMargin + barWidth) * 5).ToString() + "px; }");
                output.WriteEndTag("style");

                output.WriteBeginTag("div");
                output.WriteAttribute("id", "vertgraph");
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteBeginTag("div");
                output.WriteAttribute("id", "graph-area");
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteFullBeginTag("ul");

                int    barHeight;
                double barHeightD = 0;

                for (int i = 0; i < 6; i++)
                {
                    barHeightD = Convert.ToDouble(weekCounts[i]) * pixelUnit;
                    if (barHeightD < minBarHeight)
                    {
                        barHeight = minBarHeight;
                    }
                    else if (double.IsNaN(barHeightD))
                    {
                        barHeight = minBarHeight;
                    }
                    else
                    {
                        barHeight = Convert.ToInt32(barHeightD);
                    }

                    output.WriteBeginTag("li");
                    output.WriteAttribute("class", "week" + (i + 1).ToString());
                    output.WriteAttribute("style", "height: " + barHeight + "px;");
                    output.Write(HtmlTextWriter.TagRightChar);
                    output.Write(weekCounts[i]);
                    output.WriteEndTag("li");
                    output.WriteLine();
                }

                output.WriteEndTag("ul");
                output.WriteEndTag("div");
                output.WriteEndTag("div");

                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                // ===============================================
                // END BAR GRAPH
                // ===============================================

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.Write("<strong>Unique Hits:</strong><br />");
                output.Write(uniqueHits);
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.Write("<strong>Total Hits:</strong><br />");
                output.Write(totalHits);
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                if (hits.Count > 0)
                {
                    output.WriteFullBeginTag("tr");
                    output.WriteFullBeginTag("td");
                    output.Write("<strong>Last Hit:</strong><br />");
                    output.Write(hits[hits.Count - 1].RequestDate.ToString());
                    output.WriteEndTag("td");
                    output.WriteEndTag("tr");
                }

                #endregion

                #region Update Display

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.Write("<strong>Last Updated:</strong><br />");
                output.Write(clip.ModifyDate.ToString());
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                #endregion

                #region Admin Notices

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");

                if (!clip.ParentCatalog.Enabled)
                {
                    output.Write(string.Format("<div><font color=\"ff0000\">Admin Notice: The requested clip's parent catalog '{0}' is disabled.</font></div>", clip.ParentCatalog.Title));
                }
                if (clip.ExpirationDate < DateTime.Now)
                {
                    output.Write(string.Format("<div><font color=\"ff0000\">Admin Notice: The requested clip expired on {0}.</font></div>", clip.ExpirationDate));
                }
                if (clip.PublishDate > DateTime.Now)
                {
                    output.Write(string.Format("<div><font color=\"ff0000\">Admin Notice: The requested clip will be published on {0}.</font></div>", clip.PublishDate));
                }

                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                #endregion

                output.WriteEndTag("table");
            }

            #endregion

            #region Gloss Word Panel

            if (b.FaqCompiled)
            {
                output.Write("\r\n" +
                             "<script language=\"javascript\">\r\n" +
                             "function gfx_faqToggle(id) {\r\n" +
                             "	q = new getObj(id); \r\n"+
                             "	if(q.style.display == 'block') \r\n"+
                             "		q.style.display = 'none'; \r\n"+
                             "	else \r\n"+
                             "		q.style.display = 'block'; \r\n"+
                             "}\r\n" +
                             "</script>\r\n");
            }

            if (b.GlossWordsCompiled)
            {
                output.Write("\r\n" +
                             "<script language=\"javascript\">\r\n" +
                             "function gfx_glossCopy(id) {\r\n" +
                             "	document.getElementById('glosscontainer').innerHTML = \r\n"+
                             "		document.getElementById(id).innerHTML;\r\n"+
                             "}\r\n" +
                             "</script>\r\n");

                output.WriteBeginTag("table");
                output.WriteAttribute("border", "0");
                output.WriteAttribute("cellPadding", "5");
                output.WriteAttribute("cellSpacing", "0");
                output.WriteAttribute("width", "150px");
                if (_glossTableCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _glossTableCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteFullBeginTag("tr");
                output.WriteBeginTag("td");
                if (_glossTitleCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _glossTitleCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write("Glossary");
                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.WriteBeginTag("div");
                output.WriteAttribute("id", "glosscontainer");
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write("Please hover over a keyword to view glossary content.");
                output.WriteEndTag("div");
                output.Write(b.GlossBlock);
                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                output.WriteEndTag("table");
            }

            #endregion

            output.WriteEndTag("div");

            #endregion

            output.Write(b.Output);

            output.WriteEndTag("div");

            // DO NOT RECORD HITS ON ADMIN VIEW OR IF USER HAS ALREADY
            // HIT THIS PAGE UNIQUELY.
            if (!adminView & _hitCounterEnabled)
            {
                if (Page.Session["GFX_HIT_" + clip.ID.ToString()] == null)
                {
                    clip.SaveHit(Page.Request, true);
                    Page.Session["GFX_HIT_" + clip.ID.ToString()] = true;
                }
                else
                {
                    clip.SaveHit(Page.Request, false);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void RenderContent(HtmlTextWriter output)
        {
            EnsureChildControls();
            StringBuilder whereQuery = new StringBuilder();

            DojoClassManager m = new DojoClassManager();

            //
            // Qualify Parent Definition Selection in Query
            //
            if (parentDefinitionID == 0)
            {
                whereQuery.Append("(ParentDefinitionID=null OR ParentDefinitionID=0) ");
            }
            else if (parentDefinitionID > 0)
            {
                whereQuery.Append("ParentDefinitionID=" + parentDefinitionID.ToString() + ") ");
            }

            //
            // Qualify Parent Seminar Selection in Query
            //
            if (parentSeminarID == 0)
            {
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append("AND (ParentSeminarID=null OR ParentSeminarID=0) ");
                }
                else
                {
                    whereQuery.Append("(ParentSeminarID=null OR ParentSeminarID=0) ");
                }
            }
            else if (parentSeminarID > 0)
            {
                whereQuery.Append("(ParentSeminarID=" + parentSeminarID.ToString() + ") ");
            }

            switch (ddSearchMode.SelectedItem.Text)
            {
            case "Today":                                       // today
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(LocalTime.Date);
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(LocalTime.Date.AddDays(1));
                whereQuery.Append("#)");
                break;

            case "This Month":
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date));
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date).AddMonths(1));
                whereQuery.Append("#)");
                break;

            case "Last Month":
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(DateManipulator.SubtractMonths(DateManipulator.FirstOfMonth(LocalTime.Date), 1));
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date));
                whereQuery.Append("#)");
                break;

            case "This Week":
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date));
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).AddDays(1));
                whereQuery.Append("#)");
                break;

            case "Last Week":
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(7)));
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(6)));
                whereQuery.Append("#)");
                break;

            case "This Year":
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("(ClassStart>=#");
                whereQuery.Append(DateTime.Parse("1/1/" + LocalTime.Date.Year.ToString()));
                whereQuery.Append("# AND ClassStart <#");
                whereQuery.Append(DateTime.Parse("1/1/" + (LocalTime.Date.Year + 1).ToString()));
                whereQuery.Append("#)");
                break;
            }

            if (cbSeminarFilter.Checked)
            {
                if (whereQuery.Length > 0)
                {
                    whereQuery.Append(" AND ");
                }
                whereQuery.Append("ParentSeminarID IS NOT NULL");
            }

            DojoClassCollection dojoClassCollection = m.GetCollection(whereQuery.ToString(), "ClassStart ASC",
                                                                      new DojoClassFlags[] {
                DojoClassFlags.Instructor,
                DojoClassFlags.InstructorPrivateContact
            });

            bool   rowflag = false;
            string rowCssClass;
            string currentIndex  = string.Empty;
            string previousIndex = string.Empty;

            //
            // Render Records
            //
            foreach (DojoClass entry in dojoClassCollection)
            {
                #region Index Rows Rendering

                currentIndex = entry.ClassStart.ToLongDateString();

                if (currentIndex != previousIndex)
                {
                    output.WriteFullBeginTag("tr");
                    output.WriteBeginTag("td");
                    output.WriteAttribute("valign", "top");
                    output.WriteAttribute("colspan", "4");
                    output.WriteAttribute("class", indexRowCssClass);
                    output.Write(HtmlTextWriter.TagRightChar);
                    output.Write(currentIndex);
                    output.WriteEndTag("td");
                    output.WriteEndTag("tr");

                    previousIndex = currentIndex;
                }

                #endregion

                if (rowflag)
                {
                    rowCssClass = this.defaultRowCssClass;
                }
                else
                {
                    rowCssClass = this.alternateRowCssClass;
                }

                rowflag = !rowflag;

                output.WriteBeginTag("tr");
                output.WriteAttribute("i", entry.ID.ToString());
                output.WriteLine(HtmlTextWriter.TagRightChar);
                output.Indent++;

                //
                // Render Main Representation of Record
                //
                output.WriteBeginTag("td");
                output.WriteAttribute("valign", "top");
                output.WriteAttribute("class", rowCssClass);
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteFullBeginTag("strong");
                output.Write(entry.Name);
                output.WriteEndTag("strong");
                output.Write("<br>");
                output.Write(entry.Instructor.PrivateContact.FullName);
                output.WriteEndTag("td");
                output.WriteLine();

                //
                // Render Class Start and End Dates
                //
                output.WriteBeginTag("td");
                output.WriteAttribute("class", rowCssClass);
                output.WriteAttribute("valign", "top");
                output.Write(HtmlTextWriter.TagRightChar);
//				output.Write(entry.ClassStart.ToLongDateString());
//				output.Write("<br />");
                output.Write(entry.ClassStart.ToShortTimeString());
                output.Write(" - ");
                output.Write(entry.ClassEnd.ToShortTimeString());
                output.WriteEndTag("td");
                output.WriteLine();

                output.Indent--;
                output.WriteEndTag("tr");
                output.WriteLine();
            }
        }
Ejemplo n.º 6
0
        public void RunScan()
        {
            DojoBulkAttendanceEntryManager    bulkManager;
            DojoBulkAttendanceEntryCollection bulkAttendance;
            DojoAttendanceEntryManager        m;
            DojoAttendanceEntryCollection     attendance;
            double   classLength;
            DateTime dayIndex;
            double   dayWeightedHours;
            double   dayWeightedHoursInRank;
            DateTime firstDayOfWeek;
            DateTime lastDayOfWeek;
            DateTime firstDayOfLastWeek;
            DateTime lastDayOfLastWeek;

            bulkManager = new DojoBulkAttendanceEntryManager();

            bulkAttendance =
                bulkManager.GetCollection("MemberID=" + member.iD, string.Empty, null);

            // Load the attendance entry collection and be sure to sort by ClassStart
            // so that the system can calculate weighted hours properly.
            m          = new DojoAttendanceEntryManager();
            attendance =
                m.GetCollection("MemberID=" + member.iD, "ClassStart", DojoAttendanceEntryFlags.Class);


            // Clear Data
            this.totalBulkHours           = 0;
            this.totalBulkHoursInRank     = 0;
            this.totalHours               = 0;
            this.totalHoursInRank         = 0;
            this.totalWeightedHours       = 0;
            this.totalWeightedHoursInRank = 0;
            this.totalHoursThisWeek       = 0;
            this.totalHoursLastWeek       = 0;

            classLength            = 0;
            dayIndex               = DateTime.MinValue;
            dayWeightedHours       = 0;
            dayWeightedHoursInRank = 0;

            firstDayOfWeek     = DateManipulator.FirstOfWeek(DateTime.Now);
            lastDayOfWeek      = firstDayOfWeek.Add(new TimeSpan(6, 23, 59, 59, 999));
            firstDayOfLastWeek = DateManipulator.FirstOfWeek(DateTime.Now.Subtract(TimeSpan.FromDays(7)));
            lastDayOfLastWeek  = firstDayOfLastWeek.Add(new TimeSpan(6, 23, 59, 59, 999));

            // Scan Bulk Hours
            for (int x = 0; x < bulkAttendance.Count; x++)
            {
                totalBulkHours += bulkAttendance[x].Duration.TotalHours;

                if (bulkAttendance[x].rank.iD == member.rank.iD)
                {
                    totalBulkHoursInRank += bulkAttendance[x].Duration.TotalHours;
                }
            }

            if (attendance.Count > 0)
            {
                dayIndex = attendance[0].Class.ClassStart.Date;
            }

            for (int x = 0; x < attendance.Count; x++)
            {
                classLength = (attendance[x].Class.ClassEnd - attendance[x].Class.ClassStart).TotalHours;

                // Total Hours
                totalHours += classLength;

                // Total Hours in Rank
                if (attendance[x].rank.iD == member.rank.iD)
                {
                    totalHoursInRank += classLength;
                }

                // Total Weighted Hours
                if (attendance[x].Class.ClassStart.Date != dayIndex)
                {
                    // Add Prior Temporary Values
                    totalWeightedHours       += dayWeightedHours;
                    totalWeightedHoursInRank += dayWeightedHoursInRank;

                    // Reset Hours for Day
                    dayWeightedHours       = 0;
                    dayWeightedHoursInRank = 0;
                    dayIndex = attendance[x].Class.ClassStart.Date;
                }

                dayWeightedHours += classLength;

                if (attendance[x].rank.iD == member.rank.iD)
                {
                    dayWeightedHoursInRank += classLength;
                }

                if (dayWeightedHours > maxDayHours)
                {
                    dayWeightedHours = maxDayHours;
                }

                if (dayWeightedHoursInRank > maxDayHours)
                {
                    dayWeightedHoursInRank = maxDayHours;
                }

                if (attendance[x].Class.ClassStart >= firstDayOfLastWeek &&
                    attendance[x].Class.ClassStart <= lastDayOfLastWeek)
                {
                    totalHoursLastWeek += classLength;
                }

                if (attendance[x].Class.ClassStart >= firstDayOfWeek &&
                    attendance[x].Class.ClassStart <= lastDayOfWeek)
                {
                    totalHoursThisWeek += classLength;
                }

                // Update Last Signin
                if (attendance[x].signinTime > lastSignin)
                {
                    lastSignin = attendance[x].signinTime;
                }
            }

            // Tally Remaining Temporary Values
            totalWeightedHours       += dayWeightedHours;
            totalWeightedHoursInRank += dayWeightedHoursInRank;

            // Find Ninety Day Instructors
            DateTime maxDate = DateTime.Now;
            DateTime minDate = maxDate.Subtract(TimeSpan.FromDays(90));

            instructor1 = attendance.FindTopInstructor(minDate, maxDate, null);
            instructor2 = attendance.FindTopInstructor(minDate, maxDate, instructor1);
            instructor3 = attendance.FindTopInstructor(minDate, maxDate, instructor1, instructor2);
        }