Exemplo n.º 1
0
        // Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite curSite;
            SPWeb  curWeb;

            properties.GetSiteAndWeb(out curSite, out curWeb);

            #region Turn on auditing flags.
            curSite.Audit.AuditFlags = SPAuditMaskType.All;
            curSite.Audit.Update();
            #endregion

            #region Configure eCase DB Connection String
            string connectionString = "Initial Catalog=WSS_Content_Apps_eCase_DOI;Data Source=ECMINTSPSQL1.INTECM.GOV.TESTECM.GOV,1433;User ID=eCaseUser;Password=Devise!!!";
            if (!curSite.RootWeb.Properties.ContainsKey(eCaseConstants.PropertyBagKeys.ECASE_DB_CONNECTION_STRING))
            {
                curSite.RootWeb.Properties.Add(eCaseConstants.PropertyBagKeys.ECASE_DB_CONNECTION_STRING, connectionString);
                curSite.RootWeb.Properties.Update();
            }
            #endregion

            #region Configure Doc Id Prefix
            string prefix = "CCCM";
            if (!curSite.RootWeb.Properties.ContainsKey(eCaseConstants.PropertyBagKeys.ECASE_DOC_ID_PREFIX))
            {
                curSite.RootWeb.Properties.Add(eCaseConstants.PropertyBagKeys.ECASE_DOC_ID_PREFIX, prefix);
                curSite.RootWeb.Properties.Update();
            }
            #endregion

            // Configure Doc ID Service
            DocumentId.SetProvider(curSite, new eCaseDocIdProvider());
        }
Exemplo n.º 2
0
        // Uncomment the method below to handle the event raised before a feature is deactivated.

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite curSite;
            SPWeb  curWeb;

            properties.GetSiteAndWeb(out curSite, out curWeb);
            DocumentId.SetDefaultProvider(curSite);
        }
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite curSite;
            SPWeb  curWeb;

            properties.GetSiteAndWeb(out curSite, out curWeb);

            #region Alter Enterprise Keywords' Display Name at Site Column level and push changes down
            SPField taxKeywords = curSite.RootWeb.Fields[eCaseConstants.FieldGuids.OOTB_TAXKEYWORD];
            taxKeywords.Title = "Tags";
            taxKeywords.PushChangesToLists = true;
            taxKeywords.Update();
            #endregion

            // Use Custom Logo for Site
            curWeb.SiteLogoUrl = curWeb.Url + "/Style%20Library/images/ecase-logo.png";
            curWeb.Update();

            #region Configure Managed Metadata Properties

            //Attempt to connect the Managed Metadata Properties to the Correct Term Store

            //Associate UIL Field to Managed Metadata Store
            AssociateTaxonomyFieldToMetadataStore(curSite,
                                                  eCaseConstants.FieldGuids.ECASES_LIST_UIL,
                                                  eCaseConstants.Taxonomy.METADATA_GROUP_NAME,
                                                  eCaseConstants.Taxonomy.METADATA_TERMSET_TAX_LIL);

            //Associate Judge Field to Managed Metadata Store
            //AssociateTaxonomyFieldToMetadataStore(curSite,
            //    eCaseConstants.FieldGuids.ECASES_LIST_JUDGE,
            //    eCaseConstants.Taxonomy.METADATA_GROUP_NAME,
            //    eCaseConstants.Taxonomy.METADATA_TERMSET_TAX_JUDGE);

            //Add Columns to ContentType and List
            AddSiteColumnToListContentType(curSite,
                                           eCaseConstants.ListInternalNames.ECASES_LIST,
                                           eCaseConstants.ContentTypeNames.CASE,
                                           eCaseConstants.FieldGuids.ECASES_LIST_UIL);
            //AddSiteColumnToListContentType(curSite,
            //    eCaseConstants.ListInternalNames.ECASES_LIST,
            //    eCaseConstants.ContentTypeNames.CASE,
            //    eCaseConstants.FieldGuids.ECASES_LIST_JUDGE);

            #endregion
        }
Exemplo n.º 4
0
        // Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite curSite;
            SPWeb  curWeb;

            properties.GetSiteAndWeb(out curSite, out curWeb);
            if (curSite != null && curWeb != null)
            {
                try
                {
                    #region Configure Doc Id Prefix
                    string prefix = "CCCM";
                    if (curSite.RootWeb.Properties.ContainsKey(eCaseConstants.PropertyBagKeys.ECASE_DOC_ID_PREFIX))
                    {
                        prefix = curSite.RootWeb.Properties[eCaseConstants.PropertyBagKeys.ECASE_DOC_ID_PREFIX];
                    }

                    if (!curWeb.Properties.ContainsKey(eCaseConstants.PropertyBagKeys.ECASE_DOC_ID_PREFIX))
                    {
                        curWeb.Properties.Add(eCaseConstants.PropertyBagKeys.ECASE_DOC_ID_PREFIX, prefix);
                        curWeb.Properties.Update();
                    }
                    #endregion

                    #region Configure Workflows to Associate
                    string workflowNames = eCaseConstants.PropertyBagDefaultValues.DEFAULT_WORKFLOW_NAMES;
                    if (!curSite.RootWeb.Properties.ContainsKey(eCaseConstants.PropertyBagKeys.ECASE_WORKFLOWS_TO_ASSOCIATE))
                    {
                        curSite.RootWeb.Properties.Add(eCaseConstants.PropertyBagKeys.ECASE_WORKFLOWS_TO_ASSOCIATE, workflowNames);
                        curSite.RootWeb.Properties.Update();
                    }
                    #endregion

                    // Activate Case Site Components feature at RootWeb if not already activated
                    try { curSite.Features.Add(eCaseConstants.FeatureIds.CASE_SITE_COMPONENTS); }
                    catch (System.Data.DuplicateNameException x)
                    {
                        Logger.Instance.Info(string.Format("CaseWebComponentsEventReceiver.FeatureActivated: {0} already activated at {1}",
                                                           eCaseConstants.FeatureIds.CASE_SITE_COMPONENTS.ToString(), curSite.Url), x, DiagnosticsCategories.eCaseWeb);
                    }

                    // Activate Standard Site Collection Features if not already activated
                    try { curSite.Features.Add(eCaseConstants.FeatureIds.LEGACY_WORKFLOWS); }
                    catch (System.Data.DuplicateNameException x)
                    {
                        Logger.Instance.Info(string.Format("CaseWebComponentsEventReceiver.FeatureActivated: {0} already activated at {1}",
                                                           eCaseConstants.FeatureIds.WORKFLOWS.ToString(), curSite.Url), x, DiagnosticsCategories.eCaseWeb);
                    }

                    // Activate 2010 Workflows feature if not already activated
                    try { curSite.Features.Add(eCaseConstants.FeatureIds.WORKFLOWS); }
                    catch (System.Data.DuplicateNameException x)
                    {
                        Logger.Instance.Info(string.Format("CaseWebComponentsEventReceiver.FeatureActivated: {0} already activated at {1}",
                                                           eCaseConstants.FeatureIds.WORKFLOWS.ToString(), curSite.Url), x, DiagnosticsCategories.eCaseWeb);
                    }

                    // Associate workflows from our property bag
                    if (curSite.RootWeb.Properties.ContainsKey(eCaseConstants.PropertyBagKeys.ECASE_WORKFLOWS_TO_ASSOCIATE))
                    {
                        var workFlows = curSite.RootWeb.Properties[eCaseConstants.PropertyBagKeys.ECASE_WORKFLOWS_TO_ASSOCIATE].Split('|');
                        //ActivateWorkflowFeatures(workFlows, curSite);
                        AssociateWithWorkFlows(workFlows, curSite, curWeb);
                    }

                    #region Create RelatedLegalIssues Lookup Site Column
                    SPFieldLookup relatedLegalIssuesLookup = null;
                    if (curWeb.Fields.ContainsFieldWithStaticName("RelLglIssues"))
                    {
                        relatedLegalIssuesLookup = curWeb.Fields.GetFieldByInternalName("RelLglIssues") as SPFieldLookup;
                    }
                    else
                    {
                        SPList legalIssuesList = curWeb.GetListByInternalName(eCaseConstants.ListInternalNames.LEGAL_ISSUES);
                        curWeb.Fields.AddLookup("RelLglIssues", legalIssuesList.ID, curWeb.ID, false);
                        relatedLegalIssuesLookup                     = curWeb.Fields["RelLglIssues"] as SPFieldLookup;
                        relatedLegalIssuesLookup.LookupField         = legalIssuesList.Fields[eCaseConstants.FieldGuids.OOTB_TITLE].InternalName;
                        relatedLegalIssuesLookup.AllowMultipleValues = true;
                        relatedLegalIssuesLookup.Group               = "eCases Site Columns";
                        relatedLegalIssuesLookup.Title               = "Legal Issues";
                        relatedLegalIssuesLookup.Update();
                    }
                    #endregion

                    int autoRefreshInterval = 60;
                    #region Referral Documents
                    SPList        caseDocsList    = curWeb.GetListByInternalName(eCaseConstants.ListInternalNames.REFERRAL_DOCUMENTS);
                    SPContentType caseDocCt       = curSite.RootWeb.ContentTypes[eCaseConstants.ContentTypeIds.CASE_DOCUMENT];
                    SPContentType caseDocCtChild  = caseDocsList.ContentTypes["Case Document"];
                    bool          caseDocsCtIsNew = (caseDocCtChild == null);
                    if (caseDocsCtIsNew)
                    {
                        caseDocCtChild = new SPContentType(caseDocCt, curWeb.ContentTypes, "Case Document");
                    }
                    SPFieldLink relatedLegalIssuesFLink = new SPFieldLink(relatedLegalIssuesLookup);
                    if (caseDocCtChild.FieldLinks[relatedLegalIssuesFLink.Name] == null)
                    {
                        caseDocCtChild.FieldLinks.Add(relatedLegalIssuesFLink);
                    }
                    if (caseDocsCtIsNew)
                    {
                        caseDocsList.ContentTypes.Add(caseDocCtChild);
                        caseDocsList.Update();
                    }

                    // Enable AJAX
                    using (SPLimitedWebPartManager mgr = curWeb.GetLimitedWebPartManager(caseDocsList.DefaultViewUrl, PersonalizationScope.Shared))
                    {
                        XsltListViewWebPart xsltListViewWp = mgr.WebParts[0] as XsltListViewWebPart;
                        xsltListViewWp.AutoRefresh         = true;
                        xsltListViewWp.AutoRefreshInterval = autoRefreshInterval;
                        mgr.SaveChanges(xsltListViewWp);
                    }
                    #endregion

                    #region Investigation Documents
                    SPList        relatedDocsList = curWeb.GetListByInternalName(eCaseConstants.ListInternalNames.INVESTIGATION_DOCUMENTS);
                    SPContentType relDocCt        = curSite.RootWeb.ContentTypes[eCaseConstants.ContentTypeIds.INVESTIGATION_DOCUMENT];
                    SPContentType relDocCtChild   = relatedDocsList.ContentTypes["Related Document"];
                    bool          relDocCtIsNew   = (relDocCtChild == null);
                    if (relDocCtIsNew)
                    {
                        relDocCtChild = new SPContentType(relDocCt, curWeb.ContentTypes, "Related Document");
                    }
                    if (relDocCtChild.FieldLinks[relatedLegalIssuesFLink.Name] == null)
                    {
                        relDocCtChild.FieldLinks.Add(relatedLegalIssuesFLink);
                    }
                    if (relDocCtIsNew)
                    {
                        relatedDocsList.ContentTypes.Add(relDocCtChild);
                        relatedDocsList.Update();
                    }

                    // Enable AJAX
                    using (SPLimitedWebPartManager mgr = curWeb.GetLimitedWebPartManager(relatedDocsList.DefaultViewUrl, PersonalizationScope.Shared))
                    {
                        XsltListViewWebPart xsltListViewWp = mgr.WebParts[0] as XsltListViewWebPart;
                        xsltListViewWp.AutoRefresh         = true;
                        xsltListViewWp.AutoRefreshInterval = autoRefreshInterval;
                        mgr.SaveChanges(xsltListViewWp);
                    }
                    #endregion

                    #region SDO Documents
                    SPList        finWorkProdDocsList = curWeb.GetListByInternalName(eCaseConstants.ListInternalNames.SDO_DOCUMENTS);
                    SPContentType finWorkProdCt       = curSite.RootWeb.ContentTypes[eCaseConstants.ContentTypeIds.SDO_DOCUMENT];
                    SPContentType finWorkProdCtChild  = finWorkProdDocsList.ContentTypes["Finished Work Product"];
                    bool          finWorkProdCtIsNew  = (finWorkProdCtChild == null);
                    if (finWorkProdCtIsNew)
                    {
                        finWorkProdCtChild = new SPContentType(finWorkProdCt, curWeb.ContentTypes, "Finished Work Product");
                    }
                    if (finWorkProdCtChild.FieldLinks[relatedLegalIssuesFLink.Name] == null)
                    {
                        finWorkProdCtChild.FieldLinks.Add(relatedLegalIssuesFLink);
                    }
                    if (finWorkProdCtIsNew)
                    {
                        finWorkProdDocsList.ContentTypes.Add(finWorkProdCtChild);
                        finWorkProdDocsList.Update();
                    }

                    // Enable AJAX
                    using (SPLimitedWebPartManager mgr = curWeb.GetLimitedWebPartManager(finWorkProdDocsList.DefaultViewUrl, PersonalizationScope.Shared))
                    {
                        XsltListViewWebPart xsltListViewWp = mgr.WebParts[0] as XsltListViewWebPart;
                        xsltListViewWp.AutoRefresh         = true;
                        xsltListViewWp.AutoRefreshInterval = autoRefreshInterval;
                        mgr.SaveChanges(xsltListViewWp);
                    }
                    #endregion

                    #region Share With External User
                    SPList        shareExternalUserDocsList = curWeb.GetListByInternalName(eCaseConstants.ListInternalNames.SHARE_WITH_EXTERNAL_USERS);
                    SPContentType shareExternalUserCt       = curSite.RootWeb.ContentTypes[eCaseConstants.ContentTypeIds.SHARE_WITH_EXTERNAL_USER];
                    SPContentType shareExternalUserCtChild  = shareExternalUserDocsList.ContentTypes["ShareWithExternalUser"];
                    bool          shareExternalUserCtIsNew  = (shareExternalUserCtChild == null);
                    if (shareExternalUserCtIsNew)
                    {
                        shareExternalUserCtChild = new SPContentType(shareExternalUserCt, curWeb.ContentTypes, "ShareWithExternalUser");
                    }
                    if (shareExternalUserCtChild.FieldLinks[relatedLegalIssuesFLink.Name] == null)
                    {
                        shareExternalUserCtChild.FieldLinks.Add(relatedLegalIssuesFLink);
                    }
                    if (shareExternalUserCtIsNew)
                    {
                        shareExternalUserDocsList.ContentTypes.Add(shareExternalUserCtChild);
                        shareExternalUserDocsList.Update();
                    }

                    // Enable AJAX
                    using (SPLimitedWebPartManager mgr = curWeb.GetLimitedWebPartManager(shareExternalUserDocsList.DefaultViewUrl, PersonalizationScope.Shared))
                    {
                        XsltListViewWebPart xsltListViewWp = mgr.WebParts[0] as XsltListViewWebPart;
                        xsltListViewWp.AutoRefresh         = true;
                        xsltListViewWp.AutoRefreshInterval = autoRefreshInterval;
                        mgr.SaveChanges(xsltListViewWp);
                    }
                    #endregion

                    #region Related Dates -- NEVER GOT DONE PROPERLY, BUT DOES FUNCTION FOR THESE LISTS
                    //SPContentType relDatesCt = curSite.RootWeb.ContentTypes[eCaseConstants.ContentTypeIds.RELATED_DATES];
                    //SPContentType relDatesCtChild = new SPContentType(relDatesCt, curWeb.ContentTypes, "Related Date");
                    //relDatesCtChild.FieldLinks.Add(relatedLegalIssuesFLink);

                    //SPList caseRelatedDatesList = curWeb.GetListByInternalName(eCaseConstants.ListInternalNames.CASE_RELATED_DATES);
                    //SPContentTypeId ootbEvent = new SPContentTypeId("0x0102");
                    //caseRelatedDatesList.ContentTypes.Add(relDatesCtChild);
                    ////caseRelatedDatesList.ContentTypes.Delete(ootbEvent);
                    //caseRelatedDatesList.Update();

                    //SPList matterRelatedDatesList = curWeb.GetListByInternalName(eCaseConstants.ListInternalNames.MATTER_RELATED_DATES);
                    //matterRelatedDatesList.ContentTypes.Add(relDatesCtChild);
                    ////matterRelatedDatesList.ContentTypes.Delete(ootbEvent);
                    //matterRelatedDatesList.Update();
                    #endregion

                    // Use Custom Logo for Site
                    curWeb.SiteLogoUrl = curSite.RootWeb.Url + "/Style%20Library/images/ecase-logo.png";

                    // Push all new content types to the SPWeb collection
                    curWeb.Update();
                }
                catch (Exception x)
                {
                    Logger.Instance.Error("CaseWebComponents FeatureActivation Failure", x, DiagnosticsCategories.eCaseWeb);
                    throw x;
                }
            }
            else // Something is very wrong -- lets throw
            {
                string obj;
                if (curSite == null)
                {
                    obj = "SPSite";
                }
                else
                {
                    obj = "SPWeb";
                }

                string exceptionMsg = string.Format("Feature activation did not complete successfully.  Unable to find {0} object", obj);
                throw new Exception(exceptionMsg);
            }
        }