コード例 #1
0
        /// <summary>
        /// Runs the assembly with the specified arguments.xit
        /// </summary>
        /// <param name="workingDirectory">The working directory.</param>
        /// <param name="environmentVariables">The environment variables.</param>
        /// <param name="args">The main arguments.</param>
        /// <param name="shadowCache">If [true], use shadow cache.</param>
        /// <param name="logger">The logger.</param>
        /// <returns>System.Int32.</returns>
        public int Run(string workingDirectory, Dictionary<string, string> environmentVariables, string[] args, bool shadowCache, IServerLogger logger)
        {
            lock (disposingLock)
            {
                if (isDisposed)
                {
                    logger.OnLog("Error, server is being shutdown, cannot run Compiler", ConsoleColor.Red);
                    return 1;
                }
            }


            AppDomainShadow shadowDomain = null;
            try
            {
                shadowDomain = GetOrNew(shadowCache, IsCachingAppDomain);
                return shadowDomain.Run(workingDirectory, environmentVariables, args, logger);
            }
            finally
            {
                if (shadowDomain != null)
                {
                    shadowDomain.EndRun();
                    if (!IsCachingAppDomain)
                    {
                        shadowDomain.Dispose();
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Adds a logger to this composite logger. This means this logger's methods will be invoked by the server to log
        /// its actions.
        /// </summary>
        public void AddLogger(IServerLogger logger)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");

            Loggers.AddLast(logger);
        }
コード例 #3
0
ファイル: FosRequest.cs プロジェクト: ststeiger/NancyHub
        public FosRequest(Socket sock, Fos.Logging.IServerLogger logger)
            : base(sock)
        {
            Logger             = logger;
            CancellationSource = new CancellationTokenSource();
            OwinContext        = new OwinContext("1.0", CancellationSource.Token);

            // Streams
            stdout = new Fos.Streams.FosStdoutStream(sock);
            OwinContext.ResponseBody = Stdout;
            OwinContext.RequestBody  = Stdin;
        }
コード例 #4
0
        public MediaClientValidator(IServerLogger logger = null, string validationURL = "")
        {
            if (logger != null)
            {
                m_Logger = logger;
            }
            else
            {
                m_Logger = new ConsoleLogger();
            }

            m_ValidationURL = validationURL;
        }
コード例 #5
0
        public FosRequest(Socket sock, Fos.Logging.IServerLogger logger)
            : base(sock)
        {
            Logger             = logger;
            CancellationSource = new CancellationTokenSource();
            OwinContext        = new OwinContext("1.0", CancellationSource.Token);

            OwinContext.Add("server.OnSendingHeaders", (Action <Action <object>, object>)RegisterOnSendingHeadersCallback);

            // Streams
            stdout = new Fos.Streams.FosStdoutStream(sock);
            OwinContext.ResponseBody = Stdout;
            OwinContext.RequestBody  = Stdin;
        }
コード例 #6
0
        public void Init(IRequestHandlerFactory requestHandlerFactory, IServerLogger logger = null)
        {
            if (m_initialized)
            {
                throw new Exception("Already initialized.");
            }
            if (requestHandlerFactory == null)
            {
                throw new ArgumentNullException(nameof(requestHandlerFactory));
            }

            GDInternalResources.Init(requestHandlerFactory, logger);
            m_initialized = true;
        }
コード例 #7
0
        public BaccaratGame(IServerNode node)
        {
            m_Node   = node;
            m_Logger = m_Node.GetLogger();

            m_GameState         = GAME_STATUS.Unknown;
            m_WaitingForDealing = false;
            m_IsRunningGameLoop = false;

            PlayerPoints = -1;
            BankerPoints = -1;

            m_ShoeCode   = "";
            m_RoundIndex = 0;
        }
コード例 #8
0
        public ClientHolder(IServerNode node)
        {
            m_Node   = node;
            m_Logger = m_Node.GetLogger();

            m_ServerName = m_Node.GetName();

            if (m_Clients != null)
            {
                m_Clients.Clear();
            }
            else
            {
                m_Clients = new Dictionary <string, ClientInfo>();
            }
        }
コード例 #9
0
        public WebSocketServer(IServerNode handler, IServerLogger logger = null, int flags = 0)
        {
            RequestHandler = handler;

            Logger = logger;
            if (Logger == null)
            {
                Logger = new ConsoleLogger();
            }

            Flags = flags;

            if (WebMessage.JsonCodec == WebMessage.DefaultJsonCodec)
            {
                WebMessage.JsonCodec = new CommonJsonCodec();
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: svonidze/MediaAccess
        private static void RepeatIfFailed(Action action, IServerLogger serverLogger, int attempt = 0)
        {
            try
            {
                action();
            }
            catch (Exception e)
            {
                var delay = AttemptDelay * Math.Pow(2, attempt);

                serverLogger.Log($"Internet is{(Internet.IsAvailable() ? null : " NOT")} available");
                serverLogger.Log(e.GetFullDescription($"Attempt #{attempt} failed, next try in {delay}"));

                Thread.Sleep(delay);
                RepeatIfFailed(action, serverLogger, attempt + 1);
            }
        }
コード例 #11
0
ファイル: App.cs プロジェクト: akagkad/IdaDownload
        static void Main(string[] args)
        {
            //Controller.executeDeliveryBlocks("ES01");

            string salesOrg = args[0];

            IServerLogger log = Create.serverLogger(161);

            log.start(salesOrg);

            try {
                Controller.executeDeliveryBlocks(salesOrg);
                log.finish(salesOrg);
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, "Delivery Blocks", ex);
                log.finish(salesOrg + " Error");
            }
        }
コード例 #12
0
        public static void Main(string[] args)
        {
            string salesOrg = args[0];

            //string salesOrg = "FR01";

            IServerLogger log = Create.serverLogger(157);

            log.start();

            try {
                Controller.executeDistressReport(salesOrg);
                log.finish("success");
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, "Distress", ex);
                log.finish("error");
            }
        }
コード例 #13
0
 /// <summary>
 /// Runs the assembly with the specified arguments.xit
 /// </summary>
 /// <param name="args">The main arguments.</param>
 /// <param name="logger">The logger.</param>
 /// <returns>System.Int32.</returns>
 public int Run(string[] args, IServerLogger logger)
 {
     AppDomainShadow shadowDomain = null;
     try
     {
         shadowDomain = GetOrNew(IsCachingAppDomain);
         return shadowDomain.Run(args, logger);
     }
     finally
     {
         if (shadowDomain != null)
         {
             shadowDomain.EndRun();
             if (!IsCachingAppDomain)
             {
                 shadowDomain.Dispose();
             }
         }
     }
 }
コード例 #14
0
        public HttpServer(IServerNode handler, IServerLogger logger = null, int flags = 0, string allowOrigin = "")
        {
            m_TaskSchedulerPair   = new ConcurrentExclusiveSchedulerPair(TaskScheduler.Default, ListenerWorkerThreadCount);
            m_ListenerTaskFactory = new TaskFactory(m_TaskSchedulerPair.ConcurrentScheduler);

            RequestHandler = handler;

            Logger = logger;
            if (Logger == null)
            {
                Logger = new ConsoleLogger();
            }

            Flags = flags;

            if ((Flags & RequestContext.FLAG_PUBLIC) != 0)
            {
                AllowOrigin = allowOrigin;                                            // normally only public services need this
            }
        }
コード例 #15
0
        public static void Main(string[] args)
        {
            //TODO: Add ship to & sold to name for the email report

            //Controller.executeRejections("ZA01", true);

            string salesOrg  = args[0];
            bool   isRelease = (args[1] == "Release");

            IServerLogger log = Create.serverLogger(147);

            log.start();

            try {
                Controller.executeRejections(salesOrg, isRelease);
                log.finish("success");
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, isRelease ? "Release Rejections" : "After Release Rejections", ex);
                log.finish("error");
            }
        }
コード例 #16
0
        /// <summary>
        /// Runs the assembly with the specified arguments.xit
        /// </summary>
        /// <param name="args">The main arguments.</param>
        /// <param name="logger">The logger.</param>
        /// <returns>System.Int32.</returns>
        public int Run(string[] args, IServerLogger logger)
        {
            AppDomainShadow shadowDomain = null;

            try
            {
                shadowDomain = GetOrNew(IsCachingAppDomain);
                return(shadowDomain.Run(args, logger));
            }
            finally
            {
                if (shadowDomain != null)
                {
                    shadowDomain.EndRun();
                    if (!IsCachingAppDomain)
                    {
                        shadowDomain.Dispose();
                    }
                }
            }
        }
コード例 #17
0
        public StreamnesiaHub(
            IHubContext <UpdateHub> hub,
            ICommandPoll poll,
            CommandQueue cmdQueue,
            IPayloadLoader payloadLoader,
            Bot bot,
            Random rng,
            PollState pollState,
            StreamnesiaConfig config,
            IServerLogger logger
            )
        {
            _hub           = hub;
            _poll          = poll;
            _cmdQueue      = cmdQueue;
            _payloadLoader = payloadLoader;
            _bot           = bot;
            _rng           = rng;
            _pollState     = pollState;
            _logger        = logger;

            _canQueryPoll = true;

            _bot.OnVoted    = OnUserVoted;
            _bot.OnDeathSet = text => {
                if (config.AllowDeathMessages)
                {
                    Amnesia.SetDeathHintTextAsync(text);
                }
            };
            _bot.OnMessageSent = text => {
                if (config.AllowOnScreenMessages)
                {
                    Amnesia.DisplayTextAsync(text);
                }
            };

            _ = _cmdQueue.StartCommandProcessingAsync(CancellationToken.None);
            _ = StartLoop();
        }
コード例 #18
0
        public ServiceWrapper(Type objectType, String serviceName, Boolean isPublic = true, IServerLogger logger = null)
        {
            IsPublic    = isPublic;
            ServiceName = serviceName;

            m_Logger = logger;
            if (m_Logger == null)
            {
                m_Logger = new ConsoleLogger();
            }

            ServiceObject = Activator.CreateInstance(objectType);
            var methods = ServiceObject.GetType().GetMethods();

            foreach (var method in methods)
            {
                var attr = ServiceWrapper.GetAnnotation(method);
                if (attr != null)
                {
                    string actionName = attr.Name;
                    var    actions    = attr.IsLocal ? m_LocalActions : (attr.IsPublic ? m_PublicActions : m_InternalActions);
                    if (!actions.ContainsKey(actionName))
                    {
                        actions.Add(actionName, method);
                        if (actionName == "validate-request")
                        {
                            m_ValidationAction = method;
                        }
                        else if (actionName == "get-task-factory")
                        {
                            m_TaskFactoryAction = method;
                        }
                        else if (actionName == "default-action")
                        {
                            m_DefaultAction = method;
                        }
                    }
                }
            }
        }
コード例 #19
0
        /// <summary>
        /// SOAR script runs reports as per args that are passed to save in the SOAR folder
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            IServerLogger log = Create.serverLogger(154);

            string soarReport = args[0];
            //string soarReport = "WE05";

            var SOs = new string[] { "FR01", "NL01", "DE01", "IT01", "GR01", "PL01", "CZ01", "PT01", "ES01", "RO01", "GB01", "TR01", "UA01", "RU01", "ZA01", "KE02", "NG01" };

            log.start();

            switch (soarReport)
            {
            case "WE05": {
                Controller.executeWE05(Strings.Left(args[1], 2));
                log.finish();
                break;
            }

            case "ZV04HN": {
                Controller.executeZV04HN(args[1]);
                log.finish();
                break;
            }

            case "All": {
                runAll(SOs);
                log.finish();
                break;
            }

            default: {
                throw new NotImplementedException("no report for " + soarReport);
            }
            }
        }
コード例 #20
0
ファイル: FosSelfHost.cs プロジェクト: knocte/Fos
        public override void SetLogger(IServerLogger logger)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");

            this.UserSetLogger = logger;
        }
コード例 #21
0
        /// <summary>
        /// Runs the assembly with the specified arguments.xit
        /// </summary>
        /// <param name="workingDirectory">The working directory.</param>
        /// <param name="environmentVariables">The environment variables.</param>
        /// <param name="args">The main arguments.</param>
        /// <param name="logger">The logger.</param>
        /// <returns>System.Int32.</returns>
        public int Run(string workingDirectory, Dictionary <string, string> environmentVariables, string[] args, IServerLogger logger)
        {
            lock (disposingLock)
            {
                if (isDisposed)
                {
                    logger.OnLog("Error, server is being shutdown, cannot run Compiler", ConsoleColor.Red);
                    return(1);
                }
            }


            AppDomainShadow shadowDomain = null;

            try
            {
                shadowDomain = GetOrNew(IsCachingAppDomain);
                return(shadowDomain.Run(workingDirectory, environmentVariables, args, logger));
            }
            finally
            {
                if (shadowDomain != null)
                {
                    shadowDomain.EndRun();
                    if (!IsCachingAppDomain)
                    {
                        shadowDomain.Dispose();
                    }
                }
            }
        }
コード例 #22
0
 public void Dispose()
 {
     logger = null;
 }
コード例 #23
0
 public AppDomainRedirectLogger(IServerLogger logger)
 {
     this.logger = logger;
 }
コード例 #24
0
 static CommonLog()
 {
     m_Logger = new ServerLogger();
 }
コード例 #25
0
        public HttpSourceMediaServer(string serverName, MediaResourceManager resourceManager, IServerLogger logger = null,
                                     string inputIp = "", int inputPort = -1, string outputIp = "", int outputPort = -1,
                                     List <string> inputWhiteList = null, string certFile = "", string certKey = "")
        {
            InputQueueSize  = DEFAULT_INPUT_QUEUE_SIZE;
            InputBufferSize = DEFAULT_INPUT_BUFFER_SIZE;

            OutputQueueSize        = DEFAULT_OUTPUT_QUEUE_SIZE;
            OutputBufferSize       = DEFAULT_OUTPUT_BUFFER_SIZE;
            OutputSocketBufferSize = 0;  // use default value

            m_ServerName = serverName;

            m_CertFile = certFile;
            m_CertKey  = certKey;

            if (logger != null)
            {
                m_Logger = logger;
            }
            else
            {
                m_Logger = new ConsoleLogger();
            }

            m_ResourceManager = resourceManager;
            m_ResourceManager.AddServer(this);

            if (inputIp.Length > 0)
            {
                m_InputIp = inputIp;
            }
            if (outputIp.Length > 0)
            {
                m_OutputIp = outputIp;
            }

            if (inputPort >= 0)
            {
                m_InputPort = inputPort;
            }
            if (outputPort >= 0)
            {
                m_OutputPort = outputPort;
            }

            if (inputWhiteList != null)
            {
                m_InputWhiteList.AddRange(inputWhiteList);
            }
            if (m_InputWhiteList.Count <= 0)
            {
                m_InputWhiteList.Add("127.0.0.1");
            }
        }
コード例 #26
0
ファイル: Program.cs プロジェクト: svonidze/MediaAccess
 private static void UnhandledExceptionTrapper(UnhandledExceptionEventArgs e, IServerLogger serverLogger)
 {
     serverLogger.Log(e.ExceptionObject.ToString());
 }
コード例 #27
0
        /// <summary>
        /// Runs the main entry point method passing arguments to it
        /// </summary>
        /// <param name="workingDirectory"></param>
        /// <param name="environmentVariables">The environment variables.</param>
        /// <param name="args">The arguments.</param>
        /// <param name="logger">The logger.</param>
        /// <returns>System.Int32.</returns>
        /// <exception cref="System.InvalidOperationException">Must call TryLock before calling this method</exception>
        public int Run(string workingDirectory, Dictionary <string, string> environmentVariables, string[] args, IServerLogger logger)
        {
            if (!isRunning)
            {
                throw new InvalidOperationException("Must call TryLock before calling this method");
            }

            try
            {
                lastRunTime = DateTime.Now;
                using (var appDomainRedirectLogger = new AppDomainRedirectLogger(logger))
                {
                    appDomainCallback.Logger               = appDomainRedirectLogger;
                    appDomainCallback.CurrentDirectory     = workingDirectory;
                    appDomainCallback.EnvironmentVariables = environmentVariables;
                    appDomainCallback.Arguments            = args;
                    appDomain.DoCallBack(appDomainCallback.Run);
                    var result = appDomain.GetData("Result") as int?;

                    //var result = appDomain.ExecuteAssembly(mainAssemblyPath, args);
                    Console.WriteLine("Return result: {0}", result);
                    return(result ?? -1);
                }
            }
            catch (Exception exception)
            {
                logger.OnLog(string.Format("Unexpected exception: {0}", exception), ConsoleColor.Red);
                return(1);
            }
            finally
            {
                lastRunTime = DateTime.Now;
            }
        }
コード例 #28
0
 public DBConnector(IServerLogger logger)
 {
     this.Logger = logger;
 }
コード例 #29
0
ファイル: FosRequest.cs プロジェクト: james-andrewsmith/Fos
		public FosRequest(Socket sock, Fos.Logging.IServerLogger logger)
            : base(sock)
		{
			Logger = logger;
            CancellationSource = new CancellationTokenSource();
            OwinContext = new OwinContext("1.0", CancellationSource.Token);

            // Streams
            stdout = new Fos.Streams.FosStdoutStream(sock);
            OwinContext.ResponseBody = Stdout;
            OwinContext.RequestBody = Stdin;
		}
コード例 #30
0
 public TelegramClientAndServerLogger(ITelegramBotClient botClient, IServerLogger serverLogger, Message message)
 {
     this.botClient    = botClient;
     this.serverLogger = serverLogger;
     this.message      = message;
 }
コード例 #31
0
 public BetResultUpdater(IServerNode node)
 {
     m_Node   = node;
     m_Logger = m_Node.GetLogger();
 }
コード例 #32
0
 internal static void Init(IRequestHandlerFactory requestHandlerFactory, IServerLogger logger = null)
 {
     m_requestHandlerFactory = requestHandlerFactory;
     m_logger = logger;
 }
コード例 #33
0
 public AppDomainRedirectLogger(IServerLogger logger)
 {
     this.logger = logger;
 }
コード例 #34
0
 public void Dispose()
 {
     logger = null;
 }
コード例 #35
0
        //private Dictionary<string, List<long>> m_BetRecordLists = new Dictionary<string, List<long>>();

        public BetCollector(IServerNode node)
        {
            m_Node   = node;
            m_Logger = m_Node.GetLogger();
        }
コード例 #36
0
        //private Dictionary<string, List<long>> m_BetRecordLists = new Dictionary<string, List<long>>();

        public BetWinlossChecker(IServerNode node)
        {
            m_Node   = node;
            m_Logger = m_Node.GetLogger();
        }
コード例 #37
0
ファイル: ExecServerApp.cs プロジェクト: rohitshe/Code
 public ExecServerRemoteClient(IServerLogger logger, Binding binding, EndpointAddress remoteAddress)
     : base(logger, binding, remoteAddress)
 {
 }
コード例 #38
0
ファイル: SocketListener.cs プロジェクト: knocte/Fos
        /// <summary>
        /// Set this to an <see cref="Fos.Logging.IServerLogger"/> to log server information.
        /// </summary>
        public virtual void SetLogger(IServerLogger logger)
        {
            if (logger == null)
                throw new ArgumentNullException("logger");

            this.Logger = logger;
        }
コード例 #39
0
        /// <summary>
        /// Runs the main entry point method passing arguments to it
        /// </summary>
        /// <param name="workingDirectory"></param>
        /// <param name="environmentVariables">The environment variables.</param>
        /// <param name="args">The arguments.</param>
        /// <param name="logger">The logger.</param>
        /// <returns>System.Int32.</returns>
        /// <exception cref="System.InvalidOperationException">Must call TryLock before calling this method</exception>
        public int Run(string workingDirectory, Dictionary<string, string> environmentVariables, string[] args, IServerLogger logger)
        {
            if (!isRunning)
            {
                throw new InvalidOperationException("Must call TryLock before calling this method");
            }

            try
            {
                lastRunTime = DateTime.Now;
                using (var appDomainRedirectLogger = new AppDomainRedirectLogger(logger))
                {
                    appDomainCallback.Logger = appDomainRedirectLogger;
                    appDomainCallback.CurrentDirectory = workingDirectory;
                    appDomainCallback.EnvironmentVariables = environmentVariables;
                    appDomainCallback.Arguments = args;
                    appDomain.DoCallBack(appDomainCallback.Run);
                    var result = appDomain.GetData("Result") as int?;

                    //var result = appDomain.ExecuteAssembly(mainAssemblyPath, args);
                    Console.WriteLine("Return result: {0}", result);
                    return result ?? -1;
                }
            }
            catch (Exception exception)
            {
                logger.OnLog(string.Format("Unexpected exception: {0}", exception), ConsoleColor.Red);
                return 1;
            }
            finally
            {
                lastRunTime = DateTime.Now;
            }
        }