public IActionResult Get()
 {
     try {
         return(Ok(_db.Addresses.AsNoTracking()));
     } catch (Exception ex) {
         _telemetryTracker.TrackException(ex);
         return(StatusCode(500, ex.Message + Constants.messageAppInsights));
     }
 }
Example #2
0
        public static void CreateDirectory(string directoryPath)
        {
            ITelemetryTracker telemetryTracker = new TelemetryTracker();

            try
            {
                telemetryTracker.StartTrackRequest("Creating the directory");
                telemetryTracker.TrackEvent("Creating the directory", null);

                if (!Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                }
                else
                {
                    RemoveDirectoryFiles(directoryPath);
                }
            }
            catch (Exception e)
            {
                telemetryTracker.TrackException(new ProjectTermsException(PluginResources.Error_CreateDirectory + e.Message));
                telemetryTracker.TrackTrace((new ProjectTermsException(PluginResources.Error_CreateDirectory + e.Message)).StackTrace, Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Error);
                throw new ProjectTermsException(PluginResources.Error_CreateDirectory + e.Message);
            }
        }
        private void IncludeTermbaseInStudio(ITermbase termbase, TermbaseGeneration termbaseCreator, string termbasePath)
        {
            ITelemetryTracker telemetryTracker = new TelemetryTracker();

            try
            {
                telemetryTracker.StartTrackRequest("Including the termbase into Trados Studio");
                telemetryTracker.TrackEvent("Including the termbase into Trados Studio", null);

                #region TbConfig
                var project = SdlTradosStudio.Application.GetController <ProjectsController>().CurrentProject;
                TermbaseConfiguration termbaseConfig = project.GetTermbaseConfiguration();
                #endregion

                #region AddTb
                var studioTermbase = new LocalTermbase(termbasePath);
                termbaseConfig.Termbases.Add(studioTermbase);
                #endregion

                #region TermRecOptions
                TermRecognitionOptions options = termbaseConfig.TermRecognitionOptions;
                options.MinimumMatchValue = 50;
                options.SearchDepth       = 200;
                options.ShowWithNoAvailableTranslation = true;
                options.SearchOrder = TermbaseSearchOrder.Hierarchical;
                #endregion

                #region TermbaseLanguageIndex
                var langs = termbaseCreator.GetProjectLanguages();
                termbaseConfig.LanguageIndexes.Clear();
                foreach (var lang in langs.Keys)
                {
                    termbaseConfig.LanguageIndexes.Add(new TermbaseLanguageIndex(new Language(CultureInfo.GetCultureInfo(langs[lang])), lang));
                }
                #endregion

                #region UpdateTermbaseConfiguration
                project.UpdateTermbaseConfiguration(termbaseConfig);
                #endregion
            }
            catch (Exception e)
            {
                telemetryTracker.TrackException(new UploadTermbaseException(PluginResources.Error_IncludeTermbaseInStudio + e.Message));
                telemetryTracker.TrackTrace((new UploadTermbaseException(PluginResources.Error_IncludeTermbaseInStudio + e.Message)).StackTrace, Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Error);
                throw new UploadTermbaseException(PluginResources.Error_IncludeTermbaseInStudio + e.Message);
            }
        }
        public async Task Invoke(HttpContext context)
        {
            try {
                context.Request.EnableBuffering();
                if ((context.Request.ContentLength > 0) && (_loggingLevel == "High"))
                {
                    using (var reader = new StreamReader(context.Request.Body)) {
                        var requestBody = await reader.ReadToEndAsync();

                        context.Items.Add("RequestBody", requestBody);
                        context.Request.Body.Seek(0, SeekOrigin.Begin);
                        await _next(context);
                    }
                }
                else
                {
                    await _next(context);
                }
            } catch (Exception ex) {
                _telemetryTracker.TrackException(ex);
            }
        }