コード例 #1
0
        public void SetHistoryList(SPListInstance list)
        {
            if (list == null)
            {
                throw new JavaScriptException(this.Engine, "Error", "A SPList must be supplied as the first argument.");
            }

            m_workflowAssociation.SetHistoryList(list.List);
        }
コード例 #2
0
 private void AssociateSiteWorkflow()
 {
     if (this.associationParams.AssociationGuid == Guid.Empty)
     {
         SPWorkflowAssociation association = SPWorkflowAssociation.CreateWebAssociation(
             Web.WorkflowTemplates[new Guid(this.associationParams.BaseTemplate)],
             this.associationParams.AssociationName,
             Web.Lists[this.associationParams.TaskListGuid],
             Web.Lists[this.associationParams.HistoryListGuid]);
         PopulateAssociationParams(association);
         Web.WorkflowAssociations.Add(association);
     }
     else
     {
         SPWorkflowAssociation association = Web.WorkflowAssociations[this.associationParams.AssociationGuid];
         association.SetTaskList(Web.Lists[this.associationParams.TaskListGuid]);
         association.SetHistoryList(Web.Lists[this.associationParams.HistoryListGuid]);
         PopulateAssociationParams(association);
         Web.WorkflowAssociations.Update(association);
     }
 }
コード例 #3
0
        public void BtnOK_Click(object sender, EventArgs e)
        {
            SPList taskList    = null;
            SPList historyList = null;

            if (!IsValid)
            {
                return;
            }
            if (!m_bContentTypeTemplate)
            {
                // If the user requested a new task list, create it.
                if (m_taskListId == Guid.Empty)
                {
                    string description = string.Format("Task list for the {0} workflow.", m_workflowName);
                    m_taskListId = Web.Lists.Add(m_taskListName, description, SPListTemplateType.Tasks);
                }

                // If the user requested a new history list, create it.
                if (m_historyListId == Guid.Empty)
                {
                    string description = string.Format("History list for the {0} workflow.", m_workflowName);
                    m_historyListId = Web.Lists.Add(m_historyListName, description, SPListTemplateType.WorkflowHistory);
                }
                taskList    = Web.Lists[m_taskListId];
                historyList = Web.Lists[m_historyListId];
            }

            // perform association (if it doesn't already exist)
            bool isNewAssociation;

            if (m_assocTemplate == null)
            {
                isNewAssociation = true;
                if (!m_bContentTypeTemplate)
                {
                    m_assocTemplate = SPWorkflowAssociation.CreateListAssociation(m_baseTemplate,
                                                                                  m_workflowName,
                                                                                  taskList,
                                                                                  historyList);
                }
                else
                {
                    m_assocTemplate = SPWorkflowAssociation.CreateSiteContentTypeAssociation(m_baseTemplate,
                                                                                             m_workflowName,
                                                                                             taskList.Title,
                                                                                             historyList.Title);
                }
            }
            else // modify existing template
            {
                isNewAssociation     = false;
                m_assocTemplate.Name = m_workflowName;
                m_assocTemplate.SetTaskList(taskList);
                m_assocTemplate.SetHistoryList(historyList);
            }

            // set up starup parameters in the template
            m_assocTemplate.Name            = m_workflowName;
            m_assocTemplate.LockItem        = m_bLockItem;
            m_assocTemplate.AutoStartCreate = m_autoStartCreate;
            m_assocTemplate.AutoStartChange = m_autoStartChange;
            m_assocTemplate.AllowManual     = m_allowManual;
            if (m_assocTemplate.AllowManual)
            {
                SPBasePermissions newPerms = SPBasePermissions.EmptyMask;

                if (Request.Params["ManualPermEditItemRequired"] == "ON")
                {
                    newPerms |= SPBasePermissions.EditListItems;
                }
                if (Request.Params["ManualPermManageListRequired"] == "ON")
                {
                    newPerms |= SPBasePermissions.ManageLists;
                }

                m_assocTemplate.PermissionsManual = newPerms;
            }

            // place data from form into the association template
            m_assocTemplate.AssociationData = SerializeFormToString(FormType.Association);// SerializeFormToString(m_assocTemplate.AssociationData, FormType.Association);

            // if its a content type association, add the template to the content type
            if (m_ct != null)
            {
                if (isNewAssociation)
                {
                    m_ct.AddWorkflowAssociation(m_assocTemplate);
                }
                else
                {
                    m_ct.UpdateWorkflowAssociation(m_assocTemplate);
                }
                if (m_updateLists)
                {
                    m_ct.UpdateWorkflowAssociationsOnChildren(false);
                }
            }
            else// Else, if this is a list association,
            {
                if (isNewAssociation) //if new association
                {
                    List.AddWorkflowAssociation(m_assocTemplate);
                }
                else
                {
                    List.UpdateWorkflowAssociation(m_assocTemplate);
                }

                if (m_assocTemplate.AllowManual && List.EnableMinorVersions)
                {
                    //In case you selected this WF to be the content approval WF (m_setDefault = true see association page)
                    if (List.DefaultContentApprovalWorkflowId != m_assocTemplate.Id && m_setDefault)
                    {
                        if (!List.EnableModeration)
                        {
                            List.EnableModeration = true;
                        }
                        List.DefaultContentApprovalWorkflowId = m_assocTemplate.Id;
                        List.Update();
                    }
                    else if (List.DefaultContentApprovalWorkflowId == m_assocTemplate.Id && !m_setDefault)
                    {
                        // Reset the DefaultContentApprovalWorkflowId
                        List.DefaultContentApprovalWorkflowId = Guid.Empty;
                        List.Update();
                    }
                }
            }
            string strUrl = StrGetRelativeUrl(this, "WrkSetng.aspx", null)
                            + m_strQueryParams;

            Response.Redirect(strUrl);
        }