This class contains client members
        /// <summary>
        /// Creates Matter Landing Page on matter creation
        /// </summary>
        /// <param name="clientContext">Client Context</param>
        /// <param name="client">Client object containing Client data</param>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <returns>true if success else false</returns>
        internal static string CreateMatterLandingPage(ClientContext clientContext, Client client, Matter matter)
        {
            string response = string.Empty;

            if (null != clientContext && null != client && null != matter)
            {
                try
                {
                    using (clientContext)
                    {
                        Uri uri = new Uri(client.ClientUrl);
                        Web web = clientContext.Web;
                        FileCreationInformation objFileInfo = new FileCreationInformation();
                        List sitePageLib = null;
                        //// Create Matter Landing Web Part Page
                        objFileInfo.Url = string.Format(CultureInfo.InvariantCulture, "{0}{1}", matter.MatterGuid, Constants.AspxExtension);
                        response = CreateWebPartPage(sitePageLib, clientContext, objFileInfo, matter, web);
                        if (Constants.TRUE == response)
                        {
                            //// Configure All Web Parts
                            string[] webParts = ConfigureXMLCodeOfWebParts(client, matter, clientContext, sitePageLib, objFileInfo, uri, web);
                            Microsoft.SharePoint.Client.File file = web.GetFileByServerRelativeUrl(string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}", uri.AbsolutePath, Constants.Backslash, ConfigurationManager.AppSettings["MatterLandingPageRepository"].Replace(Constants.SPACE, string.Empty), Constants.Backslash, objFileInfo.Url));
                            clientContext.Load(file);
                            clientContext.ExecuteQuery();

                            LimitedWebPartManager limitedWebPartManager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
                            WebPartDefinition webPartDefinition = null;

                            string[] zones = { Constants.HeaderZone, Constants.TopZone, Constants.RightZone, Constants.TopZone, Constants.RightZone, Constants.RightZone, Constants.FooterZone, Constants.RightZone, Constants.RightZone };
                            AddWebPart(clientContext, limitedWebPartManager, webPartDefinition, webParts, zones);
                        }
                        else
                        {
                            response = Constants.FALSE;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ////Generic Exception                    
                    MatterProvisionHelperFunction.DisplayAndLogError(errorFilePath, string.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["ErrorMessage"], "creating Matter Landing page"));
                    MatterProvisionHelperFunction.DisplayAndLogError(errorFilePath, "Message: " + ex.Message + "\nStacktrace: " + ex.StackTrace);
                    throw;
                }

                return response;
            }
            else
            {
                return string.Format(CultureInfo.InvariantCulture, Constants.ServiceResponse, string.Empty, Constants.MessageNoInputs);
            }
        }
        /// <summary>
        /// Inserts details into LegalDMSMatters list
        /// </summary>
        /// <param name="configVal">Dictionary object</param>
        /// <param name="title">Title of matter</param>
        /// <param name="matter">Matter object</param>
        /// <param name="client">client object</param>
        /// <returns>Boolen value</returns>
        internal static string InsertIntoMatterCenterMatters(Dictionary<string, string> configVal, string title, Matter matter, Client client)
        {
            try
            {
                using (ClientContext clientContext = MatterProvisionHelperUtility.GetClientContext(configVal["CatalogSiteURL"], configVal))
                {
                    bool isConflict = Convert.ToBoolean(matter.Conflict.ConflictIdentified, CultureInfo.InvariantCulture);
                    List<FieldUserValue> conflictByUsers = MatterProvisionHelperUtility.ResolveUserNames(configVal, matter.Conflict.ConflictCheckBy).ToList<FieldUserValue>(),
                        blockedUsers = !string.IsNullOrEmpty(matter.TeamInfo.BlockedUsers.Trim()) ? MatterProvisionHelperUtility.ResolveUserNames(configVal, matter.TeamInfo.BlockedUsers).ToList<FieldUserValue>() : null,
                        managingUsers = MatterProvisionHelperUtility.ResolveUserNames(configVal, matter.TeamInfo.ResponsibleAttorneys).ToList<FieldUserValue>(),
                        supportUsers = !string.IsNullOrEmpty(matter.TeamInfo.Attorneys.Trim()) ? MatterProvisionHelperUtility.ResolveUserNames(configVal, matter.TeamInfo.Attorneys).ToList<FieldUserValue>() : null;

                    List list = clientContext.Web.Lists.GetByTitle(ConfigurationManager.AppSettings["MatterCenterList"]);
                    ListItemCreationInformation listCreationInformation = new ListItemCreationInformation();
                    ListItem listItem = list.AddItem(listCreationInformation);
                    listItem["Title"] = title; // "MyTitle";
                    listItem["ClientName"] = client.ClientName;
                    listItem["ClientID"] = client.ClientId; // "MyID";
                    listItem["MatterName"] = matter.MatterName;
                    listItem["MatterID"] = matter.MatterId;

                    listItem["ConflictCheckBy"] = conflictByUsers;
                    listItem["ConflictCheckOn"] = matter.Conflict.ConflictCheckOn;
                    listItem["ConflictIdentified"] = isConflict;

                    if (isConflict)
                    {
                        listItem["BlockUsers"] = blockedUsers;
                    }
                    listItem["ManagingAttorney"] = managingUsers;
                    listItem["Support"] = supportUsers;

                    listItem.Update();
                    clientContext.ExecuteQuery();
                }
                return "true";
            }
            catch (Exception exception)
            {
                Utility.DisplayAndLogError(Utility.ErrorFilePath, string.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["ErrorMessage"], "while updating Metadata"));
                Utility.DisplayAndLogError(Utility.ErrorFilePath, "Message: " + exception.Message + "Matter name: " + matter.MatterName + "\nStacktrace: " + exception.StackTrace);
                throw;
            }
        }
        /// <summary>
        /// Function is used to Configure XML of web parts
        /// </summary>
        /// <param name="client">Client object containing Client data</param>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <param name="clientContext">SharePoint Client Context</param>
        /// <param name="sitePageLib">SharePoint List of matter library</param>
        /// <param name="objFileInfo">Object of FileCreationInformation</param>
        /// <param name="uri">To get URL segments</param>
        /// <param name="web">Web object of the current context</param>
        /// <returns>List of Web Parts</returns>                              
        internal static string[] ConfigureXMLCodeOfWebParts(Client client, Matter matter, ClientContext clientContext, List sitePageLib, FileCreationInformation objFileInfo, Uri uri, Web web)
        {
            string[] result = null;
            try
            {
                sitePageLib = web.Lists.GetByTitle(matter.MatterName);
                clientContext.Load(sitePageLib);
                clientContext.ExecuteQuery();

                ////Configure list View Web Part XML
                string listViewWebPart = ConfigureListViewWebPart(sitePageLib, clientContext, objFileInfo, client, matter, string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}", uri.AbsolutePath, Constants.Backslash, matter.MatterName, Constants.Backslash, objFileInfo.Url));
                string[] contentEditorSectionIds = ConfigurationManager.AppSettings["MatterLandingPageSections"].Split(',');
                ////Configure content Editor Web Part of user information XML
                string contentEditorWebPartTasks = string.Empty;
                if (Convert.ToBoolean(ConfigurationManager.AppSettings["TaskListCreationEnabled"], CultureInfo.InvariantCulture))
                {
                    contentEditorWebPartTasks = string.Format(CultureInfo.InvariantCulture, Constants.ContentEditorWebPart, string.Format(CultureInfo.InvariantCulture, Constants.MatterLandingSectionContent, contentEditorSectionIds[Convert.ToInt32(Constants.MatterLandingSection.TaskPanel, CultureInfo.InvariantCulture)]));
                }

                string calendarWebpart = string.Empty, rssFeedWebPart = string.Empty, rssTitleWebPart = string.Empty;
                if (Convert.ToBoolean(ConfigurationManager.AppSettings["TaskListCreationEnabled"], CultureInfo.InvariantCulture))
                {
                    rssFeedWebPart = string.Format(CultureInfo.InvariantCulture, Constants.RssFeedWebpart, HttpUtility.UrlEncode(matter.MatterName));
                    rssTitleWebPart = string.Format(CultureInfo.InvariantCulture, Constants.ContentEditorWebPart, string.Format(CultureInfo.InvariantCulture, Constants.MatterLandingSectionContent, contentEditorSectionIds[Convert.ToInt32(Constants.MatterLandingSection.RSSTitlePanel, CultureInfo.InvariantCulture)]));
                }

                ////Configure calendar Web Part XML
                if (Convert.ToBoolean(ConfigurationManager.AppSettings["TaskListCreationEnabled"], CultureInfo.InvariantCulture))
                {
                    ////If create calendar is enabled configure calendar Web Part XML; else don't configure
                    calendarWebpart = string.Format(CultureInfo.InvariantCulture, Constants.ContentEditorWebPart, string.Format(CultureInfo.InvariantCulture, Constants.MatterLandingSectionContent, contentEditorSectionIds[Convert.ToInt32(Constants.MatterLandingSection.CalendarPanel, CultureInfo.InvariantCulture)]));
                }

                string matterInformationSection = string.Format(CultureInfo.InvariantCulture, Constants.ContentEditorWebPart, string.Format(CultureInfo.InvariantCulture, Constants.MatterLandingSectionContent, contentEditorSectionIds[Convert.ToInt32(Constants.MatterLandingSection.InformationPanel, CultureInfo.InvariantCulture)]));
                string cssLink = string.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["MatterLandingCSSFileName"], ConfigurationManager.AppSettings["MatterLandingFolderName"]);
                string cssLinkCommon = string.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["CommonCSSFileName"], ConfigurationManager.AppSettings["CommonFolderName"]);
                string jsLinkMatterLandingPage = string.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["MatterLandingJSFileName"], ConfigurationManager.AppSettings["MatterLandingFolderName"]);
                string jsLinkJQuery = string.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["JQueryFileName"], ConfigurationManager.AppSettings["CommonFolderName"]);
                string jsCommonLink = string.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["CommonJSFileName"], ConfigurationManager.AppSettings["CommonFolderName"]);
                string headerWebPartSection = string.Format(CultureInfo.InvariantCulture, Constants.MatterLandingSectionContent, contentEditorSectionIds[Convert.ToInt32(Constants.MatterLandingSection.HeaderPanel, CultureInfo.InvariantCulture)]);
                string footerWebPartSection = string.Format(CultureInfo.InvariantCulture, Constants.MatterLandingSectionContent, contentEditorSectionIds[Convert.ToInt32(Constants.MatterLandingSection.FooterPanel, CultureInfo.InvariantCulture)]);
                headerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, Constants.StyleTag, cssLink), headerWebPartSection);
                headerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, Constants.StyleTag, cssLinkCommon), headerWebPartSection);
                headerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, Constants.ScriptTagWithContents, string.Format(CultureInfo.InvariantCulture, Constants.MatterLandingStampProperties, matter.MatterName, matter.MatterGuid)), headerWebPartSection);
                footerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, Constants.ScriptTag, jsLinkMatterLandingPage), footerWebPartSection);
                footerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, Constants.ScriptTag, jsCommonLink), footerWebPartSection);
                footerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, Constants.ScriptTag, jsLinkJQuery), footerWebPartSection);
                string headerWebPart = string.Format(CultureInfo.InvariantCulture, Constants.ContentEditorWebPart, headerWebPartSection);
                string footerWebPart = string.Format(CultureInfo.InvariantCulture, Constants.ContentEditorWebPart, footerWebPartSection);
                string oneNoteWebPart = string.Format(CultureInfo.InvariantCulture, Constants.ContentEditorWebPart, string.Format(CultureInfo.InvariantCulture, Constants.MatterLandingSectionContent, contentEditorSectionIds[Convert.ToInt32(Constants.MatterLandingSection.OneNotePanel, CultureInfo.InvariantCulture)]));
                string[] webParts = { headerWebPart, matterInformationSection, oneNoteWebPart, listViewWebPart, rssFeedWebPart, rssTitleWebPart, footerWebPart, calendarWebpart, contentEditorWebPartTasks };
                result = webParts;
            }
            catch (Exception exception)
            {
                MatterProvisionHelper.DeleteMatter(clientContext, matter);
                Utility.DisplayAndLogError(Utility.ErrorFilePath, "Message: " + exception.Message + "\nStacktrace: " + exception.StackTrace);
            }
            return result;
        }
        /// <summary>
        /// Configure XML Code of List View Web Part
        /// </summary>
        /// <param name="sitePageLib">SharePoint List of matter library</param>
        /// <param name="clientContext">SharePoint Client Context</param>
        /// <param name="objFileInfo">Object of FileCreationInformation</param>
        /// <param name="client">Client object containing Client data</param>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <param name="titleUrl">Segment of URL</param>
        /// <returns>Configured ListView Web Part</returns>
        internal static string ConfigureListViewWebPart(List sitePageLib, ClientContext clientContext, FileCreationInformation objFileInfo, Client client, Matter matter, string titleUrl)
        {
            string listViewWebPart = Constants.ListviewWebpart;

            Uri uri = new Uri(client.ClientUrl);
            ViewCollection viewColl = sitePageLib.Views;
            clientContext.Load(
                viewColl,
                views => views.Include(
                    view => view.Title,
                    view => view.Id));
            clientContext.ExecuteQuery();
            string viewName = string.Empty;

            foreach (View view in viewColl)
            {
                viewName = view.Id.ToString();
                break;
            }

            viewName = string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", Constants.OpeningCurlyBrace, viewName, Constants.ClosingCurlyBrace);

            listViewWebPart = string.Format(CultureInfo.InvariantCulture, listViewWebPart, sitePageLib.Id.ToString(), titleUrl, string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", Constants.OpeningCurlyBrace, sitePageLib.Id.ToString(), Constants.ClosingCurlyBrace), viewName, string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}", uri.AbsolutePath, Constants.Backslash, matter.MatterName, Constants.Backslash, objFileInfo.Url));

            return listViewWebPart;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates metadata for list
        /// </summary>
        /// <param name="clientContext">CLient context</param>
        /// <param name="matter">Matter object</param>
        /// <param name="client">Client object</param>
        /// <returns>String value</returns>
        internal static string UpdateMetadataForList(ClientContext clientContext, Matter matter, Client client)
        {
            string properties = string.Empty;
            try
            {
                var props = clientContext.Web.Lists.GetByTitle(matter.MatterName).RootFolder.Properties;
                List<string> keys = new List<string>();
                keys.Add("PracticeGroup");
                keys.Add("AreaOfLaw");
                keys.Add("SubAreaOfLaw");
                keys.Add("MatterName");
                keys.Add("MatterID");
                keys.Add("ClientName");
                keys.Add("ClientID");
                keys.Add("ResponsibleAttorney");
                keys.Add("TeamMembers");
                keys.Add("IsMatter");
                keys.Add("OpenDate");
                keys.Add("SecureMatter");
                keys.Add("BlockedUploadUsers");
                keys.Add("Success");
                keys.Add("IsConflictIdentified");
                keys.Add("MatterConflictCheckBy");
                keys.Add("MatterConflictCheckDate");
                keys.Add("MatterCenterPermissions");
                keys.Add("MatterCenterRoles");
                keys.Add("MatterCenterUsers");
                keys.Add("DocumentTemplateCount");
                keys.Add("MatterCenterDefaultContentType");
                keys.Add("MatterDescription");
                keys.Add("BlockedUsers");
                keys.Add("MatterGUID");

                Dictionary<string, string> propertyList = new Dictionary<string, string>();
                propertyList.Add("PracticeGroup", Microsoft.Security.Application.Encoder.HtmlEncode(matter.MatterType.PracticeGroup));
                propertyList.Add("AreaOfLaw", Microsoft.Security.Application.Encoder.HtmlEncode(matter.MatterType.AreaofLaw));
                propertyList.Add("SubAreaOfLaw", Microsoft.Security.Application.Encoder.HtmlEncode(matter.MatterType.SubAreaofLaw));
                propertyList.Add("MatterName", Microsoft.Security.Application.Encoder.HtmlEncode(matter.MatterName));
                propertyList.Add("MatterID", Microsoft.Security.Application.Encoder.HtmlEncode(matter.MatterId));
                propertyList.Add("ClientName", Microsoft.Security.Application.Encoder.HtmlEncode(client.ClientName));
                propertyList.Add("ClientID", Microsoft.Security.Application.Encoder.HtmlEncode(client.ClientId));
                propertyList.Add("ResponsibleAttorney", Microsoft.Security.Application.Encoder.HtmlEncode(matter.TeamInfo.ResponsibleAttorneys));
                propertyList.Add("TeamMembers", Microsoft.Security.Application.Encoder.HtmlEncode(matter.TeamInfo.Attorneys));
                propertyList.Add("IsMatter", Microsoft.Security.Application.Encoder.HtmlEncode("true"));
                propertyList.Add("OpenDate", Microsoft.Security.Application.Encoder.HtmlEncode(matter.OpenDate));
                propertyList.Add("SecureMatter", Microsoft.Security.Application.Encoder.HtmlEncode(matter.Conflict.SecureMatter));
                propertyList.Add("Success", Microsoft.Security.Application.Encoder.HtmlEncode("true"));
                propertyList.Add("BlockedUsers", Microsoft.Security.Application.Encoder.HtmlEncode(matter.TeamInfo.BlockedUsers));
                propertyList.Add("IsConflictIdentified", Microsoft.Security.Application.Encoder.HtmlEncode("true"));
                propertyList.Add("MatterConflictCheckBy", Microsoft.Security.Application.Encoder.HtmlEncode(matter.Conflict.ConflictCheckBy.TrimEnd(';')));
                propertyList.Add("MatterConflictCheckDate", Microsoft.Security.Application.Encoder.HtmlEncode(matter.Conflict.ConflictCheckOn));
                propertyList.Add("MatterCenterRoles", Microsoft.Security.Application.Encoder.HtmlEncode(ConfigurationManager.AppSettings["Roles"]));
                propertyList.Add("MatterCenterUsers", Microsoft.Security.Application.Encoder.HtmlEncode(matter.TeamInfo.ResponsibleAttorneys + Constants.SEPARATOR + matter.TeamInfo.Attorneys + Constants.SEPARATOR + matter.TeamInfo.BlockedUploadUsers).TrimEnd(';'));
                propertyList.Add("MatterCenterPermissions", Microsoft.Security.Application.Encoder.HtmlEncode(ConfigurationManager.AppSettings["FullControl"] + Constants.SEPARATOR + ConfigurationManager.AppSettings["Contribute"] + Constants.SEPARATOR + ConfigurationManager.AppSettings["Read"]));
                propertyList.Add("DocumentTemplateCount", Microsoft.Security.Application.Encoder.HtmlEncode(matter.DocumentCount));
                propertyList.Add("MatterCenterDefaultContentType", Microsoft.Security.Application.Encoder.HtmlEncode(matter.DefaultContentType));
                propertyList.Add("MatterDescription", Microsoft.Security.Application.Encoder.HtmlEncode(matter.MatterDescription));
                propertyList.Add("BlockedUploadUsers", Microsoft.Security.Application.Encoder.HtmlEncode(matter.TeamInfo.BlockedUploadUsers.TrimEnd(';')));
                propertyList.Add("MatterGUID", Microsoft.Security.Application.Encoder.HtmlEncode(matter.MatterGuid));
                propertyList.Add("vti_indexedpropertykeys", Microsoft.Security.Application.Encoder.HtmlEncode(MatterProvisionHelperUtility.GetEncodedValueForSearchIndexProperty(keys)));

                clientContext.Load(props);
                clientContext.ExecuteQuery();

                SetPropertyValueForList(clientContext, props, matter.MatterName, propertyList);
                properties = ListOperations.GetPropertyValueForList(clientContext, matter.MatterName, propertyList);
            }
            catch (Exception exception)
            {
                Utility.DisplayAndLogError(Utility.ErrorFilePath, string.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["ErrorMessage"], "while updating Metadata"));
                Utility.DisplayAndLogError(Utility.ErrorFilePath, "Message: " + exception.Message + "Matter name: " + matter.MatterName + "\nStacktrace: " + exception.StackTrace);
                throw;
            }
            return properties;
        }