Пример #1
0
        /// <summary>
        /// Starter macro form
        /// </summary>
        /// <param name="dateArg">Dato på hva som skal importeres</param>
        /// <param name="macroProgramArg">Makro program som skal benyttes</param>
        /// <param name="attemptsArg">Hvilket forsøkt dette er</param>
        /// <returns>Form som ble brukt for å hente ut returkoder</returns>
        public Form StartMacro(DateTime dateArg, string macroProgramArg, BackgroundWorker bw, int attemptsArg = 0, bool ignoreExtraWait = false)
        {
            Form form = new FormMacro(this, dateArg, macroProgramArg, attemptsArg, ignoreExtraWait, bw);
            form.StartPosition = FormStartPosition.CenterScreen;
            form.ShowDialog();

            return form;
        }
Пример #2
0
        private void bwMacro_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                FormMain.autoMode = true;
                SendMessage("Starter test makro..");

                DateTime date = DateTime.Now;
                date = date.AddDays(-2);

                FormMacro form = new FormMacro(main, date, FormMain.macroProgram, 0, true, bwMacro);
                form.StartPosition = FormStartPosition.CenterScreen;
                form.ShowDialog();
                if (form.errorCode != 0)
                {
                    e.Result = "Makro returnerte med feilkode " + form.errorCode + " - Feilmelding: " + form.errorMessage;
                    return;
                }

                SendMessage("Importerer data..");

                var csvFilesToImport = new List<string>() { };
                ImportManager importMng = new ImportManager(main, csvFilesToImport);
                importMng.DoImportTransactions(bwMacro, false);

                if (importMng.returnCode != 0)
                {
                    e.Result = "Importering misslyktes med feilkode " + importMng.returnCode;
                    return;
                }

                SendMessage("Forbereder ranking..");
                main.RetrieveDb(true);

                SendMessage("Lager PDF..");
                string pdf = main.CreatePDF("Full", "", bwMacro);

                List<MailAddress> recip = new List<MailAddress>() { };
                recip.Add(new MailAddress(kgsaEmail.emailDb.Rows[0]["Address"].ToString(), kgsaEmail.emailDb.Rows[0]["Name"].ToString()));

                SendMessage("Sender e-post for mottaker " + kgsaEmail.emailDb.Rows[0]["Address"].ToString() + "..");
                if (!kgsaEmail.InternalSendMail(recip, main.appConfig.epostEmne, main.appConfig.epostBody, new List<string> { pdf }, main.appConfig.epostBrukBcc))
                {
                    e.Result = "Sending av e-post misslyktes";
                    return;
                }

                e.Result = "OK";
            }
            catch (Exception ex)
            {
                SendMessage("Kritisk feil oppstod under kjøring av Test Makro! Se logg for detaljer.", Color.Red);
                Log.Unhandled(ex);
                e.Result = "Exception: " + ex.Message;
            }
        }