コード例 #1
0
        public void SetUp()
        {
            //fake webclient object
            _fakeWebClient = new Mock <IWebClientManager>();

            _installHelper = new InstallerHelper(_fakeWebClient.Object);
        }
コード例 #2
0
ファイル: MembershipHttpModule.cs プロジェクト: terry2012/DSV
        /// <summary>
        /// Handlers the EndRequest event of the application
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The instance containing the event data.</param>
        private void Application_EndRequest(object sender, EventArgs e)
        {
            if (InstallerHelper.ConnectionStringIsSet())
            {
                try
                {
                    //exit if a request for a .net mapping that isn't a content page is made i.e. axd
                    if (!CommonHelper.IsContentPageRequested())
                    {
                        return;
                    }

                    //session workflow
                    bool sessionReseted = false;
                    if (NopContext.Current["Nop.SessionReseted"] != null)
                    {
                        sessionReseted = Convert.ToBoolean(NopContext.Current["Nop.SessionReseted"]);
                    }
                    if (!sessionReseted)
                    {
                        NopContext.Current.SessionSaveToClient();
                    }

                    //online user tracking
                    OnlineUserManager.TrackCurrentUser();
                }
                catch (Exception exc)
                {
                    //LogManager.InsertLog(LogTypeEnum.Unknown, exc.Message, exc);
                    Debug.WriteLine(exc.Message);
                }
            }
        }
        public void Setup()
        {
            var setupDestinationFile = @"C:\dev";

            _installerHelperRepository = new Mock <IInstallerHelperRepository>();
            _installerHelper           = new InstallerHelper(setupDestinationFile, _installerHelperRepository.Object);
        }
コード例 #4
0
        /// <summary>
        /// Handlers the BeginRequest event of the application
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The instance containing the event data.</param>
        private void Application_BeginRequest(object sender, EventArgs e)
        {
            if (InstallerHelper.ConnectionStringIsSet())
            {
                if (NopContext.Current.Session != null)
                {
                    var dtNow = DateTime.UtcNow;
                    if (NopContext.Current.Session.LastAccessed.AddMinutes(1.0) < dtNow)
                    {
                        NopContext.Current.Session.LastAccessed = dtNow;
                        NopContext.Current.Session = CustomerManager.SaveCustomerSession(
                            NopContext.Current.Session.CustomerSessionGuid,
                            NopContext.Current.Session.CustomerId,
                            NopContext.Current.Session.LastAccessed,
                            false);
                    }
                }

                var currentLanguage = NopContext.Current.WorkingLanguage;
                if (currentLanguage != null)
                {
                    NopContext.Current.SetCulture(new CultureInfo(currentLanguage.LanguageCulture));
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Handlers the BeginRequest event of the application
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The instance containing the event data.</param>
        private void Application_BeginRequest(object sender, EventArgs e)
        {
            if (!InstallerHelper.ConnectionStringIsSet())
            {
                return;
            }
            //exit if a request for a .net mapping that isn't a content page is made i.e. axd
            if (!CommonHelper.IsContentPageRequested())
            {
                return;
            }

            //update session last access time
            if (NopContext.Current.Session != null)
            {
                var dtNow = DateTime.UtcNow;
                if (NopContext.Current.Session.LastAccessed.AddMinutes(1.0) < dtNow)
                {
                    NopContext.Current.Session.LastAccessed = dtNow;
                    NopContext.Current.Session = IoC.Resolve <ICustomerService>().SaveCustomerSession(
                        NopContext.Current.Session.CustomerSessionGuid,
                        NopContext.Current.Session.CustomerId,
                        NopContext.Current.Session.LastAccessed,
                        false);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Restore database
        /// </summary>
        /// <param name="fileName">Backup file name</param>
        public void RestoreBackup(string fileName)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }

            if (File.Exists(fileName))
            {
                switch (Path.GetExtension(fileName).ToLowerInvariant())
                {
                case ".zip":
                    if (Path.GetFileName(fileName).StartsWith("images"))
                    {
                        using (ZipFile zipFile = new ZipFile(fileName))
                        {
                            zipFile.ExtractAll(this.LocalFTPFolderPath, ExtractExistingFileAction.OverwriteSilently);
                        }
                    }
                    break;

                case ".bak":
                    InstallerHelper.RestoreBackup(fileName);
                    break;
                }
            }
            else
            {
                throw new CRMException("File doesn't exist");
            }
        }
コード例 #7
0
        /// <summary>
        /// Event handler for BeginRequest.
        /// </summary>
        /// <param name="sender">Sender object instance.</param>
        /// <param name="e">Event arguments.</param>
        void Context_BeginRequest(object sender, EventArgs e)
        {
            if (InstallerHelper.ConnectionStringIsSet())
            {
                try
                {
                    if (HttpContext.Current != null && !HttpContext.Current.Request.Url.IsLoopback)
                    {
                        HttpApplication application = sender as HttpApplication;
                        BannedIpAddress clientIP    = new BannedIpAddress();
                        clientIP.Address = application.Request.UserHostAddress;
                        // On any unexpected error we let visitor to visit website
                        if (IpBlacklistManager.IsIpAddressBanned(clientIP))
                        {
                            // Blocking process

                            // for now just show error 404 - Forbidden
                            // later let the user know that his ip address/network
                            // was banned and a reason why... this means we need an error page (aspx)
                            application.Response.StatusCode = 403;
                            application.Server.Transfer("~/BannedAddress.htm");
                            application.Response.StatusDescription = "Access is denied";
                            application.Response.End();
                        }
                    }
                }
                catch (Exception exc)
                {
                }
            }
        }
コード例 #8
0
            public void SubThreadUninstall()
            {
                DialogResult result = MessageBox.Show(Resources.Are_you_sure_you_want_to_deactivate_the_Translator + TxtUrl + Resources._Web_Application_, Resources._Attention, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    FrmInstaller1.EnableControls(false);
                    FrmInstaller1.SetApplicationState(ApplicationState.AppStateDeactivationInProgress);
                    FrmInstaller1.ShowWaitCursor(true);

                    try
                    {
                        SPSecurity.RunWithElevatedPrivileges(delegate
                        {
                            var obj = new InstallerHelper(MoveProgressBar);

                            if (!obj.CheckPermissions(TxtUrl))
                            {
                                MessageBox.Show(Resources.Unable_to_access_ + TxtUrl +
                                                Resources.Please_verify_the_url_and_permissions_you_need_to_use_a_Farm_Admin_Account);
                            }
                            else
                            {
                                DialogResult resultRemoveList = MessageBox.Show(@"Do you wish to delete the translator lists on the " + TxtUrl + @" Web Application ?", @"Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                if (resultRemoveList == DialogResult.Yes)
                                {
                                    FrmInstaller1.SetAction(ActionUninstallDelSpList);
                                    obj.RemoveLists(TxtUrl);
                                    FrmInstaller1.SetActionDone(ActionUninstallDelSpList);
                                }

                                FrmInstaller1.SetAction(ActionUninstallDeactivateManagementFeature);
                                obj.DeActivateManagementFeature(TxtUrl, TxtAppFolder);

                                Thread.Sleep(8000);
                                FrmInstaller1.SetActionDone(ActionUninstallDeactivateManagementFeature);

                                FrmInstaller1.MoveProgressBar("Done !");
                                FrmInstaller1.AllActionCompleted();

                                MessageBox.Show(Resources.Deactivation_Completed_Successfully);
                            }
                        });
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(Resources.Deactivation_Completed_Unsuccessfully + e.Message);
                    }
                    finally
                    {
                        FrmInstaller1.EnableControls(true);
                    }
                }

                FrmInstaller1.MoveProgressBar("");
                FrmInstaller1.ResetActionList();
                FrmInstaller1.ShowWaitCursor(false);
                FrmInstaller1.SetApplicationState(ApplicationState.AppStateIdle);
            }
コード例 #9
0
 public void SetUp()
 {
     _fileDownloader  = new Mock <IFileDownloader>();
     _installerHelper = new InstallerHelper(_fileDownloader.Object);
     _customerName    = "a";
     _installerName   = "b";
 }
コード例 #10
0
ファイル: MembershipHttpModule.cs プロジェクト: terry2012/DSV
        /// <summary>
        /// Handlers the BeginRequest event of the application
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The instance containing the event data.</param>
        private void Application_BeginRequest(object sender, EventArgs e)
        {
            if (InstallerHelper.ConnectionStringIsSet())
            {
                //exit if a request for a .net mapping that isn't a content page is made i.e. axd
                if (!CommonHelper.IsContentPageRequested())
                {
                    return;
                }

                //set current culture
                var currentLanguage = NopContext.Current.WorkingLanguage;
                if (currentLanguage != null)
                {
                    NopContext.Current.SetCulture(new CultureInfo(currentLanguage.LanguageCulture));
                }

                //session workflow
                if (NopContext.Current.Session != null)
                {
                    var dtNow = DateTime.UtcNow;
                    if (NopContext.Current.Session.LastAccessed.AddMinutes(1.0) < dtNow)
                    {
                        NopContext.Current.Session.LastAccessed = dtNow;
                        NopContext.Current.Session = CustomerManager.SaveCustomerSession(
                            NopContext.Current.Session.CustomerSessionGuid,
                            NopContext.Current.Session.CustomerId,
                            NopContext.Current.Session.LastAccessed,
                            false);
                    }
                }
            }
        }
コード例 #11
0
        public void SetUp()
        {
            _fileDownloader = new Mock <IFileDownloader>();

            _installerHelper = new InstallerHelper {
                FileDownloader = _fileDownloader.Object
            };
        }
コード例 #12
0
 void Application_BeginRequest(object sender, EventArgs e)
 {
     TCwebConfig.Init();
     if (!InstallerHelper.ConnectionStringIsSet())
     {
         // InstallerHelper.RedirectToInstallationPage();
     }
 }
コード例 #13
0
 void Application_End(object sender, EventArgs e)
 {
     //  Code that runs on application shutdown
     if (InstallerHelper.ConnectionStringIsSet())
     {
         TaskManager.Instance.Stop();
     }
 }
コード例 #14
0
        public void DownloadInstaller_FileIsSucessfullyDownloaded_ReturnTrue()
        {
            var fileDownloader  = new Mock <IFileDownloader>();
            var installerHelper = new InstallerHelper();
            var result          = installerHelper.DownloadInstaller("", "", fileDownloader.Object);

            Assert.That(result, Is.EqualTo(true));
        }
コード例 #15
0
        public void DownloadInstaller_FileDownloadSuccessfully_ReturnsTrue()
        {
            var fileDownloader = new Mock <IFileDownloader>();
            var service        = new InstallerHelper(fileDownloader.Object);

            var result = service.DownloadInstaller("", "");

            Assert.That(result, Is.True);
        }
コード例 #16
0
 void Application_Start(object sender, EventArgs e)
 {
     // Code that runs on application startup
     NopConfig.Init();
     if (InstallerHelper.ConnectionStringIsSet())
     {
         TaskManager.Instance.Initialize(NopConfig.ScheduleTasks);
         TaskManager.Instance.Start();
     }
 }
コード例 #17
0
 void Application_End(object sender, EventArgs e)
 {
     //  在应用程序关闭时运行的代码
     //  在应用程序关闭时运行的代码
     IoC.Dispose();
     if (InstallerHelper.ConnectionStringIsSet())
     {
         TaskManager.Instance.Stop();
     }
 }
コード例 #18
0
        public void DownloadInstaller_ExceptionHappenedWhenDownloading_ReturnFalse()
        {
            var fileDownloader = new Mock <IFileDownloader>();

            fileDownloader.Setup(fd => fd.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws <WebException>();

            var installerHelper = new InstallerHelper();
            var result          = installerHelper.DownloadInstaller("", "", fileDownloader.Object);

            Assert.That(result, Is.EqualTo(false));
        }
コード例 #19
0
        public ActionResult UpgradeDb()
        {
            // Work out this install can be upgraded, and if not redirect
            var previousVersionNo = AppHelpers.PreviousVersionNo();
            var currentVersionNo  = AppHelpers.GetCurrentVersionNo();

            var installerResult = new InstallerResult {
                Successful = true, Message = string.Format("Upgrade to v{0} was successful", currentVersionNo)
            };

            // Can't upgrade so redirect
            if (Convert.ToDouble(previousVersionNo) < 1.3d)
            {
                return(RedirectToAction("ManualUpgradeNeeded"));
            }

            //***** Old version is v1.3 or greater so we can run the installer ****

            // Firstly add any new tables needed via the SQL
            // Get the SQL file and if it exists then run it
            var dbFilePath = Server.MapPath(InstallerHelper.GetUpdateDatabaseFilePath(currentVersionNo));

            // See whether this version needs a table update
            if (System.IO.File.Exists(dbFilePath))
            {
                // There is a file so update the database with the new tables
                installerResult = _installerService.CreateDbTables(null, dbFilePath, currentVersionNo);
                if (!installerResult.Successful)
                {
                    // Was an error creating the tables
                    return(RedirectToCreateDb(installerResult, GenericMessages.danger));
                }
            }

            // Tables created or updated - So now update all the data
            installerResult = UpdateData(currentVersionNo, previousVersionNo, installerResult);

            // See if upgrade was successful or not
            if (installerResult.Successful)
            {
                TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel
                {
                    Message     = installerResult.OnScreenMessage,
                    MessageType = GenericMessages.success
                };

                // Finally update the web.config to the new version
                UpdateWebConfigVersionNo(installerResult, currentVersionNo);

                return(RedirectToAction("Complete"));
            }

            return(RedirectToCreateDb(installerResult, GenericMessages.danger));
        }
コード例 #20
0
 /// <summary>
 /// Handlers the PostAcquireRequestState event of the application
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The instance containing the event data.</param>
 protected void Application_PostAcquireRequestState(object sender, EventArgs e)
 {
     if (InstallerHelper.ConnectionStringIsSet())
     {
         //if (NopContext.Current.Session != null)
         //{
         //    Customer customer = NopContext.Current.Session.Customer;
         //    if (customer != null)
         //        NopContext.Current.User = customer;
         //}
     }
 }
コード例 #21
0
ファイル: App.xaml.cs プロジェクト: ondraslim/WPF.TicTacToe
        private void ConfigureServices(IConfiguration configuration, IServiceCollection services)
        {
            new InfrastructureInstaller().Install(services, DependencyInjectionService);
            InstallerHelper.Install <EntityFrameworkInfrastructureInstaller>(services);
            InstallerHelper.Install <BusinessInstaller>(services);
            InstallerHelper.Install <CoreInstaller>(services);
            InstallerHelper.Install <AppInstaller>(services);

            services.AddDbContext <TicTacToeDbContext>(options => options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")), ServiceLifetime.Transient);
            services.AddSingleton(provider => new Func <DbContext>(provider.GetRequiredService <TicTacToeDbContext>));

            DependencyInjectionService.Build(services);
        }
コード例 #22
0
        public void DownloadInstaller_DownloadSucceeds_ReturnsTrue()
        {
            // Arrange
            var fileDownloader = new Mock <IFileDownloader>();

            var installerHelper = new InstallerHelper(null, fileDownloader.Object);

            // Act
            var result = installerHelper.DownloadInstaller("customerName", "installerName");

            // Assert
            Assert.Equal(true, result);
        }
コード例 #23
0
        public void Install()
        {
            string installerRawScript = InstallerHelper.GetInstallRawScript();
            string installerScript    = InstallerHelper.ReplacePlaceHolders(installerRawScript, new());

            using SqlConnection sqlConnection = new(_connectionString);
            using SqlCommand sqlCommand       = new(installerScript, sqlConnection);

            sqlConnection.Open();
            int auditInserted = sqlCommand.ExecuteNonQuery();

            sqlConnection.Close();
        }
コード例 #24
0
 private void CreateViews(InstallerHelper installerHelper)
 {
     installerHelper.CreateTransListNormView(TxtUrl);
     installerHelper.CreateTransListDataSheetView(TxtUrl);
     installerHelper.CreateTransListNonCustomizeNormalView(TxtUrl);
     installerHelper.CreateTransListNonCustomizeGridView(TxtUrl);
     installerHelper.CreateTransListCustomizeNormalView(TxtUrl);
     installerHelper.CreateTransListCustomizeGridView(TxtUrl);
     installerHelper.CreatePagesTransListNormalView(TxtUrl);
     installerHelper.CreatePagesTransListGridView(TxtUrl);
     installerHelper.CreateLanguagesVisibilityNormalView(TxtUrl);
     installerHelper.CreateLanguagesVisibilityGridView(TxtUrl);
     installerHelper.CreateConfigurationStoreView(TxtUrl);
 }
コード例 #25
0
        void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码

            TCwebConfig.Init();
            if (InstallerHelper.ConnectionStringIsSet())
            {
                IoC.InitializeWith();

                //initialize task manager
                //  TaskManager.Instance.Initialize(TCwebConfig.ScheduleTasks);
                //  TaskManager.Instance.Start();
            }
        }
コード例 #26
0
        protected bool createHisDatabase()
        {
            addResult(String.Format("创建新数据库 {0}", this.txtHisNewDatabaseName.Text));
            var connectionString = InstallerHelper.CreateConnectionString(this.HisTrustedConnection, this.txtHisServerName.Text.Trim(), Int32.Parse(this.txtHisServerPort.Text.Trim()), "master", this.txtHisUsername.Text.Trim(), ViewState["install.hisPassword"].ToString(), 120);
            var error            = InstallerHelper.CreateDatabase(this.txtHisNewDatabaseName.Text.Trim(), connectionString, this.txtHisNewDatabasePath.Text.Trim());

            if (!String.IsNullOrEmpty(error))
            {
                this.pnlLog.Visible = true;
                addResult(String.Format("创建数据库错误: {0}", error));
                return(false);
            }
            return(true);
        }
コード例 #27
0
ファイル: install.aspx.cs プロジェクト: terry2012/DSV
        protected bool createDatabase()
        {
            addResult(string.Format("Creating a new database {0}", this.txtNewDatabaseName.Text));
            string connectionString = InstallerHelper.CreateConnectionString(this.TrustedConnection, this.txtServerName.Text.Trim(), "master", this.txtUsername.Text.Trim(), Convert.ToString(ViewState["install.password"]), 120);
            string error            = InstallerHelper.CreateDatabase(this.txtNewDatabaseName.Text.Trim(), connectionString);

            if (!String.IsNullOrEmpty(error))
            {
                this.pnlLog.Visible = true;
                addResult(string.Format("An error occured when creating database: {0}", error));
                return(false);
            }
            return(true);
        }
コード例 #28
0
        public void DownloadInstaller_DownloadFails_ReturnsFalse()
        {
            // Arrange
            var fileDownloader = new Mock <IFileDownloader>();

            fileDownloader.Setup(f => f.DownloadFile(It.IsAny <string>(), It.IsAny <string>())).Throws(new WebException());

            var installerHelper = new InstallerHelper(null, fileDownloader.Object);

            // Act
            var result = installerHelper.DownloadInstaller("customerName", "installerName");

            // Assert
            Assert.Equal(false, result);
        }
コード例 #29
0
        public void DownloadInstaller_DownloadSucceeds_ReturnsTrue()
        {
            // Arrange
            var instHelper = new InstallerHelper();
            var webClient  = new FakeWebClient();

            instHelper.Client = webClient;
            var customerName  = "vlad_beliakov";
            var installerName = "installer_name";

            // Act
            var result = instHelper.DownloadInstaller(customerName, installerName);

            // Assert
            Assert.IsTrue(result);
        }
コード例 #30
0
        /// <summary>
        /// Backup database
        /// </summary>
        public void Backup()
        {
            string path = IoC.Resolve <ISettingManager>().GetSettingValue("Maintenance.BackupPath").Trim();

            if (String.IsNullOrEmpty(path))
            {
                path = string.Format("{0}{1}", HttpContext.Current.Request.PhysicalApplicationPath, "Upload\\backups\\");
            }

            string fileName = string.Format(
                "{0}database_{1}_{2}.bak",
                path,
                DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"),
                CommonHelper.GenerateRandomDigitCode(4));

            InstallerHelper.Backup(fileName);
        }