Пример #1
0
        public void BuildWebRankingTele(List<string> doc, DateTime date)
        {
            Log.n("Web: Lager [Tele] ranking..", Color.DarkGoldenrod);
            try
            {
                DateTime dtFra = GetFirstDayOfMonth(date);
                DateTime dtTil = date;
                timewatch.Start();

                var ranking = new RankingTele(this, dtFra, dtTil, dtTil);

                GetHtmlStart(doc, true, "Ranking: Tele");

                doc.Add("<h1>Avdeling: Tele (" + avdeling.Get(appConfig.Avdeling) + ")</h1>");

                doc.Add("<h2>Dagens ranking for " + dtTil.ToString("dddd d. MMMM yyyy", norway) + "</h2>");
                doc.AddRange(ranking.GetTableHtml("dag"));

                doc.Add("<h2>" + StringRankingDato(dtTil) + "</h2>");
                doc.AddRange(ranking.GetTableHtml("måned"));

                if (appConfig.rankingCompareLastyear > 0)
                {
                    doc.Add("<h2>Sammenlignet " + StringRankingDato(dtTil.AddYears(-1)) + "</h2>");
                    doc.AddRange(ranking.GetTableCompareHtml());
                }
                if (appConfig.rankingCompareLastmonth > 0)
                {
                    doc.Add("<h2>Sammenlignet " + StringRankingDato(dtTil.AddMonths(-1)) + "</h2>");
                    doc.AddRange(ranking.GetTableCompareLastMonthHtml());
                }
                if (appConfig.favVis && Favoritter.Count > 0)
                {
                    doc.Add("<h2>Favoritt avdelinger " + StringRankingDato(dtTil) + "</h2>");
                    doc.AddRange(ranking.GetAvdHtml());
                }

                if (appConfig.graphVis && appConfig.graphTele)
                {
                    if (appConfig.pdfExpandedGraphs)
                        doc.Add("<div class='Hidegraph'>");

                    doc.Add("<h2>Siste " + appConfig.graphDager + " dager Datamaskiner:</h2>");
                    gc.SaveImageChunk("Tele", settingsPath + @"\graphTeleWeb.png", appConfig.graphResX, appConfig.graphResY, "", dtTil.AddDays(-appConfig.graphDager), dtTil, false, null);
                    doc.Add("<a href='#grafTele'><img src='graphTeleWeb.png' style='width:" + appConfig.graphWidth + "px;height:auto;'></a>");

                    if (appConfig.pdfExpandedGraphs)
                        doc.Add("</div>");
                }

                doc.Add(Resources.htmlEnd);
                Log.n("Web: Ranking [Tele] tok " + timewatch.Stop() + " sekunder.", Color.DarkGoldenrod, true);
            }
            catch (Exception ex)
            {
                Log.Unhandled(ex);
            }
        }
Пример #2
0
        private void BuildTeleRanking(bool bg = false, BackgroundWorker bw = null)
        {
            string katArg = "Tele";
            bool abort = HarSisteVersjon(katArg, appConfig.strTele);
            try
            {
                if (!bg && !abort) timewatch.Start();
                if (!bg)
                    appConfig.savedPage = katArg;
                if (!abort)
                {
                    Log.n("Oppdaterer [" + katArg + "]..");
                    if (!bg)
                        webRanking.Navigate(htmlLoading);
                    var doc = new List<string>();
                    DateTime dtPick = pickerRankingDate.Value;
                    DateTime dtFra = GetFirstDayOfMonth(dtPick); DateTime dtTil = dtPick;
                    if (datoPeriodeVelger && !bg)
                    {
                        dtFra = datoPeriodeFra;
                        dtTil = datoPeriodeTil;
                    }

                    var ranking = new RankingTele(this, dtFra, dtTil, dtPick);

                    openXml.DeleteDocument(katArg, dtPick);

                    GetHtmlStart(doc, true, "Ranking: " + katArg);

                    doc.Add("<h1>Avdeling: Tele (" + avdeling.Get(appConfig.Avdeling) + ")</h1>");

                    if (!datoPeriodeVelger || bg)
                        doc.Add("<h3>Dagens ranking for " + dtPick.ToString("dddd d. MMMM yyyy", norway) + "</h3>");
                    else
                        doc.Add("<h3>Ranking for perioden fra " + dtFra.ToString("dddd d. MMMM yyyy", norway) + " til " + dtTil.ToString("dddd d. MMMM yyyy", norway) + "</h3>");
                    doc.Add("<span class='Loading'>Beregner..</span>");
                    if (!bg && timewatch.ReadyForRefresh())
                        webRanking.DocumentText = string.Join(null, doc.ToArray());
                    doc.RemoveAt(doc.Count - 1);
                    doc.AddRange(ranking.GetTableHtml("dag"));

                    if (!datoPeriodeVelger || bg)
                    {
                        doc.Add("<h3>" + StringRankingDato(dtPick) + "</h3>");
                        doc.Add("<span class='Loading'>Beregner..</span>");
                        if (!bg && timewatch.ReadyForRefresh())
                            webRanking.DocumentText = string.Join(null, doc.ToArray());
                        doc.RemoveAt(doc.Count - 1);
                        doc.AddRange(ranking.GetTableHtml("måned"));

                        if (appConfig.rankingCompareLastyear > 0)
                        {
                            doc.Add("<h3>" + StringRankingDato(dtPick.AddYears(-1)) + "</h3>");
                            doc.Add("<span class='Loading'>Beregner..</span>");
                            if (!bg && timewatch.ReadyForRefresh())
                                webRanking.DocumentText = string.Join(null, doc.ToArray());
                            doc.RemoveAt(doc.Count - 1);
                            doc.AddRange(ranking.GetTableCompareHtml());
                        }
                        if (appConfig.rankingCompareLastmonth > 0)
                        {
                            doc.Add("<h3>" + StringRankingDato(dtPick.AddMonths(-1)) + "</h3>");
                            doc.Add("<span class='Loading'>Beregner..</span>");
                            if (!bg && timewatch.ReadyForRefresh())
                                webRanking.DocumentText = string.Join(null, doc.ToArray());
                            doc.RemoveAt(doc.Count - 1);
                            doc.AddRange(ranking.GetTableCompareLastMonthHtml());
                        }
                        if (appConfig.favVis && Favoritter.Count > 0)
                        {
                            doc.Add("<h3>Favoritt avdelinger " + StringRankingDato(dtPick) + "</h3>");
                            doc.Add("<span class='Loading'>Beregner..</span>");
                            if (!bg && timewatch.ReadyForRefresh())
                                webRanking.DocumentText = string.Join(null, doc.ToArray());
                            doc.RemoveAt(doc.Count - 1);
                            doc.AddRange(ranking.GetAvdHtml());
                        }
                    }
                    if (appConfig.graphVis && appConfig.graphTele)
                    {
                        doc.Add("<span class='Loading'>Henter graf..</span>");
                        if (!bg && timewatch.ReadyForRefresh())
                            webRanking.DocumentText = string.Join(null, doc.ToArray());
                        doc.RemoveAt(doc.Count - 1);

                        if (appConfig.pdfExpandedGraphs)
                            doc.Add("<div class='Hidegraph'>");

                        if (!datoPeriodeVelger || bg)
                            doc.Add("<h3>Siste " + appConfig.graphDager + " dager</h3>");
                        else
                            doc.Add("<h3>Viser " + (datoPeriodeTil - datoPeriodeFra).Days + " dager</h3>");

                        if (datoPeriodeVelger && !bg)
                        {
                            gc.SaveImageChunk("Tele", settingsPath + @"\graphTelePeriode.png", appConfig.graphResX, appConfig.graphResY, "", dtFra, dtTil, false, bw);
                            doc.Add("<a href='#grafTele'><img src='graphTelePeriode.png' style='width:" + appConfig.graphWidth + "px;height:auto;'></a>");
                        }
                        else
                        {
                            gc.SaveImageChunk("Tele", settingsPath + @"\graphTele.png", appConfig.graphResX, appConfig.graphResY, "", dtTil.AddDays(-appConfig.graphDager), dtTil, false, bw);
                            doc.Add("<a href='#grafTele'><img src='graphTele.png' style='width:" + appConfig.graphWidth + "px;height:auto;'></a>");
                        }

                        if (appConfig.pdfExpandedGraphs)
                            doc.Add("</div>");
                    }

                    doc.Add(Resources.htmlEnd);

                    if (stopRanking)
                    {
                        stopRanking = false;
                        ClearHash(katArg);
                        Log.n("Ranking stoppet.", Color.Red);
                        webRanking.Navigate(htmlStopped);
                    }
                    else
                    {
                        if (datoPeriodeVelger && !bg)
                        {
                            File.WriteAllLines(htmlPeriode, doc.ToArray(), Encoding.Unicode);
                            webRanking.Navigate(htmlPeriode);
                        }
                        else
                        {
                            File.WriteAllLines(htmlRankingTele, doc.ToArray(), Encoding.Unicode);
                            if (!bg)
                                webRanking.Navigate(htmlRankingTele);
                            if (!bg) Log.n("Ranking [" + katArg + "] tok " + timewatch.Stop() + " sekunder.", Color.Black, true);
                        }
                    }
                }
                else if (!bg)
                    webRanking.Navigate(htmlRankingTele);
            }
            catch (Exception ex)
            {
                Log.Unhandled(ex);
                if (!bg)
                {
                    webRanking.Navigate(htmlError);
                    FormError errorMsg = new FormError("Feil ved generering av ranking for [" + katArg + "]", ex);
                    errorMsg.ShowDialog();
                }
            }
        }