/// <summary> /// Extracts matter details from matter library property bag. /// </summary> /// <param name="stampedPropertyValues">Dictionary object containing matter property bag key/value pairs</param> /// <returns>Matter details from matter library property bag</returns> internal static MatterDetails ExtractMatterDetails(Dictionary <string, object> stampedPropertyValues) { MatterDetails matterDetails = new MatterDetails() { PracticeGroup = GetStampPropertyValue(stampedPropertyValues, ServiceConstantStrings.StampedPropertyPracticeGroup), AreaOfLaw = GetStampPropertyValue(stampedPropertyValues, ServiceConstantStrings.StampedPropertyAreaOfLaw), SubareaOfLaw = GetStampPropertyValue(stampedPropertyValues, ServiceConstantStrings.StampedPropertySubAreaOfLaw), ResponsibleAttorney = GetStampPropertyValue(stampedPropertyValues, ServiceConstantStrings.StampedPropertyResponsibleAttorney), TeamMembers = GetStampPropertyValue(stampedPropertyValues, ServiceConstantStrings.StampedPropertyTeamMembers), UploadBlockedUsers = GetStampPropertyValue(stampedPropertyValues, ServiceConstantStrings.StampedPropertyBlockedUploadUsers).Split(new string[] { ConstantStrings.Semicolon }, StringSplitOptions.RemoveEmptyEntries).ToList() }; return(matterDetails); }
/// <summary> /// Provides the team members and their respective permission details. /// </summary> /// <param name="matterDetails">Matter Details object</param> /// <param name="mailBodyTeamInformation">Team members permission information</param> /// <returns>Team members permission information</returns> private static string TeamMembersPermissionInformation(MatterDetails matterDetails, string mailBodyTeamInformation) { if (null != matterDetails && !string.IsNullOrWhiteSpace(matterDetails.RoleInformation)) { Dictionary <string, string> roleInformation = JsonConvert.DeserializeObject <Dictionary <string, string> >(matterDetails.RoleInformation); foreach (KeyValuePair <string, string> entry in roleInformation) { mailBodyTeamInformation = string.Format(CultureInfo.InvariantCulture, ServiceConstants.RoleInfoHtmlChunk, entry.Key, entry.Value) + mailBodyTeamInformation; } } return(mailBodyTeamInformation); }
private static void SentEmailNotificationForCreatedIsBackwardCompatibleMatters(MatterInformationVM matterInformation1, ExchangeService service, TextWriter log, IConfigurationRoot configuration) { string mailSubject = configuration.GetSection("Mail").GetSection("MatterMailSubject").Value; string defaultHtmlChunk = configuration.GetSection("Mail").GetSection("MatterMailDefaultContentTypeHtmlChunk").Value; string oneNoteLibrarySuffix = configuration.GetSection("Matter").GetSection("OneNoteLibrarySuffix").Value; string matterMailBodyMatterInformation = configuration.GetSection("Mail").GetSection("MatterMailBodyMatterInformation").Value; string matterMailBodyConflictCheck = configuration.GetSection("Mail").GetSection("MatterMailBodyConflictCheck").Value; string matterCenterDateFormat = configuration.GetSection("Mail").GetSection("MatterCenterDateFormat").Value; string matterMailBodyTeamMembers = configuration.GetSection("Mail").GetSection("MatterMailBodyTeamMembers").Value; ///For isbackward compatability true MatterInformationVM originalMatter = JsonConvert.DeserializeObject <MatterInformationVM>(matterInformation1.SerializeMatter); Matter matter = originalMatter.Matter; MatterDetails matterDetails = originalMatter.MatterDetails; Client client = originalMatter.Client; string practiceGroupColumnName = configuration["ContentTypes:ManagedColumns:ColumnName1"].ToString(); string areaOfLawColumnName = configuration["ContentTypes:ManagedColumns:ColumnName2"].ToString(); string matterMailBody; string practiceGroupValue = originalMatter.MatterDetails.ManagedColumnTerms[practiceGroupColumnName].TermName; string areaOfLawValue = originalMatter.MatterDetails.ManagedColumnTerms[areaOfLawColumnName].TermName; // Generate Mail Subject string matterMailSubject = string.Format(CultureInfo.InvariantCulture, mailSubject, matter.Id, matter.Name, originalMatter.MatterCreator); // Step 1: Create Matter Information string defaultContentType = string.Format(CultureInfo.InvariantCulture, defaultHtmlChunk, matter.DefaultContentType); string matterType = string.Join(";", matter.ContentTypes.ToArray()).TrimEnd(';').Replace(matter.DefaultContentType, defaultContentType); if (matterType == string.Empty) { matterType = 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); string oneNotePath = string.Concat(client.Url, ServiceConstants.FORWARD_SLASH, matter.MatterGuid, oneNoteLibrarySuffix, ServiceConstants.FORWARD_SLASH, matter.Name, ServiceConstants.FORWARD_SLASH, matter.MatterGuid); string conflictIdentified = ServiceConstants.FALSE.ToUpperInvariant() == matter.Conflict.Identified.ToUpperInvariant() ? ServiceConstants.NO : ServiceConstants.YES; matterMailBody = string.Format(CultureInfo.InvariantCulture, matterMailBodyMatterInformation, practiceGroupValue, areaOfLawValue, matter.Name, matter.Description, matter.Name + " OneNote", matterType, originalMatter.MatterCreator, string.Format("{0:MMM dd, yyyy}", DateTime.Now), originalMatter.MatterLocation, client.Url, oneNotePath, configuration["General:SiteURL"].ToString()); EmailMessage email = new EmailMessage(service); foreach (IList <string> userNames in matter.AssignUserEmails) { foreach (string userName in userNames) { if (!string.IsNullOrWhiteSpace(userName)) { using (var ctx = new ClientContext(originalMatter.Client.Url)) { SecureString password = Utility.GetEncryptedPassword(configuration["General:AdminPassword"]); ctx.Credentials = new SharePointOnlineCredentials(configuration["General:AdminUserName"], password); if (CheckUserPresentInMatterCenter(ctx, originalMatter.Client.Url, userName, null, log)) { email.ToRecipients.Add(userName); } } } } } string adminUserName = configuration["General:AdminUserName"]; email.From = new EmailAddress(adminUserName); email.Subject = matterMailSubject; email.Body = matterMailBody; email.Send(); log.WriteLine($"connection string. {configuration["General:CloudStorageConnectionString"]}"); Utility.UpdateTableStorageEntity(originalMatter, log, configuration["General:CloudStorageConnectionString"], configuration["Settings:MatterRequests"], "Accepted"); }
private static void SentEmailNotificationForCreatedMatters(MatterInformationVM matterInformation1, ExchangeService service, TextWriter log, IConfigurationRoot configuration) { string mailSubject = configuration.GetSection("Mail").GetSection("MatterMailSubject").Value; string defaultHtmlChunk = configuration.GetSection("Mail").GetSection("MatterMailDefaultContentTypeHtmlChunk").Value; string oneNoteLibrarySuffix = configuration.GetSection("Matter").GetSection("OneNoteLibrarySuffix").Value; string matterMailBodyMatterInformation = configuration.GetSection("Mail").GetSection("MatterMailBodyMatterInformation").Value; string matterMailBodyConflictCheck = configuration.GetSection("Mail").GetSection("MatterMailBodyConflictCheck").Value; string matterCenterDateFormat = configuration.GetSection("Mail").GetSection("MatterCenterDateFormat").Value; string matterMailBodyTeamMembers = configuration.GetSection("Mail").GetSection("MatterMailBodyTeamMembers").Value; //De Serialize the matter information MatterInformationVM originalMatter = JsonConvert.DeserializeObject <MatterInformationVM>(matterInformation1.SerializeMatter); Matter matter = originalMatter.Matter; MatterDetails matterDetails = originalMatter.MatterDetails; Client client = originalMatter.Client; string matterMailBody, blockUserNames; // Generate Mail Subject string matterMailSubject = string.Format(CultureInfo.InvariantCulture, mailSubject, matter.Id, matter.Name, originalMatter.MatterCreator); // Step 1: Create Matter Information string defaultContentType = string.Format(CultureInfo.InvariantCulture, defaultHtmlChunk, matter.DefaultContentType); string matterType = string.Join(";", matter.ContentTypes.ToArray()).TrimEnd(';').Replace(matter.DefaultContentType, defaultContentType); if (matterType == string.Empty) { matterType = 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); string oneNotePath = string.Concat(client.Url, ServiceConstants.FORWARD_SLASH, matter.MatterGuid, oneNoteLibrarySuffix, ServiceConstants.FORWARD_SLASH, matter.MatterGuid, ServiceConstants.FORWARD_SLASH, matter.MatterGuid); if (originalMatter.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, matterMailBodyMatterInformation, client.Name, client.Id, matter.Name, matter.Id, matter.Description, matterType) + string.Format(CultureInfo.InvariantCulture, matterMailBodyConflictCheck, ServiceConstants.YES, matter.Conflict.CheckBy, Convert.ToDateTime(matter.Conflict.CheckOn, CultureInfo.InvariantCulture).ToString(matterCenterDateFormat, CultureInfo.InvariantCulture), conflictIdentified) + string.Format(CultureInfo.InvariantCulture, matterMailBodyTeamMembers, secureMatter, mailBodyTeamInformation, blockUserNames, client.Url, oneNotePath, matter.Name, originalMatter.MatterLocation, matter.Name); } else { blockUserNames = string.Empty; matterMailBody = string.Format(CultureInfo.InvariantCulture, matterMailBodyMatterInformation, client.Name, client.Id, matter.Name, matter.Id, matter.Description, matterType) + string.Format(CultureInfo.InvariantCulture, matterMailBodyTeamMembers, secureMatter, mailBodyTeamInformation, blockUserNames, client.Url, oneNotePath, matter.Name, originalMatter.MatterLocation, matter.Name); } EmailMessage email = new EmailMessage(service); foreach (IList <string> userNames in matter.AssignUserEmails) { foreach (string userName in userNames) { if (!string.IsNullOrWhiteSpace(userName)) { using (var ctx = new ClientContext(originalMatter.Client.Url)) { SecureString password = Utility.GetEncryptedPassword(configuration["General:AdminPassword"]); ctx.Credentials = new SharePointOnlineCredentials(configuration["General:AdminUserName"], password); if (CheckUserPresentInMatterCenter(ctx, originalMatter.Client.Url, userName, null, log)) { email.ToRecipients.Add(userName); } } } } } email.From = new EmailAddress(configuration["General:AdminUserName"]); email.Subject = matterMailSubject; email.Body = matterMailBody; email.Send(); Utility.UpdateTableStorageEntity(originalMatter, log, configuration["General:CloudStorageConnectionString"], configuration["Settings:MatterRequests"], "Accepted"); }
/// <summary> /// This web job function will process matter that is there in azure table storage called MatterRequests. /// If there are any new matter is created, this web job function will get invoked for the time duration that has /// been specified and will preocess all new matters and will send notification for those respective users /// Once the matter has been processed, it will change the status of that matter to "Send" so that it will not /// be processed again /// </summary> /// <param name="timerInfo"></param> /// <param name="matterInformationVM"></param> public static void ProcessMatter([TimerTrigger("00:00:05", RunOnStartup = true)] TimerInfo timerInfo, [Table("MatterRequests")] IQueryable <MatterInformationVM> matterInformationVM, TextWriter log) { var query = from p in matterInformationVM select p; if (query.ToList().Count() > 0) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appSettings.json") .AddInMemoryCollection() .AddEnvironmentVariables();//appsettings.json will be overridden with azure web appsettings ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013); var configuration = builder.Build(); KeyVaultHelper kv = new KeyVaultHelper(configuration); KeyVaultHelper.GetCert(configuration); kv.GetKeyVaultSecretsCerticate(); //// can use on premise exchange server credentials with service.UseDefaultCredentials = true, or //explicitly specify the admin account (set default to false) string adminUserName = configuration.GetSection("General").GetSection("AdminUserName").Value; string adminPassword = configuration.GetSection("General").GetSection("AdminPassword").Value; service.Credentials = new WebCredentials(adminUserName, adminPassword); service.Url = new Uri(configuration.GetSection("Settings").GetSection("ExchangeServiceURL").Value); string mailSubject = configuration.GetSection("Mail").GetSection("MatterMailSubject").Value; string defaultHtmlChunk = configuration.GetSection("Mail").GetSection("MatterMailDefaultContentTypeHtmlChunk").Value; string oneNoteLibrarySuffix = configuration.GetSection("Matter").GetSection("OneNoteLibrarySuffix").Value; string matterMailBodyMatterInformation = configuration.GetSection("Mail").GetSection("MatterMailBodyMatterInformation").Value; string matterMailBodyConflictCheck = configuration.GetSection("Mail").GetSection("MatterMailBodyConflictCheck").Value; string matterCenterDateFormat = configuration.GetSection("Mail").GetSection("MatterCenterDateFormat").Value; string matterMailBodyTeamMembers = configuration.GetSection("Mail").GetSection("MatterMailBodyTeamMembers").Value; foreach (MatterInformationVM matterInformation1 in query) { if (matterInformation1 != null) { if (matterInformation1.Status.ToLower() == "pending") { //De Serialize the matter information MatterInformationVM originalMatter = JsonConvert.DeserializeObject <MatterInformationVM>(matterInformation1.SerializeMatter); Matter matter = originalMatter.Matter; MatterDetails matterDetails = originalMatter.MatterDetails; Client client = originalMatter.Client; string matterMailBody, blockUserNames; // Generate Mail Subject string matterMailSubject = string.Format(CultureInfo.InvariantCulture, mailSubject, matter.Id, matter.Name, originalMatter.MatterCreator); // Step 1: Create Matter Information string defaultContentType = string.Format(CultureInfo.InvariantCulture, defaultHtmlChunk, matter.DefaultContentType); string matterType = string.Join(";", matter.ContentTypes.ToArray()).TrimEnd(';').Replace(matter.DefaultContentType, defaultContentType); if (matterType == string.Empty) { matterType = 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); string oneNotePath = string.Concat(client.Url, ServiceConstants.FORWARD_SLASH, matter.MatterGuid, oneNoteLibrarySuffix, ServiceConstants.FORWARD_SLASH, matter.MatterGuid, ServiceConstants.FORWARD_SLASH, matter.MatterGuid); if (originalMatter.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, matterMailBodyMatterInformation, client.Name, client.Id, matter.Name, matter.Id, matter.Description, matterType) + string.Format(CultureInfo.InvariantCulture, matterMailBodyConflictCheck, ServiceConstants.YES, matter.Conflict.CheckBy, Convert.ToDateTime(matter.Conflict.CheckOn, CultureInfo.InvariantCulture).ToString(matterCenterDateFormat, CultureInfo.InvariantCulture), conflictIdentified) + string.Format(CultureInfo.InvariantCulture, matterMailBodyTeamMembers, secureMatter, mailBodyTeamInformation, blockUserNames, client.Url, oneNotePath, matter.Name, originalMatter.MatterLocation, matter.Name); } else { blockUserNames = string.Empty; matterMailBody = string.Format(CultureInfo.InvariantCulture, matterMailBodyMatterInformation, client.Name, client.Id, matter.Name, matter.Id, matter.Description, matterType) + string.Format(CultureInfo.InvariantCulture, matterMailBodyTeamMembers, secureMatter, mailBodyTeamInformation, blockUserNames, client.Url, oneNotePath, matter.Name, originalMatter.MatterLocation, matter.Name); } EmailMessage email = new EmailMessage(service); foreach (IList <string> userNames in matter.AssignUserEmails) { foreach (string userName in userNames) { if (!string.IsNullOrWhiteSpace(userName)) { using (var ctx = new ClientContext(originalMatter.Client.Url)) { SecureString password = Utility.GetEncryptedPassword(configuration["General:AdminPassword"]); ctx.Credentials = new SharePointOnlineCredentials(configuration["General:AdminUserName"], password); if (CheckUserPresentInMatterCenter(ctx, originalMatter.Client.Url, userName, null, log)) { email.ToRecipients.Add(userName); } } } } } email.From = new EmailAddress(adminUserName); email.Subject = matterMailSubject; email.Body = matterMailBody; email.Send(); Utility.UpdateTableStorageEntity(originalMatter, log, configuration["Data:DefaultConnection:AzureStorageConnectionString"], configuration["Settings:MatterRequests"], "Accepted"); } } } } }
public bool UpdateMatterStampedProperties(ClientContext clientContext, MatterDetails matterDetails, Matter matter, PropertyValues matterStampedProperties, bool isEditMode, IConfigurationRoot configuration) { try { if (null != clientContext && null != matter && null != matterDetails && (0 < matterStampedProperties.FieldValues.Count)) { Dictionary <string, string> propertyList = new Dictionary <string, string>(); // Get existing stamped properties string stampedUsers = GetStampPropertyValue(matterStampedProperties.FieldValues, configuration["Matter:StampedPropertyMatterCenterUsers"]); string stampedUserEmails = GetStampPropertyValue(matterStampedProperties.FieldValues, configuration["Matter:StampedPropertyMatterCenterUserEmails"]); string stampedPermissions = GetStampPropertyValue(matterStampedProperties.FieldValues, configuration["Matter:StampedPropertyMatterCenterPermissions"]); string stampedRoles = GetStampPropertyValue(matterStampedProperties.FieldValues, configuration["Matter:StampedPropertyMatterCenterRoles"]); string stampedResponsibleAttorneys = GetStampPropertyValue(matterStampedProperties.FieldValues, configuration["Matter:StampedPropertyResponsibleAttorney"]); string stampedResponsibleAttorneysEmail = GetStampPropertyValue(matterStampedProperties.FieldValues, configuration["Matter:StampedPropertyResponsibleAttorneyEmail"]); string stampedTeamMembers = GetStampPropertyValue(matterStampedProperties.FieldValues, configuration["Matter:StampedPropertyTeamMembers"]); string stampedBlockedUploadUsers = GetStampPropertyValue(matterStampedProperties.FieldValues, configuration["Matter:StampedPropertyBlockedUploadUsers"]); string currentPermissions = string.Join(ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR, matter.Permissions.Where(user => !string.IsNullOrWhiteSpace(user))); string currentRoles = string.Join(ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR, matter.Roles.Where(user => !string.IsNullOrWhiteSpace(user))); string currentBlockedUploadUsers = string.Join(ServiceConstants.SEMICOLON, matterDetails.UploadBlockedUsers.Where(user => !string.IsNullOrWhiteSpace(user))); string currentUsers = GetMatterAssignedUsers(matter); string currentUserEmails = SPList.GetMatterAssignedUsersEmail(clientContext, matter); string finalMatterPermissions = string.Concat(stampedPermissions, ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR, currentPermissions); string finalMatterRoles = string.Concat(stampedRoles, ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR, currentRoles); string finalTeamMembers = string.Concat(stampedTeamMembers, ServiceConstants.SEMICOLON, ServiceConstants.SEMICOLON, matterDetails.TeamMembers); string finalMatterCenterUsers = string.Concat(stampedUsers, ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR, currentUsers); string finalBlockedUploadUsers = string.Concat(stampedBlockedUploadUsers, ServiceConstants.SEMICOLON, currentBlockedUploadUsers); //if(stampedUserEmails.LastIndexOf("$|$")>0) //{ // stampedUserEmails = stampedUserEmails.Remove(stampedUserEmails.Length - 3); //} string finalMatterCenterUserEmails = string.Concat(stampedUserEmails, ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR, currentUserEmails); string finalResponsibleAttorneysEmail = ""; string finalResponsibleAttorneys = ""; if (matterDetails.ResponsibleAttorneyEmail != null) { finalResponsibleAttorneysEmail = string.IsNullOrWhiteSpace(stampedResponsibleAttorneysEmail) || isEditMode ? matterDetails.ResponsibleAttorneyEmail : string.Concat(stampedResponsibleAttorneysEmail, ServiceConstants.SEMICOLON, matterDetails.ResponsibleAttorneyEmail); finalResponsibleAttorneys = string.IsNullOrWhiteSpace(stampedResponsibleAttorneys) || isEditMode ? matterDetails.ResponsibleAttorney : string.Concat(stampedResponsibleAttorneys, ServiceConstants.SEMICOLON, matterDetails.ResponsibleAttorney); } else { finalResponsibleAttorneysEmail = stampedResponsibleAttorneysEmail; finalResponsibleAttorneys = stampedResponsibleAttorneys; } propertyList.Add(configuration["Matter:StampedPropertyResponsibleAttorney"], WebUtility.HtmlEncode(finalResponsibleAttorneys)); propertyList.Add(configuration["Matter:StampedPropertyResponsibleAttorneyEmail"], WebUtility.HtmlEncode(finalResponsibleAttorneysEmail)); propertyList.Add(configuration["Matter:StampedPropertyTeamMembers"], WebUtility.HtmlEncode(finalTeamMembers)); propertyList.Add(configuration["Matter:StampedPropertyBlockedUploadUsers"], WebUtility.HtmlEncode(finalBlockedUploadUsers)); propertyList.Add(configuration["Matter:StampedPropertyMatterCenterRoles"], WebUtility.HtmlEncode(finalMatterRoles)); propertyList.Add(configuration["Matter:StampedPropertyMatterCenterPermissions"], WebUtility.HtmlEncode(finalMatterPermissions)); propertyList.Add(configuration["Matter:StampedPropertyMatterCenterUsers"], WebUtility.HtmlEncode(finalMatterCenterUsers)); propertyList.Add(configuration["Matter:StampedPropertyMatterCenterUserEmails"], WebUtility.HtmlEncode(finalMatterCenterUserEmails)); SPList.SetPropertBagValuesForList(clientContext, matterStampedProperties, matter.Name, propertyList); return(true); } } catch (Exception) { throw; //// This will transfer control to catch block of parent function. } return(false); }
/// <summary> /// Validates the inputs for matter provision app and returns the validation status (success/failure). /// </summary> /// <param name="requestObject">Request Object containing SharePoint App Token</param> /// <param name="client">Client object containing Client data</param> /// <param name="clientContext">Client context object for SharePoint</param> /// <param name="matter">Matter object containing Matter data</param> /// <param name="matterDetails">Matter details object which has data of properties to be stamped</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 static string ProvisionMatterValidation(RequestObject requestObject, Client client, ClientContext clientContext, Matter matter, MatterDetails matterDetails, int methodNumber, MatterConfigurations matterConfigurations) { if (int.Parse(ConstantStrings.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) <= methodNumber && int.Parse(ConstantStrings.EditMatterPermission, CultureInfo.InvariantCulture) >= methodNumber && !Lists.CheckPermissionOnList(ServiceUtility.GetClientContext(null, new Uri(ConstantStrings.ProvisionMatterAppURL), requestObject.RefreshToken), ConstantStrings.SendMailListName, PermissionKind.EditListItems)) { return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, ServiceConstantStrings.IncorrectInputUserAccessCode, ServiceConstantStrings.IncorrectInputUserAccessMessage)); } else { if (null != requestObject) { if (string.IsNullOrWhiteSpace(requestObject.RefreshToken) && string.IsNullOrWhiteSpace(requestObject.SPAppToken)) { return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputRequestObjectCode, TextConstants.IncorrectInputRequestObjectMessage)); } } if (null != client) { string result = ValidateClientInformation(client, methodNumber); if (!string.IsNullOrEmpty(result)) { return(result); } } if (null != matter) { string MatterMetadataValidationResponse = MatterMetadataValidation(matter, clientContext, methodNumber, matterConfigurations); if (!string.IsNullOrEmpty(MatterMetadataValidationResponse)) { return(MatterMetadataValidationResponse); } if (int.Parse(ConstantStrings.EditMatterPermission, CultureInfo.InvariantCulture) == methodNumber) { string roleCheck = ValidationHelperFunctions.RoleCheck(requestObject, matter, client); if (!string.IsNullOrEmpty(roleCheck)) { return(roleCheck); } } if (null != matter.Permissions) { bool isFullControlPresent = EditMatterHelperFunctions.ValidateFullControlPermission(matter); if (!isFullControlPresent) { return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, ServiceConstantStrings.IncorrectInputUserAccessCode, ServiceConstantStrings.ErrorEditMatterMandatoryPermission)); } } } if (null != matterDetails && !(int.Parse(ConstantStrings.EditMatterPermission, CultureInfo.InvariantCulture) == methodNumber)) { if (string.IsNullOrWhiteSpace(matterDetails.PracticeGroup)) { return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputPracticeGroupCode, TextConstants.IncorrectInputPracticeGroupMessage)); } if (string.IsNullOrWhiteSpace(matterDetails.AreaOfLaw)) { return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputAreaOfLawCode, TextConstants.IncorrectInputAreaOfLawMessage)); } if (string.IsNullOrWhiteSpace(matterDetails.SubareaOfLaw)) { return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputSubareaOfLawCode, TextConstants.IncorrectInputSubareaOfLawMessage)); } try { if (string.IsNullOrWhiteSpace(matterDetails.ResponsibleAttorney)) { return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputResponsibleAttorneyCode, TextConstants.IncorrectInputResponsibleAttorneyMessage)); } else { IList <string> userNames = matterDetails.ResponsibleAttorney.Split(';').ToList <string>(); SharePointHelper.ResolveUserNames(clientContext, userNames).FirstOrDefault(); } } catch (Exception) { return(string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, TextConstants.IncorrectInputResponsibleAttorneyCode, TextConstants.IncorrectInputResponsibleAttorneyMessage)); } } } return(string.Empty); }
/// <summary> /// Function to create dictionary object for stamp property /// </summary> /// <param name="client">Client object containing Client data</param> /// <param name="matter">Matter object containing Matter data</param> /// <param name="matterDetails">Matter details object which has data of properties to be stamped</param> /// <returns>returns dictionary object</returns> internal Dictionary <string, string> SetStampProperty(Client client, Matter matter, MatterDetails matterDetails) { string matterCenterPermission = string.Join(ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR, matter.Permissions); string matterCenterRoles = string.Join(ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR, matter.Roles); string documentTemplateCount = string.Join(ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR, matter.DocumentTemplateCount); string matterCenterUsers = string.Empty; string separator = string.Empty; foreach (IList <string> userNames in matter.AssignUserNames) { matterCenterUsers += separator + string.Join(ServiceConstants.SEMICOLON, userNames.Where(user => !string.IsNullOrWhiteSpace(user))); separator = ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR; } List <string> keys = new List <string>(); Dictionary <string, string> propertyList = new Dictionary <string, string>(); keys.Add(matterSettings.StampedPropertyPracticeGroup); keys.Add(matterSettings.StampedPropertyAreaOfLaw); keys.Add(matterSettings.StampedPropertySubAreaOfLaw); keys.Add(matterSettings.StampedPropertyMatterName); keys.Add(matterSettings.StampedPropertyMatterID); keys.Add(matterSettings.StampedPropertyClientName); keys.Add(matterSettings.StampedPropertyClientID); keys.Add(matterSettings.StampedPropertyResponsibleAttorney); keys.Add(matterSettings.StampedPropertyTeamMembers); keys.Add(matterSettings.StampedPropertyIsMatter); keys.Add(matterSettings.StampedPropertyOpenDate); keys.Add(matterSettings.StampedPropertySecureMatter); keys.Add(matterSettings.StampedPropertyBlockedUploadUsers); keys.Add(matterSettings.StampedPropertyMatterDescription); keys.Add(matterSettings.StampedPropertyConflictCheckDate); keys.Add(matterSettings.StampedPropertyConflictCheckBy); keys.Add(matterSettings.StampedPropertyMatterCenterRoles); keys.Add(matterSettings.StampedPropertyMatterCenterPermissions); keys.Add(matterSettings.StampedPropertyMatterCenterUsers); keys.Add(matterSettings.StampedPropertyDefaultContentType); keys.Add(matterSettings.StampedPropertyIsConflictIdentified); keys.Add(matterSettings.StampedPropertyDocumentTemplateCount); keys.Add(matterSettings.StampedPropertyBlockedUsers); keys.Add(matterSettings.StampedPropertyMatterGUID); propertyList.Add(matterSettings.StampedPropertyPracticeGroup, WebUtility.HtmlEncode(matterDetails.PracticeGroup)); propertyList.Add(matterSettings.StampedPropertyAreaOfLaw, WebUtility.HtmlEncode(matterDetails.AreaOfLaw)); propertyList.Add(matterSettings.StampedPropertySubAreaOfLaw, WebUtility.HtmlEncode(matterDetails.SubareaOfLaw)); propertyList.Add(matterSettings.StampedPropertyMatterName, WebUtility.HtmlEncode(matter.Name)); propertyList.Add(matterSettings.StampedPropertyMatterID, WebUtility.HtmlEncode(matter.Id)); propertyList.Add(matterSettings.StampedPropertyClientName, WebUtility.HtmlEncode(client.Name)); propertyList.Add(matterSettings.StampedPropertyClientID, WebUtility.HtmlEncode(client.Id)); propertyList.Add(matterSettings.StampedPropertyResponsibleAttorney, WebUtility.HtmlEncode(matterDetails.ResponsibleAttorney)); propertyList.Add(matterSettings.StampedPropertyTeamMembers, WebUtility.HtmlEncode(matterDetails.TeamMembers)); propertyList.Add(matterSettings.StampedPropertyIsMatter, ServiceConstants.TRUE); propertyList.Add(matterSettings.StampedPropertyOpenDate, WebUtility.HtmlEncode(DateTime.Now.ToString(matterSettings.ValidDateFormat, CultureInfo.InvariantCulture))); propertyList.Add(matterSettings.PropertyNameVtiIndexedPropertyKeys, WebUtility.HtmlEncode(ServiceUtility.GetEncodedValueForSearchIndexProperty(keys))); propertyList.Add(matterSettings.StampedPropertySecureMatter, (matter.Conflict != null) ? (matter.Conflict.SecureMatter != null) ? WebUtility.HtmlEncode(matter.Conflict.SecureMatter) : "False" : "False"); propertyList.Add(matterSettings.StampedPropertyBlockedUploadUsers, WebUtility.HtmlEncode(string.Join(";", matterDetails.UploadBlockedUsers))); propertyList.Add(matterSettings.StampedPropertyMatterDescription, WebUtility.HtmlEncode(matter.Description)); propertyList.Add(matterSettings.StampedPropertyConflictCheckDate, (string.IsNullOrEmpty(matter.Conflict.CheckOn)) ? "" : WebUtility.HtmlEncode(Convert.ToDateTime(matter.Conflict.CheckOn, CultureInfo.InvariantCulture).ToString(matterSettings.ValidDateFormat, CultureInfo.InvariantCulture))); propertyList.Add(matterSettings.StampedPropertyConflictCheckBy, WebUtility.HtmlEncode(matter.Conflict.CheckBy)); propertyList.Add(matterSettings.StampedPropertyMatterCenterRoles, WebUtility.HtmlEncode(matterCenterRoles)); propertyList.Add(matterSettings.StampedPropertyMatterCenterPermissions, WebUtility.HtmlEncode(matterCenterPermission)); propertyList.Add(matterSettings.StampedPropertyMatterCenterUsers, WebUtility.HtmlEncode(matterCenterUsers)); propertyList.Add(matterSettings.StampedPropertyDefaultContentType, WebUtility.HtmlEncode(matter.DefaultContentType)); propertyList.Add(matterSettings.StampedPropertyIsConflictIdentified, WebUtility.HtmlEncode(matter.Conflict.Identified)); propertyList.Add(matterSettings.StampedPropertyDocumentTemplateCount, WebUtility.HtmlEncode(documentTemplateCount)); propertyList.Add(matterSettings.StampedPropertyBlockedUsers, WebUtility.HtmlEncode(string.Join(";", matter.BlockUserNames))); propertyList.Add(matterSettings.StampedPropertyMatterGUID, WebUtility.HtmlEncode(matter.MatterGuid)); propertyList.Add(matterSettings.StampedPropertySuccess, ServiceConstants.TRUE); return(propertyList); }
/// <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); }
/// <summary> /// Updates the matter stamped properties with new details for user permissions. /// </summary> /// <param name="clientContext">ClientContext object</param> /// <param name="matterDetails">MatterDetails object</param> /// <param name="matter">Matter object</param> /// <param name="matterStampedProperties">Matter stamped properties</param> /// <param name="isEditMode">Page opened in edit mode</param> /// <returns>Status of operation</returns> internal static string UpdateMatterStampedProperties(ClientContext clientContext, MatterDetails matterDetails, Matter matter, PropertyValues matterStampedProperties, bool isEditMode) { string result = ConstantStrings.FALSE; try { if (null != clientContext && null != matter && null != matterDetails && (0 < matterStampedProperties.FieldValues.Count)) { Dictionary <string, string> propertyList = new Dictionary <string, string>(); // Get existing stamped properties string stampedUsers = GetStampPropertyValue(matterStampedProperties.FieldValues, ServiceConstantStrings.StampedPropertyMatterCenterUsers); string stampedPermissions = GetStampPropertyValue(matterStampedProperties.FieldValues, ServiceConstantStrings.StampedPropertyMatterCenterPermissions); string stampedRoles = GetStampPropertyValue(matterStampedProperties.FieldValues, ServiceConstantStrings.StampedPropertyMatterCenterRoles); string stampedResponsibleAttorneys = GetStampPropertyValue(matterStampedProperties.FieldValues, ServiceConstantStrings.StampedPropertyResponsibleAttorney); string stampedTeamMembers = GetStampPropertyValue(matterStampedProperties.FieldValues, ServiceConstantStrings.StampedPropertyTeamMembers); string stampedBlockedUploadUsers = GetStampPropertyValue(matterStampedProperties.FieldValues, ServiceConstantStrings.StampedPropertyBlockedUploadUsers); string currentPermissions = string.Join(ConstantStrings.DOLLAR + ConstantStrings.Pipe + ConstantStrings.DOLLAR, matter.Permissions.Where(user => !string.IsNullOrWhiteSpace(user))); string currentRoles = string.Join(ConstantStrings.DOLLAR + ConstantStrings.Pipe + ConstantStrings.DOLLAR, matter.Roles.Where(user => !string.IsNullOrWhiteSpace(user))); string currentBlockedUploadUsers = string.Join(ConstantStrings.Semicolon, matterDetails.UploadBlockedUsers.Where(user => !string.IsNullOrWhiteSpace(user))); string currentUsers = GetMatterAssignedUsers(matter); string finalMatterPermissions = string.IsNullOrWhiteSpace(stampedPermissions) || isEditMode ? currentPermissions : string.Concat(stampedPermissions, ConstantStrings.DOLLAR + ConstantStrings.Pipe + ConstantStrings.DOLLAR, currentPermissions); string finalMatterRoles = string.IsNullOrWhiteSpace(stampedRoles) || isEditMode ? currentRoles : string.Concat(stampedRoles, ConstantStrings.DOLLAR + ConstantStrings.Pipe + ConstantStrings.DOLLAR, currentRoles); string finalResponsibleAttorneys = string.IsNullOrWhiteSpace(stampedResponsibleAttorneys) || isEditMode ? matterDetails.ResponsibleAttorney : string.Concat(stampedResponsibleAttorneys, ConstantStrings.Semicolon, matterDetails.ResponsibleAttorney); string finalTeamMembers = string.IsNullOrWhiteSpace(stampedTeamMembers) || isEditMode ? matterDetails.TeamMembers : string.Concat(stampedTeamMembers, ConstantStrings.Semicolon, matterDetails.TeamMembers); string finalMatterCenterUsers = string.IsNullOrWhiteSpace(stampedUsers) || isEditMode ? currentUsers : string.Concat(stampedUsers, ConstantStrings.DOLLAR + ConstantStrings.Pipe + ConstantStrings.DOLLAR, currentUsers); string finalBlockedUploadUsers = string.IsNullOrWhiteSpace(stampedBlockedUploadUsers) || isEditMode ? currentBlockedUploadUsers : string.Concat(stampedBlockedUploadUsers, ConstantStrings.Semicolon, currentBlockedUploadUsers); propertyList.Add(ServiceConstantStrings.StampedPropertyResponsibleAttorney, Encoder.HtmlEncode(finalResponsibleAttorneys)); propertyList.Add(ServiceConstantStrings.StampedPropertyTeamMembers, Encoder.HtmlEncode(finalTeamMembers)); propertyList.Add(ServiceConstantStrings.StampedPropertyBlockedUploadUsers, Encoder.HtmlEncode(finalBlockedUploadUsers)); propertyList.Add(ServiceConstantStrings.StampedPropertyMatterCenterRoles, Encoder.HtmlEncode(finalMatterRoles)); propertyList.Add(ServiceConstantStrings.StampedPropertyMatterCenterPermissions, Encoder.HtmlEncode(finalMatterPermissions)); propertyList.Add(ServiceConstantStrings.StampedPropertyMatterCenterUsers, Encoder.HtmlEncode(finalMatterCenterUsers)); Lists.SetPropertBagValuesForList(clientContext, matterStampedProperties, matter.Name, propertyList); result = ConstantStrings.TRUE; } } catch (Exception) { throw; //// This will transfer control to catch block of parent function. } return(result); }