Example #1
0
        static async Task Main(string[] args)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            //Here we can use dependency injection container, I picked up poor man's dependency injection
            IConfiguration configuration = new Configuration();

            Common.ILogger logger = new Logger(new LoggerConfiguration()
                                               .MinimumLevel.Debug()
                                               .WriteTo.File("log.txt")
                                               .CreateLogger());
            IUILogger uiLogger = new UILogger();

            RegisterGlobalExceptionHandler(logger);
            InitializeStorage(configuration);

            using (var httpClient = new HttpClient(new HttpRetryMessageHandler(new HttpClientHandler(), logger)))
            {
                IJob job = new Job(
                    new CurrencyListProvider(httpClient, configuration),
                    new RateProviderFactory(httpClient, configuration),
                    new RepositoryFactory(configuration.StoragePath),
                    uiLogger,
                    logger);

                uiLogger.Message("Starting process.");
                await job.Execute(DateTime.Now.AddDays(-1), DateTime.Now);
            }

            Console.WriteLine("Process done.");
            Console.WriteLine("Press any key to close.");
            Console.Read();
        }
Example #2
0
        public void ShowError(Exception ex)
        {
            if (ex is NuGetResolverConstraintException ||
                ex is PackageAlreadyInstalledException ||
                ex is MinClientVersionException ||
                ex is FrameworkException ||
                ex is NuGetProtocolException ||
                ex is PackagingException ||
                ex is InvalidOperationException)
            {
                // for exceptions that are known to be normal error cases, just
                // display the message.
                ProjectContext.Log(MessageLevel.Info, ExceptionUtilities.DisplayMessage(ex, indent: true));

                // write to activity log
                var activityLogMessage = string.Format(CultureInfo.CurrentCulture, ex.ToString());
                ActivityLog.LogError(LogEntrySource, activityLogMessage);
            }
            else
            {
                ProjectContext.Log(MessageLevel.Error, ex.ToString());
            }

            UILogger.ReportError(ExceptionUtilities.DisplayMessage(ex, indent: false));
        }
Example #3
0
 /// What to do when an extra player has joined the room
 public virtual void OnPeersConnected(string[] participantIds)
 {
     foreach (string participantID in participantIds)
     {
         UILogger.Log("Player " + participantID + " has joined.");
     }
 }
Example #4
0
        /// What to do when a player declines an invitiation to join a room
        public virtual void OnParticipantLeft(Participant participant)
        {
            startedMatching = false;
            UILogger.Log("Player " + participant.DisplayName + " has not connected.");

            // we should also exit the room

            LeaveGame();
        }
Example #5
0
        private void ProcessSignatureIssues(PackageVerificationResult result, PackageIdentity packageIdentity)
        {
            var errorList   = result.GetErrorIssues().ToList();
            var warningList = result.GetWarningIssues().ToList();

            errorList.ForEach(p => UILogger.ReportError(p.Message));

            errorList.ForEach(p => ProjectContext.Log(MessageLevel.Error, p.FormatWithCode()));
            warningList.ForEach(p => ProjectContext.Log(MessageLevel.Warning, p.FormatWithCode()));
        }
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(this);
     }
     Instance = this;
     if (!debug)
     {
         LogText.gameObject.SetActive(false);
     }
 }
Example #7
0
        // STARTING A GAME

        /// Look for a suitable partner to play the game with
        public virtual void StartMatchMaking(string level, IRoomListener room = null)
        {
            uint gameVariation = (uint)Maps.GetIndex(level);

            UILogger.Log("index: " + gameVariation);

            this.roomListener = room;

            startedMatching = true;
            ShowMPStatus("Connecting...");
            PlayGamesPlatform.Instance.RealTime.CreateQuickGame(minimumPartners, maximumPartners, gameVariation, this);
        }
Example #8
0
        public void ShowError(Exception ex)
        {
            var signException = ex as SignatureException;

            if (signException != null)
            {
                foreach (var result in signException.Results)
                {
                    ProcessSignatureIssues(result, signException.PackageIdentity);
                }
            }
            else
            {
                if (ex is NuGetResolverConstraintException ||
                    ex is PackageAlreadyInstalledException ||
                    ex is MinClientVersionException ||
                    ex is FrameworkException ||
                    ex is NuGetProtocolException ||
                    ex is PackagingException ||
                    ex is InvalidOperationException ||
                    ex is PackageReferenceRollbackException)
                {
                    // for exceptions that are known to be normal error cases, just
                    // display the message.
                    ProjectContext.Log(MessageLevel.Info, ExceptionUtilities.DisplayMessage(ex, indent: true));

                    // write to activity log
                    var activityLogMessage = string.Format(CultureInfo.CurrentCulture, ex.ToString());
                    ActivityLog.LogError(LogEntrySource, activityLogMessage);

                    // Log additional messages to the error list to provide context on why the rollback failed
                    var rollbackException = ex as PackageReferenceRollbackException;
                    if (rollbackException != null)
                    {
                        foreach (var message in rollbackException.LogMessages)
                        {
                            if (message.Level == LogLevel.Error)
                            {
                                UILogger.ReportError(message.Message);
                            }
                        }
                    }
                }
                else
                {
                    ProjectContext.Log(MessageLevel.Error, ex.ToString());
                }

                UILogger.ReportError(ExceptionUtilities.DisplayMessage(ex, indent: false));
            }
        }
Example #9
0
        // STARTING A GAME

        /// Look for a suitable partner to play the game with
        public override void StartMatchMaking(string level, IRoomListener room = null)
        {
            uint gameVariation = (uint)Maps.GetIndex(level);

            UILogger.Log("index: " + gameVariation);

            this.roomListener = room;

            startedMatching = true;
            ShowMPStatus("Connecting...");

            // start a matchmaking game right here
            OnRoomConnected(true);
        }
Example #10
0
        private void ProcessSignatureIssues(SignatureException ex)
        {
            if (!string.IsNullOrEmpty(ex.Message))
            {
                UILogger.ReportError(ex.AsLogMessage().FormatWithCode());
                ProjectContext.Log(MessageLevel.Error, ex.AsLogMessage().FormatWithCode());
            }

            foreach (var result in ex.Results)
            {
                var errorList   = result.GetErrorIssues().ToList();
                var warningList = result.GetWarningIssues().ToList();

                errorList.ForEach(p => UILogger.ReportError(p.FormatWithCode()));

                errorList.ForEach(p => ProjectContext.Log(MessageLevel.Error, p.FormatWithCode()));
                warningList.ForEach(p => ProjectContext.Log(MessageLevel.Warning, p.FormatWithCode()));
            }
        }
Example #11
0
        /// What to do when any players leave the room
        public virtual void OnPeersDisconnected(string[] participantIds)
        {
            foreach (string participantID in participantIds)
            {
                UILogger.Log("Player " + participantID + " has left.");
            }

            // we should also exit the room

            LeaveGame();

            // and we should bring up the disconnection dialog if we are in a game
            InGameGUIController gui = GameObject.FindObjectOfType <InGameGUIController>();

            if (gui != null)
            {
                // we are in a level
                gui.DisconnectionHandler();
                return;
            }

            // if that didn't work, maybe we are in the postgame menu! in which case,
            // we should let the menu controller know about the disconnection
            PostSubmissionMenuController menu = GameObject.FindObjectOfType <PostSubmissionMenuController> ();

            if (menu != null)
            {
                menu.OnDisconnect();
                return;
            }

            // hmm, if we're here, we much not be in a level yet,
            // which is unlikely. But, if that's the case, we have
            // to handle the transition ourselves
            SceneManager.LoadMainMenu();
        }
Example #12
0
 public void EndOperation()
 {
     UILogger.End();
 }
Example #13
0
 public void BeginOperation()
 {
     _projectContext.FileConflictAction = FileConflictAction;
     UILogger.Start();
 }
Example #14
0
        // ROOM EVENTS DURING GAMEPLAY

        /// What to do if the player leaves the room.
        public virtual void OnLeftRoom()
        {
            UILogger.Log("I have left the game");
        }
Example #15
0
 /// What to do when a player declines an invitiation to join a room
 public override void OnParticipantLeft(Participant participant)
 {
     startedMatching = false;
     UILogger.Log("Player " + participant.DisplayName + " has left.");
 }
        /// welcome to the start of our multiplayer connection!
        /// today we will be setting up a level with all of
        /// its child objects and their components, so that they
        /// can send and receive updates over the network!
        public static void MultiplayerAwake(GameObject level)
        {
            // decide which player is the host by participant ID

            string             myID         = MultiPlayerController.Instance.GetMyParticipantId();
            List <Participant> participants = MultiPlayerController.Instance.GetAllPlayers();

            // the host is the participant with the first ID in the list

            bool host = (participants [0].ParticipantId.Equals(myID));

            MultiPlayerController.Instance.host = host;

            UILogger.Log("I am the " + (host ? "host" : "client"));


            // Get localPlayer and remotePlayer gameObjects sorted

            LocalPlayerController[] players = level.GetComponentsInChildren <LocalPlayerController>();
            GameObject localPlayer;
            GameObject remotePlayer;

            if (host)
            {
                localPlayer  = players [0].gameObject;
                remotePlayer = players [1].gameObject;
            }
            else
            {
                localPlayer  = players [1].gameObject;
                remotePlayer = players [0].gameObject;
            }

            // Enter update manager, stage left!

            UpdateManager updateManager = MultiPlayerController.Instance.updateManager;


            // Link the update manager to componenets it needs to know about

            LinkUpdateManager(updateManager);


            // Link the camera to follow the local player

            LinkCamera(localPlayer);


            // set up objects and their components!

            InitializePlayers(localPlayer, remotePlayer, updateManager);


            if (host)
            {
                InitializeObstaclesHost(level, updateManager);
            }
            else
            {
                InitializeObstaclesClient(level, updateManager);
            }

            // assign serialisers unique IDs

            SetObjectIDs(level);


            // set up the start lines, finish lines and finalizer

            InitializeFinalization(level, updateManager);



            // Dont forget to let our peer know our gamertag!

            updateManager.SendGamerTag();
        }