/// <summary>
    /// Gets and bulk updates integration connectors. Called when the "Get and bulk update connectors" button is pressed.
    /// Expects the CreateIntegrationConnector method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateIntegrationConnectors()
    {
        // Prepare the parameters
        string where = "ConnectorName LIKE N'MyNewConnector%'";

        // Get the data
        DataSet connectors = IntegrationConnectorInfoProvider.GetIntegrationConnectors(where, null);

        if (!DataHelper.DataSourceIsEmpty(connectors))
        {
            // Loop through the individual items
            foreach (DataRow connectorDr in connectors.Tables[0].Rows)
            {
                // Create object from DataRow
                IntegrationConnectorInfo modifyConnector = new IntegrationConnectorInfo(connectorDr);

                // Update the properties
                modifyConnector.ConnectorDisplayName = modifyConnector.ConnectorDisplayName.ToUpper();

                // Save the changes
                IntegrationConnectorInfoProvider.SetIntegrationConnectorInfo(modifyConnector);
            }

            return(true);
        }

        return(false);
    }
示例#2
0
 protected override void OnPreRender(EventArgs e)
 {
     if (SynchronizationInfo != null)
     {
         IntegrationTaskInfo      ti = IntegrationTaskInfo.Provider.Get(SynchronizationInfo.SynchronizationTaskID);
         IntegrationConnectorInfo si = IntegrationConnectorInfo.Provider.Get(SynchronizationInfo.SynchronizationConnectorID);
         // Prepare task description
         StringBuilder sbTaskInfo = new StringBuilder();
         sbTaskInfo.Append("<div class=\"form-horizontal\">");
         if ((ti != null) || (si != null))
         {
             if (ti != null)
             {
                 sbTaskInfo.Append("<div class=\"form-group\"><div class=\"editing-form-label-cell\"><span class=\"control-label\">" + GetString("integration.tasktitle") + ":</span></div><div class=\"editing-form-value-cell\"><span class=\"form-control-text\">" + HTMLHelper.HTMLEncode(ti.TaskTitle) + "</span></div></div>");
             }
             if (si != null)
             {
                 sbTaskInfo.Append("<div class=\"form-group\"><div class=\"editing-form-label-cell\"><span class=\"control-label\">" + GetString("integration.connectorname") + ":</span></div><div class=\"editing-form-value-cell\"><span class=\"form-control-text\">" + HTMLHelper.HTMLEncode(si.ConnectorDisplayName) + "</span></div></div>");
             }
         }
         sbTaskInfo.Append("</div>");
         lblInfo.Text = sbTaskInfo.ToString();
     }
     lblInfo.Visible = (lblInfo.Text != "");
     base.OnPreRender(e);
 }
示例#3
0
 protected override void OnPreRender(EventArgs e)
 {
     if (SynchronizationInfo != null)
     {
         IntegrationTaskInfo      ti = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(SynchronizationInfo.SynchronizationTaskID);
         IntegrationConnectorInfo si = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(SynchronizationInfo.SynchronizationConnectorID);
         // Prepare task description
         StringBuilder sbTaskInfo = new StringBuilder();
         sbTaskInfo.Append("<table>");
         if ((ti != null) || (si != null))
         {
             if (ti != null)
             {
                 sbTaskInfo.Append("<tr><td class=\"Title Grid\">" + GetString("integration.tasktitle") + ":</td><td>" + HTMLHelper.HTMLEncode(ti.TaskTitle) + "</td></tr>");
             }
             if (si != null)
             {
                 sbTaskInfo.Append("<tr><td class=\"Title Grid\">" + GetString("integration.connectorname") + ":</td><td>" + HTMLHelper.HTMLEncode(si.ConnectorDisplayName) + "</td></tr>");
             }
         }
         sbTaskInfo.Append("</table>");
         lblInfo.Text = sbTaskInfo.ToString();
     }
     lblInfo.Visible = (lblInfo.Text != "");
     base.OnPreRender(e);
 }
    /// <summary>
    /// Deletes integration connector. Called when the "Delete connector" button is pressed.
    /// Expects the CreateIntegrationConnector method to be run first.
    /// </summary>
    private bool DeleteIntegrationConnector()
    {
        // Get the integration connector
        IntegrationConnectorInfo deleteConnector = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo("MyNewConnector");

        // Delete the integration connector
        IntegrationConnectorInfoProvider.DeleteIntegrationConnectorInfo(deleteConnector);

        return(deleteConnector != null);
    }
    /// <summary>
    /// Creates integration connector. Called when the "Create connector" button is pressed.
    /// </summary>
    private bool CreateIntegrationConnector()
    {
        // Create new integration connector object
        IntegrationConnectorInfo newConnector = new IntegrationConnectorInfo();

        // Set the properties
        newConnector.ConnectorDisplayName  = "My new connector";
        newConnector.ConnectorName         = "MyNewConnector";
        newConnector.ConnectorAssemblyName = "App_Code";
        newConnector.ConnectorClassName    = "SampleIntegrationConnector";
        newConnector.ConnectorEnabled      = false;

        // Save the integration connector
        IntegrationConnectorInfoProvider.SetIntegrationConnectorInfo(newConnector);

        return(true);
    }
    /// <summary>
    /// Creates integration connector. Called when the "Create connector" button is pressed.
    /// </summary>
    private bool CreateIntegrationConnector()
    {
        // Create new integration connector object
        IntegrationConnectorInfo newConnector = new IntegrationConnectorInfo();

        // Set the properties
        newConnector.ConnectorDisplayName = "My new connector";
        newConnector.ConnectorName = "MyNewConnector";
        newConnector.ConnectorAssemblyName = "App_Code";
        newConnector.ConnectorClassName = "SampleIntegrationConnector";
        newConnector.ConnectorEnabled = false;

        // Save the integration connector
        IntegrationConnectorInfoProvider.SetIntegrationConnectorInfo(newConnector);

        return true;
    }
示例#7
0
    private string ProcessSynchronization(int connectorId, int taskId)
    {
        if ((taskId > 0) && (connectorId > 0))
        {
            // Get connector and task
            IntegrationConnectorInfo connectorInfo = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(connectorId);
            IntegrationTaskInfo      taskInfo      = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(taskId);
            if ((connectorInfo != null) && (taskInfo != null))
            {
                if (connectorInfo.ConnectorEnabled)
                {
                    // Get connector instance
                    BaseIntegrationConnector connector = IntegrationHelper.GetConnector(connectorInfo.ConnectorName) as BaseIntegrationConnector;
                    if (connector != null)
                    {
                        AddLog(String.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(taskInfo.TaskTitle)));

                        // Process the task
                        if (TasksAreInbound)
                        {
                            // Always try to process the task when requested from UI
                            taskInfo.TaskProcessType = IntegrationProcessTypeEnum.Default;
                            return(connector.ProcessExternalTask(taskInfo));
                        }
                        else
                        {
                            return(connector.ProcessInternalTask(taskInfo));
                        }
                    }
                    else
                    {
                        // Can't load connector
                        AddLog(String.Format(ResHelper.GetAPIString("synchronization.skippingunavailable", "Skipping '{0}' task - failed to load associated connector."), HTMLHelper.HTMLEncode(taskInfo.TaskTitle)));
                    }
                }
                else
                {
                    // Connector is disabled
                    AddLog(String.Format(ResHelper.GetAPIString("synchronization.skippingdisabled", "Skipping '{0}' task - associated connector is disabled."), HTMLHelper.HTMLEncode(taskInfo.TaskTitle)));
                }
            }
        }

        return(null);
    }
    /// <summary>
    /// Gets and updates integration connector. Called when the "Get and update connector" button is pressed.
    /// Expects the CreateIntegrationConnector method to be run first.
    /// </summary>
    private bool GetAndUpdateIntegrationConnector()
    {
        // Get the integration connector
        IntegrationConnectorInfo updateConnector = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo("MyNewConnector");

        if (updateConnector != null)
        {
            // Update the properties
            updateConnector.ConnectorDisplayName = updateConnector.ConnectorDisplayName.ToLower();

            // Save the changes
            IntegrationConnectorInfoProvider.SetIntegrationConnectorInfo(updateConnector);

            return(true);
        }

        return(false);
    }
示例#9
0
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        int synchronizationId = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerInvariant())
        {
        case "delete":
            // Delete synchronization
            IntegrationSynchronizationInfoProvider.DeleteIntegrationSynchronizationInfo(synchronizationId);
            break;

        case "run":
            // Get synchronization
            IntegrationSynchronizationInfo synchronization = IntegrationSynchronizationInfoProvider.GetIntegrationSynchronizationInfo(synchronizationId);
            if (synchronization != null)
            {
                // Get connector and task
                IntegrationConnectorInfo connectorInfo = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(synchronization.SynchronizationConnectorID);
                IntegrationTaskInfo      taskInfo      = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(synchronization.SynchronizationTaskID);
                if ((connectorInfo != null) && (taskInfo != null))
                {
                    // Get connector instance
                    BaseIntegrationConnector connector = IntegrationHelper.GetConnector(connectorInfo.ConnectorName) as BaseIntegrationConnector;
                    if (connector != null)
                    {
                        // Process the task
                        if (TasksAreInbound)
                        {
                            // Always try to process the task when requested from UI
                            taskInfo.TaskProcessType = IntegrationProcessTypeEnum.Default;
                            connector.ProcessExternalTask(taskInfo);
                        }
                        else
                        {
                            connector.ProcessInternalTask(taskInfo);
                        }
                    }
                }
            }
            break;
        }
    }
    protected override void OnPreRender(EventArgs e)
    {
        // Hide multiple actions if grid is empty
        pnlFooter.Visible = !gridElem.IsEmpty;

        // Initialize actions dropdown list - they need to be refreshed on connector selection
        drpAction.Items.Clear();
        drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString()));

        // Add synchronize option only when task processing is enabled
        IntegrationConnectorInfo connector = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(ConnectorID);

        if ((TasksAreInbound ? IntegrationHelper.IntegrationProcessExternal : IntegrationHelper.IntegrationProcessInternal) && ((ConnectorID <= 0) || (connector != null) && connector.ConnectorEnabled && (IntegrationHelper.GetConnector(connector.ConnectorName) != null)))
        {
            drpAction.Items.Add(new ListItem(GetString("general." + Action.Synchronize), Convert.ToInt32(Action.Synchronize).ToString()));
        }
        drpAction.Items.Add(new ListItem(GetString("general." + Action.Delete), Convert.ToInt32(Action.Delete).ToString()));

        base.OnPreRender(e);
    }
    /// <summary>
    /// Gets and bulk updates integration connectors. Called when the "Get and bulk update connectors" button is pressed.
    /// Expects the CreateIntegrationConnector method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateIntegrationConnectors()
    {
        // Prepare the parameters
        string where = "ConnectorName LIKE N'MyNewConnector%'";

        // Get the data
        DataSet connectors = IntegrationConnectorInfoProvider.GetIntegrationConnectors(where, null);
        if (!DataHelper.DataSourceIsEmpty(connectors))
        {
            // Loop through the individual items
            foreach (DataRow connectorDr in connectors.Tables[0].Rows)
            {
                // Create object from DataRow
                IntegrationConnectorInfo modifyConnector = new IntegrationConnectorInfo(connectorDr);

                // Update the properties
                modifyConnector.ConnectorDisplayName = modifyConnector.ConnectorDisplayName.ToUpper();

                // Save the changes
                IntegrationConnectorInfoProvider.SetIntegrationConnectorInfo(modifyConnector);
            }

            return true;
        }

        return false;
    }