Esempio n. 1
0
        public void WriteMessage(TeamCollectionMessage message)
        {
            Messages.Add(message);
            SIL.Reporting.Logger.WriteEvent(message.TextForDisplay);
            TeamCollectionManager.RaiseTeamCollectionStatusChanged();
            // Using Environment.NewLine here means the format of the file will be appropriate for the
            // computer we are running on. It's possible a shared collection might be used by both
            // Linux and Windows. But that's OK, because .NET line reading accepts either line
            // break on either platform.
            var toPersist = message.ToPersistedForm + Environment.NewLine;

            // There ought to be a RobustFile.AppendAllText, but there isn't.
            // However, as this promises to close the file each call, it should be pretty reliable.
            RetryUtility.Retry(() => File.AppendAllText(_logFilePath, toPersist));
        }
Esempio n. 2
0
 public void HandleSelectedBookStatus(ApiRequest request)
 {
     try
     {
         if (!TeamCollectionManager.IsRegistrationSufficient())
         {
             request.Failed("not registered");
             return;
         }
         request.ReplyWithJson(GetBookStatusJson(BookFolderName));
     }
     catch (Exception e)
     {
         // Not sure what to do here: getting the current book status crashed.
         Logger.WriteError("TeamCollectionApi.HandleSelectedBookStatus() crashed", e);
         SentrySdk.AddBreadcrumb(string.Format("Something went wrong for {0}", request.LocalPath()));
         SentrySdk.CaptureException(e);
         request.Failed("getting the current book status failed");
     }
 }
Esempio n. 3
0
        public void HandleBookStatus(ApiRequest request)
        {
            try
            {
                if (!TeamCollectionManager.IsRegistrationSufficient())
                {
                    request.Failed(HttpStatusCode.ServiceUnavailable, "Team Collection not active");
                    return;
                }

                var bookFolderName = request.RequiredParam("folderName");
                request.ReplyWithJson(GetBookStatusJson(bookFolderName));
            }
            catch (Exception e)
            {
                // Not sure what to do here: getting the current book status crashed.
                Logger.WriteError("TeamCollectionApi.HandleCurrentBookStatus() crashed", e);
                NonFatalProblem.ReportSentryOnly(e, $"Something went wrong for {request.LocalPath()}");
                request.Failed("getting the book status failed");
            }
        }