Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine(OperatingSystemInfo.Get().ToString());
            DSSwitch.NiceApiLibrary_StartUp(s_Log, true);
            s_Log.logSQL = true;

            bool     go   = true;
            Question ques = new Question();

            ques.Add(new QuestionOption("Email templates", EmailTemplates.Go));
            ques.Add(new QuestionOption("Add Tel# to free account...", NumberManager.AddToFree));
            ques.Add(new QuestionOption("Add Tel# to COMMERCIAL account...", NumberManager.Manager));
            ques.Add(new QuestionOption("Get Credit", WhatsappMessages.CheckCredit));
            ques.Add(new QuestionOption("EmailFromAPpiKey", Tests.EmailFromAPpiKey));

            // ques.Add(new QuestionOption("Send Moved emails", ); rrt//SendMovedEmail.Go(s_LogZap); break;
            //ques.Add(new QuestionOption("Send Nice test mail", SendNiceTestMail.Go));
            ques.Add(new QuestionOption("show Lib Version", Others.LibVersion));
            //            ques.Add(new QuestionOption("Just a log message", Others.JustALogMessage));
            ques.Add(new QuestionOption("Send Whatsapp messages...", WhatsappMessages.Go));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys01", WhatsappMessages.GoSys01));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys02", WhatsappMessages.GoSys02));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys03", WhatsappMessages.GoSys03));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys03 group", WhatsappMessages.GoSys03group));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys04", WhatsappMessages.GoSys04));
            ques.Add(new QuestionOption("Send Whatsapp messages SysTest", WhatsappMessages.GoSysTest));
            //            ques.Add(new QuestionOption("Send ANY email", SendEmail.All));
            ques.Add(new QuestionOption("Show Logs", ShowLogs.Go));
            //ques.Add(new QuestionOption("Test SQL Copy", SQLCopy.Go));
            ques.Add(new QuestionOption("IIS Log All (dataLogger output)", IISLog.All));
            ques.Add(new QuestionOption("IIS Log Day Sum (dataLogger output)", IISLog.DaySummary));
            ques.Add(new QuestionOption("Tel# Analyser", TelNumberAnalyser.Analyse));
//            ques.Add(new QuestionOption("Test commercial code changes", CommercialCodeChange.Test));
            //ques.Add(new QuestionOption("Send Tel Check...", NumberManager.SendTelCheck));
            //ques.Add(new QuestionOption("Send Tel Sync (Dangerous)...", NumberManager.SendTelSync));
            ques.Add(new QuestionOption("Show Data_MessageFile content ...", ShowData_MessageFileContent.ShowAll));
            ques.Add(new QuestionOption("Get new APIId ...", Others.GetNewAPIId));
            //ques.Add(new QuestionOption("Test LibAPI...", Tests.LibAPI));
            ques.Add(new QuestionOption("Show Wallet contents", ShowWallet.Go));
            ques.Add(new QuestionOption("Ftp backup", FtpBackup.Go));
//            ques.Add(new QuestionOption("Sql Tester", SqlTesterForm.Show));
            ques.Add(new QuestionOption("Set LowLevelHttpDumping", delegate(IMyLog log, QuestionOption it) { LowLevelHttpDumper.Enabled = true; }));
            //ques.Add(new QuestionOption("500 Error Test", WhatsappMessages.Error500));
            //            ques.Add(new QuestionOption("Tests.TestQueuePriority", Tests.TestQueuePriority));
            //ques.Add(new QuestionOption("MultySystem Debug", Tests.MultySystemDebugs));
            //ques.Add(new QuestionOption("cUrl Command", cUrl_Command.Go));
            //ques.Add(new QuestionOption("Debug Loopback process...", Tests.DebugLoopback));
            //ques.Add(new QuestionOption("Debug DisplayTextControllerPart_MultiLine", Tests.DebugDisplayTextControllerPart_MultiLine));
            //ques.Add(new QuestionOption("Debug Android Sync in low lib", Tests.DebugAndroidSyncInLowLib));
            //ques.Add(new QuestionOption("Debug Debug_DirectTel", Tests.Debug_DirectTel));



            while (go)
            {
                ques.AskAndAct("What to do (SQLite Version", s_Log);
            }
        }
Example #2
0
        internal static void StartUp(IMyLog _log, bool waitUntilStartupIsDone)
        {
            maintenanceLog = new MyMemoryLog();

            IMyLog log = new MyManyLog(new List <IMyLog>()
            {
                maintenanceLog, _log
            });

            log.Info("DSSwitch.StartUp");
            System.Reflection.Assembly.GetAssembly(typeof(IMyLog)).GetAssemblyVersion().ToList().ForEach(_ => log.Debug(_));

            ManualResetEvent bgDone = new ManualResetEvent(false);

            Thread bg = new Thread(
                delegate()
            {
                try
                {
                    log.Debug("This is the startup background thread.");
                    log.Debug(OperatingSystemInfo.Get().ToString());
                    log.Debug(System.Reflection.Assembly.GetExecutingAssembly().Location);
                    log.Debug(log.GetLoggerInfo());
                    log.Debug("Reading instruction file");
                    string instruction = "IniAndRunFile";
                    try
                    {
                        //instruction =
                        //    File.ReadAllText(
                        //        FolderNames.GetFolder(MyFolders.ASP_ServerStateFolder) + "\\StartupInstruction.txt")
                        //        .Trim()
                        //        .Replace("\r", "")
                        //        .Replace("\n", "")
                        //        .Replace("\t", "")
                        //        .Replace(" ", "");
                    }
                    catch (SystemException)
                    {
                        log.Error("Unable to read instruction file, using default values.");
                    }
                    log.Debug("=> " + instruction);
                    foreach (string i1 in instruction.Split(new char[] { ',' }))
                    {
                        log.Debug("-> " + i1);
                        switch (i1)
                        {
                        case "Wait":
                            try
                            {
                                log.Debug("Waiting...");
                                Thread.Sleep(5000);
                                log.Debug("Waiting done");
                            }
                            catch (Exception ex)
                            {
                                log.Error(ex.ToString());
                            }
                            break;

                        //case "SQLiteLogFilename":
                        //    try
                        //    {
                        //        log.Debug(FolderNames.GetFolder(MyFolders.sqlite_All));
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        //case "SQLiteTestStartup":
                        //    try
                        //    {
                        //        log.Debug(TestStartUp());
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        //case "SQLiteExists":
                        //    try
                        //    {
                        //        if (File.Exists(FolderNames.GetFolder(MyFolders.sqlite_All)))
                        //        {
                        //            log.Info("SQLite is there.");
                        //        }
                        //        else
                        //        {
                        //            log.Info("SQLite is NOT there.");
                        //        }
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        //case "CopyToSQLiteIfNotExist":
                        //    try
                        //    {
                        //        if (File.Exists(FolderNames.GetFolder(MyFolders.sqlite_All)))
                        //        {
                        //            log.Info("SQLite is there. So nothing to copy");
                        //        }
                        //        else
                        //        {
                        //            if (sqLiteConnectionHolder.StartUp(log))
                        //            {
                        //                File2DbConverter.Convert(true, log);
                        //            }
                        //        }
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        //case "IniAndRunSQLite":
                        //    try
                        //    {
                        //        if (sqLiteConnectionHolder.StartUp(log))
                        //        {
                        //            appUser_SQLite = new Data_AppUserFileHandling_SQLite(log);
                        //            appWallet_SQLite = new Data_AppUserWalletHandling_SQLite(log);
                        //            sql_SQLite = new Data_SqlHandling_SQLite(log);
                        //            msg00_SQLite = new Data_Net__00NormalMessage_SQLite(log);
                        //            msg02_SQLite = new Data_Net__02ScreenshotRequest_SQLite(log);
                        //            msg04_SQLite = new Data_Net__04CheckTelNumbers_SQLite(log);
                        //            ChangeDataSource(eDataSource.SQLite);
                        //            underMaintenance = false;
                        //            log.Info("Startup.Running");
                        //        }
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        case "IniAndRunFile":
                            try
                            {
                                _data_Full = new DataFull_File();

                                var ini = _data_Full.GetSystems(true);


                                //appUser_File = new Data_AppUserFileHandling_File();
                                //appWallet_File = new Data_AppUserWalletHandling_File();
                                //sql_File = new Data_SqlHandling_File();
                                //msg00_File = new Data_Net__00NormalMessage_File();
                                //msg02_File = new Data_Net__02ScreenshotRequest_File();
                                //msg04_File = new Data_Net__04CheckTelNumbers_File();
                                //ChangeDataSource(eDataSource.File);
                                underMaintenance = false;
                                log.Info("Startup.Running");
                            }
                            catch (Exception ex)
                            {
                                log.Error(ex.ToString());
                            }
                            break;

                        default:
                            log.Error("instruction not recognised");
                            break;
                        }
                    }
                }
                catch (SystemException se)
                {
                    log.Error(se.Message);
                }
                bgDone.Set();
            });

            bg.Start();

            if (waitUntilStartupIsDone)
            {
                bgDone.WaitOne();
            }
            log.Info("DSSwitch.StartUp done");
        }