Beispiel #1
0
    /// <summary>
    /// Initializes the web farm environment
    /// </summary>
    public static void InitWebFarm()
    {
        // Delete memory synchronization tasks
        WebSyncHelper.DeleteMemorySynchronizationTasks();

        string serverDisplayName = string.Empty;
        string serverUrl         = string.Empty;
        bool   createServer      = false;

        // Create web farm server if running on Azure
        if (AzureHelper.IsRunningOnAzure)
        {
            // Set web farm server name
            WebSyncHelperClass.ServerName = ValidationHelper.GetCodeName(AzureHelper.CurrentInstanceID);
            serverDisplayName             = AzureHelper.CurrentInstanceID;
            serverUrl = AzureHelper.CurrentInternalEndpoint;

            createServer = true;
        }
        // Get dynamic name for server name
        else if (WebSyncHelperClass.GenerateWebFarmServers)
        {
            WebSyncHelperClass.WebFarmEnabled = true;
            serverUrl    = HTTPHelper.UserHostAddress + SettingsKeyProvider.ApplicationPath.TrimEnd('/') + WebSyncHelperClass.WebFarmUpdaterPage;
            createServer = true;

            if (string.IsNullOrEmpty(WebSyncHelperClass.ServerName))
            {
                serverDisplayName             = WebFarmServerInfoProvider.GetAutomaticServerName();
                WebSyncHelperClass.ServerName = ValidationHelper.GetCodeName(serverDisplayName);
            }
            else
            {
                serverDisplayName = WebSyncHelperClass.ServerName;
            }
        }

        // Create new web farm server if is needed
        if (createServer)
        {
            string serverName = WebSyncHelperClass.ServerName;

            // Create web farm server
            WebFarmServerInfo wfsi = WebFarmServerInfoProvider.GetWebFarmServerInfo(serverName);
            if (wfsi == null)
            {
                wfsi = new WebFarmServerInfo();
            }

            wfsi.ServerName        = serverName;
            wfsi.ServerEnabled     = true;
            wfsi.ServerDisplayName = serverDisplayName;
            wfsi.ServerURL         = serverUrl;

            WebFarmServerInfoProvider.SetWebFarmServerInfo(wfsi);
        }
    }
    /// <summary>
    /// Run task list.
    /// </summary>
    protected void btnRunTasks_Click(object sender, EventArgs e)
    {
        // Call synchronization method
        WebSyncHelper.ProcessMyTasks();

        UniGrid.ReloadData();

        // Show info label
        ShowInformation(GetString("webfarmtasks.taskexecuted"));
    }
    /// <summary>
    /// Run task list.
    /// </summary>
    protected void btnRunTasks_Click(object sender, EventArgs e)
    {
        // Call synchronization method
        WebSyncHelper.ProcessMyTasks();

        UniGrid.ReloadData();

        // Show info label
        lblInfo.Text    = GetString("webfarmtasks.taskexecuted");
        lblInfo.Visible = true;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Process online update
        Guid taskGuid = QueryHelper.GetGuid("taskguid", Guid.Empty);

        if (taskGuid != Guid.Empty)
        {
            // Run specific task
            WebSyncHelper.ProcessTask(taskGuid);
        }
        else
        {
            // Process all tasks for the given server
            WebSyncHelper.ProcessMyTasks();
        }
    }
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "empty":
            // Delete anonymous tasks
            WebFarmTaskInfoProvider.DeleteAllTaskInfo(null);
            UniGrid.ReloadData();
            break;

        case "run":
            // Call synchronization method
            WebSyncHelper.ProcessMyTasks();
            UniGrid.ReloadData();

            // Show info label
            ShowInformation(GetString("webfarmtasks.taskexecuted"));
            break;
        }
    }
Beispiel #6
0
    /// <summary>
    /// Handles changed event of file system watcher.
    /// </summary>
    /// <param name="sender">File system watcher</param>
    /// <param name="e">File system event argument</param>
    private static void NotifyWatcher_Changed(object sender, IOExceptions.FileSystemEventArgs e)
    {
        try
        {
            // Temporarily disable raising events because event OnChange is called twice when file is changed
            WebSyncHelper.NotifyWatcher.EnableRaisingEvents = false;

            // Process web farm tasks
            WebSyncHelper.ProcessMyTasks();
        }
        catch (Exception ex)
        {
            // Log exception
            EventLogProvider.LogException("FileSystemWatcher", "Changed", ex);
        }
        finally
        {
            // Enable raising events
            WebSyncHelper.NotifyWatcher.EnableRaisingEvents = true;
        }
    }
    /// <summary>
    /// Run task list.
    /// </summary>
    protected void btnRunTasks_Click(object sender, EventArgs e)
    {
        switch (selectedServer)
        {
        case allServers:
            WebSyncHelper.SynchronizeWebFarm(true);
            // Call synchronization method
            WebSyncHelper.ProcessMyTasks();
            break;

        default:
            // Get the server info object
            WebFarmServerInfo wfsi = WebFarmServerInfoProvider.GetWebFarmServerInfo(SqlHelperClass.GetSafeQueryString(selectedServer, false));
            // If server is enabled
            if (wfsi.ServerEnabled)
            {
                if (wfsi.ServerName.ToLower() == WebSyncHelperClass.ServerName.ToLower())
                {
                    // Call synchronization method
                    WebSyncHelper.ProcessMyTasks();
                }
                else
                {
                    if (WebSyncHelperClass.Servers.Contains(wfsi.ServerID))
                    {
                        WebFarmUpdaterAsync wfu = new WebFarmUpdaterAsync();
                        // Add server for sync
                        wfu.Urls.Add(wfsi.ServerURL.TrimEnd('/') + WebSyncHelperClass.WebFarmUpdaterPage);
                    }
                }
            }
            break;
        }

        UniGrid.ReloadData();

        // Show info label
        lblInfo.Text    = GetString("webfarmtasks.taskexecuted");
        lblInfo.Visible = true;
    }
    /// <summary>
    /// Run task list.
    /// </summary>
    private void RunTasks()
    {
        switch (selectedServer)
        {
        case allServers:
        {
            WebSyncHelper.NotifyServers(true);
            WebSyncHelper.ProcessMyTasks();
        }
        break;

        default:
            // Get the server info object
            WebFarmServerInfo wfsi = WebFarmServerInfoProvider.GetWebFarmServerInfo(SqlHelper.GetSafeQueryString(selectedServer, false));
            // If server is enabled
            if (wfsi.ServerEnabled)
            {
                if (wfsi.ServerName.ToLowerCSafe() == WebSyncHelper.ServerName.ToLowerCSafe())
                {
                    // Call synchronization method
                    WebSyncHelper.ProcessMyTasks();
                }
                else if (WebSyncHelper.EnabledServers.Any(s => s.ServerID == wfsi.ServerID))
                {
                    WebFarmUpdaterAsync wfu = new WebFarmUpdaterAsync();

                    // Add server for sync
                    wfu.Urls.Add(wfsi.ServerURL);
                    wfu.Run();
                }
            }
            break;
        }

        UniGrid.ReloadData();

        // Show info label
        ShowInformation(GetString("webfarmtasks.taskexecuted"));
    }
Beispiel #9
0
    /// <summary>
    /// Runs all my web farm tasks. Called when the "Run my tasks" button is pressed.
    /// </summary>
    private bool RunMyTasks()
    {
        WebSyncHelper.ProcessMyTasks();

        return(true);
    }