private static void RemoveClass1File(Project newlyCreatedProject)
        {
            ProjectItem projectItem = null;

            if (ContainsItem(Class1ItemCreatedByTemplate, newlyCreatedProject.ProjectItems))
            {
                projectItem = newlyCreatedProject.ProjectItems.Item(Class1ItemCreatedByTemplate);
            }
            if (projectItem != null)
            {
                var fileName = projectItem.get_FileNames(0);
                if (File.Exists(fileName))
                {
                    try
                    {
                        Logger.InfoFormat("CreateProjectHelper.RemoveClass1File removing file={0}", fileName);
                        File.Delete(fileName);
                    }
                    catch (Exception e)
                    {
                        ExceptionLogHelper.LogException(e);
                    }
                }
                projectItem.Delete();
            }
        }
        private static void AddTestFrameworkReferenceWithNuGet(Project testProject)
        {
            if (!StaticOptions.ReferencesOptions.UseNuGet ||
                string.IsNullOrEmpty(StaticOptions.ReferencesOptions.PackageId))
            {
                return;
            }
            int verMajor;
            int verMinor;
            int verBuild;

            if (!int.TryParse(StaticOptions.ReferencesOptions.VersionMajor, out verMajor))
            {
                verMajor = 1;
            }
            int.TryParse(StaticOptions.ReferencesOptions.VersionMinor, out verMinor);
            int.TryParse(StaticOptions.ReferencesOptions.VersionBuild, out verBuild);
            try
            {
                Logger.InfoFormat("CreateProjectHelper.AddTestFrameworkReferenceWithNuGet, Installing package with nuget, " +
                                  "testProject={0}, packageId={1}, verMaj={2}, verMin={3}, verBuild={4}",
                                  testProject.Name, StaticOptions.ReferencesOptions.PackageId,
                                  verMajor, verMinor, verBuild);
                Access.PackageInstaller.InstallPackage(null, testProject,
                                                       StaticOptions.ReferencesOptions.PackageId,
                                                       new Version(verMajor, verMinor, verBuild),
                                                       false);
            }
            catch (Exception e)
            {
                ExceptionLogHelper.LogException(e);
            }
        }
Exemple #3
0
        private void currentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = e.ExceptionObject as Exception;

            if (ex == null)
            {
                return;
            }
            ExceptionLogHelper.LogException(ex);
        }
Exemple #4
0
 static void RunDebt()
 {
     try
     {
         var s = new Schedule();
         s.RunDebtSms();
     }
     catch (Exception ex)
     {
         ExceptionLogHelper.Write(ex);
     }
     return;
 }
Exemple #5
0
        /// <summary>
        /// Save exception
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="fileName"></param>
        protected virtual void LogException(Exception ex, string fileName = null)
        {
            if (IsWriteLine)
            {
                Console.WriteLine();
                var foregroundColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.ToString());
                Console.ForegroundColor = foregroundColor;
                Console.WriteLine();
            }

            ExceptionLogHelper.Write(ex, fileName);
        }
Exemple #6
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            CurrentEnvironment = env;

            var forwardingOptions = new ForwardedHeadersOptions {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            };

            forwardingOptions.KnownNetworks.Clear();
            forwardingOptions.KnownProxies.Clear();
            app.UseForwardedHeaders(forwardingOptions);

            app.UseStaticFiles();
            app.UseResponseCaching();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseHttpsRedirection();
            }
            else
            {
                app.UseExceptionHandler(x =>
                {
                    x.Run(async(context) =>
                    {
                        var feature = context.Features.Get <IExceptionHandlerPathFeature>();

                        var exceptionHelper = new ExceptionLogHelper();
                        exceptionHelper.LogException(feature.Error, CurrentEnvironment.ContentRootPath);

                        await Task.Run(() => context.Response.Redirect("/views/error.html"));
                    });
                });
            }

            app.UseAuthentication();
            app.UseMvc(x => { x.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"); });

            Container.Install(new SettingAndHelperInstaller());
            Container.Install(new FactoryAndMapperInstaller());
            Container.Install(new RepositoryAndUnitOfWorkInstaller());
            Container.Install(new ServiceInstaller());

            DbGeneratorHelper.Generate(Container, env.WebRootPath);
        }
Exemple #7
0
        private void LoadAndPlaceImplementationAndTest()
        {
            // Make sure the active window is in the first tab well
            // as we will load our douments there
            ActivateFirstDocument();

            try
            {
                if (StaticOptions.MainOptions.UnitTestLeft ^ SourceTargetInfo.IsSourcePathTest)
                {
                    Access.Dte.ExecuteCommand(OpenFileCommand, SourceTargetInfo.QuotedTargetPath);
                    Access.Dte.ExecuteCommand(OpenFileCommand, SourceTargetInfo.QuotedSourcePath);
                }
                else
                {
                    Access.Dte.ExecuteCommand(OpenFileCommand, SourceTargetInfo.QuotedSourcePath);
                    Access.Dte.ExecuteCommand(OpenFileCommand, SourceTargetInfo.QuotedTargetPath);
                }

                if (ViewUtil.IsMoreThanOneTabWellShown())
                {
                    Access.Dte.ExecuteCommand(WindowMoveToNextTabGroupCommand);
                }
                else
                {
                    Access.Dte.ExecuteCommand(NewVerticalTabGroupCommand);
                }
            }
            catch (COMException e)
            {
                Logger.Warn("JumpToTestOrImplmentation: LoadAndPlaceImplementationAndTest(), got COM Exception");
                ExceptionLogHelper.LogException(e);
            }
            catch (Exception e)
            {
                Logger.Warn("JumpToTestOrImplmentation: LoadAndPlaceImplementationAndTest(), got other exception");
                ExceptionLogHelper.LogException(e);
            }
        }
Exemple #8
0
 /// <summary>
 /// Save exception
 /// </summary>
 /// <param name="ex"></param>
 /// <param name="fileName"></param>
 public virtual void LogException(Exception ex, string fileName = null)
 {
     ExceptionLogHelper.Write(ex, fileName);
 }