/// <summary>
    /// Set connection string into web.config.
    /// </summary>
    private void SetConnectionString()
    {
        if (!AzureHelper.IsRunningOnAzure)
        {
            if (!SettingsHelper.RemoveConnectionString(DBSeparationHelper.ConnStringSeparateName))
            {
                separationFinished.ErrorLabel.Visible = true;
                string resultStringDisplay = " <br/><br/><strong>&lt;add name=\"" + DBSeparationHelper.ConnStringSeparateName + "\" connectionString=\"" + DBSeparationHelper.ConnStringSeparate + "\"/&gt;</strong><br/><br/>";
                separationFinished.ErrorLabel.Text = GetString("separationDB.removeConnectionStringError") + resultStringDisplay;
            }
        }
        else
        {
            string connString = "&lt;add name=\"" + DBSeparationHelper.ConnStringSeparateName + "\" connectionString=\"" + DBSeparationHelper.ConnStringSeparate + "\"/&gt;";
            string appSetting = "&lt;Setting name=\"" + DBSeparationHelper.ConnStringSeparateName + "\" value=\"" + DBSeparationHelper.ConnStringSeparate + "\"/&gt;";

            separationFinished.AzureErrorLabel.Visible = true;
            separationFinished.AzureErrorLabel.Text    = String.Format(ResHelper.GetString("separationDB.removeConnectionStringErrorAzure"), connString, appSetting);
            separationFinished.AzureErrorLabel.Text   += GetManualCopyText();
        }

        if (PersistentStorageHelper.GetValueFromFile("SeparateDBSites") == null)
        {
            if (!separationFinished.ErrorLabel.Visible)
            {
                separationFinished.ErrorLabel.Text += "<br />";
            }
            else
            {
                separationFinished.ErrorLabel.Visible = true;
            }
            separationFinished.ErrorLabel.Text += ResHelper.GetFileString("separationdb.startsites");
        }
    }
示例#2
0
        private void CheckVersion()
        {
            PersistentStorageData data = PersistentStorageHelper.Load(PersistantStorageName);
            bool executeCheck          = false;

            if (data != null && data.Count > 0)
            {
                // get the last update date from the registry:
                lastUpdateCheck = data.GetDateTime("LastUpdateDate");
                sleepTime       = (int)data.GetUInt("SleepTimeBeforeUpdateCheck", SleepTimeBeforeUpdateCheck) * 1000;

                // check if update-check was performed at least one week ago:
                if (lastUpdateCheck.AddDays(PeriodBeforeUpdateCheck) < DateTime.Today)
                {
                    executeCheck = true;
                }
                else
                {
                    // prevent updating the date inside the registry:
                    lastUpdateCheck = DateTime.MinValue;
                }
            }
            else
            {
                executeCheck = true;
            }

            if (executeCheck && sleepTime != 0)
            {
                // start asynchronously new thread that will perform check and update the registry:
                Thread threadCheck = new Thread(PerformUpdateCheck);
                threadCheck.Start();
            }
        }
示例#3
0
 /// <summary>
 /// Sets the configuration object for given action.
 /// </summary>
 private static void UpdateActionConfig(IPackageConfigUpdater cu, Type actionType, PersistentStorageData config)
 {
     if (cu != null && config != null && actionType != null)
     {
         PersistentStorageHelper.Save(config);
         cu.UpdateConfiguration(actionType, config);
     }
 }
        public void LogError(string message, string sourceText, string eventCodeText, bool logToEventLog)
        {
            string value = FAILED_SIGN + AbstractImportExportSettings.SEPARATOR + "<span class=\"SelectorError\">" + message + "</span>" + content;

            PersistentStorageHelper.SetValue(STORAGE_KEY, value);
            if (logToEventLog)
            {
                new EventLogProvider().LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, sourceText, eventCodeText, URLHelper.CurrentURL, message);
            }
        }
        public void LogQuit(string message, string sourceText, string eventCodeText, bool logToEventLog)
        {
            string value = QUIT_SIGN + AbstractImportExportSettings.SEPARATOR + message + content;

            PersistentStorageHelper.SetValue(STORAGE_KEY, value);
            if (logToEventLog)
            {
                new EventLogProvider().LogEvent(EventLogProvider.EVENT_TYPE_INFORMATION, DateTime.Now, sourceText, eventCodeText, URLHelper.CurrentURL, message);
            }
        }
        public void LogQuit(string message, string sourceText, string eventCodeText, bool logToEventLog)
        {
            string value = QUIT_SIGN + AbstractImportExportSettings.SEPARATOR + message + content;

            PersistentStorageHelper.SetValue(STORAGE_KEY, value);
            if (logToEventLog)
            {
                EventLogProvider.LogEvent(EventType.INFORMATION, sourceText, eventCodeText, message, RequestContext.CurrentURL);
            }
        }
 public ProgressMessagesHelper()
 {
     storageContent = PersistentStorageHelper.GetValue(STORAGE_KEY) as String;
     if (!String.IsNullOrEmpty(storageContent))
     {
         string[] items = storageContent.Split(new[] { AbstractImportExportSettings.SEPARATOR }, StringSplitOptions.None);
         state   = items[0];
         content = items[1];
     }
 }
        public void LogError(string message, string sourceText, string eventCodeText, bool logToEventLog)
        {
            string value = FAILED_SIGN + AbstractImportExportSettings.SEPARATOR + "<span class=\"SelectorError\">" + message + "</span>" + content;

            PersistentStorageHelper.SetValue(STORAGE_KEY, value);
            if (logToEventLog)
            {
                EventLogProvider.LogEvent(EventType.ERROR, sourceText, eventCodeText, message, RequestContext.CurrentURL);
            }
        }
示例#9
0
    /// <summary>
    /// Enables tasks after separation is over.
    /// </summary>
    private void EnableTasks()
    {
        if (ValidationHelper.GetBoolean(PersistentStorageHelper.GetValue("CMSSchedulerTasksEnabled"), false))
        {
            SettingsKeyInfoProvider.SetGlobalValue("CMSSchedulerTasksEnabled", true);

            // Restart win service
            WinServiceHelper.RestartService(WinServiceHelper.HM_SERVICE_BASENAME, false);
        }
        PersistentStorageHelper.RemoveValue("CMSSchedulerTasksEnabled");
    }
示例#10
0
        /// <summary>
        /// Destroy elements that belong to customizator's GUI.
        /// </summary>
        public void Destroy()
        {
            if (tytanToolbar != null)
            {
                // store the config option:
                config.Add(ShowTytanToolbarOption, (uint)(tytanToolbar.Visible ? 1 : 0));
                PersistentStorageHelper.Save(config);

                tytanToolbar.Visible = false;
            }
        }
示例#11
0
    /// <summary>
    /// Gets the current export state.
    /// </summary>
    /// <param name="argument">Argument</param>
    public string GetExportState(string argument)
    {
        string result = null;

        // Get arguments
        string[] args = argument.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

        bool   cancel        = ValidationHelper.GetBoolean(args[0], false);
        int    messageLength = 0;
        int    errorLength   = 0;
        int    warningLength = 0;
        string machineName   = null;

        if (args.Length == 5)
        {
            messageLength = ValidationHelper.GetInteger(args[1], 0);
            errorLength   = ValidationHelper.GetInteger(args[2], 0);
            warningLength = ValidationHelper.GetInteger(args[3], 0);
            machineName   = ValidationHelper.GetString(args[4], null);
        }

        // Check if on same machine
        if (machineName == SqlHelperClass.MachineName.ToLower())
        {
            try
            {
                // Cancel export
                if (cancel)
                {
                    ExportManager.Settings.Cancel();
                }

                result = ExportManager.Settings.GetLimitedProgressLog(messageLength, errorLength, warningLength);
            }
            catch (Exception ex)
            {
                EventLogProvider ev = new EventLogProvider();
                ev.LogEvent("ExportWizard", "EXPORT", ex);

                result = ExportManager.Settings.GetLimitedProgressLog(messageLength, errorLength, warningLength);
            }
            finally
            {
                if (ExportManager.Settings.GetProgressState() != LogStatusEnum.Info)
                {
                    // Delete presistent data
                    PersistentStorageHelper.RemoveValue(PersistentSettingsKey);
                }
            }
        }

        return(result);
    }
示例#12
0
        /// <summary>
        /// Writes the current state of the control to a persistent storage area.
        /// </summary>
        public void StoreState()
        {
            if (treeView.SelectedNode != null)
            {
                PersistentStorageData data = new PersistentStorageData(ToolName);

                data.Add(Settings_Path, treeView.SelectedNode.FullPath);
                data.Add(Settings_Favorites, ExportFavorites());

                PersistentStorageHelper.Save(data);
            }
        }
示例#13
0
 /// <summary>
 /// Runs appropriate action for specific wizard step.
 /// </summary>
 private void RunAction()
 {
     switch (wzdInstaller.ActiveStepIndex)
     {
     case 2:
         PreviousButton.Attributes.Add("disabled", "true");
         NextButton.Attributes.Add("disabled", "true");
         PersistentStorageHelper.RemoveValue(STORAGE_KEY);
         progress.StartLogging();
         asyncControl.RunAsync(StartSeparation, WindowsIdentity.GetCurrent());
         break;
     }
 }
示例#14
0
        public void SaveState()
        {
            string[] storedFilter = FilterMessages;

            if (storedFilter != null && storedFilter.Length > 0)
            {
                PersistentStorageData data = new PersistentStorageData(ToolName);

                data.Add("Filter", storedFilter);

                PersistentStorageHelper.Save(data);
            }
        }
示例#15
0
    /// <summary>
    /// Takes all sites offline.
    /// </summary>
    private void TakeSitesOffline()
    {
        var sites   = SiteInfoProvider.GetSites("(SiteIsOffline IS NULL) OR (SiteIsOffline = 0)", null);
        var siteIDs = new List <int>(sites.Items.Count);

        foreach (var site in sites)
        {
            site.SiteIsOffline = true;
            SiteInfoProvider.SetSiteInfo(site);
            siteIDs.Add(site.SiteID);
        }
        PersistentStorageHelper.SetValue("SeparateDBSites", siteIDs);
    }
示例#16
0
        /// <summary>
        /// Store inside the persistent storage, when the last update took place.
        /// </summary>
        private void StoreCheckState()
        {
            if (lastUpdateCheck == DateTime.MinValue)
            {
                return;
            }

            PersistentStorageData data = new PersistentStorageData(PersistantStorageName);

            data.Add("LastUpdateDate", lastUpdateCheck.ToShortDateString());

            // store:
            PersistentStorageHelper.Save(data);
        }
        public void FileStorage_CreateBlobReturnsNullIfStorageIsFull()
        {
            var testDirectory = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));

            using var storage = new FileStorage(testDirectory.FullName, 10000);

            PersistentStorageHelper.UpdateDirectorySize(10000);

            var data = Encoding.UTF8.GetBytes("Hello, World!");

            Assert.Null(storage.CreateBlob(data));

            testDirectory.Delete(true);
        }
示例#18
0
        /// <summary>
        /// Restores the stored state of the editor.
        /// </summary>
        public void RestoreState()
        {
            PersistentStorageData data = PersistentStorageHelper.Load(ToolName);

            if (data != null && data.Count > 0)
            {
                NavigateTo(data.GetString(Settings_Path));
                ImportFavorites(data.GetMultiString(Settings_Favorites));
            }

            navigator.Clear();
            RefreshNavigationButtons();
            RefreshFavoritesMenu();
        }
示例#19
0
    /// <summary>
    /// Takes sites online.
    /// </summary>
    private void TakeSitesOnline()
    {
        var siteIDs = (List <int>)PersistentStorageHelper.GetValue("SeparateDBSites");

        if ((siteIDs != null) && (siteIDs.Count > 0))
        {
            foreach (var siteID in siteIDs)
            {
                SiteInfo site = SiteInfoProvider.GetSiteInfo(siteID);
                site.SiteIsOffline = false;
                SiteInfoProvider.SetSiteInfo(site);
            }
        }
        PersistentStorageHelper.RemoveValue("SeparateDBSites");
    }
示例#20
0
    /// <summary>
    /// Enables tasks after separation is over.
    /// </summary>
    private void EnableTasks()
    {
        if (ValidationHelper.GetBoolean(PersistentStorageHelper.GetValue("CMSSchedulerTasksEnabled"), false))
        {
            SettingsKeyInfoProvider.SetGlobalValue("CMSSchedulerTasksEnabled", true);

            // Restart win service
            WinServiceItem def = WinServiceHelper.GetServiceDefinition(WinServiceHelper.HM_SERVICE_BASENAME);
            if (def != null)
            {
                WinServiceHelper.RestartService(def.GetServiceName());
            }
        }
        PersistentStorageHelper.RemoveValue("CMSSchedulerTasksEnabled");
    }
示例#21
0
        public void LogError(string message, string sourceText, string eventCodeText, bool logToEventLog)
        {
            string value = FAILED_SIGN + AbstractImportExportSettings.SEPARATOR + "<span class=\"SelectorError\">" + message + "</span>" + content;

            PersistentStorageHelper.SetValue(STORAGE_KEY, value);
            if (logToEventLog)
            {
                var logData = new EventLogData(EventTypeEnum.Error, sourceText, eventCodeText)
                {
                    EventDescription = message,
                    EventUrl         = RequestContext.CurrentURL
                };

                Service.Resolve <IEventLogService>().LogEvent(logData);
            }
        }
示例#22
0
        public void LogQuit(string message, string sourceText, string eventCodeText, bool logToEventLog)
        {
            string value = QUIT_SIGN + AbstractImportExportSettings.SEPARATOR + message + content;

            PersistentStorageHelper.SetValue(STORAGE_KEY, value);
            if (logToEventLog)
            {
                var logData = new EventLogData(EventTypeEnum.Information, sourceText, eventCodeText)
                {
                    EventDescription = message,
                    EventUrl         = RequestContext.CurrentURL
                };

                Service.Resolve <IEventLogService>().LogEvent(logData);
            }
        }
    /// <summary>
    /// Stop tasks.
    /// </summary>
    void btnStopTasks_Click(object sender, EventArgs e)
    {
        // Stop tasks
        PersistentStorageHelper.SetValue("CMSSchedulerTasksEnabled", SettingsKeyInfoProvider.GetBoolValue("CMSSchedulerTasksEnabled"));
        if (SchedulingHelper.EnableScheduler)
        {
            SettingsKeyInfoProvider.SetGlobalValue("CMSSchedulerTasksEnabled", false);
        }

        WinServiceHelper.RestartService(WinServiceHelper.HM_SERVICE_BASENAME, false);

        // Display stopping progress
        iconHelp.Visible = btnStopTasks.Visible = false;
        DisplayStoppingTasks();
        TasksManuallyStopped = true;
    }
示例#24
0
    /// <summary>
    /// Callback event handler.
    /// </summary>
    /// <param name="argument">Callback argument</param>
    public void RaiseCallbackEvent(string argument)
    {
        // Get arguments
        string[] args          = argument.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries);
        bool     cancel        = ValidationHelper.GetBoolean(args[0], false);
        int      messageLength = 0;
        int      errorLength   = 0;
        int      warningLength = 0;
        string   machineName   = null;

        if (args.Length == 5)
        {
            messageLength = ValidationHelper.GetInteger(args[1], 0);
            errorLength   = ValidationHelper.GetInteger(args[2], 0);
            warningLength = ValidationHelper.GetInteger(args[3], 0);
            machineName   = ValidationHelper.GetString(args[4], null);
        }

        // Check if on same machine
        if (machineName == SystemContext.MachineName.ToLowerCSafe())
        {
            try
            {
                // Cancel Import
                if (cancel)
                {
                    ImportManager.Settings.Cancel();
                }

                hdnState.Value = ImportManager.Settings.GetLimitedProgressLog(messageLength, errorLength, warningLength);
            }
            catch (Exception ex)
            {
                EventLogProvider.LogException("ImportWizard", "IMPORT", ex);

                hdnState.Value = ImportManager.Settings.GetLimitedProgressLog(messageLength, errorLength, warningLength);
            }
            finally
            {
                if (ImportManager.Settings.GetProgressState() != LogStatusEnum.Info)
                {
                    // Delete presistent data
                    PersistentStorageHelper.RemoveValue(PersistentSettingsKey);
                }
            }
        }
    }
示例#25
0
    /// <summary>
    /// Set connection string into web.config.
    /// </summary>
    private void SetConnectionString()
    {
        string connectionStringName = DatabaseSeparationHelper.ConnStringSeparateName;
        string encodedPassword      = HttpUtility.HtmlEncode(HttpUtility.HtmlEncode(databaseDialog.Password));

        if (!SystemContext.IsRunningOnAzure)
        {
            if (!SettingsHelper.SetConnectionString(connectionStringName, databaseDialog.ConnectionString))
            {
                string connStringDisplay   = ConnectionHelper.BuildConnectionString(databaseDialog.AuthenticationType, databaseDialog.ServerName, databaseDialog.Database, databaseDialog.Username, encodedPassword, 240);
                string resultStringDisplay = "&lt;add name=\"" + connectionStringName + "\" connectionString=\"" + connStringDisplay + "\"/&gt;";

                separationFinished.ErrorLabel.Visible = true;
                separationFinished.ErrorLabel.Text    = string.Format(ResHelper.GetFileString("Install.ConnectionStringError"), resultStringDisplay);
            }
        }
        else
        {
            string connStringValue = ConnectionHelper.BuildConnectionString(databaseDialog.AuthenticationType, databaseDialog.ServerName, databaseDialog.Database, databaseDialog.Username, encodedPassword, 240, isForAzure: true);
            string connString      = "&lt;add name=\"" + connectionStringName + "\" connectionString=\"" + connStringValue + "\"/&gt;";
            string appSetting      = "&lt;Setting name=\"" + connectionStringName + "\" value=\"" + connStringValue + "\"/&gt;";

            separationFinished.AzureErrorLabel.Visible = true;
            separationFinished.AzureErrorLabel.Text    = string.Format(ResHelper.GetFileString("Install.ConnectionStringAzure"), connString, appSetting);
        }

        // If it doesn't support OpenQuery command, show info about need to do manual data move.
        if (!SqlServerCapabilities.SupportsOpenQueryCommand)
        {
            separationFinished.AzureErrorLabel.Visible = true;
            separationFinished.AzureErrorLabel.Text   += GetManualCopyText();
        }

        if (PersistentStorageHelper.GetValue("SeparateDBSites") == null)
        {
            if (!separationFinished.ErrorLabel.Visible)
            {
                separationFinished.ErrorLabel.Text += "<br />";
            }
            else
            {
                separationFinished.ErrorLabel.Visible = true;
            }
            separationFinished.ErrorLabel.Text += ResHelper.GetFileString("separationdb.startsites");
        }
    }
示例#26
0
    /// <summary>
    /// Set connection string into web.config.
    /// </summary>
    private void SetConnectionString()
    {
        string connectionStringName = DatabaseSeparationHelper.ConnStringSeparateName;

        if (!SystemContext.IsRunningOnAzure)
        {
            if (!SettingsHelper.SetConnectionString(connectionStringName, databaseDialog.ConnectionString))
            {
                string connStringDisplay   = ConnectionHelper.GetConnectionString(databaseDialog.AuthenticationType, databaseDialog.ServerName, databaseDialog.Database, databaseDialog.Username, databaseDialog.Password, 240, true);
                string resultStringDisplay = "&lt;add name=\"" + connectionStringName + "\" connectionString=\"" + connStringDisplay + "\"/&gt;";

                separationFinished.ErrorLabel.Visible = true;
                separationFinished.ErrorLabel.Text    = string.Format(ResHelper.GetFileString("Install.ConnectionStringError"), resultStringDisplay);
            }
        }
        else
        {
            string connStringValue = ConnectionHelper.GetConnectionString(databaseDialog.AuthenticationType, databaseDialog.ServerName, databaseDialog.Database, databaseDialog.Username, databaseDialog.Password, 240, true, "English", true);
            string connString      = "&lt;add name=\"" + connectionStringName + "\" connectionString=\"" + connStringValue + "\"/&gt;";
            string appSetting      = "&lt;Setting name=\"" + connectionStringName + "\" value=\"" + connStringValue + "\"/&gt;";

            separationFinished.AzureErrorLabel.Visible = true;
            separationFinished.AzureErrorLabel.Text    = string.Format(ResHelper.GetFileString("Install.ConnectionStringAzure"), connString, appSetting);
        }

        bool dbEngineSupportsOpenqueryCommand = !DatabaseSeparationHelper.IsUsingAzureDatabase;

        if (!dbEngineSupportsOpenqueryCommand)
        {
            separationFinished.AzureErrorLabel.Visible = true;
            separationFinished.AzureErrorLabel.Text   += GetManualCopyText();
        }

        if (PersistentStorageHelper.GetValueFromFile("SeparateDBSites") == null)
        {
            if (!separationFinished.ErrorLabel.Visible)
            {
                separationFinished.ErrorLabel.Text += "<br />";
            }
            else
            {
                separationFinished.ErrorLabel.Visible = true;
            }
            separationFinished.ErrorLabel.Text += ResHelper.GetFileString("separationdb.startsites");
        }
    }
示例#27
0
        /// <summary>
        /// Init constructor.
        /// </summary>
        public CustomAddInManager(DTE2 applicationObject, AddIn addInInst, IMenuCustomizator menuCustomizator, Assembly assemblyForSatellites)
        {
            appObject     = applicationObject;
            addInInstance = addInInst;
            actions       = new CustomAddInActionDictionary();
            menuManager   = new CustomAddInMenuManager(applicationObject, addInInst, menuCustomizator);
            assist        = new PackageAssist(this);
            mainAssembly  = assemblyForSatellites;

            selectionContainer = new Microsoft.VisualStudio.Shell.SelectionContainer();
            selectedItems      = new System.Collections.ArrayList();
            selectedElements   = new object[1];

            // all settings read/writes will be pefrom according current version of Visual Studio IDE:
            PersistentStorageHelper.Attach(applicationObject);
            BaseOptionPage.ConfigProvider = this;
        }
示例#28
0
    /// <summary>
    /// Takes all sites offline.
    /// </summary>
    private void TakeSitesOffline()
    {
        var sites = SiteInfoProvider.GetSites()
                    .WhereNull("SiteIsOffline")
                    .Or()
                    .WhereEquals("SiteIsOffline", 0)
                    .TypedResult;

        var siteIDs = new List <int>(sites.Items.Count);

        foreach (var site in sites)
        {
            site.SiteIsOffline = true;
            SiteInfoProvider.SetSiteInfo(site);
            siteIDs.Add(site.SiteID);
        }
        PersistentStorageHelper.SetValue("SeparateDBSites", siteIDs);
    }
示例#29
0
        /// <summary>
        /// Performs the cleanup actions.
        /// </summary>
        public void Dispose()
        {
            // notify about the exit event:
            foreach (IPackageAction addIn in data)
            {
                PersistentStorageData config = addIn.Configuration;

                // write configuration if needed:
                if (config != null && config.IsDirty)
                {
                    PersistentStorageHelper.Save(config);
                }

                // and finally release resources:
                addIn.Destroy();
            }

            data.Clear();
        }
示例#30
0
        public void RestoreState()
        {
            PersistentStorageData data = PersistentStorageHelper.Load(ToolName);

            if (data != null && data.Count > 0)
            {
                string[] storedFilter = data.GetMultiString("Filter");
                if (storedFilter == null)
                {
                    string f = data.GetString("Filter");

                    if (f != null)
                    {
                        storedFilter = new string[] { f }
                    }
                    ;
                }

                FilterMessages = storedFilter;
            }
        }