Пример #1
0
 public ActionResult GenerateEntriesReport(EntriesReport request)
 {
     HostingEnvironment.QueueBackgroundWorkItem(ct => ReportsService.GenerateReport(request));
     return(new HttpStatusCodeResult(HttpStatusCode.OK));
 }
Пример #2
0
        static void Main(string[] args)
        {
            #region AppDomainInitializer Seed flex_response_values validation

            /*
             * try
             * {
             * if (NewIndigoRepo.DoesNewDatabaseExists())
             * {
             * var errorMsg = OriginalIndigoRepo.CompareSeedValues();
             * if (!string.IsNullOrEmpty(errorMsg))
             *  throw new Exception(errorMsg);
             *
             * }// end if (NewIndigoRepo.DoesNewDatabaseExists())
             *
             * }// end try
             * catch (Exception ex)
             * {
             * Console.ForegroundColor = ConsoleColor.Red;
             *
             * Console.WriteLine("\nError - {0}", ex.Message);
             * if (ex.InnerException != null)
             * Console.WriteLine("\nInner Error - {0}", ex.InnerException.Message);
             *
             * Console.WriteLine("\nStack Trace - {0}\n\n", ex.StackTrace);
             * Console.ForegroundColor = ConsoleColor.Gray;
             * ErrorLogger.LogError(ex);
             *
             * goto shutdown;
             * }// end catch (Exception ex)
             */
            #endregion

            var mainMenuStr = BuildMainMenu();

            Console.WriteLine(mainMenuStr);
            Console.Write("Please select an action or enter 'x' to quit: ");
            var input = Console.ReadLine();

            while (!input.ToLower().Equals("x"))
            {
                try
                {
                    var isDone = false;
                    var msg    = string.Empty;

                    switch (input)
                    {
                    case "0":
                        if (!NewIndigoRepo.DoesNewDatabaseExists())
                        {
                            Console.WriteLine("Please enter Master Key password for DB encryption:");
                            string masterKey = Console.ReadLine();
                            isDone = NewIndigoRepo.SetupDatabase(masterKey);

                            if (isDone)
                            {
                                Console.ForegroundColor = ConsoleColor.Green;
                                Console.WriteLine("\nDatabase generate script has been created.");
                                Console.ForegroundColor = ConsoleColor.Gray;

                                //msg = string.Format("Please locate it here: '{0}'and run it before continuing.\n\n",
                                //    (FilesUtils.dirPath + "Output/Database/"));

                                //Console.WriteLine(msg);
                                //ErrorLogger.LogInfo("Database generate script has been created, and can be found here: "
                                //    + Environment.NewLine + (FilesUtils.dirPath + "Output/Database/"));

                                Console.WriteLine("Press enter to continue.");
                                Console.ReadLine();

                                //if (NewIndigoRepo.DoesNewDatabaseExists())
                                //{
                                //    msg = string.Format("Please wait while '{0}' is being prepared...", NewIndigoRepo.DatabaseName);
                                //    Console.WriteLine(msg);
                                //    ErrorLogger.LogInfo(msg);


                                //    isDone = NewIndigoRepo.SetupDatabase(masterKey);

                                //    if (isDone)
                                //        isDone = OriginalIndigoRepo.LogCurrentSeeds();
                                //}// end if (NewIndigoRepo.DoesNewDatabaseExists())
                                //else
                                //    throw new Exception(string.Format("Cannot continue with the selected process as '{0}' does not exists!", NewIndigoRepo.DatabaseName));
                            } // end if (isDone)
                        }     // end if (!NewIndigoRepo.DoesNewDatabaseExists())
                        else
                        {
                            throw new Exception(string.Format("Cannot create '{0}' as it already exists!", NewIndigoRepo.DatabaseName));
                        }

                        break;

                    case "1":
                        if (NewIndigoRepo.DoesNewDatabaseExists())
                        {
                            var errorMsg = OriginalIndigoRepo.CompareSeedValues();
                            if (!string.IsNullOrEmpty(errorMsg))
                            {
                                throw new Exception(errorMsg);
                            }

                            msg = "Please wait while backing up the databases...";

                            Console.WriteLine("\n{0}", msg);
                            ErrorLogger.LogInfo(msg);

                            if (OriginalIndigoRepo.BackupDatabase())
                            {
                                if (NewIndigoRepo.BackupDatabase())
                                {
                                    msg = "Database bakcups complete...";

                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("{0}\n\n", msg);
                                    ErrorLogger.LogInfo(msg);
                                    Console.ForegroundColor = ConsoleColor.Gray;

                                    var selectedIssuer = BuildSelectIssuerMenu();

                                    if (selectedIssuer != null)
                                    {
                                        msg = string.Format("Issuer: {0} ({1}) is being migrated", selectedIssuer.issuer_name, selectedIssuer.issuer_code);

                                        Console.ForegroundColor = ConsoleColor.Green;
                                        Console.WriteLine(msg);
                                        ErrorLogger.LogInfo(msg);
                                        Console.ForegroundColor = ConsoleColor.Gray;

                                        //isDone = NewIndigoRepo.MigrateIssuer(selectedIssuer.issuer_id);
                                        isDone = ReportsService.GenerateReport(OriginalIndigoRepo.OriginalDataContext, selectedIssuer, false);

                                        if (isDone)
                                        {
                                            isDone = OriginalIndigoRepo.MigrateIssuer(selectedIssuer.issuer_id);
                                        }

                                        if (isDone)
                                        {
                                            isDone = ReportsService.GenerateReport(NewIndigoRepo.NewIndigoDataModel, selectedIssuer, true);
                                        }
                                    }    // end if (selectedIssuer != null)
                                    else
                                    {
                                        throw new Exception(string.Format("Issuer not found"));
                                    }
                                }    // end if (NewIndigoRepo.BackupDatabase())
                                else
                                {
                                    throw new Exception(string.Format("Could not backup '{0}'", NewIndigoRepo.DatabaseName));
                                }
                            }    // if (OriginalIndigoRepo.BackupDatabase())
                            else
                            {
                                throw new Exception(string.Format("Could not backup '{0}'", OriginalIndigoRepo.DatabaseName));
                            }
                        }    // end if (NewIndigoRepo.DoesNewDatabaseExists())
                        else
                        {
                            throw new Exception(string.Format("Cannot continue with the selected process as '{0}' does not exists!", NewIndigoRepo.DatabaseName));
                        }

                        break;

                    case "2":
                        if (NewIndigoRepo.DoesNewDatabaseExists())
                        {
                            Console.WriteLine("\nPlease wait while backing up the databases...");

                            if (OriginalIndigoRepo.BackupDatabase())
                            {
                                if (NewIndigoRepo.BackupDatabase())
                                {
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("Database bakcups complete...\n\n");
                                    Console.ForegroundColor = ConsoleColor.Gray;

                                    msg = "Please wait while updating the seed values...";

                                    Console.WriteLine("\n{0}", msg);
                                    ErrorLogger.LogInfo(msg);

                                    isDone = OriginalIndigoRepo.LogCurrentSeeds();

                                    msg = "Updating seed values complete...";

                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("{0}\n\n", msg);
                                    Console.ForegroundColor = ConsoleColor.Gray;
                                }    // end if (NewIndigoRepo.BackupDatabase())
                                else
                                {
                                    throw new Exception(string.Format("Could not backup '{0}'", NewIndigoRepo.DatabaseName));
                                }
                            }    // if (OriginalIndigoRepo.BackupDatabase())
                            else
                            {
                                throw new Exception(string.Format("Could not backup '{0}'", OriginalIndigoRepo.DatabaseName));
                            }
                        }    // end if (NewIndigoRepo.DoesNewDatabaseExists())
                        else
                        {
                            throw new Exception(string.Format("Cannot continue with the selected process - Database backup as '{0}' does not exists!", NewIndigoRepo.DatabaseName));
                        }

                        break;

                    default:
                        msg = "Error - Invalid selection. Please try again";
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\n{0}", msg);
                        ErrorLogger.LogError(msg);
                        Console.ForegroundColor = ConsoleColor.Gray;

                        break;
                    }// end switch (input)

                    if (isDone)
                    {
                        msg = "Operation complete! :)";

                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("\n{0}\n", msg);
                        ErrorLogger.LogInfo(msg);
                        Console.ForegroundColor = ConsoleColor.Gray;
                    }// end if (isDone)
                    else
                    {
                        msg = "Operation could not be completed :{";
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\n{0}\n", msg);
                        ErrorLogger.LogError(msg);
                        Console.ForegroundColor = ConsoleColor.Gray;
                    }
                }// end try
                catch (Exception ex)
                {
                    Console.ForegroundColor = ConsoleColor.Red;

                    Console.WriteLine("\nError - {0}", ex.Message);
                    if (ex.InnerException != null)
                    {
                        Console.WriteLine("\nInner Error - {0}", ex.InnerException.Message);
                    }

                    Console.WriteLine("\nStack Trace - {0}\n\n", ex.StackTrace);

                    Console.ForegroundColor = ConsoleColor.Gray;

                    ErrorLogger.LogError(ex);
                }// end catch (Exception ex)



                mainMenuStr = BuildMainMenu();
                Console.WriteLine(mainMenuStr);
                Console.Write("Please select an action or enter 'x' to quit: ");

                input = Console.ReadLine();
            }// end while (!input.ToLower().Equals("x"))

shutdown:
            Console.WriteLine("\n\nApplication is shutting down...\nPress any key to close.");
            ErrorLogger.LogInfo("Application is shutting down");
            Console.ReadLine();
        }