Exemplo n.º 1
0
        public void BuildWebRankingAudioVideo(List<string> doc, DateTime date)
        {
            Log.n("Web: Lager [AudioVideo] ranking..", Color.DarkGoldenrod);
            try
            {
                DateTime dtFra = GetFirstDayOfMonth(date);
                DateTime dtTil = date;
                timewatch.Start();

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

                GetHtmlStart(doc, true, "Ranking: Lyd & Bilde");

                doc.Add("<h1>Avdeling: Lyd & Bilde (" + 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.graphAudioVideo)
                {
                    if (appConfig.pdfExpandedGraphs)
                        doc.Add("<div class='Hidegraph'>");

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

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

                doc.Add(Resources.htmlEnd);
                Log.n("Web: Ranking [AudioVideo] tok " + timewatch.Stop() + " sekunder.", Color.DarkGoldenrod, true);
            }
            catch (Exception ex)
            {
                Log.Unhandled(ex);
            }
        }
Exemplo n.º 2
0
        private void BuildAudioVideoRanking(bool bg = false, BackgroundWorker bw = null)
        {
            string katArg = "AudioVideo";
            bool abort = HarSisteVersjon(katArg, appConfig.strAudioVideo);
            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 RankingAudioVideo(this, dtFra, dtTil, dtPick);

                    openXml.DeleteDocument(katArg, dtPick);

                    GetHtmlStart(doc, true, "Ranking: Lyd & Bilde");

                    doc.Add("<h1>Avdeling: Lyd & Bilde (" + 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.graphAudioVideo)
                    {
                        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("AudioVideo", settingsPath + @"\graphAudioVideoPeriode.png", appConfig.graphResX, appConfig.graphResY, "", dtFra, dtTil, false, bw);
                            doc.Add("<a href='#grafAudioVideo'><img src='graphAudioVideoPeriode.png' style='width:" + appConfig.graphWidth + "px;height:auto;'></a>");
                        }
                        else
                        {
                            gc.SaveImageChunk("AudioVideo", settingsPath + @"\graphAudioVideo.png", appConfig.graphResX, appConfig.graphResY, "", dtTil.AddDays(-appConfig.graphDager), dtTil, false, bw);
                            doc.Add("<a href='#grafAudioVideo'><img src='graphAudioVideo.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(htmlRankingAudioVideo, doc.ToArray(), Encoding.Unicode);
                            if (!bg)
                                webRanking.Navigate(htmlRankingAudioVideo);
                            if (!bg) Log.n("Ranking [" + katArg + "] tok " + timewatch.Stop() + " sekunder.", Color.Black, true);
                        }
                    }
                }
                else if (!bg)
                    webRanking.Navigate(htmlRankingAudioVideo);
            }
            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();
                }
            }
        }