Example #1
0
        static void Main(string[] args)
        {
            LogInitializer.InitializeLogger("BLW.WindowServiceInvokation");
            try
            {
                // Invoke class instance
                Factory getInstance = new Factory();
                SingletonLogger.Instance.Error(ConfigurationManager.AppSettings["DbFile"]);
                try
                {
                    // Class Trigger based
                    var tiggerBased = getInstance.GetInstance("TRIGGERBASE");
                    tiggerBased.Processing();
                }
                catch (Exception ex)
                {
                    SingletonLogger.Instance.Error(ex.GetBaseException().ToString());
                }

                // Call Time based
                try
                {
                    var timeBased = getInstance.GetInstance("TIMEBASE");
                    timeBased.Processing();
                }
                catch (Exception ex)
                {
                    SingletonLogger.Instance.Error(ex.GetBaseException().ToString());
                }
            }
            catch (Exception ex)
            {
                SingletonLogger.Instance.Error(ex.Message, ex.GetBaseException());
            }
        }
        protected override void ProcessRecord()
        {
            LogInitializer.Initialize();

            var ctx = new Bb.Oracle.Reader.ArgumentContext()
            {
                Login           = Username,
                Pwd             = Password,
                Source          = Source,
                Filename        = this.OutputFilename,
                ExcludeCode     = ExcludeCode,
                Name            = string.IsNullOrEmpty(Name) ? Source : Name,
                ExcludedSchemas = ExcludedSchemas,
                OwnerFilter     = this.OwnerFilter
            };

            FileInfo f = new FileInfo(this.OutputFilename);

            if (!f.Directory.Exists)
            {
                f.Directory.Create();
            }

            OracleDatabase db = Database.GenerateFile(ctx);

            base.WriteObject(db);

            base.ProcessRecord();
        }
Example #3
0
        public bool Initialize(string[] args)
        {
#if DEBUG
            Console.WriteLine("Starting Debugging Mode..");
#else
            Console.WriteLine("Starting Production Mode..");
#endif

            //Initializing variables
            LogInitializer.InitializeLogger(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
            //show current assembly version
            SingletonLogger.Instance.Info("Assembly Version Infomration : " +
                                          System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());

#if !DEBUG
            //Validate command line arguments
            #region Validate Arguments
            SingletonLogger.Instance.Debug("Validating command arguments..");
            if (args.Length == 0)
            {
                SingletonLogger.Instance.Debug("System generated GUID not passed to.");
                return(false);
            }
            var systemGuid = args[0];
            SingletonLogger.Instance.Debug(" System generated GUID = " + systemGuid);
            #endregion
#endif
            return(true);
        }
Example #4
0
        /// <summary>
        /// Registers external services for commerce like MVC constructs, security providers and Analytics
        /// </summary>
        internal static void RegisterExternalServices()
        {
            // Register log.
            LogInitializer.CreateLogInstance(CommerceServiceConfig.Instance.LogVerbosity,
                                             CommerceServiceConfig.Instance.ForceEventLog,
                                             General.CommerceLogSource,
                                             CommerceServiceConfig.Instance);

            // Register MVC constructs.
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Register security providers.
            IUsersDal usersDal = PartnerFactory.UsersDal(CommerceServiceConfig.Instance);

            if (CommerceServiceConfig.Instance.EnableDebugSecurityProvider == true)
            {
                Security.Add("user_debug", new UserDebugSecurityProvider(usersDal));
            }
            Security.Add("usertoken", new UserTokenSecurityProvider());

            // Register Analytics Service
            Analytics.Initialize(CommerceServiceConfig.Instance);
        }
Example #5
0
        public IComGeneralDemo(ILegacyMetasysClient legacyClient)
        {
            this.legacyClient = legacyClient;
            Type declaringType = MethodBase.GetCurrentMethod().DeclaringType;

            log = new LogInitializer(declaringType);
        }
Example #6
0
 public CLI(ILog logger, LogInitializer logInitializer, IDirectoryLocator directoryLocator, PluginLoader pluginLoader, IController controller)
 {
     _logger         = logger;
     _logInitializer = logInitializer;
     _pluginLoader   = pluginLoader;
     _controller     = controller;
 }
 /// <summary>
 /// Initialise Manage Licences form
 /// </summary>
 public frmManageLicences()
 {
     InitializeComponent();
     LogInitializer.InitializeLogger("LicenceApp");
     lblMessage.Visible = true;
     SingletonLogger.Instance.Attach(new ObserverLogToWindows(lblMessage)); // Send log messages to debugger form lbl message (output window).
 }
Example #8
0
        public void Start()
        {
            LogInitializer.InitializeLogger();

            Global.Logger.Info("Initializing database.");
            var databaseInitializer = new DatabaseInitializer();

            databaseInitializer.Initialize();

            Global.Logger.Info("Initializing snapshot update scheduler.");
            var damSnapshotUpdateService = new DamSnapshotUpdateService(
                new DamExcelDownloader(new DownloadService()),
                new ExcelReader(),
                new DataSetToDamSnapshotTranslator(new DamRepository(() => new DataContext())),
                new DamSnapshotRepository(() => new DataContext()));

            _updateDamSnapshotsScheduler = new UpdateDamSnapshotsScheduler(
                damSnapshotUpdateService);

            Global.Logger.Info("Strating scheduler database.");
            var task = _updateDamSnapshotsScheduler.Start();

            task.Wait(TimeSpan.FromSeconds(30));
            if (task.Status != TaskStatus.RanToCompletion)
            {
                throw new Exception("Failed to start scheduler.");
            }
        }
Example #9
0
        static void Main(string[] args)
        {
            var logInitializer = new LogInitializer();
            var logger         = logInitializer.InitializeLogger();
            var engine         = new Engine(logger);

            engine.Run();
        }
Example #10
0
        protected override void ProcessRecord()
        {
            LogInitializer.Initialize();

            FileInfo f = new FileInfo(this.InputFilename);
            if (!f.Exists)
                throw new FileNotFoundException(f.FullName);

            var db = OracleDatabase.ReadFile(f.FullName);

            base.WriteObject(db);

            base.ProcessRecord();
        }
Example #11
0
        private void LogError()
        {
            /* SNIPPET 4: START */
            // Initialize Logger with your context Class
            var log = new LogInitializer(typeof(Program));

            try
            {
                // Your Try logic here...
            }
            catch (Exception ex) {
                log.Logger.Error(string.Format("An error occured - {0}", ex.Message));
            }
            /* SNIPPET 4: END */
        }
Example #12
0
        /// <summary>
        /// Registers external services for commerce like MVC constructs, security providers and Analytics
        /// </summary>
        internal static void RegisterExternalServices()
        {
            // Use only for debugging
            // TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true;
            TelemetryConfiguration.Active.InstrumentationKey = CloudConfigurationManager.GetSetting("APPINSIGHTS_INSTRUMENTATIONKEY");

            // Register log.
            LogInitializer.CreateLogInstance(CommerceServiceConfig.Instance.LogVerbosity,
                                             CommerceServiceConfig.Instance.ForceEventLog,
                                             General.CommerceLogSource,
                                             CommerceServiceConfig.Instance);

            Log.Info("Started Commerce MBI service.");

            // Register MVC constructs.
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            // Bing FrontDoor and user debug security providers.
            IUsersDal usersDal = PartnerFactory.UsersDal(CommerceServiceConfig.Instance);

            if (CommerceServiceConfig.Instance.EnableDebugSecurityProvider == true)
            {
                Security.Add("user_debug", new UserDebugSecurityProvider(usersDal));
            }

            Security.Add("lomo", new LomoSecurityProvider(usersDal));

            // Register the mutual SSL security provider.
            Security.Add(MutualSslSecurityProvider.Name, new MutualSslSecurityProvider());

            // Register the Simple Web Token security provider.
            string environment      = string.Concat("commerce-", CommerceServiceConfig.Instance.Environment);
            string resourceTemplate = string.Concat(string.Format("https://{0}.TODO_INSERT_YOUR_DOMAIN_HERE/api/commerce/service/",
                                                                  environment), "{0}");

            Security.Add(SimpleWebTokenSecurityProvider.Name,
                         new SimpleWebTokenSecurityProvider(environment, resourceTemplate,
                                                            CommerceServiceConfig.Instance.SimpleWebTokenKey));

            // Amex payment authorization SWT security provider
            Security.Add("Bearer", new SimpleWebTokenSecurityProvider(environment,
                                                                      string.Concat(string.Format("https://{0}.TODO_INSERT_YOUR_DOMAIN_HERE/api/commerce/amex/", environment), "{0}"),
                                                                      CommerceServiceConfig.Instance.SimpleWebTokenKey));

            // Register Analytics Service
            Analytics.Initialize(CommerceServiceConfig.Instance);
        }
Example #13
0
        protected override void ProcessRecord()
        {
            LogInitializer.Initialize();

            var    sf = new FileInfo(Output);
            string folderForSource = Path.Combine(sf.Directory.FullName, Path.GetFileNameWithoutExtension(sf.Name), Path.GetFileNameWithoutExtension(Source.Name));
            string folderForTarget = Path.Combine(sf.Directory.FullName, Path.GetFileNameWithoutExtension(sf.Name), Path.GetFileNameWithoutExtension(Target.Name));

            ModelComparer    comparer = new ModelComparer();
            DifferenceModels diff     = new DifferenceModels(folderForSource, folderForTarget, c => Trace.WriteLine(c));

            comparer.CompareModels(Source, Target, diff, new CompareContext()
            {
            });

            base.WriteObject(diff);

            base.ProcessRecord();
        }
Example #14
0
        // This an entry point
        static PluginEntryPoint()
        {
            if (UnityUtils.IsInBatchModeAndNotInRiderTests)
            {
                return;
            }

            LogInitializer.InitLog(PluginSettings.SelectedLoggingLevel); // init log before doing any logging
            UnityEventLogSender.Start();                                 // start collecting Unity messages asap

            ourPluginSettings    = new PluginSettings();
            ourRiderPathProvider = new RiderPathProvider(ourPluginSettings);

            if (IsLoadedFromAssets()) // old mechanism, when EditorPlugin was copied to Assets folder
            {
                var riderPath = ourRiderPathProvider.GetActualRider(EditorPrefsWrapper.ExternalScriptEditor,
                                                                    RiderPathLocator.GetAllFoundPaths(ourPluginSettings.OperatingSystemFamilyRider));
                if (!string.IsNullOrEmpty(riderPath))
                {
                    AddRiderToRecentlyUsedScriptApp(riderPath);
                    if (IsRiderDefaultEditor() && PluginSettings.UseLatestRiderFromToolbox)
                    {
                        EditorPrefsWrapper.ExternalScriptEditor = riderPath;
                    }
                }

                if (!PluginSettings.RiderInitializedOnce)
                {
                    EditorPrefsWrapper.ExternalScriptEditor = riderPath;
                    PluginSettings.RiderInitializedOnce     = true;
                }

                InitForPluginLoadedFromAssets();
                Init();
            }
            else
            {
                Init();
            }
        }
Example #15
0
        protected override void ProcessRecord()
        {
            LogInitializer.Initialize();

            string path = SourcePath;

            SolutionFolder sln = new SolutionFolder(new ScriptParserContext(path, searchPattern));

            OracleDatabase db = new OracleDatabase()
            {
                SourceScript = true,
                Name         = Name,
            };

            var visitor = new ConvertScriptToModelVisitor();

            if (this.Validators != null)
            {
                visitor.Validators.AddRange(this.Validators);
            }

            sln.Visit(visitor);

            // Map items in db


            FileInfo file = new FileInfo(OutputFilename);

            if (!file.Directory.Exists)
            {
                file.Directory.Create();
            }

            db.WriteFile(file.FullName);

            base.WriteObject(db);

            base.ProcessRecord();
        }
Example #16
0
        public FormMain(ILog logger, LogInitializer logInitializer, IDirectoryLocator directoryLocator, IPreferenceManager preferenceManager,
                        PluginLoader pluginLoader, IPluginRepository pluginRepository, IController controller,
                        IDriveDetector driveDetector, ITaskbarItemFactory taskbarItemFactory, IWindowMenuFactory windowMenuFactory,
                        INetworkStatusMonitor networkStatusMonitor, UpdateClient updateClient, AppConfig appConfig)
        {
            InitializeComponent();

            Load        += OnLoad;
            FormClosing += OnFormClosing;

            _logger               = logger;
            _logInitializer       = logInitializer;
            _directoryLocator     = directoryLocator;
            _preferenceManager    = preferenceManager;
            _pluginLoader         = pluginLoader;
            _pluginRepository     = pluginRepository;
            _controller           = controller;
            _driveDetector        = driveDetector;
            _taskbarItem          = taskbarItemFactory.GetInstance(Handle);
            _windowMenuFactory    = windowMenuFactory;
            _networkStatusMonitor = networkStatusMonitor;
            _updateClient         = updateClient;
            _appConfig            = appConfig;

            progressBar.UseCustomColors = true;
            progressBar.GenerateText    = percentComplete => string.Format("{0}: {1:0.00}%", _state, percentComplete);

            var recentFiles = _preferenceManager.Preferences.RecentFiles;

            if (recentFiles.RememberRecentFiles && recentFiles.RecentBDROMPaths.Any())
            {
                textBoxInput.Text = recentFiles.RecentBDROMPaths.First();
            }

            toolsToolStripMenuItem.Visible      = false;
            debugToolStripMenuItem.Visible      = _appConfig.IsDebugMode;
            updateToolStripMenuItem.Visible     = false;
            toolStripStatusLabelOffline.Visible = false;
        }
Example #17
0
        /// <summary>
        /// When the worker role starts, we do the following:
        /// 1. Initialize Logger to be used
        /// 2. Schedule Extract Processing job on startup if configured for.
        /// 3. Schedule Ping Job
        /// </summary>
        /// <remarks>
        /// If we schedule Extract Processing job at the same time everyday, we might get
        /// duplicate jobs to execute at the same time (which might be a problem when we have
        /// more than one instance of the role). We can revisit this later, but for now we will
        /// schedule it at the start.
        /// </remarks>
        /// <returns>
        /// boolean status about startup
        /// </returns>
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 100 * Environment.ProcessorCount;

            // Use only for debugging
            // TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true;
            //TelemetryConfiguration.Active.InstrumentationKey = CloudConfigurationManager.GetSetting("APPINSIGHTS_INSTRUMENTATIONKEY");

            // Create a CommerceLog instance to funnel log entries to the log.
            LogInitializer.CreateLogInstance(CommerceWorkerConfig.Instance.LogVerbosity,
                                             CommerceWorkerConfig.Instance.ForceEventLog, CommerceLogSource,
                                             CommerceWorkerConfig.Instance);
            Log = new CommerceLog(Guid.NewGuid(), CommerceWorkerConfig.Instance.LogVerbosity, CommerceLogSource);
            ConfigChangeHandler = new ConfigChangeHandler(Log, ExemptConfigurationItems);

            // turn off processing jobs at start
            ProcessJobs = Convert.ToBoolean(CloudConfigurationManager.GetSetting(ProcessJobsPropertyKey));
            // role should not exit even after processing jobs stop
            ExitRole = false;

            // event handlers
            RoleEnvironment.Changing += RoleEnvironmentChanging;
            RoleEnvironment.Changed  += RoleEnvironmentChanged;

            if (!string.IsNullOrEmpty(ConcurrencyMonitorConnectionString))
            {
                Log.Verbose("Initializing Jobs.");
                using (ConcurrencyMonitor monitor = new ConcurrencyMonitor(ConcurrencyMonitorConnectionString))
                {
                    monitor.InvokeWithLease(() => PartnerJobInitializer.InitializeJobs(Scheduler));
                }
                Log.Verbose("Initialized Jobs.");
            }

            return(base.OnStart());
        }
Example #18
0
        static void Main(string[] args)
        {
            var log = new LogInitializer(typeof(Program));

            try
            {
                var comMetasysClientFactory = new ComMetasysClientFactory();
                Console.WriteLine("Please enter your credentials." +
                                  "\nRefer to the metasys-server/basic-services-dotnet README if you need help getting started.");
                Console.Write("Enter the Hostname:");
                var hostName = Console.ReadLine();
                Console.Write("Enter the Username:"******"Enter the Password:"******"Logging In.....");
                Console.WriteLine("Login Successfull...");
                #endregion

                bool showMenu = true;
                while (showMenu)
                {
                    showMenu = MainMenu(legacyClient);
                }
            }
            catch (Exception exception)
            {
                log.Logger.Error(string.Format("An error occured while login - {0}", exception.Message));
                Console.WriteLine("\n \nAn Error occurred. Press Enter to return to exit");
            }
            Console.ReadLine();
        }
Example #19
0
        static void Main(string[] args)
        {
            var systemGuid = string.Empty;

            try
            {
                LogInitializer.InitializeLogger("Trigger Manager");

                SingletonLogger.Instance.Debug("Trigger Manager Component starts.");

                #region Validate Command Arguments
                if (args.Length == 0)
                {
                    throw new ArgumentOutOfRangeException("No argument supplied for run Trigger manager");
                }

                if (String.IsNullOrEmpty(args[0]))
                {
                    throw new ArgumentOutOfRangeException("System Guid not supplied");
                }
                else
                {
                    systemGuid = Convert.ToString(args[0]);
                }
                #endregion

                try
                {
                    SingletonLogger.Instance.Debug("System generated GUID = " + systemGuid);

                    IRunDetailsRepository _runRepository = new RunDetailsRepository();

                    // Getting Active RunNumber From RunDetails Table. Get only those RunNumber those have "RunStatus=1"
                    var runNumberDetailList = _runRepository.GetRunDetailByStatus((int)RunNumberStatusType.Ready);

                    if (runNumberDetailList.Count() == 0)
                    {
                        SingletonLogger.Instance.Debug("No run number found for trigger generation.");
                        return;
                    }

                    SingletonLogger.Instance.Debug("Total " + runNumberDetailList.Count() + " run number found for trigger generation.");

                    TriggerFileGenerator objTriggerFileGenerator = new TriggerFileGenerator();

                    foreach (var runNumber in runNumberDetailList)
                    {
                        // If any component for this run number is already running or error out
                        // then no need to created the trigger file and continue for other run number trigger file creation.
                        bool status = objTriggerFileGenerator.CheckForTriggerFileCreation(runNumber);

                        if (!status)
                        {
                            continue;
                        }

                        // Get total trigger file to be generated for run number
                        SingletonLogger.Instance.Debug("Process has been started for creating trigger file for RunNumber = " + runNumber.RunNumber);
                        List <TriggerFileGenerator> TriggerFileGeneratorList = objTriggerFileGenerator.GetTriggerFileGeneratorList(runNumber);

                        if (TriggerFileGeneratorList.Count() > 0)
                        {
                            try
                            {
                                objTriggerFileGenerator.CreateTriggerFile(TriggerFileGeneratorList);
                            }
                            catch (IOBLWException iEx)
                            {
                                SingletonLogger.Instance.Warning(iEx.ToString());
                                continue;
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                        }
                        else
                        {
                            SingletonLogger.Instance.Debug("No Component Found For Trigger file Generation for RunNumber = " + runNumber.RunNumber);
                        }

                        SingletonLogger.Instance.Debug("All trigger file for RunNumber = " + runNumber.RunNumber + " has been created.");

                        //Update RunStatus of RunNumber to 2
                        using (IRunDetailsRepository repository = new RunDetailsRepository())
                        {
                            repository.UpdateRunStatusByRunNumberId(runNumber.RunDetailId, (int)RunNumberStatusType.Running);
                        }
                        SingletonLogger.Instance.Debug("RunStatus of RunNumber in table RunDetails has been Updated to 2.");
                    }
                }
                catch (Exception ex)
                {
                    SingletonLogger.Instance.Error("Error occur while generating trigger for RunNumber. Error detail : " + ex.GetBaseException().StackTrace);
                }
                finally
                {
                    #region Deleting Entry from Transaction Table
                    try
                    {
                        // SQLITE Database Initialization
                        Transaction trans = Transaction.Get(systemGuid);
                        if (Transaction.Delete(systemGuid))
                        {
                            if (trans != null)
                            {
                                Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now);
                            }
                            SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid);
                        }
                        else
                        {
                            SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid);
                        }
                    }
                    catch (Exception ex2)
                    {
                        SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString());
                    }
                    #endregion
                }
                SingletonLogger.Instance.Debug("Trigger Generation process has been Completed.");
            }
            catch (Exception ex)
            {
                //If errors, then do nothing (just exit)
                SingletonLogger.Instance.Fatal(ex.ToString());
            }
        }
 public SpacesDemo(MetasysClient client)
 {
     this.client = client;
     log         = new LogInitializer(typeof(SpacesDemo));
 }
Example #21
0
        static void Main(string[] args)
        {
            var systemGuid = string.Empty;

            try
            {
                #region Validate Command Arguments
                if (args.Length == 0)
                {
                    throw new ArgumentOutOfRangeException("No argument supplied for run Trigger manager");
                }

                if (String.IsNullOrEmpty(args[0]))
                {
                    throw new ArgumentOutOfRangeException("System Guid not supplied");
                }
                else
                {
                    systemGuid = Convert.ToString(args[0]);
                }

                #endregion

                LogInitializer.InitializeLogger("Email Sender");
                SingletonLogger.Instance.Debug("Email Sender Component starts.");
                SingletonLogger.Instance.Info("Assembly Version Infomration : " +
                                              System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());

                Processing obj = new Processing();
                obj.SendEmails();
            }
            catch (Exception ex)
            {
                SingletonLogger.Instance.Error(ex.GetBaseException().ToString());
            }
            finally
            {
                #region Deleting Entry from Transaction Table
                try
                {
                    // SQLITE Database Initialization
                    Transaction trans = Transaction.Get(systemGuid);
                    if (Transaction.Delete(systemGuid))
                    {
                        if (trans != null)
                        {
                            Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now);
                        }
                        SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid);
                    }
                    else
                    {
                        SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid);
                    }
                }
                catch (Exception ex2)
                {
                    SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString());
                }
                #endregion
            }
        }
Example #22
0
        static void Main(string[] args)
        {
            var    log = new LogInitializer(typeof(Program));
            string connectionDetails;

            try
            {
                if (args.Length != 3)
                {
                    Console.WriteLine("Please enter in your credentials in this format: {username} {password} {hostname} {api_version} or as an alternative you can specify just the Credential Manager target and the hostname in this way {credmantarget} {hostname} {api_version}." +
                                      "\nRefer to the metasys-server/basic-services-dotnet README if you need help getting started.");
                    connectionDetails = Console.ReadLine();
                    args = connectionDetails.Split(' ');
                }
                string username = null, password = null, hostname = null, credManTarget = null; string version = null;

                if (args.Length > 3)
                {
                    username = args[0];
                    password = args[1];
                    hostname = args[2];
                    version  = args[3];
                }
                else
                {
                    credManTarget = args[0];
                    hostname      = args[1];
                    version       = args[2];
                }

                #region Login
                Console.WriteLine("Default culture is en_US. The culture for client translations can be changed in the code.");
                // CultureInfo culture = new CultureInfo("en-US");

                Console.WriteLine("\nLogging in...");
                var apiVersion = (ApiVersion)Enum.Parse(typeof(ApiVersion), version);
                var client     = new MetasysClient(hostname, true, apiVersion, logClientErrors: false); // Disable default logging since it is handled in this app.
                // var client = new MetasysClient(hostname, true); // Ignore Certificate Errors
                // var client = new MetasysClient(hostname, false, ApiVersion.v2, culture);

                AccessToken token;
                if (string.IsNullOrWhiteSpace(credManTarget))
                {
                    token = client.TryLogin(username, password);
                }
                else
                {
                    // Read and login using cred managerfrom Credential manager
                    token = client.TryLogin(credManTarget);
                }
                Console.WriteLine($"Access token: {token.Token} expires {token.Expires}.");
                #endregion

                bool showMenu = true;
                while (showMenu)
                {
                    showMenu = MainMenu(client);
                }
            }
            catch (Exception exception)
            {
                log.Logger.Error(string.Format("An error occured while login - {0}", exception.Message));
                Console.WriteLine("\n \nAn Error occurred. Press Enter to exit");
                Console.ReadLine();
            }
        }
Example #23
0
        /// <summary>
        /// Entry point of the application
        /// </summary>
        /// <param name="args">Command Line arguments</param>
        static void Main(string[] args)
        {
            var systemGuid = string.Empty;

            try
            {
                #region Validate Command Arguments

                if (args.Length == 0)
                {
                    throw new ArgumentOutOfRangeException("No argument supplied for run ProcSession manager");
                }

                if (String.IsNullOrEmpty(args[0]))
                {
                    throw new ArgumentOutOfRangeException("System Guid not supplied");
                }
                else
                {
                    systemGuid = args[0];
                }


                #endregion

                try
                {
                    LogInitializer.InitializeLogger("ProcSessionManager");
                    SingletonLogger.Instance.Debug(" Application ProcSession Manager Component starts.");
                    SingletonLogger.Instance.Debug(" System generated GUID = " + systemGuid);

                    IProcSessionsRepository sessionRepository = new ProcSessionsRepository();

                    SingletonLogger.Instance.Debug("Getting the list of the Unused process");
                    // get list of Unused process from ProcSessions table whose killrequired= true or status=3 or status=2 etc.
                    var unUsedProcessList = sessionRepository.GetAllUnusedProcess();

                    if (unUsedProcessList != null)
                    {
                        foreach (var unusedProcSession in unUsedProcessList)
                        {
                            // validating unusedProcSession
                            if (unusedProcSession != null)
                            {
                                // kill the Process if killrequired = true or expected datetime is < current datetime
                                if (unusedProcSession.KillRequired)
                                {
                                    //Check that no component is running for it

                                    int processId = 0;
                                    // parsing the processId
                                    if (!int.TryParse(unusedProcSession.ProcessID, out processId))
                                    {
                                        throw new Exception("ProcessId is not valid" + processId);
                                    }

                                    Process process = Process.GetProcessById(processId);
                                    if (process == null)
                                    {
                                        SingletonLogger.Instance.Error("No process is running with id{0}" + processId);
                                    }
                                    else
                                    {
                                        try
                                        {
                                            SingletonLogger.Instance.Debug("Start killing the ProcessId = " + processId);
                                            //Killing the process for particular ProcessId
                                            process.Kill();
                                        }
                                        catch (Exception ex)
                                        {
                                            throw new Exception("Error while killing the process for processId" + processId, ex);
                                        }
                                    }
                                }
                            }
                            //update the status of the RunningJob table
                            byte jobstatus = 0;
                            if (unusedProcSession.KillRequired)
                            {
                                jobstatus = (byte)JobStatusType.Status_Killed;
                            }
                            if (unusedProcSession.ExpectedDateTime < DateTime.Now)
                            {
                                jobstatus = (byte)JobStatusType.Status_TimeExp;
                            }
                            if (unusedProcSession.ProcStatus == (Int32)SessionStatusType.Status_Error)
                            {
                                jobstatus = (byte)JobStatusType.Error;
                            }
                            if (unusedProcSession.ProcStatus == (Int32)SessionStatusType.Status_Complete)
                            {
                                jobstatus = (byte)JobStatusType.Complete;
                            }
                            SingletonLogger.Instance.Debug("Deleting the entry from procsession table for ProcsessionId =" + unusedProcSession.ProcSessionId);
                            //Delete ProcSession entry from ProcSessions table
                            sessionRepository.Delete(unusedProcSession.ProcSessionId);
                            SingletonLogger.Instance.Debug("Proc session has been deleted due to status = " + jobstatus);
                        }
                        SingletonLogger.Instance.Debug("ProcSessionManager Component has been Completed");
                    }
                }
                catch (Exception ex)
                {
                    SingletonLogger.Instance.Error("Error occur in ProcSession component Error detail : " + ex.Message);
                }
                finally
                {
                    #region Deleting Entry from Transaction Table
                    try
                    {
                        // SQLITE Database Initialization
                        Transaction trans = Transaction.Get(systemGuid);
                        if (Transaction.Delete(systemGuid))
                        {
                            if (trans != null)
                            {
                                Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now);
                            }
                            Console.WriteLine("Successfully removed column. GUID = " + systemGuid);
                        }
                        else
                        {
                            Console.WriteLine("Error while removing column. GUID = " + systemGuid);
                        }
                    }
                    catch (Exception ex2)
                    {
                        SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString());
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                //If errors, then do nothing (just exit)
                SingletonLogger.Instance.Fatal(ex.ToString());
            }
        }
Example #24
0
        static void Main(string[] args)
        {
            #region Variable Declarations

            var systemGuid  = string.Empty;
            var triggerFile = string.Empty;

            #endregion

            try
            {
                LogInitializer.InitializeLogger("ArchiveManager");
                SingletonLogger.Instance.Debug("Archive Manager component has been started.");

                #region Validate Command Arguments

                // Start Processing
                if (args.Length != 2)
                {
                    SingletonLogger.Instance.Debug("Number of passed arguments are Invalid.");
                    return;
                }
                else
                {
                    triggerFile = args[0];
                    systemGuid  = args[1];
                }

                if (!File.Exists(triggerFile))
                {
                    SingletonLogger.Instance.Error("Trigger file does not exist at = " + triggerFile);
                    return;
                }
                else
                {
                    SingletonLogger.Instance.Debug("Trigger file = " + triggerFile);
                }


                if (String.IsNullOrEmpty(systemGuid))
                {
                    SingletonLogger.Instance.Error("Trigger file does not exist at = " + triggerFile);
                    return;
                }
                else
                {
                    SingletonLogger.Instance.Debug("System generated GUID = " + systemGuid);
                }

                #endregion

                #region Move trigger file from Invoker trigger location to Component trigger location

                // We are moving trigger file from invoker location to avoid reprocessing of same file
                var intermediateTriggerDirectory = AppConfig.GetValueByKey("TriggerFileDirectory");
                if (!Directory.Exists(intermediateTriggerDirectory))
                {
                    Directory.CreateDirectory(intermediateTriggerDirectory);
                }
                var intermediateTriggerFile = Path.Combine(intermediateTriggerDirectory, Path.GetFileName(triggerFile));
                //Move to intermediate directory
                File.Move(triggerFile, intermediateTriggerFile);
                SingletonLogger.Instance.Debug("Trigger has been moved at " + intermediateTriggerFile);

                #endregion

                #region Start processing

                Processing objProcessing = new Processing(intermediateTriggerFile);
                objProcessing.Run();

                SingletonLogger.Instance.Debug("Process of Archive Manager has been completed sucesfully.");
                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                #region Deleting Entry from Transaction Table
                try
                {
                    // SQLITE Database Initialization
                    Transaction trans = Transaction.Get(systemGuid);
                    if (Transaction.Delete(systemGuid))
                    {
                        if (trans != null)
                        {
                            Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now);
                        }
                        SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid);
                    }
                    else
                    {
                        SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid);
                    }
                }
                catch (Exception ex2)
                {
                    SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString());
                }
                #endregion
            }
        }
Example #25
0
        /// <summary>
        /// Entry point of application
        /// </summary>
        /// <param name="args">Command line arguments({Session Key} and {AppId})</param>
        static void Main(string[] args)
        {
            //Declare global variables
            String sessionKey = String.Empty;
            int    appId      = -1;

            //start application
            try
            {
                Console.WriteLine("======Job initialization Process started======");

                #region Validate Command Arguments
                //Validating arguments
                if (args.Count() == 0)
                {
                    throw new ArgumentOutOfRangeException("No argument supplied for run Job initialization");
                }
                if (String.IsNullOrEmpty(args[0]))
                {
                    throw new ArgumentOutOfRangeException("Session key not supplied");
                }
                else
                {
                    sessionKey = Convert.ToString(args[0]);
                }

                if (String.IsNullOrEmpty(args[1]))
                {
                    throw new ArgumentOutOfRangeException("Application ID not supplied");
                }
                else
                {
                    appId = Convert.ToInt32(args[1]);
                }
                #endregion

                LogInitializer.InitializeLogger("JobInitialization_" + appId);
                SingletonLogger.Instance.Info("Assembly Version Infomration : " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                SingletonLogger.Instance.Debug("Connecting to WCF.");
                JobInitHelper helper = new JobInitHelper();
                SingletonLogger.Instance.Debug("Connected.");

                var runNos = helper.Processing(sessionKey, appId);
                if (runNos.Count() != 0)
                {
                    foreach (var runNo in runNos)
                    {
                        SingletonLogger.Instance.Debug("Start preprocessing for run number " + runNo.RunNumber + " and outputPath" + runNo.Output);
                        Main processRunNo = new Main();
                        int  status       = processRunNo.Run(runNo.RunNumber, runNo.Output);
                        if (status == 0)
                        {
                            SingletonLogger.Instance.Debug("Completed preprocessing for run number " + runNo.RunNumber + " and outputPath" + runNo.Output);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error " + e.ToString());
                //If errors, then do nothing (just exit)
                try
                {
                    if (!string.IsNullOrEmpty(sessionKey))
                    {
                        using (IProcSessionsRepository repository = new ProcSessionsRepository())
                        {
                            repository.UpdateBySessionKey(sessionKey, Convert.ToByte(JobStatusType.Error));
                        }
                    }
                }
                catch (Exception ex)
                {
                    /*Error in update session key*/
                    SingletonLogger.Instance.Error("Error in update session key" + ex.ToString());
                }
                SingletonLogger.Instance.Error("Error in Job Initializer" + e.ToString());
                //  SingletonLogger.Instance.Error(e.ToString());
            }
        }
 public GetObjectIdentifierDemo(MetasysClient client)
 {
     this.client = client;
     log         = new LogInitializer(typeof(GetObjectIdentifierDemo));
 }
Example #27
0
 public JsonOutputDemo(MetasysClient client)
 {
     this.client = client;
     log         = new LogInitializer(typeof(JsonOutputDemo));
 }
Example #28
0
        static void Main(string[] args)
        {
            var systemGuid = string.Empty;

            try
            {
                LogInitializer.InitializeLogger("Status Manager");

                SingletonLogger.Instance.Debug("Application Status Manager Component started.");

                #region Validate Command Arguments

                if (args.Length == 0)
                {
                    throw new ArgumentOutOfRangeException("No argument supplied for run Status Manager");
                }

                if (String.IsNullOrEmpty(args[0]))
                {
                    throw new ArgumentOutOfRangeException("System Guid not supplied");
                }
                else
                {
                    systemGuid = Convert.ToString(args[0]);
                }

                #endregion

                StatusUpdater objStatusUpdater = new StatusUpdater();

                // Get all status location to check status file.
                List <string> statusFileList = objStatusUpdater.GetAllActiveComponentTriggerAndStatusFileLocation().Select(x => x.StepStatusLocation).Distinct().ToList();
                SingletonLogger.Instance.Debug("Total Component status location " + statusFileList.Count());

                if (statusFileList.Count() > 0)
                {
                    SingletonLogger.Instance.Debug("Total " + statusFileList.Count() + " Status locations found for status file update.");
                    //Process for each location for status file update.
                    foreach (var item in statusFileList)
                    {
                        try
                        {
                            SingletonLogger.Instance.Debug("Status File location = " + item);
                            objStatusUpdater.UpdateStatus(item);
                        }
                        catch (Exception ex)
                        {
                            SingletonLogger.Instance.Info(ex.ToString());
                            continue;
                        }
                    }
                }
                else
                {
                    SingletonLogger.Instance.Debug("No Status location found for status file update.");
                }
            }
            catch (Exception ex)
            {
                SingletonLogger.Instance.Error(ex.ToString());
            }
            finally
            {
                #region Deleting Entry from Transaction Table
                try
                {
                    // SQLITE Database Initialization
                    Transaction trans = Transaction.Get(systemGuid);
                    if (Transaction.Delete(systemGuid))
                    {
                        if (trans != null)
                        {
                            Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now);
                        }
                        SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid);
                    }
                    else
                    {
                        SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid);
                    }
                }
                catch (Exception ex2)
                {
                    SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString());
                }
                #endregion
            }
            SingletonLogger.Instance.Debug(" Application Status Manager Component ended.");
        }
Example #29
0
        static void Main(string[] args)
        {
            LogInitializer.InitializeLogger("ZipExtractor");
            SingletonLogger.Instance.Debug("Extractor component has been started.");
            var systemGuid  = string.Empty;
            var triggerFile = string.Empty;

            #region Validate Command Arguments

            // Start Processing
            if (args.Length != 2)
            {
                SingletonLogger.Instance.Debug("Number of passed arguments are Invalid.");
                return;
            }
            else
            {
                triggerFile = args[0];
                systemGuid  = args[1];
            }

            if (!File.Exists(triggerFile))
            {
                SingletonLogger.Instance.Error("Trigger file does not exist at = " + triggerFile);
                return;
            }
            else
            {
                SingletonLogger.Instance.Debug("Trigger file = " + triggerFile);
            }


            if (String.IsNullOrEmpty(systemGuid))
            {
                SingletonLogger.Instance.Error("Trigger file does not exist at = " + triggerFile);
                return;
            }
            else
            {
                SingletonLogger.Instance.Debug("System generated GUID = " + systemGuid);
            }

            #endregion

            #region Move trigger file from Invoker trigger location to Component trigger location

            // We are moving trigger file from invoker location to avoid reprocessing of same file
            TriggerFileLocation = AppConfig.GetValueByKey("TriggerFileDirectory");
            if (!Directory.Exists(TriggerFileLocation))
            {
                Directory.CreateDirectory(TriggerFileLocation);
            }
            TriggerFileLocation = Path.Combine(TriggerFileLocation, Path.GetFileName(triggerFile));
            //Move to intermediate directory
            File.Move(triggerFile, TriggerFileLocation);
            SingletonLogger.Instance.Debug("Trigger has been moved at " + TriggerFileLocation);

            #endregion

            XmlHelper objXmlHelper       = new XmlHelper();
            var       componentStartDate = DateTime.Now.ToString();

            SingletonLogger.Instance.Debug("Process start reading Trigger XML file " + TriggerFileLocation);
            TriggerFileReader objTriggerFileReader = new TriggerFileReader();
            objTriggerFileReader.TriggerFileLocaton = TriggerFileLocation;
            var triggerFileDetail = objTriggerFileReader.GetTriggerFileDetail();
            SingletonLogger.Instance.Debug("Process successfully read trigger XML file.");
            try
            {
                mapper = new PatternMatchingMapper();
                mapper.SetCurrentDateFormat();
                mapper.SetClientAndAppDetails(triggerFileDetail.RunNumber);


                var inputLocation  = triggerFileDetail.InputDetails.FirstOrDefault();
                var outputLocation = triggerFileDetail.OutputDetails.FirstOrDefault();
                if (inputLocation == null)
                {
                    throw new Exception("");
                }

                string inputLoc  = mapper.EvaluateString(inputLocation.DirectoryLocation);
                string outputLoc = mapper.EvaluateString(outputLocation.DirectoryLocation);
                if (String.IsNullOrEmpty(inputLoc))
                {
                    throw new Exception("Input loction is never be null or empty");
                }
                if (!Directory.Exists(inputLoc))
                {
                    throw new Exception("Input loction not exists" + inputLoc);
                }
                var availableFiles = Directory.GetFiles(inputLoc, inputLocation.FileMask);

                if (String.IsNullOrEmpty(outputLoc))
                {
                    throw new Exception("Output loction is never be null or empty");
                }
                if (!Directory.Exists(outputLoc))
                {
                    Directory.CreateDirectory(outputLoc);
                }


                foreach (var zipfile in availableFiles)
                {
                    // Start Extracting
                    SingletonLogger.Instance.Debug("Start processing " + Path.GetFileName(TriggerFileLocation) + " file.");
                    ExtractOperations.ExtractFile(zipfile, outputLoc);


                    if (AppConfig.FileOperation)
                    {
                        File.Delete(zipfile);
                    }
                }

                objXmlHelper.WriteComponentStatusInTriggerFile(TriggerFileLocation, componentStartDate, DateTime.Now.ToString());
                File.Move(TriggerFileLocation, triggerFileDetail.ComponentStatusDirectory + "\\status_" + Path.GetFileName(TriggerFileLocation));
            }
            catch (Exception ex)
            {
                objXmlHelper.WriteComponentStatusInTriggerFile(TriggerFileLocation, componentStartDate, DateTime.Now.ToString(), "Error", ex.GetBaseException().ToString());
                File.Move(TriggerFileLocation, triggerFileDetail.ComponentStatusDirectory + "\\status_" + Path.GetFileName(TriggerFileLocation));
                SingletonLogger.Instance.Error("Error in ZipExtractor. Error message : " + ex.Message + ". Error Detail : " + ex.StackTrace);
            }
            finally
            {
                #region Deleting Entry from Transaction Table
                try
                {
                    // SQLITE Database Initialization
                    Transaction trans = Transaction.Get(systemGuid);
                    if (Transaction.Delete(systemGuid))
                    {
                        if (trans != null)
                        {
                            Licence.UpdateLastRunEndTime(trans.ExeName, DateTime.Now);
                        }
                        SingletonLogger.Instance.Debug("Successfully removed column. GUID = " + systemGuid);
                    }
                    else
                    {
                        SingletonLogger.Instance.Debug("Error while removing column. GUID = " + systemGuid);
                    }
                }
                catch (Exception ex2)
                {
                    SingletonLogger.Instance.Debug("Error while removing column. GUID = " + ex2.ToString());
                }
                #endregion
            }
        }
Example #30
0
 public RefreshTokenDemo(MetasysClient client)
 {
     this.client = client;
     log         = new LogInitializer(typeof(RefreshTokenDemo));
 }