Ejemplo n.º 1
0
        private void BuildStoreObsoleteList(bool bg = false)
        {
            string katArg = "ObsoleteList";
            bool abort = HarSisteVersjonStore(katArg, appConfig.strObsoleteList);
            try
            {
                if (!bg && !abort) timewatch.Start();
                if (!bg)
                    appConfig.savedStorePage = katArg;
                if (!abort)
                {
                    Log.n("Oppdaterer [" + katArg + "]..");
                    if (!bg)
                        webStore.Navigate(htmlLoading);
                    var doc = new List<string>();

                    DateTime dtPick = pickerLagerDato.Value;
                    DateTime dtFra = GetFirstDayOfMonth(dtPick); DateTime dtTil = dtPick;
                    if (datoPeriodeVelger && !bg)
                    {
                        dtFra = datoPeriodeFra;
                        dtTil = datoPeriodeTil;
                    }

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

                    openXml.DeleteDocument(katArg, dtPick);

                    GetHtmlStart(doc, true);

                    doc.Add("<h1>Utgåtte varer (" + avdeling.Get(appConfig.Avdeling) + ")</h1>");
                    doc.Add("<span class='Generated'>Ranking generert: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "</span><br>");

                    doc.AddRange(ranking.GetTableHtmlUkurantGrupper());

                    doc.Add(Resources.htmlEnd);

                    if (stopRanking)
                    {
                        stopRanking = false;
                        ClearHash(katArg);
                        Log.n("Ranking stoppet.", Color.Red);
                        webStore.Navigate(htmlStopped);
                    }
                    else
                    {
                        if (datoPeriodeVelger && !bg)
                        {
                            File.WriteAllLines(htmlPeriode, doc.ToArray(), Encoding.Unicode);
                            webStore.Navigate(htmlPeriode);
                        }
                        else
                        {
                            File.WriteAllLines(htmlStoreObsoleteList, doc.ToArray(), Encoding.Unicode);
                            if (!bg)
                                webStore.Navigate(htmlStoreObsoleteList);
                            if (!bg) Log.n("Ranking [" + katArg + "] tok " + timewatch.Stop() + " sekunder.", Color.Black, true);
                        }
                    }
                }
                else if (!bg)
                    webStore.Navigate(htmlStoreObsoleteList);
            }
            catch (Exception ex)
            {
                Log.n("Feil ved generering av ranking for [" + katArg + "] Exception: " + ex.ToString(), Color.Red);
                if (!bg)
                {
                    webStore.Navigate(htmlError);
                    FormError errorMsg = new FormError("Feil ved generering av ranking for [" + katArg + "]", ex);
                    errorMsg.ShowDialog(this);
                }
            }
        }
Ejemplo n.º 2
0
        private void BuildStoreStatus(bool bg = false)
        {
            string katArg = "Obsolete";
            bool abort = HarSisteVersjonStore(katArg, appConfig.strObsolete);
            try
            {
                if (!bg && !abort) timewatch.Start();
                if (!bg)
                    appConfig.savedStorePage = katArg;
                if (!abort)
                {
                    Log.n("Oppdaterer [" + katArg + "]..");
                    if (!bg)
                        webStore.Navigate(htmlLoading);
                    var doc = new List<string>();

                    DateTime dtPick = pickerLagerDato.Value;
                    DateTime dtFra = GetFirstDayOfMonth(dtPick); DateTime dtTil = dtPick;

                    dtPick = obsolete.FindNearestDate(dtPick);
                    dtTil = obsolete.FindNearestDate(dtTil);
                    dtFra = obsolete.FindNearestDate(dtFra);

                    if (!appConfig.storeCompareMtd)
                        dtFra = appConfig.dbStoreViewpoint;

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

                    openXml.DeleteDocument(katArg, dtPick);

                    GetHtmlStart(doc, true);

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

                    doc.Add("<h3>Oversikt utgåtte varer hovedlager (" + dtTil.ToString("dddd d. MMMM yyyy", norway) + ")</h3>");
                    doc.Add("<span class='Loading'>Beregner..</span>");
                    if (!bg && timewatch.ReadyForRefresh())
                        webStore.DocumentText = string.Join(null, doc.ToArray());
                    doc.RemoveAt(doc.Count - 1);
                    doc.AddRange(ranking.GetTableHtml(false));

                    if (appConfig.storeShowStoreTwo)
                    {
                        doc.Add("<h3>Oversikt utgåtte varer B/V lager (" + dtTil.ToString("dddd d. MMMM yyyy", norway) + ")</h3>");
                        doc.Add("<span class='Loading'>Beregner..</span>");
                        if (!bg && timewatch.ReadyForRefresh())
                            webStore.DocumentText = string.Join(null, doc.ToArray());
                        doc.RemoveAt(doc.Count - 1);
                        doc.AddRange(ranking.GetTableHtml(true));
                    }

                    doc.Add("<h3>Utvikling hovedlager (Sammenlignet mot " + dtFra.ToString("dddd d. MMMM yyyy", norway) + ")</h3>");
                    doc.Add("<span class='Loading'>Beregner..</span>");
                    if (!bg && timewatch.ReadyForRefresh())
                        webStore.DocumentText = string.Join(null, doc.ToArray());
                    doc.RemoveAt(doc.Count - 1);
                    doc.AddRange(ranking.GetTableHtmlUtvikling(false));

                    if (appConfig.storeShowStoreTwo)
                    {
                        doc.Add("<h3>Utvikling B/V lager (Sammenlignet mot " + dtFra.ToString("dddd d. MMMM yyyy", norway) + ")</h3>");
                        doc.Add("<span class='Loading'>Beregner..</span>");
                        if (!bg && timewatch.ReadyForRefresh())
                            webStore.DocumentText = string.Join(null, doc.ToArray());
                        doc.RemoveAt(doc.Count - 1);
                        doc.AddRange(ranking.GetTableHtmlUtvikling(true));
                    }

                    //obsolete.RetreieveHistoryTable();
                    //doc.Add("<img src='" + obsolete.SaveChartImage(appConfig.graphResX, appConfig.graphResY, "MDA", appConfig.Avdeling) + "' style='width:900px;height:auto;'><br>");

                    //doc.Add("<img src='" + obsolete.SaveChartImage(appConfig.graphResX, appConfig.graphResY, "AudioVideo", appConfig.Avdeling) + "' style='width:900px;height:auto;'><br>");

                    doc.Add(Resources.htmlEnd);

                    if (stopRanking)
                    {
                        stopRanking = false;
                        ClearHash(katArg);
                        Log.n("Ranking stoppet.", Color.Red);
                        webStore.Navigate(htmlStopped);
                    }
                    else
                    {
                        if (datoPeriodeVelger && !bg)
                        {
                            File.WriteAllLines(htmlPeriode, doc.ToArray(), Encoding.Unicode);
                            webStore.Navigate(htmlPeriode);
                        }
                        else
                        {
                            File.WriteAllLines(htmlStoreObsolete, doc.ToArray(), Encoding.Unicode);
                            if (!bg)
                                webStore.Navigate(htmlStoreObsolete);
                            if (!bg) Log.n("Ranking [" + katArg + "] tok " + timewatch.Stop() + " sekunder.", Color.Black, true);
                        }
                    }
                }
                else if (!bg)
                    webStore.Navigate(htmlStoreObsolete);
            }
            catch (Exception ex)
            {
                Log.n("Feil ved generering av ranking for [" + katArg + "] Exception: " + ex.ToString(), Color.Red);
                if (!bg)
                {
                    webStore.Navigate(htmlError);
                    FormError errorMsg = new FormError("Feil ved generering av ranking for [" + katArg + "]", ex);
                    errorMsg.ShowDialog(this);
                }
            }
        }
Ejemplo n.º 3
0
        private void BuildStoreObsoleteImports(bool bg = false)
        {
            string katArg = "ObsoleteImports";
            bool abort = HarSisteVersjonStore(katArg, appConfig.strObsoleteImports);
            try
            {
                if (!bg && !abort) timewatch.Start();
                if (!bg)
                    appConfig.savedStorePage = katArg;
                if (!abort)
                {
                    Log.n("Oppdaterer [" + katArg + "]..");
                    if (!bg)
                        webStore.Navigate(htmlLoading);
                    var doc = new List<string>();

                    DateTime dtPick = pickerLagerDato.Value;
                    DateTime dtFra = GetFirstDayOfMonth(dtPick); DateTime dtTil = dtPick;
                    if (datoPeriodeVelger && !bg)
                    {
                        dtFra = datoPeriodeFra;
                        dtTil = datoPeriodeTil;
                    }

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

                    openXml.DeleteDocument(katArg, dtPick);

                    GetHtmlStart(doc, true);

                    doc.Add("<span class='Title'>Lager status (" + avdeling.Get(appConfig.Avdeling) + ")</span><span style='font-size:10.0pt;font-weight:400;font-style:normal;text-decoration:none;font-family:Calibri, sans-serif;color:gray;float:right'>Ranking generert: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "</span><br><br>");
                    doc.Add("<span class='xTitle'>Viser alle importeringer</span>");

                    doc.AddRange(ranking.GetTableHtmlReport());

                    doc.Add(Resources.htmlEnd);

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