Esempio n. 1
0
        private void LoopTran()
        {
            byte[] buffer = new byte[BufferSize];
            logger.Info($"listener prepare to receive {this.GetHashCode()}");

            var result = opendSocket.Receive(buffer, SocketFlags.None, out var errorCode);

            if (result < 0 || errorCode != SocketError.Success)
            {
                breakLoopTrace = true;
                logger.Error($"Socket closed by client! {errorCode}");
                throw new Exception($"Socket closed by client! {errorCode}");
            }
            else if (result > 0)
            {
                Array.Resize <byte>(ref buffer, result);
                if (!opendSocks5Client.Send(buffer, out var code))
                {
                    logger.Error(code.ToString());
                }
                else
                {
                    logger.Debug("Send data:" + Encoding.UTF8.GetString(buffer));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create a zip file.
        /// </summary>
        /// <param name="cmdOptions">The zip program command line arguments.</param>
        /// <param name="outputFile">The file path of the output zip file.</param>
        /// <param name="inputSpec">The files and/or directories to archive.</param>
        public bool MakeZipFile(string cmdOptions, string outputFile, string inputSpec)
        {
            // Verify input file and output path have been specified
            if (string.IsNullOrEmpty(m_ZipProgramPath) || string.IsNullOrEmpty(m_WorkDir))
            {
                var msg = "Zip program path and/or working path not specified";
#pragma warning disable 618
                m_EventLogger?.PostEntry(msg, logMsgType.logError, true);
#pragma warning restore 618
                m_Logger?.Error(msg);

                return(false);
            }

            // Setup the zip program
            var zipper = new ProgRunner
            {
                Arguments          = "-Add " + cmdOptions + " \"" + outputFile + "\" \"" + inputSpec + "\"",
                Program            = m_ZipProgramPath,
                WorkDir            = m_WorkDir,
                MonitoringInterval = m_WaitInterval,
                Name              = "Zipper",
                Repeat            = false,
                RepeatHoldOffTime = 0,
                CreateNoWindow    = m_CreateNoWindow
            };

            // Start the zip program
            zipper.StartAndMonitorProgram();

            // Wait for zipper program to complete
            var success = WaitForZipProgram(zipper);

            return(success);
        }
Esempio n. 3
0
        public static void TestLogging()
        {
            BaseLogger logger = Logger.GetLogger(typeof(Logging));

            logger.Debug("Debug message");
            logger.Info("Info message");
            logger.Error("Error message");
        }
Esempio n. 4
0
        /// <summary>
        /// Create a new NHibernate factory and save reference in CurrentFactory property
        /// </summary>
        /// <returns></returns>
        public static void CreateFactory()
        {
            _logger.Debug("Creating NHibernate session factory");

            try
            {
                // Create and configure factory
                ISessionFactory factory = Fluently.Configure()
                                          .Database(Configuration.Database.NHibernateConfiguration())
                                          .Mappings(m => m.FluentMappings.AddFromAssemblyOf <BaseMapping <Object> >())
                                          .BuildSessionFactory();
                CurrentFactory = factory;
            }
            catch (FluentConfigurationException ex)
            {
                _logger.Error("Fatal exception occured while creating NHibernate session factory", ex);
                throw;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Exports the object model to the database schema
        /// </summary>
        /// <param name="updateDatabase">If true the schema is committed to the database</param>
        /// <param name="saveScript">If true saves the update script to a file</param>
        /// <param name="scriptFile">Path of the file to save the script to</param>
        /// <returns>true if export succeeded</returns>
        public static bool ExportObjectModel(bool updateDatabase, bool saveScript, string scriptFile = null)
        {
            _logger.Debug("ExportObjectModel(updateDatabase:{0}, saveScript:{1}, scriptFile:{2})", updateDatabase, saveScript, scriptFile);

            if (!updateDatabase && !saveScript)
            {
                _logger.Error("ExportObjectModel() requires either updateDatabase or saveScript to be true");
                return(false);
            }
            else if (updateDatabase && !Configuration.Database.AllowSchemaUpdate)
            {
                _logger.Error("Update of database schema is prevented by configuration (Configuration.Database.AllowSchemaUpdate=false)");
                return(false);
            }

            try
            {
                // Load NHibernate configuration
                FluentConfiguration config = Fluently.Configure()
                                             .Database(Configuration.Database.NHibernateConfiguration())
                                             .Mappings(m => m.FluentMappings.AddFromAssemblyOf <BaseMapping <Object> >());

                // Setup SchemaExport
                var export = new SchemaExport(config.BuildConfiguration());
                if (!String.IsNullOrEmpty(scriptFile))
                {
                    export.SetOutputFile(scriptFile);
                }

                // Execute
                export.Execute(saveScript, updateDatabase, false);
                _logger.Debug("ExportObjectModel succeeded");
                return(true);
            }
            catch (Exception ex)
            {
                _logger.Error("ExportObjectModel failed", ex);
                return(false);
            }
        }
        public void StopALLCoroutines(string coreName)
        {
            CoroutineCore curCore = GetCoroutineCore(coreName);

            if (curCore != null)
            {
                curCore.StopAllCoroutines();
            }
            else
            {
                BaseLogger.Error("Not have this coreName:{0}", coreName);
            }
        }
        public void StopCoroutine(string coreName, IEnumerator routine)
        {
            CoroutineCore curCore = GetCoroutineCore(coreName);

            if (curCore != null)
            {
                curCore.StopCoroutine(routine);
            }
            else
            {
                BaseLogger.Error("you stopCoroutine with error coreName:{0}", coreName);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Returns web services configuration
        /// </summary>
        /// <returns>Configuration</returns>
        public static System.Configuration.Configuration GetServicesConfiguration()
        {
            try
            {
                if (_logger != null)
                {
                    _logger.Debug("Configuration.GetServicesConfiguration()");
                }

                ExeConfigurationFileMap executionFileMap = new ExeConfigurationFileMap();
                executionFileMap.ExeConfigFilename = GetConfigPath("Services.xml");

                return(ConfigurationManager.OpenMappedExeConfiguration(executionFileMap, ConfigurationUserLevel.None));
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.Error("Error occured in Configuration.GetServicesConfiguration()", ex);
                }
                throw new CustomException("Error occured in Configuration.GetServicesConfiguration()", ex);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Returns translation for specified ky
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string Translate(string key)
        {
            _logger.Debug("Translate(\"{0}\")", key);

            // Load translation from database
            var translation = Translation.Load(key);

            // Return translation for active language
            switch (SessionManager.ActiveLanguage)
            {
            case Languages.Dutch:
                _logger.Debug("Returned \"{0}\"", translation.TranslationNL);
                return(translation.TranslationNL);

            case Languages.English:
                _logger.Debug("Returned \"{0}\"", translation.TranslationEN);
                return(translation.TranslationEN);
            }

            // If we get here it means there is not translation implemented for the active language
            _logger.Error("Translation not implemented for active language ({0})", SessionManager.ActiveLanguage);
            return(translation.TranslationEN);
        }
Esempio n. 10
0
 public new static void Error(string message)
 {
     Singleton.Error(message);
 }
Esempio n. 11
0
 public static void Error(object message, params object[] argv)
 {
     BaseLogger.Error(message, argv);
 }