/// <summary>
        /// Get the default configuration for the workflow action.
        /// </summary>
        /// <param name="context">The context in which the method was invoked.</param>
        /// <returns>The default configuration for the workflow action.</returns>
        /// <remarks></remarks>
        public override NWActionConfig GetDefaultConfig(GetDefaultConfigContext context)
        {
            NWActionConfig config = new NWActionConfig(this);

            config.Parameters = new ActivityParameter[3];

            config.Parameters[0]                          = new ActivityParameter();
            config.Parameters[0].Name                     = UploadItemToSignActivity.KeyApproversPropertyName;
            config.Parameters[0].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[0].PrimitiveValue.Value     = string.Empty;
            config.Parameters[0].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

            config.Parameters[1]                          = new ActivityParameter();
            config.Parameters[1].Name                     = UploadItemToSignActivity.KeyUrlMiscInfoPropertyName;
            config.Parameters[1].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[1].PrimitiveValue.Value     = string.Empty;
            config.Parameters[1].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

            config.Parameters[2]          = new ActivityParameter();
            config.Parameters[2].Name     = UploadItemToSignActivity.KeyOutAdobeAgreementIDProperty;
            config.Parameters[2].Variable = new NWWorkflowVariable();

            config.TLabel = ActivityReferenceCollection.FindByAdapter(this).Name;
            return(config);
        }
Ejemplo n.º 2
0
        public override NWActionConfig GetDefaultConfig(GetDefaultConfigContext context)
        {
            NWActionConfig c = new NWActionConfig(this);

            c.Parameters = new ActivityParameter[4];

            c.Parameters[0]                = new ActivityParameter();
            c.Parameters[0].Name           = Parameter_lookupList;
            c.Parameters[0].PrimitiveValue = new PrimitiveValue();

            c.Parameters[1]                = new ActivityParameter();
            c.Parameters[1].Name           = Parameter_itemID;
            c.Parameters[1].PrimitiveValue = new PrimitiveValue();

            c.Parameters[2]                = new ActivityParameter();
            c.Parameters[2].Name           = Parameter_FieldValue;
            c.Parameters[2].PrimitiveValue = new PrimitiveValue();

            c.Parameters[3]                = new ActivityParameter();
            c.Parameters[3].Name           = Parameter_TaxonomyFieldName;
            c.Parameters[3].PrimitiveValue = new PrimitiveValue();

            c.TLabel  = ActivityReferenceCollection.FindByAdapter(this).Name;
            c.IsValid = false;
            return(c);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the default configuration for the workflow action.
        /// </summary>
        /// <param name="context">The context in which the method was invoked.</param>
        /// <returns>The default configuration for the workflow action.</returns>
        /// <remarks></remarks>
        public override NWActionConfig GetDefaultConfig(GetDefaultConfigContext context)
        {
            NWActionConfig config = new NWActionConfig(this);

            config.Parameters = new ActivityParameter[4];

            config.Parameters[0]                          = new ActivityParameter();
            config.Parameters[0].Name                     = CheckAgreementStatusActivity.KeyAgreementID;
            config.Parameters[0].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[0].PrimitiveValue.Value     = string.Empty;
            config.Parameters[0].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

            config.Parameters[1]          = new ActivityParameter();
            config.Parameters[1].Name     = CheckAgreementStatusActivity.KeyOutStaus;
            config.Parameters[1].Variable = new NWWorkflowVariable();


            config.Parameters[2]          = new ActivityParameter();
            config.Parameters[2].Name     = CheckAgreementStatusActivity.KeyOutPendingApprovers;
            config.Parameters[2].Variable = new NWWorkflowVariable();

            config.Parameters[3]          = new ActivityParameter();
            config.Parameters[3].Name     = CheckAgreementStatusActivity.KeyOutEvents;
            config.Parameters[3].Variable = new NWWorkflowVariable();


            config.TLabel = ActivityReferenceCollection.FindByAdapter(this).Name;
            return(config);
        }
Ejemplo n.º 4
0
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPWebApplication parent = (SPWebApplication)properties.Feature.Parent;

            ActivityReference action = ActivityReferenceCollection.FindByAdapter(adapterType, adapterAssembly);

            if (action != null)
            {
                // Remove the action definition from the workflow configuration database if the Feature is not activated elsewhere
                if (!IsFeatureActivatedInAnyWebApp(parent, properties.Definition.Id))
                {
                    ActivityReferenceCollection.RemoveAction(action.ActivityId);
                }

                string activityTypeName  = string.Empty;
                string activityNamespace = string.Empty;
                Utility.ExtractNamespaceAndClassName(action.ActivityType, out activityTypeName, out activityNamespace);

                // Remove the web.config entry
                Collection <SPWebConfigModification> modifications = parent.WebConfigModifications;
                foreach (SPWebConfigModification modification in modifications)
                {
                    if (modification.Owner == AuthorisedTypes.OWNER_TOKEN) // OWNER_TOKEN is the owner for any web config modification added by Nintex Workflow
                    {
                        if (IsAuthorizedTypeMatch(modification.Value, action.ActivityAssembly, activityTypeName, activityNamespace))
                        {
                            modifications.Remove(modification);
                            parent.Farm.Services.GetValue <SPWebService>().ApplyWebConfigModifications();
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWebApplication parent = (SPWebApplication)properties.Feature.Parent;

            // First step is register the action to the Nintex Workflow database
            XmlDocument nwaXml = GetNWADefinition(properties);

            ActivityReference newActivityReference = ActivityReference.ReadFromNWA(nwaXml);

            ActivityReference action = ActivityReferenceCollection.FindByAdapter(newActivityReference.AdapterType, newActivityReference.AdapterAssembly);

            if (action != null)
            {
                // update the details if the adapter already exists
                ActivityReferenceCollection.UpdateActivity(action.ActivityId, newActivityReference.Name, newActivityReference.Description, newActivityReference.Category, newActivityReference.ActivityAssembly, newActivityReference.ActivityType, newActivityReference.AdapterAssembly, newActivityReference.AdapterType, newActivityReference.HandlerUrl, newActivityReference.ConfigPage, newActivityReference.RenderBehaviour, newActivityReference.Icon, newActivityReference.ToolboxIcon, newActivityReference.WarningIcon, newActivityReference.QuickAccess, newActivityReference.ListTypeFilter);
            }
            else
            {
                ActivityReferenceCollection.AddActivity(newActivityReference.Name, newActivityReference.Description, newActivityReference.Category, newActivityReference.ActivityAssembly, newActivityReference.ActivityType, newActivityReference.AdapterAssembly, newActivityReference.AdapterType, newActivityReference.HandlerUrl, newActivityReference.ConfigPage, newActivityReference.RenderBehaviour, newActivityReference.Icon, newActivityReference.ToolboxIcon, newActivityReference.WarningIcon, newActivityReference.QuickAccess, newActivityReference.ListTypeFilter);
                action = ActivityReferenceCollection.FindByAdapter(newActivityReference.AdapterType, newActivityReference.AdapterAssembly);
            }

            // Second step is to modify the web.config file to allow use of the activity in declarative workflows
            string activityTypeName  = string.Empty;
            string activityNamespace = string.Empty;

            Utility.ExtractNamespaceAndClassName(action.ActivityType, out activityTypeName, out activityNamespace);
            AuthorisedTypes.InstallAuthorizedWorkflowTypes(parent, action.ActivityAssembly, activityNamespace, activityTypeName);

            // Third step is to activate the action for the farm
            ActivityActivationReference reference = new ActivityActivationReference(action.ActivityId, Guid.Empty, Guid.Empty);

            reference.AddOrUpdateActivationReference();
        }
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            // Retrieve a reference to the parent web application for the feature.
            SPWebApplication parent = (SPWebApplication)properties.Feature.Parent;

            foreach (var file in GetAllNwaFilesNWADefinition())
            {
                XmlDocument       nwaXml = GetNWADefinition(file);
                ActivityReference action = ActivityReference.ReadFromNWA(nwaXml);
                if (action != null)
                {
                    // If the feature is not activated in any other web application, remove the action
                    // definition from the configuration database.
                    if (!IsFeatureActivatedInAnyWebApp(parent, properties.Definition.Id))
                    {
                        ActivityReferenceCollection.RemoveAction(action.ActivityId);
                    }

                    // Remove the modification from the web.config file for the web application, to uninstall the
                    // custom workflow activity from the collection of authorized activity types for the
                    // web application.
                    string activityTypeName  = string.Empty;
                    string activityNamespace = string.Empty;

                    // Extract the type name and namespace name from the value of the ActivityType property.
                    Utility.ExtractNamespaceAndClassName(action.ActivityType, out activityTypeName, out activityNamespace);

                    // Identify and remove the modification from the web.config file.
                    Collection <SPWebConfigModification> modifications = parent.WebConfigModifications;
                    foreach (SPWebConfigModification modification in modifications)
                    {
                        // If the modification was added by Nintex Workflow, compare the assembly, namespace, and type of the workflow activity to the collection of
                        // authorized activity types in the modification. If they match, remove the modification.
                        // NOTE: AuthorizedTypes.OWNER_TOKEN is the owner token for any modification added by
                        // Nintex Workflow.
                        if (modification.Owner == AuthorisedTypes.OWNER_TOKEN)
                        {
                            if (IsAuthorizedTypeMatch(modification.Value, action.ActivityAssembly, activityTypeName, activityNamespace))
                            {
                                // Remove the modification.
                                modifications.Remove(modification);
                                // Apply the updated modifications to the SharePoint farm containing the web application.
                                parent.Farm.Services.GetValue <SPWebService>().ApplyWebConfigModifications();
                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get the default configuration for the workflow action.
        /// </summary>
        /// <param name="context">The context in which the method was invoked.</param>
        /// <returns>The default configuration for the workflow action.</returns>
        /// <remarks></remarks>
        public override NWActionConfig GetDefaultConfig(GetDefaultConfigContext context)
        {
            NWActionConfig config = new NWActionConfig(this);

            config.Parameters = new ActivityParameter[5];

            config.Parameters[0]                          = new ActivityParameter();
            config.Parameters[0].Name                     = DownloadDocumentActivity.KeyAgreementID;
            config.Parameters[0].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[0].PrimitiveValue.Value     = string.Empty;
            config.Parameters[0].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

            config.Parameters[1]                          = new ActivityParameter();
            config.Parameters[1].Name                     = DownloadDocumentActivity.KeyDestWebUrl;
            config.Parameters[1].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[1].PrimitiveValue.Value     = string.Empty;
            config.Parameters[1].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

            config.Parameters[2]                          = new ActivityParameter();
            config.Parameters[2].Name                     = DownloadDocumentActivity.KeyDestDocLib;
            config.Parameters[2].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[2].PrimitiveValue.Value     = string.Empty;
            config.Parameters[2].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

            config.Parameters[3]                          = new ActivityParameter();
            config.Parameters[3].Name                     = DownloadDocumentActivity.KeyDestDocName;
            config.Parameters[3].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[3].PrimitiveValue.Value     = string.Empty;
            config.Parameters[3].PrimitiveValue.ValueType = SPFieldType.Text.ToString();


            config.Parameters[4]          = new ActivityParameter();
            config.Parameters[4].Name     = DownloadDocumentActivity.KeyOutDocumentID;
            config.Parameters[4].Variable = new NWWorkflowVariable();


            config.TLabel = ActivityReferenceCollection.FindByAdapter(this).Name;
            return(config);
        }
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            // Retrieve a reference to the parent web application for the feature.
            SPWebApplication parent = (SPWebApplication)properties.Feature.Parent;

            foreach (var file in GetAllNwaFilesNWADefinition())
            {
                // Retrieve the contents of the action definition file.
                XmlDocument nwaXml = GetNWADefinition(file);

                // Instantiate an ActivityReference object from the action definition file.
                ActivityReference newActivityReference = ActivityReference.ReadFromNWA(nwaXml);

                // Attempt to instantiate an ActivityReference object from the the workflow action adapter
                // identified by the AdapterType and AdapterAssembly elements from the action definition file.
                // For new deployments, action is set to null; otherwise, the existing ActivityReference
                // for the custom workflow action is retrieved.
                ActivityReference action = ActivityReferenceCollection.FindByAdapter(
                    newActivityReference.AdapterType, newActivityReference.AdapterAssembly);

                // If the custom workflow action has been previously deployed,
                // update the ActivityReference for the custom action; otherwise,
                // add a new Activityreference for the custom action and then
                // instantiate it.
                if (action != null)
                {
                    // Update the ActivityReference for the custom workflow action.
                    ActivityReferenceCollection.UpdateActivity(
                        action.ActivityId,
                        newActivityReference.Name,
                        newActivityReference.Description,
                        newActivityReference.Category,
                        newActivityReference.ActivityAssembly,
                        newActivityReference.ActivityType,
                        newActivityReference.AdapterAssembly,
                        newActivityReference.AdapterType,
                        newActivityReference.HandlerUrl,
                        newActivityReference.ConfigPage,
                        newActivityReference.RenderBehaviour,
                        newActivityReference.Icon,
                        newActivityReference.ToolboxIcon,
                        newActivityReference.WarningIcon,
                        newActivityReference.QuickAccess,
                        newActivityReference.ListTypeFilter);
                }
                else
                {
                    // Add a new ActivityReference for the custom workflow action.
                    ActivityReferenceCollection.AddActivity(
                        newActivityReference.Name,
                        newActivityReference.Description,
                        newActivityReference.Category,
                        newActivityReference.ActivityAssembly,
                        newActivityReference.ActivityType,
                        newActivityReference.AdapterAssembly,
                        newActivityReference.AdapterType,
                        newActivityReference.HandlerUrl,
                        newActivityReference.ConfigPage,
                        newActivityReference.RenderBehaviour,
                        newActivityReference.Icon,
                        newActivityReference.ToolboxIcon,
                        newActivityReference.WarningIcon,
                        newActivityReference.QuickAccess,
                        newActivityReference.ListTypeFilter);

                    // Instantiate the newly-added ActivityReference.
                    action = ActivityReferenceCollection.FindByAdapter(
                        newActivityReference.AdapterType, newActivityReference.AdapterAssembly);
                }


                // Add a modification to the web.config file for the web application, to install the
                // custom workflow activity to the collection of authorized activity types for the
                // web application.
                string activityTypeName  = string.Empty;
                string activityNamespace = string.Empty;

                // Extract the type name and namespace name from the value of the ActivityType property.
                Utility.ExtractNamespaceAndClassName(action.ActivityType, out activityTypeName, out activityNamespace);

                // Add the assembly, namespace, and type of the workflow activity to the collection of
                // authorized activity types for the web application.

                // Activate the custom workflow action.
                ActivityActivationReference reference = new ActivityActivationReference(
                    action.ActivityId, Guid.Empty, Guid.Empty);
                reference.AddOrUpdateActivationReference();
            }
        }
Ejemplo n.º 9
0
        public override NWActionConfig GetDefaultConfig(GetDefaultConfigContext context)
        {
            // Build the default parameters for the action. Populate an array of ActivityParameters to represent each parameter.

            NWActionConfig config = new NWActionConfig(this);

            config.Parameters = new ActivityParameter[9];

            config.Parameters[0]                          = new ActivityParameter();
            config.Parameters[0].Name                     = PSScriptProperty;
            config.Parameters[0].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[0].PrimitiveValue.Value     = string.Empty;
            config.Parameters[0].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

            config.Parameters[1]                      = new ActivityParameter();
            config.Parameters[1].Name                 = LoginUserNameProperty;
            config.Parameters[1].PrimitiveValue       = new PrimitiveValue();
            config.Parameters[1].PrimitiveValue.Value = string.Empty;

            config.Parameters[2]                      = new ActivityParameter();
            config.Parameters[2].Name                 = LoginPasswordProperty;
            config.Parameters[2].PrimitiveValue       = new PrimitiveValue();
            config.Parameters[2].PrimitiveValue.Value = string.Empty;

            config.Parameters[3]          = new ActivityParameter();
            config.Parameters[3].Name     = ResultOutputProperty;
            config.Parameters[3].Variable = new NWWorkflowVariable();

            config.Parameters[4]                          = new ActivityParameter();
            config.Parameters[4].Name                     = SSLEnabledProperty;
            config.Parameters[4].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[4].PrimitiveValue.Value     = false.ToString();
            config.Parameters[4].PrimitiveValue.ValueType = SPFieldType.Boolean.ToString();

            config.Parameters[5]                          = new ActivityParameter();
            config.Parameters[5].Name                     = ComputerNameProperty;
            config.Parameters[5].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[5].PrimitiveValue.Value     = string.Empty;
            config.Parameters[5].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

            config.Parameters[6]                          = new ActivityParameter();
            config.Parameters[6].Name                     = PortNumberProperty;
            config.Parameters[6].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[6].PrimitiveValue.Value     = "5985";
            config.Parameters[6].PrimitiveValue.ValueType = SPFieldType.Integer.ToString();

            config.Parameters[7]                          = new ActivityParameter();
            config.Parameters[7].Name                     = AppNameProperty;
            config.Parameters[7].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[7].PrimitiveValue.Value     = "/wsman";
            config.Parameters[7].PrimitiveValue.ValueType = SPFieldType.Text.ToString();

            config.Parameters[8]                          = new ActivityParameter();
            config.Parameters[8].Name                     = ShellUriProperty;
            config.Parameters[8].PrimitiveValue           = new PrimitiveValue();
            config.Parameters[8].PrimitiveValue.Value     = "http://schemas.microsoft.com/powershell/Microsoft.PowerShell";
            config.Parameters[8].PrimitiveValue.ValueType = SPFieldType.Text.ToString();


            // Set the default label for the action.
            config.TLabel = ActivityReferenceCollection.FindByAdapter(this).Name;
            return(config);
        }