Represents configuration for the matter. Holds value for various entities on the Matter Provision page
예제 #1
0
 /// <summary>
 /// Checks if the lists exist
 /// </summary>
 /// <param name="client"></param>
 /// <param name="matterName"></param>
 /// <param name="matterConfigurations"></param>
 /// <returns></returns>
 private bool CheckListExists(Client client, string matterName, MatterConfigurations matterConfigurations = null)
 {
     List<string> lists = new List<string>();
     lists.Add(matterName);
     lists.Add(matterName + matterSettings.OneNoteLibrarySuffix);
     if (null == matterConfigurations || matterConfigurations.IsCalendarSelected)
     {
         lists.Add(matterName + matterSettings.CalendarNameSuffix);
     }
     if (null == matterConfigurations || matterConfigurations.IsTaskSelected)
     {
         lists.Add(matterName + matterSettings.TaskNameSuffix);
     }
     bool listExists = spList.Exists(client, new ReadOnlyCollection<string>(lists));
     return listExists;
 }
예제 #2
0
        /// <summary>
        /// Configures XML of web parts.
        /// </summary>
        /// <param name="requestObject">Request Object</param>
        /// <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>
        public string[] ConfigureXMLCodeOfWebParts(Client client, Matter matter, ClientContext clientContext, string pageName, Uri uri, 
            Web web, MatterConfigurations matterConfigurations)
        {
            string[] result = null;
            try
            {
                List sitePageLib = web.Lists.GetByTitle(matter.Name);
                clientContext.Load(sitePageLib);
                clientContext.ExecuteQuery();

                ////Configure list View Web Part XML
                string listViewWebPart = ConfigureListViewWebPart(sitePageLib, clientContext, pageName, client, matter, 
                    string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}", uri.AbsolutePath, ServiceConstants.FORWARD_SLASH, matter.Name, 
                    ServiceConstants.FORWARD_SLASH, pageName));
                string[] contentEditorSectionIds = matterSettings.MatterLandingPageSections.Split(Convert.ToChar(ServiceConstants.COMMA, CultureInfo.InvariantCulture));

                ////Configure content Editor Web Part of user information XML
                string contentEditorWebPartTasks = string.Empty;
                if (matterConfigurations.IsTaskSelected)
                {
                    contentEditorWebPartTasks = string.Format(CultureInfo.InvariantCulture, ServiceConstants.CONTENT_EDITOR_WEB_PART, 
                        string.Format(CultureInfo.InvariantCulture, ServiceConstants.MATTER_LANDING_SECTION_CONTENT, 
                        contentEditorSectionIds[Convert.ToInt32(MatterLandingSection.TaskPanel, CultureInfo.InvariantCulture)]));
                }

                string calendarWebpart = string.Empty, rssFeedWebPart = string.Empty, rssTitleWebPart = string.Empty;
                if (matterConfigurations.IsRSSSelected)
                {
                    rssFeedWebPart = string.Format(CultureInfo.InvariantCulture, ServiceConstants.RSS_FEED_WEB_PART, WebUtility.UrlEncode(matter.Name));
                    rssTitleWebPart = string.Format(CultureInfo.InvariantCulture, ServiceConstants.CONTENT_EDITOR_WEB_PART, 
                        string.Format(CultureInfo.InvariantCulture, ServiceConstants.MATTER_LANDING_SECTION_CONTENT, 
                        contentEditorSectionIds[Convert.ToInt32(MatterLandingSection.RSSTitlePanel, CultureInfo.InvariantCulture)]));
                }

                ////Configure calendar Web Part XML
                if (matterConfigurations.IsCalendarSelected)
                {
                    ////If create calendar is enabled configure calendar Web Part XML; else dont configure
                    calendarWebpart = string.Format(CultureInfo.InvariantCulture, ServiceConstants.CONTENT_EDITOR_WEB_PART, string.Format(CultureInfo.InvariantCulture, ServiceConstants.MATTER_LANDING_SECTION_CONTENT, contentEditorSectionIds[Convert.ToInt32(MatterLandingSection.CalendarPanel, CultureInfo.InvariantCulture)]));
                }

                string matterInformationSection = string.Format(CultureInfo.InvariantCulture, ServiceConstants.CONTENT_EDITOR_WEB_PART, string.Format(CultureInfo.InvariantCulture, ServiceConstants.MATTER_LANDING_SECTION_CONTENT, contentEditorSectionIds[Convert.ToInt32(MatterLandingSection.InformationPanel, CultureInfo.InvariantCulture)]));
                string cssLink = string.Format(CultureInfo.InvariantCulture, matterSettings.MatterLandingCSSFileName, matterSettings.MatterLandingFolderName);
                string commonCssLink = string.Format(CultureInfo.InvariantCulture, matterSettings.CommonCSSFileLink, matterSettings.CommonFolderName);
                string jsLinkMatterLandingPage = string.Format(CultureInfo.InvariantCulture, matterSettings.MatterLandingJSFileName, matterSettings.MatterLandingFolderName);
                string jsLinkJQuery = string.Format(CultureInfo.InvariantCulture, matterSettings.JQueryFileName, matterSettings.CommonFolderName);
                string jsLinkCommon = string.Format(CultureInfo.InvariantCulture, matterSettings.CommonJSFileLink, matterSettings.CommonFolderName);
                string headerWebPartSection = string.Format(CultureInfo.InvariantCulture, ServiceConstants.MATTER_LANDING_SECTION_CONTENT, contentEditorSectionIds[Convert.ToInt32(MatterLandingSection.HeaderPanel, CultureInfo.InvariantCulture)]);
                string footerWebPartSection = string.Format(CultureInfo.InvariantCulture, ServiceConstants.MATTER_LANDING_SECTION_CONTENT, contentEditorSectionIds[Convert.ToInt32(MatterLandingSection.FooterPanel, CultureInfo.InvariantCulture)]);
                headerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, ServiceConstants.STYLE_TAG, cssLink), headerWebPartSection);
                headerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, ServiceConstants.STYLE_TAG, commonCssLink), headerWebPartSection);
                headerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, ServiceConstants.SCRIPT_TAG_WITH_CONTENTS, string.Format(CultureInfo.InvariantCulture, ServiceConstants.MATTER_LANDING_STAMP_PROPERTIES, matter.Name, matter.MatterGuid)), headerWebPartSection);
                footerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, ServiceConstants.SCRIPT_TAG, jsLinkMatterLandingPage), footerWebPartSection);
                footerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, ServiceConstants.SCRIPT_TAG, jsLinkCommon), footerWebPartSection);
                footerWebPartSection = string.Concat(string.Format(CultureInfo.InvariantCulture, ServiceConstants.SCRIPT_TAG, jsLinkJQuery), footerWebPartSection);
                string headerWebPart = string.Format(CultureInfo.InvariantCulture, ServiceConstants.CONTENT_EDITOR_WEB_PART, headerWebPartSection);
                string footerWebPart = string.Format(CultureInfo.InvariantCulture, ServiceConstants.CONTENT_EDITOR_WEB_PART, footerWebPartSection);
                string oneNoteWebPart = string.Format(CultureInfo.InvariantCulture, ServiceConstants.CONTENT_EDITOR_WEB_PART, string.Format(CultureInfo.InvariantCulture, ServiceConstants.MATTER_LANDING_SECTION_CONTENT, contentEditorSectionIds[Convert.ToInt32(MatterLandingSection.OneNotePanel, CultureInfo.InvariantCulture)]));
                string[] webParts = { headerWebPart, matterInformationSection, oneNoteWebPart, listViewWebPart, rssFeedWebPart, rssTitleWebPart, footerWebPart, calendarWebpart, contentEditorWebPartTasks };
                result = webParts;
            }
            catch (Exception exception)
            {
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
            return result;
        }
예제 #3
0
 public GenericResponseVM IsMatterValid(MatterInformationVM matterInformation, int methodNumber, MatterConfigurations matterConfigurations)
 {
     GenericResponseVM genericResponse = null;
     var matterDetails = matterInformation.MatterDetails;
     if (int.Parse(ServiceConstants.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) <= methodNumber && 
         int.Parse(ServiceConstants.EditMatterPermission, CultureInfo.InvariantCulture) >= methodNumber && 
         !spList.CheckPermissionOnList(matterSettings.ProvisionMatterAppURL, matterSettings.SendMailListName, PermissionKind.EditListItems))
     {
         genericResponse = new GenericResponseVM();
         //return string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, ServiceConstantStrings.IncorrectInputUserAccessCode, ServiceConstantStrings.IncorrectInputUserAccessMessage);
         genericResponse.Code = errorSettings.IncorrectInputUserAccessCode;
         genericResponse.Value = errorSettings.IncorrectInputUserAccessMessage;
     }
     else
     {
         
         if (matterInformation.Client!=null)
         {
             genericResponse = new GenericResponseVM();
             genericResponse = ValidateClientInformation(matterInformation.Client, methodNumber);
             if (genericResponse!=null)
             {
                 return genericResponse;
             }
         }
         if (matterInformation.Matter!=null)
         {
             genericResponse = MatterMetadataValidation(matterInformation.Matter, matterInformation.Client, 
                 methodNumber, matterConfigurations);
             if (genericResponse!=null)
             {
                 return genericResponse;
             }
             if (int.Parse(ServiceConstants.EditMatterPermission, CultureInfo.InvariantCulture) == methodNumber)
             {
                 genericResponse = RoleCheck(matterInformation.Matter);
                 if (genericResponse!=null)
                 {
                     return genericResponse;
                 }
             }
             if (matterInformation.Matter.Permissions!=null)
             {
                 bool isFullControlPresent = ValidateFullControlPermission(matterInformation.Matter);
                 if (!isFullControlPresent)
                 {                            
                     return GenericResponse(errorSettings.IncorrectInputUserAccessCode, errorSettings.ErrorEditMatterMandatoryPermission);
                 }
             }
         }
         if (null != matterDetails && !(int.Parse(ServiceConstants.EditMatterPermission, CultureInfo.InvariantCulture) == methodNumber))
         {
             if (string.IsNullOrWhiteSpace(matterDetails.PracticeGroup))
             {                        
                 return GenericResponse(errorSettings.IncorrectInputPracticeGroupCode, errorSettings.IncorrectInputPracticeGroupMessage);
             }
             if (string.IsNullOrWhiteSpace(matterDetails.AreaOfLaw))
             {
                 
                 return GenericResponse(errorSettings.IncorrectInputAreaOfLawCode, errorSettings.IncorrectInputAreaOfLawMessage);
             }
             if (string.IsNullOrWhiteSpace(matterDetails.SubareaOfLaw))
             {                        
                 return GenericResponse(errorSettings.IncorrectInputSubareaOfLawCode, errorSettings.IncorrectInputSubareaOfLawMessage);
             }
             try
             {
                 if (string.IsNullOrWhiteSpace(matterDetails.ResponsibleAttorney))
                 {                            
                     return GenericResponse(errorSettings.IncorrectInputResponsibleAttorneyCode, errorSettings.IncorrectInputResponsibleAttorneyMessage);
                 }
                 else
                 {
                     IList<string> userNames = matterDetails.ResponsibleAttorney.Split(';').ToList<string>();
                     matterRespository.ResolveUserNames(matterInformation.Client, userNames).FirstOrDefault();
                 }
             }
             catch (Exception)
             {                        
                 return GenericResponse(errorSettings.IncorrectInputResponsibleAttorneyCode, errorSettings.IncorrectInputResponsibleAttorneyMessage);
             }
         }
     }
     return genericResponse;
 }
예제 #4
0
        /// <summary>
        /// Validates meta-data of a matter and returns the validation status (success/failure).
        /// </summary>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <param name="clientContext">Client context object for SharePoint</param>  
        /// <param name="methodNumber">Number indicating which method needs to be validated</param>     
        /// <returns>A string value indicating whether validations passed or fail</returns>
        internal GenericResponseVM MatterMetadataValidation(Matter matter, Client client, 
            int methodNumber, MatterConfigurations matterConfigurations)
        {
            GenericResponseVM genericResponseVM = null;
            genericResponseVM = MatterNameValidation(matter);
            if (genericResponseVM!=null)
            {
                return genericResponseVM;
            }
            if (int.Parse(ServiceConstants.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) == methodNumber || 
                int.Parse(ServiceConstants.ProvisionMatterAssignContentType, CultureInfo.InvariantCulture) == methodNumber || 
                int.Parse(ServiceConstants.ProvisionMatterUpdateMetadataForList, CultureInfo.InvariantCulture) == methodNumber)
            {
                if (string.IsNullOrWhiteSpace(matter.Id))
                {   
                    return GenericResponse(errorSettings.IncorrectInputMatterIdCode, errorSettings.IncorrectInputMatterIdMessage);
                }
                else
                {
                    var matterId = Regex.Match(matter.Id, matterSettings.SpecialCharacterExpressionMatterId, RegexOptions.IgnoreCase);
                    if (int.Parse(matterSettings.MatterIdLength, CultureInfo.InvariantCulture) < matter.Id.Length || !matterId.Success)
                    {     
                        return GenericResponse(errorSettings.IncorrectInputMatterIdCode, errorSettings.IncorrectInputMatterIdMessage);
                    }
                }
            }
            if (int.Parse(ServiceConstants.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) == methodNumber || 
                int.Parse(ServiceConstants.ProvisionMatterShareMatter, CultureInfo.InvariantCulture) == methodNumber || 
                int.Parse(ServiceConstants.ProvisionMatterMatterLandingPage, CultureInfo.InvariantCulture) == methodNumber)
            {
                genericResponseVM = MatterDetailsValidation(matter, client, methodNumber, matterConfigurations);
                if (genericResponseVM!=null)
                {
                    return genericResponseVM;
                }
            }
            try
            {
                if (!(int.Parse(ServiceConstants.ProvisionMatterCheckMatterExists, CultureInfo.InvariantCulture) == methodNumber) && 
                    !(int.Parse(ServiceConstants.ProvisionMatterAssignContentType, CultureInfo.InvariantCulture) == methodNumber))
                {
                    if (0 >= matter.AssignUserNames.Count())
                    {                                                
                        return GenericResponse(errorSettings.IncorrectInputUserNamesCode, errorSettings.IncorrectInputUserNamesMessage);
                    }
                    else
                    {
                        IList<string> userList = matter.AssignUserNames.SelectMany(x => x).Distinct().ToList();
                        //ToDo: Need to know the use of this method
                        matterRespository.ResolveUserNames(client, userList).FirstOrDefault();
                    }
                }
            }
            catch (Exception)
            {                
                return GenericResponse(errorSettings.IncorrectInputUserNamesCode, errorSettings.IncorrectInputUserNamesMessage);
            }

            if (int.Parse(ServiceConstants.ProvisionMatterAssignUserPermissions, CultureInfo.InvariantCulture) == methodNumber || 
                int.Parse(ServiceConstants.ProvisionMatterMatterLandingPage, CultureInfo.InvariantCulture) == methodNumber || 
                int.Parse(ServiceConstants.EditMatterPermission, CultureInfo.InvariantCulture) == methodNumber)
            {
                GenericResponseVM genericResponse = CheckUserPermission(matter);
                if (genericResponse!=null)
                {
                    return genericResponse;
                }
            }
            if (int.Parse(ServiceConstants.ProvisionMatterAssignContentType, CultureInfo.InvariantCulture) == methodNumber || 
                int.Parse(ServiceConstants.ProvisionMatterShareMatter, CultureInfo.InvariantCulture) == methodNumber)
            {
                GenericResponseVM genericResponse = ValidateContentType(matter);
                if (genericResponse!=null)
                {
                    return genericResponse;
                }
            }
            return genericResponseVM;
        }
예제 #5
0
        /// <summary>
        /// Validates details of a matter and returns the validation status.
        /// </summary>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <param name="clientContext">Client context object for SharePoint</param>  
        /// <param name="methodNumber">Number indicating which method needs to be validated</param>        
        /// <returns>A string value indicating whether validations passed or fail</returns>
        internal GenericResponseVM MatterDetailsValidation(Matter matter, Client client, int methodNumber, 
            MatterConfigurations matterConfigurations)
        {
            GenericResponseVM genericResponseVM = null;
            if (matterConfigurations.IsMatterDescriptionMandatory)
            {
                if (string.IsNullOrWhiteSpace(matter.Description))
                {             
                    return GenericResponse(errorSettings.IncorrectInputMatterDescriptionCode, errorSettings.IncorrectInputMatterDescriptionMessage);
                }
                else
                {
                    var matterDescription = Regex.Match(matter.Description, matterSettings.SpecialCharacterExpressionMatterDescription, RegexOptions.IgnoreCase);
                    if (int.Parse(matterSettings.MatterDescriptionLength, CultureInfo.InvariantCulture) < matter.Description.Length || !matterDescription.Success)
                    {  
                        return GenericResponse(errorSettings.IncorrectInputMatterDescriptionCode, errorSettings.IncorrectInputMatterDescriptionMessage);
                    }
                }
            }
            if (matterConfigurations.IsConflictCheck)
            {
                DateTime conflictCheckedOnDate;
                bool isValidDate = DateTime.TryParse(matter.Conflict.CheckOn, out conflictCheckedOnDate);
                if (!isValidDate || 0 > DateTime.Compare(DateTime.Now, conflictCheckedOnDate))
                {
                    return GenericResponse(errorSettings.IncorrectInputConflictDateCode, errorSettings.IncorrectInputConflictDateMessage);
                }
                if (string.IsNullOrWhiteSpace(matter.Conflict.Identified))
                {
                    return GenericResponse(errorSettings.IncorrectInputConflictIdentifiedCode, errorSettings.IncorrectInputConflictIdentifiedMessage);
                }
                else
                {
                    try
                    {
                        if (0 > string.Compare(ServiceConstants.FALSE, matter.Conflict.Identified, StringComparison.OrdinalIgnoreCase))
                        {
                            if (0 >= matter.BlockUserNames.Count())
                            {
                                return GenericResponse(errorSettings.IncorrectInputBlockUserNamesCode, errorSettings.IncorrectInputBlockUserNamesMessage);
                            }
                            else
                            {
                                //ToDo: Need to understand the need of this method
                                matterRespository.ResolveUserNames(client, matter.BlockUserNames).FirstOrDefault();
                            }
                        }
                    }
                    catch (Exception)
                    {              
                        return GenericResponse(errorSettings.IncorrectInputBlockUserNamesCode, errorSettings.IncorrectInputBlockUserNamesMessage);
                    }

                }
                if (string.IsNullOrWhiteSpace(matter.Conflict.CheckBy))
                {                                       
                    return GenericResponse(errorSettings.IncorrectInputConflictCheckByCode, errorSettings.IncorrectInputConflictCheckByMessage);
                }
                else
                {
                    try
                    {
                        //ToDo: Need to understand the need of this method                   
                        matterRespository.ResolveUserNames(client, new List<string>() { matter.Conflict.CheckBy }).FirstOrDefault();
                    }
                    catch (Exception)
                    {             
                        return GenericResponse(errorSettings.IncorrectInputConflictCheckByCode, errorSettings.IncorrectInputConflictCheckByMessage);
                    }
                }
            }
            if (int.Parse(ServiceConstants.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) == methodNumber && 0 >= matter.Roles.Count())
            {        
                return GenericResponse(errorSettings.IncorrectInputUserRolesCode, errorSettings.IncorrectInputUserRolesMessage);
            }
            return genericResponseVM;
        }
예제 #6
0
 public List<string> MatterAssociatedLists(ClientContext clientContext, string matterName, MatterConfigurations matterConfigurations = null)
 {
     List<string> lists = new List<string>();
     lists.Add(matterName);
     lists.Add(matterName + "_OneNote");
     if (null == matterConfigurations || matterConfigurations.IsCalendarSelected)
     {
         lists.Add(matterName + "_Calendar");
     }
     if (null == matterConfigurations || matterConfigurations.IsTaskSelected)
     {
         lists.Add(matterName + "_Task");
     }
     List<string> listExists = SPList.MatterAssociatedLists(clientContext, new System.Collections.ObjectModel.ReadOnlyCollection<string>(lists));
     return listExists;
 }
예제 #7
0
        public GenericResponseVM SavConfigurations(MatterConfigurations matterConfiguration)
        {
            ClientContext clientContext = null;
            GenericResponseVM returnFlag = null;
            try
            {
                clientContext = spoAuthorization.GetClientContext(matterConfiguration.ClientUrl);
                Matter matter = new Matter();
                matter.AssignUserNames = GetUserList(matterConfiguration.MatterUsers);
                matter.AssignUserEmails = GetUserList(matterConfiguration.MatterUserEmails);
                if (0 < matter.AssignUserNames.Count)
                {
                    returnFlag = matterRepositoy.ValidateTeamMembers(clientContext, matter, matterConfiguration.UserId);
                }
                if (returnFlag != null)
                {
                    returnFlag = matterRepositoy.SaveConfigurationToList(matterConfiguration, clientContext, matterConfiguration.CachedItemModifiedDate);
                    bool tempResult = false;
                    if (returnFlag != null)
                    {
                        tempResult = bool.Parse(returnFlag.Value);
                        if (tempResult)
                        {
                            string listQuery = string.Format(CultureInfo.InvariantCulture, camlQueries.MatterConfigurationsListQuery, searchSettings.ManagedPropertyTitle, searchSettings.MatterConfigurationTitleValue);
                            ListItem settingsItem = matterRepositoy.GetItem(clientContext, listNames.MatterConfigurationsList, listQuery);
                            if (null != settingsItem)
                            {
                                matterConfiguration.CachedItemModifiedDate = Convert.ToString(settingsItem[matterSettings.ColumnNameModifiedDate], CultureInfo.InvariantCulture);
                            }
                            returnFlag.Value = string.Concat(returnFlag.Value, ServiceConstants.PIPE, ServiceConstants.DOLLAR, ServiceConstants.PIPE, matterConfiguration.CachedItemModifiedDate);

                        }
                    }
                }
                return returnFlag;
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
예제 #8
0
        /// <summary>
        /// Function to share the matter.
        /// </summary>
        /// <param name="requestObject">Request Object containing SharePoint App Token</param>
        /// <param name="client">Client object containing Client data</param>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <param name="subAreaOfLawList">String contains all sub area of law</param>
        /// <param name="mailListURL">URL contains list of mail recipients</param>
        /// <returns>Result of operation: Matter Shared successfully or not</returns>        
        internal GenericResponseVM ShareMatterUtility(Client client, Matter matter, MatterDetails matterDetails, string mailSiteURL,
            string centralMailListURL, string matterLandingFlag, MatterConfigurations matterConfigurations)
        {
            bool shareFlag = false;
            string mailListName = centralMailListURL.Substring(centralMailListURL.LastIndexOf(ServiceConstants.FORWARD_SLASH, StringComparison.OrdinalIgnoreCase) + 1);
            string matterLocation = string.Concat(client.Url, ServiceConstants.FORWARD_SLASH, matter.Name);
            string ProvisionMatterValidation = string.Empty;
            GenericResponseVM genericResponse = null;
            if (!string.IsNullOrWhiteSpace(mailSiteURL))
            {
                using (ClientContext clientContext = spoAuthorization.GetClientContext(mailSiteURL))
                {                  
                    
                    genericResponse = validationFunctions.MatterDetailsValidation(matter, client,
                        int.Parse(ServiceConstants.ProvisionMatterShareMatter, CultureInfo.InvariantCulture), matterConfigurations);
                    if (genericResponse != null)
                    {
                        return genericResponse;
                    }

                    MatterInformationVM matterInformation = new MatterInformationVM()
                    {
                        Client = client,
                        Matter = matter,
                        MatterDetails = matterDetails
                    };

                    // Get the current logged in User
                    clientContext.Load(clientContext.Web.CurrentUser);
                    clientContext.ExecuteQuery(); 
                    matterInformation.MatterCreator = clientContext.Web.CurrentUser.Title;
                   
                    if (ServiceConstants.TRUE == matterLandingFlag)
                    {
                        matterLocation = string.Concat(client.Url, ServiceConstants.FORWARD_SLASH,
                            matterSettings.MatterLandingPageRepositoryName.Replace(ServiceConstants.SPACE, string.Empty),
                            ServiceConstants.FORWARD_SLASH, matter.MatterGuid, ServiceConstants.ASPX_EXTENSION);
                        matterInformation.MatterLocation = matterLocation;
                    }
                    

                    // Step 4: Create Conflict check Information based on the conflict check flag and create mail body
                    if (matterConfigurations.IsConflictCheck)
                    {
                        matterInformation.IsConflictCheck = true;
                        
                    }
                    else
                    {
                        matterInformation.IsConflictCheck = false;
                    }                    
                    //List<FieldUserValue> userList = new List<FieldUserValue>();
                    //List<FieldUserValue> userEmailList = GenerateMailList(matter, new Client { Url = mailSiteURL }, ref userList);
                    /////// Add the Matter URL in list
                    //FieldUrlValue matterPath = new FieldUrlValue()
                    //{
                    //    Url = string.Concat(client.Url.Replace(String.Concat(ServiceConstants.HTTPS, ServiceConstants.COLON,
                    //    ServiceConstants.FORWARD_SLASH, ServiceConstants.FORWARD_SLASH), String.Concat(ServiceConstants.HTTP, ServiceConstants.COLON,
                    //    ServiceConstants.FORWARD_SLASH, ServiceConstants.FORWARD_SLASH)), ServiceConstants.FORWARD_SLASH, matter.Name,
                    //    ServiceConstants.FORWARD_SLASH, matter.Name),
                    //    Description = matter.Name
                    //};
                    //matterInformation.MatterUrlPath = matterPath.Url;                    
                    SerializeMatterToTableStorage(matterInformation);
                }
            }
            return genericResponse;
        }
예제 #9
0
        /// <summary>
        /// This method will save matter configurations in sharepoint list
        /// </summary>
        /// <param name="matterConfigurations"></param>
        /// <returns></returns>
        public GenericResponseVM SaveConfigurations(MatterConfigurations matterConfigurations)
        {
            try
            {
                Matter matter = new Matter();
                matter.AssignUserNames = GetUserList(matterConfigurations.MatterUsers);
                matter.AssignUserEmails = GetUserList(matterConfigurations.MatterUserEmails);
                ClientContext clientContext = null;
                clientContext = spoAuthorization.GetClientContext(matterConfigurations.ClientUrl);
                GenericResponseVM genericResponseVM = null;
                if (0 < matter.AssignUserNames.Count)
                {
                    genericResponseVM = matterRepositoy.ValidateTeamMembers(clientContext, matter, matterConfigurations.UserId);
                }

                if (genericResponseVM != null)
                {
                    return genericResponseVM;
                }
                genericResponseVM = matterRepositoy.SaveConfigurations(clientContext, matterConfigurations);
                return genericResponseVM;
            }            
            catch (Exception ex)
            {                
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
예제 #10
0
        /// <summary>
        /// Function to share the matter.
        /// </summary>
        /// <param name="requestObject">Request Object containing SharePoint App Token</param>
        /// <param name="client">Client object containing Client data</param>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <param name="subAreaOfLawList">String contains all sub area of law</param>
        /// <param name="mailListURL">URL contains list of mail recipients</param>
        /// <returns>Result of operation: Matter Shared successfully or not</returns>        
        internal GenericResponseVM  ShareMatterUtility(Client client, Matter matter, MatterDetails matterDetails, string mailSiteURL, string centralMailListURL, string matterLandingFlag, MatterConfigurations matterConfigurations)
        {
            bool shareFlag = false;
            string mailListName = centralMailListURL.Substring(centralMailListURL.LastIndexOf(ServiceConstants.FORWARD_SLASH, StringComparison.OrdinalIgnoreCase) + 1);
            string matterLocation = string.Concat(client.Url, ServiceConstants.FORWARD_SLASH, matter.Name);
            string ProvisionMatterValidation = string.Empty;
            GenericResponseVM genericResponse = null;
            if (!string.IsNullOrWhiteSpace(mailSiteURL))
            {
                using (ClientContext clientContext = spoAuthorization.GetClientContext(mailSiteURL))
                {
                    
                    genericResponse = validationFunctions.MatterDetailsValidation(matter, client, 
                        int.Parse(ServiceConstants.ProvisionMatterShareMatter, CultureInfo.InvariantCulture), matterConfigurations);
                    if(genericResponse!=null)
                    {
                        return genericResponse;
                    }
                    
                    // Get the current logged in User
                    clientContext.Load(clientContext.Web.CurrentUser);
                    clientContext.ExecuteQuery();
                    string matterMailBody, blockUserNames;
                    // Generate Mail Subject
                    string matterMailSubject = string.Format(CultureInfo.InvariantCulture, mailSettings.MatterMailSubject, 
                        matter.Id, matter.Name, clientContext.Web.CurrentUser.Title);

                    // Logic to Create Mail body
                    // Step 1: Create Matter Information
                    // Step 2: Create Team Information
                    // Step 3: Create Access Information
                    // Step 4: Create Conflict check Information based on the conflict check flag and create mail body

                    // Step 1: Create Matter Information
                    string defaultContentType = string.Format(CultureInfo.InvariantCulture, 
                        mailSettings.MatterMailDefaultContentTypeHtmlChunk, matter.DefaultContentType);
                    string matterType = string.Join(";", matter.ContentTypes.ToArray()).TrimEnd(';').Replace(matter.DefaultContentType, defaultContentType);

                    // Step 2: Create Team Information
                    string secureMatter = ServiceConstants.FALSE.ToUpperInvariant() == matter.Conflict.SecureMatter.ToUpperInvariant() ?
                        ServiceConstants.NO : ServiceConstants.YES;
                    string mailBodyTeamInformation = string.Empty;
                    mailBodyTeamInformation = TeamMembersPermissionInformation(matterDetails, mailBodyTeamInformation);

                    // Step 3: Create Access Information
                    if (ServiceConstants.TRUE == matterLandingFlag)
                    {
                        matterLocation = string.Concat(client.Url, ServiceConstants.FORWARD_SLASH, 
                            matterSettings.MatterLandingPageRepositoryName.Replace(ServiceConstants.SPACE, string.Empty), 
                            ServiceConstants.FORWARD_SLASH, matter.MatterGuid, ServiceConstants.ASPX_EXTENSION);
                    }
                    string oneNotePath = string.Concat(client.Url, ServiceConstants.FORWARD_SLASH, 
                        matter.MatterGuid, matterSettings.OneNoteLibrarySuffix, 
                        ServiceConstants.FORWARD_SLASH, matter.MatterGuid, ServiceConstants.FORWARD_SLASH, matter.MatterGuid);

                    // Step 4: Create Conflict check Information based on the conflict check flag and create mail body
                    if (matterConfigurations.IsConflictCheck)
                    {
                        string conflictIdentified = ServiceConstants.FALSE.ToUpperInvariant() == matter.Conflict.Identified.ToUpperInvariant() ?
                        ServiceConstants.NO : ServiceConstants.YES;
                        blockUserNames = string.Join(";", matter.BlockUserNames.ToArray()).Trim().TrimEnd(';');

                        blockUserNames = !String.IsNullOrEmpty(blockUserNames) ? string.Format(CultureInfo.InvariantCulture, 
                            "<div>{0}: {1}</div>", "Conflicted User", blockUserNames) : string.Empty;
                        matterMailBody = string.Format(CultureInfo.InvariantCulture, 
                            mailSettings.MatterMailBodyMatterInformation, client.Name, client.Id, 
                            matter.Name, matter.Id, matter.Description, matterType) + string.Format(CultureInfo.InvariantCulture, 
                            mailSettings.MatterMailBodyConflictCheck, ServiceConstants.YES, matter.Conflict.CheckBy, 
                            Convert.ToDateTime(matter.Conflict.CheckOn, CultureInfo.InvariantCulture).ToString(matterSettings.MatterCenterDateFormat, CultureInfo.InvariantCulture), 
                            conflictIdentified) + string.Format(CultureInfo.InvariantCulture, 
                            mailSettings.MatterMailBodyTeamMembers, secureMatter, mailBodyTeamInformation, 
                            blockUserNames, client.Url, oneNotePath, matter.Name, matterLocation, matter.Name);
                    }
                    else
                    {
                        blockUserNames = string.Empty;
                        matterMailBody = string.Format(CultureInfo.InvariantCulture, mailSettings.MatterMailBodyMatterInformation, 
                            client.Name, client.Id, matter.Name, matter.Id, 
                            matter.Description, matterType) + string.Format(CultureInfo.InvariantCulture, mailSettings.MatterMailBodyTeamMembers, secureMatter, 
                            mailBodyTeamInformation, blockUserNames, client.Url, oneNotePath, matter.Name, matterLocation, matter.Name);
                    }

                    Web web = clientContext.Web;
                    List mailList = web.Lists.GetByTitle(mailListName);
                    List<FieldUserValue> userList = new List<FieldUserValue>();
                    List<FieldUserValue> userEmailList = GenerateMailList(matter, new Client {Url = mailSiteURL }, ref userList);
                    ///// Add the Matter URL in list
                    FieldUrlValue matterPath = new FieldUrlValue()
                    {
                        Url = string.Concat(client.Url.Replace(String.Concat(ServiceConstants.HTTPS, ServiceConstants.COLON, 
                        ServiceConstants.FORWARD_SLASH, ServiceConstants.FORWARD_SLASH), String.Concat(ServiceConstants.HTTP, ServiceConstants.COLON, 
                        ServiceConstants.FORWARD_SLASH, ServiceConstants.FORWARD_SLASH)), ServiceConstants.FORWARD_SLASH, matter.Name, 
                        ServiceConstants.FORWARD_SLASH, matter.Name),
                        Description = matter.Name
                    };
                    List<string> columnNames = new List<string>() { matterSettings.ShareListColumnMatterPath, matterSettings.ShareListColumnMailList,
                        mailSettings.ShareListColumnMailBody, mailSettings.ShareListColumnMailSubject };
                    List<object> columnValues = new List<object>() { matterPath, userEmailList, matterMailBody, matterMailSubject };
                    // To avoid the invalid symbol error while parsing the JSON, return the response in lower case 
                    matterRepositoy.AddItem(clientContext, mailList, columnNames, columnValues);
                    
                }
            }
            return genericResponse;
        }