/// <summary> /// Function to validate client information /// </summary> /// <param name="client">Client object</param> /// <param name="methodNumber">Number indicating which method needs to be validated</param> /// <returns>ErrorResponse that contains error message with error code</returns> internal static ErrorResponse ValidateClientInformation(Client client, int methodNumber) { ErrorResponse errorResponse = new ErrorResponse(); if (string.IsNullOrWhiteSpace(client.Url)) { errorResponse.ErrorCode = ErrorSettings.IncorrectInputClientUrlCode; errorResponse.Message = ErrorSettings.IncorrectInputClientUrlMessage; } //else if (int.Parse(ConstantStrings.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) == methodNumber || // int.Parse(ConstantStrings.ProvisionMatterAssignContentType, CultureInfo.InvariantCulture) == methodNumber || // int.Parse(ConstantStrings.ProvisionMatterUpdateMetadataForList, CultureInfo.InvariantCulture) == methodNumber) //{ // if (string.IsNullOrWhiteSpace(client.Id)) // { // result = string.Format(CultureInfo.InvariantCulture, ConstantStrings.ServiceResponse, // TextConstants.IncorrectInputClientIdCode, TextConstants.IncorrectInputClientIdMessage); // } // else if (string.IsNullOrWhiteSpace(client.Name)) // { // result = string.Format(CultureInfo.InvariantCulture, // ConstantStrings.ServiceResponse, TextConstants.IncorrectInputClientNameCode, // TextConstants.IncorrectInputClientNameMessage); // } //} return errorResponse; }
/// <summary> /// This method will get all content types from the specified content type group and will filter out the content types that user has selected /// when creating the matter /// </summary> /// <param name="clientContext">The sharepoint context object</param> /// <param name="contentTypesNames">Content Type Names that user selected in the create matter screen</param> /// <param name="client">The client object which contains information for which client the matter is getting created and the url of the client</param> /// <param name="matter">The matter information that is getting created</param> /// <returns></returns> public IList<ContentType> GetContentTypeData(ClientContext clientContext, IList<string> contentTypesNames, Client client, Matter matter) { ContentTypeCollection contentTypeCollection = null; IList<ContentType> selectedContentTypeCollection = new List<ContentType>(); try { if (null != clientContext && null != contentTypesNames) { Web web = clientContext.Web; string contentTypeName = contentTypesConfig.OneDriveContentTypeGroup.Trim(); contentTypeCollection = web.ContentTypes; clientContext.Load(contentTypeCollection, contentType => contentType.Include(thisContentType => thisContentType.Name).Where(currContentType => currContentType.Group == contentTypeName)); clientContext.ExecuteQuery(); selectedContentTypeCollection = GetContentTypeList(contentTypesNames, contentTypeCollection.ToList()); } } catch (Exception exception) { customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable); throw; } return selectedContentTypeCollection; }
/// <summary> /// This method will get user profile picture of the login user /// </summary> /// <param name="client"></param> /// <returns></returns> public async Task<Users> GetUserProfilePicture(Client client) { Users users = new Users(); try { string accessToken = spoAuthorization.GetGraphAccessToken(); using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); var url = $"{generalSettings.GraphUrl}/v1.0/me/photo/$value"; var resultAsString = await httpClient.GetStreamAsync(url); using (var newStream = new MemoryStream()) { resultAsString.CopyTo(newStream); byte[] bytes = newStream.ToArray(); users.LargePictureUrl = ServiceConstants.BASE64_IMAGE_FORMAT + Convert.ToBase64String(bytes); } return users; } } catch(Exception ex) when(ex.Message.Contains("404")) { users.LargePictureUrl = ""; return users; } catch (Exception ex) { throw; } }
public GenericResponseVM CheckSecurityGroupInTeamMembers(Client client, Matter matter, IList<string> userId) { try { GenericResponseVM genericResponse = null; int securityGroupRowNumber = -1; // Blocked user field has security group List<Tuple<int, Principal>> teamMemberPrincipalCollection = new List<Tuple<int, Principal>>(); if (null != matter && null != matter.AssignUserNames && null != matter.BlockUserNames) { teamMemberPrincipalCollection = matterRespository.CheckUserSecurity(client, matter, userId); foreach (Tuple<int, Principal> teamMemberPrincipal in teamMemberPrincipalCollection) { Principal currentTeamMemberPrincipal = teamMemberPrincipal.Item2; if (currentTeamMemberPrincipal.PrincipalType == PrincipalType.SecurityGroup) { securityGroupRowNumber = teamMemberPrincipal.Item1; return ServiceUtility.GenericResponse(errorSettings.ErrorCodeSecurityGroupExists, errorSettings.ErrorMessageSecurityGroupExists + ServiceConstants.DOLLAR + userId[securityGroupRowNumber]); } } } else { return ServiceUtility.GenericResponse(errorSettings.IncorrectTeamMembersCode, errorSettings.IncorrectTeamMembersMessage); } return genericResponse; } catch (Exception) { throw; } }
public string GetCurrentSite(Client client) { clientContext = spoAuthorization.GetClientContext(client.Url); var spWeb = clientContext.Web; clientContext.Load(spWeb); clientContext.ExecuteQuery(); return spWeb.Title.ToString(); }
/// <summary> /// /// </summary> /// <param name="client"></param> /// <returns></returns> public Users GetUserProfilePicture(Client client) { try { return userDetails.GetUserProfilePicture(client).Result; } catch(Exception ex) { throw; } }
public async void Get_UserProfile_Picture() { var matterClient = new Client() { Url = "https://msmatter.sharepoint.com" }; using (var client = testServer.CreateClient().AcceptJson()) { var response = await client.PostAsJsonAsync("http://localhost:44323/api/v1/user/getuserprofilepicture", matterClient); var result = response.Content.ReadAsJsonAsync<GenericResponseVM>().Result; Assert.NotNull(result); } }
public async void Get_Roles() { var matterClient = new Client() { Url = "https://msmatter.sharepoint.com/sites/catalog" }; using (var client = testServer.CreateClient().AcceptJson()) { var response = await client.PostAsJsonAsync("http://localhost:44323/api/v1/user/getroles", matterClient); var result = response.Content.ReadAsJsonAsync<IList<Role>>().Result; Assert.NotNull(result); } }
public async void Test_Doc_Attachment() { var attachments = new List<AttachmentDetails>(); AttachmentDetails attachmentDetails = new AttachmentDetails() { attachmentType = "0", name = "program to modify MARCH2016.docx", originalName = "program to modify MARCH2016.docx", isInline = false, contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", id = "AAMkADFmMzhhNmQ2LWFmYTQtNGE3YS1hODdiLWQ2NGMyNTg0OGY5ZgBGAAAAAAAfTUpGeW9YQ4uc53qRcWuoBwCtg7dRFpaYTr7nouEpW+c6AAAAAAEMAACtg7dRFpaYTr7nouEpW+c6AAAE+eM8AAABEgAQAGDuo5aZZdBAnm7TVKY1EoE=", size = 335497 }; attachments.Add(attachmentDetails); var foldePath = new List<string>(); foldePath.Add("/sites/microsoft/1C0B1194EBF746DE829B8432A130EED3/Documents"); var serviceRequestVM = new ServiceRequest() { AllowContentCheck = true, AttachmentToken = "eyJpc3MiOiIwMDAwMDAwMi0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDBAM2M0NTYyY2EtMzlhNC00ZDhiLTkxZmYtNmQzZWVmYWI1YzFkIiwiYXVkIjoiMDAwMDAwMDItMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwL291dGxvb2sub2ZmaWNlMzY1LmNvbUAzYzQ1NjJjYS0zOWE0LTRkOGItOTFmZi02ZDNlZWZhYjVjMWQiLCJuYmYiOjE0NjM0MjMwODcsImV4cCI6MTQ2MzQyMzM4NywibmFtZWlkIjoiMTA3OGNjMjQtZTg5Yy00OGY4LWFmYTEtY2IzMzIxNjM2OTY2QDNjNDU2MmNhLTM5YTQtNGQ4Yi05MWZmLTZkM2VlZmFiNWMxZCIsInZlciI6IkV4Y2hhbmdlLkNhbGxiYWNrLlYxIiwiYXBwY3R4c2VuZGVyIjoiaHR0cHM6Ly9tYXR0ZXJ3ZWJhcHAuYXp1cmV3ZWJzaXRlcy5uZXRAM2M0NTYyY2EtMzlhNC00ZDhiLTkxZmYtNmQzZWVmYWI1YzFkIiwiYXBwY3R4Ijoie1wib2lkXCI6XCI5MzNjZTFmZC0yNjkzLTRhYWUtYjdiYS0yYTBiNjhlNDEwMjlcIixcInB1aWRcIjpcIjEwMDNCRkZEOTc3QTM4REJcIixcInNtdHBcIjpcIm1hdHRlcmFkbWluQE1TbWF0dGVyLm9ubWljcm9zb2Z0LmNvbVwiLFwidXBuXCI6XCJtYXR0ZXJhZG1pbkBNU21hdHRlci5vbm1pY3Jvc29mdC5jb21cIixcInNjb3BlXCI6XCJQYXJlbnRJdGVtSWQ6QUFNa0FERm1NemhoTm1RMkxXRm1ZVFF0TkdFM1lTMWhPRGRpTFdRMk5HTXlOVGcwT0dZNVpnQkdBQUFBQUFBZlRVcEdlVzlZUTR1YzUzcVJjV3VvQndDdGc3ZFJGcGFZVHI3bm91RXBXK2M2QUFBQUFBRU1BQUN0ZzdkUkZwYVlUcjdub3VFcFcrYzZBQUFKZ1JvS0FBQT1cIn0ifQ.b1emwSawJwObcPJ5i8t4Y2GpYgmYyjxMtX-CkTmO72S6nhroYI1fqe_VlCjzkkGBvmRQ6BZslYaukem3mh_GPQAJAhOCcmFx5lVxJ3Ttivol-PHLMoQWUf9DloDo0_nIENLm9LFwqvYK2Yhp5zNTF9TMu7PDcuw2dKbTZqTQUm99y-ajqNx1tj1Zu23iXJj--DEjXdzSDtPzoAOhWyvq9c4WuvSbE07bXtXpIe0hf_A3MO7L4W2ERuJuiDmA_E1YanxzD9iSrN1vlSbLHdRI_hoqON0i3vUUjDYyeW5qNvpOLJfy48Uz5p1Tx_arIL5HXkHv6mI31jXwY8B3okzGJg", Attachments = attachments, EwsUrl = new System.Uri("https://outlook.office365.com/EWS/Exchange.asmx"), DocumentLibraryName = "Matter For Debugging Unit", FolderPath= foldePath, MailId= "AAMkADFmMzhhNmQ2LWFmYTQtNGE3YS1hODdiLWQ2NGMyNTg0OGY5ZgBGAAAAAAAfTUpGeW9YQ4uc53qRcWuoBwCtg7dRFpaYTr7nouEpW+c6AAAAAAEMAACtg7dRFpaYTr7nouEpW+c6AAAE+eM8AAA=", PerformContentCheck=false, Overwrite=false, Subject= "Test email" }; var matterClient = new Client() { Url = "https://msmatter.sharepoint.com/sites/microsoft" }; var attachmentRequestVM = new AttachmentRequestVM() { ServiceRequest = serviceRequestVM, Client = matterClient }; using (var client = testServer.CreateClient().AcceptJson()) { var response = await client.PostAsJsonAsync("http://localhost:44323/api/v1/document/uploadattachments", attachmentRequestVM); var result = response.Content.ReadAsStringAsync().Result; Assert.NotNull(result); } }
public async void No_User_Pinned_Matter_Found() { var client = new Client() { Url = "https://microsoft.sharepoint.com/teams/mcuisite" }; using (var testClient = testServer.CreateClient().AcceptJson()) { var response = await testClient.PostAsJsonAsync("http://localhost:58775/api/v1/matter/getpinnedmatters", client); var result = response.Content.ReadAsJsonAsync<ErrorResponse>().Result; Assert.NotNull(result); Assert.Equal("404", result.ErrorCode); } }
/// <summary> /// This method will validate the client object and if there are any errors in the client inout object, the method will /// return ErrorResponse object or it will return null /// </summary> /// <param name="client">Contains the information such as ClientId, ClientUrl etc</param> /// <returns>ErrorResponse</returns> internal static ErrorResponse TaxonomyValidation(Client client) { if(client!=null) { return ValidateClientInformation(client, 0); } else { ErrorResponse errorResponse = new ErrorResponse(); errorResponse.ErrorCode = ""; errorResponse.Message = ErrorSettings.MessageNoInputs; return errorResponse; } return null; }
/// <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; }
public async void Get_User_Pinned_Matter() { var client = new Client() { Id = "123456", Name = "Microsoft", Url = "https://msmatter.sharepoint.com/sites/catalog" }; using (var testClient = testServer.CreateClient().AcceptJson()) { var response = await testClient.PostAsJsonAsync("http://localhost:58775/api/v1/matter/getpinned", client); var result = response.Content.ReadAsJsonAsync<SearchResponseVM>().Result; Assert.NotNull(result); Assert.NotNull(result.MatterDataList); Assert.NotEmpty(result.MatterDataList); } }
public async Task<IActionResult> UrlExists(Client client, string oneNoteUrl, string matterLandingPageUrl) { string result = string.Empty; try { spoAuthorization.AccessToken = HttpContext.Request.Headers["Authorization"]; #region Error Checking ErrorResponse errorResponse = null; //if the token is not valid, immediately return no authorization error to the user if (errorResponse != null && !errorResponse.IsTokenValid) { return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.Unauthorized); } if (client == null && string.IsNullOrEmpty(oneNoteUrl) && string.IsNullOrEmpty(matterLandingPageUrl)) { errorResponse = new ErrorResponse() { Message = errorSettings.MessageNoInputs, ErrorCode = HttpStatusCode.BadRequest.ToString(), Description = "No input data is passed" }; return matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.NotFound); } #endregion var oneNoteUrlExists = await sharedRepository.UrlExistsAsync(client, oneNoteUrl); var matterLandingUrlExists = await sharedRepository.UrlExistsAsync(client, matterLandingPageUrl); var urlExists = new { OneNoteExists = oneNoteUrlExists, MatterLandingExists = matterLandingUrlExists }; return matterCenterServiceFunctions.ServiceResponse(urlExists, (int)HttpStatusCode.OK); } catch (Exception exception) { customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable); throw; } }
/// <summary> /// This method will assign content types to the matter that is getting created /// </summary> /// <param name="matterMetadata"></param> /// <param name="clientContext"></param> /// <param name="contentTypeCollection"></param> /// <param name="client"></param> /// <param name="matter"></param> /// <returns></returns> public GenericResponseVM AssignContentTypeHelper(MatterMetadata matterMetadata, ClientContext clientContext, IList<ContentType> contentTypeCollection, Client client, Matter matter) { try { Web web = clientContext.Web; List matterList = web.Lists.GetByTitle(matter.Name); SetFieldValues(clientContext, contentTypeCollection, matterList, matterMetadata); clientContext.ExecuteQuery(); SetDefaultContentType(clientContext, matterList, client, matter); string[] viewColumnList = contentTypesConfig.ViewColumnList.Split(new string[] { ServiceConstants.SEMICOLON }, StringSplitOptions.RemoveEmptyEntries).Select(listEntry => listEntry.Trim()).ToArray(); string strQuery = string.Format(CultureInfo.InvariantCulture, camlQueries.ViewOrderByQuery, contentTypesConfig.ViewOrderByColumn); bool isViewCreated = spList.AddView(clientContext, matterList, viewColumnList, contentTypesConfig.ViewName, strQuery); return ServiceUtility.GenericResponse(string.Empty, Convert.ToString(isViewCreated, CultureInfo.CurrentCulture).ToLower(CultureInfo.CurrentCulture)); } catch (Exception exception) { customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable); throw; } }
/// <summary> /// Function to validate client information /// </summary> /// <param name="client">Client object</param> /// <param name="methodNumber">Number indicating which method needs to be validated</param> /// <returns>String that contains error message</returns> internal GenericResponseVM ValidateClientInformation(Client client, int methodNumber) { GenericResponseVM response = new GenericResponseVM(); if (string.IsNullOrWhiteSpace(client.Url)) { response.Code = errorSettings.IncorrectInputClientUrlCode; response.Value = errorSettings.IncorrectInputClientUrlMessage; } else 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(client.Id)) { response.Code = errorSettings.IncorrectInputClientIdCode; response.Value = errorSettings.IncorrectInputClientIdMessage; } else if (string.IsNullOrWhiteSpace(client.Name)) { response.Code = errorSettings.IncorrectInputClientNameCode; response.Value = errorSettings.IncorrectInputClientNameMessage; } } return response; }
/// <summary> /// This method will get all permissions levels that are configured for a given site collection /// </summary> /// <param name="client"></param> /// <returns></returns> public async Task<IList<Role>> GetPermissionLevelsAsync(Client client) { IList<Role> roles = new List<Role>(); List<RoleDefinition> roleDefinitions = await Task.FromResult(search.GetWebRoleDefinitions(client)); if (roleDefinitions.Count != 0) { foreach (RoleDefinition role in roleDefinitions) { Role tempRole = new Role(); tempRole.Name = role.Name; tempRole.Id = Convert.ToString(role.Id, CultureInfo.InvariantCulture); roles.Add(tempRole); } } return roles; }
/// <summary> /// Thios method will get all roles such as attorney journal etc which are configured in the catalog site collection /// </summary> /// <param name="client"></param> /// <returns>async Task<IList<Role>></returns> public async Task<IList<Role>> GetRolesAsync(Client client) { IList<Role> roles = new List<Role>(); ListItemCollection collListItem = await Task.FromResult(spList.GetData(client, listNames.DMSRoleListName, camlQueries.DMSRoleQuery)); if (null != collListItem && 0 != collListItem.Count) { foreach (ListItem item in collListItem) { Role tempRole = new Role(); tempRole.Id = Convert.ToString(item[matterSettings.ColumnNameGuid], CultureInfo.InvariantCulture); tempRole.Name = Convert.ToString(item[matterSettings.RoleListColumnRoleName], CultureInfo.InvariantCulture); tempRole.Mandatory = Convert.ToBoolean(item[matterSettings.RoleListColumnIsRoleMandatory], CultureInfo.InvariantCulture); roles.Add(tempRole); } } return roles; }
/// <summary> /// Configures XML code of List View web part. /// </summary> /// <param name="requestObject">Request Object</param> /// <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 string ConfigureListViewWebPart(List sitePageLib, ClientContext clientContext, string pageName, Client client, Matter matter, string titleUrl) { string viewName = string.Empty; string result = string.Empty; try { Uri uri = new Uri(client.Url); ViewCollection viewColl = sitePageLib.Views; clientContext.Load( viewColl, views => views.Include( view => view.Title, view => view.Id)); clientContext.ExecuteQuery(); foreach (View view in viewColl) { viewName = Convert.ToString(view.Id, CultureInfo.InvariantCulture); break; } viewName = string.Concat(ServiceConstants.OPENING_CURLY_BRACE, viewName, ServiceConstants.CLOSING_CURLY_BRACE); string listViewWebPart = ServiceConstants.LIST_VIEW_WEBPART; listViewWebPart = string.Format(CultureInfo.InvariantCulture, listViewWebPart, Convert.ToString(sitePageLib.Id, CultureInfo.InvariantCulture), titleUrl, string.Concat(ServiceConstants.OPENING_CURLY_BRACE, Convert.ToString(sitePageLib.Id, CultureInfo.InvariantCulture), ServiceConstants.CLOSING_CURLY_BRACE), viewName, string.Concat(uri.AbsolutePath, ServiceConstants.FORWARD_SLASH, matter.Name, ServiceConstants.FORWARD_SLASH, pageName)); result = listViewWebPart; } catch (Exception exception) { customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable); throw; } return result; }
public async void Test_Mail_Attachment() { #region New Code Data //var attachments = new List<AttachmentDetails>(); //AttachmentDetails attachmentDetails = new AttachmentDetails() //{ // attachmentType = "0", // name= "program to modify MARCH2016.docx", // originalName= "program to modify MARCH2016.docx", // isInline= false, // contentType= "application/vnd.openxmlformats-officedocument.wordprocessingml.document", // id= "AAMkADFmMzhhNmQ2LWFmYTQtNGE3YS1hODdiLWQ2NGMyNTg0OGY5ZgBGAAAAAAAfTUpGeW9YQ4uc53qRcWuoBwCtg7dRFpaYTr7nouEpW+c6AAAAAAEMAACtg7dRFpaYTr7nouEpW+c6AAAJgRoKAAABEgAQAJ0HuxfoKzZCt0IGCqWvGxE=", // size= 335497 //}; //attachments.Add(attachmentDetails); //var foldePath = new List<string>(); //foldePath.Add("/sites/microsoft/12e53e87cbc16d97763d4e87f1fbb8f9/Emails"); //var serviceRequestVM = new ServiceRequest() //{ // AllowContentCheck = true, // AttachmentToken = "", // Attachments = attachments, // EwsUrl = new System.Uri("https://outlook.office365.com/EWS/Exchange.asmx"), // DocumentLibraryName = "testerV123", // FolderPath = foldePath, // MailId = "AAMkADFmMzhhNmQ2LWFmYTQtNGE3YS1hODdiLWQ2NGMyNTg0OGY5ZgBGAAAAAAAfTUpGeW9YQ4uc53qRcWuoBwCtg7dRFpaYTr7nouEpW+c6AAAAAAEMAACtg7dRFpaYTr7nouEpW+c6AAAJgRoKAAA=", // PerformContentCheck = false, // Overwrite = false, // Subject = "Test attachments.eml" //}; //var matterClient = new Client() //{ // Url = "https://msmatter.sharepoint.com/sites/microsoft" //}; //var attachmentRequestVM = new AttachmentRequestVM() //{ // ServiceRequest = serviceRequestVM, // Client = matterClient //}; #endregion #region Old Code Data var attachments = new List<AttachmentDetails>(); AttachmentDetails attachmentDetails = new AttachmentDetails() { attachmentType = "0", name = "program to modify MARCH2016.docx", isInline = false, contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", id = "AAMkADFmMzhhNmQ2LWFmYTQtNGE3YS1hODdiLWQ2NGMyNTg0OGY5ZgBGAAAAAAAfTUpGeW9YQ4uc53qRcWuoBwCtg7dRFpaYTr7nouEpW+c6AAAAAAEMAACtg7dRFpaYTr7nouEpW+c6AAAJgRoKAAABEgAQAJ0HuxfoKzZCt0IGCqWvGxE=", size = 335497 }; attachments.Add(attachmentDetails); var foldePath = new List<string>(); foldePath.Add("/sites/microsoft/12e53e87cbc16d97763d4e87f1fbb8f9/Emails"); var serviceRequestVM = new ServiceRequest() { AllowContentCheck = true, AttachmentToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IkkzTDVfM3pTRVZPT3RmQmZFTGpXRmMwaFNwWSJ9.eyJpc3MiOiIwMDAwMDAwMi0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDBAM2M0NTYyY2EtMzlhNC00ZDhiLTkxZmYtNmQzZWVmYWI1YzFkIiwiYXVkIjoiMDAwMDAwMDItMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwL291dGxvb2sub2ZmaWNlMzY1LmNvbUAzYzQ1NjJjYS0zOWE0LTRkOGItOTFmZi02ZDNlZWZhYjVjMWQiLCJuYmYiOjE0NjM0NDEwMjIsImV4cCI6MTQ2MzQ0MTMyMiwibmFtZWlkIjoiMTA3OGNjMjQtZTg5Yy00OGY4LWFmYTEtY2IzMzIxNjM2OTY2QDNjNDU2MmNhLTM5YTQtNGQ4Yi05MWZmLTZkM2VlZmFiNWMxZCIsInZlciI6IkV4Y2hhbmdlLkNhbGxiYWNrLlYxIiwiYXBwY3R4c2VuZGVyIjoiaHR0cHM6Ly9tYXR0ZXJ3ZWJhcHAuYXp1cmV3ZWJzaXRlcy5uZXRAM2M0NTYyY2EtMzlhNC00ZDhiLTkxZmYtNmQzZWVmYWI1YzFkIiwiYXBwY3R4Ijoie1wib2lkXCI6XCI5MzNjZTFmZC0yNjkzLTRhYWUtYjdiYS0yYTBiNjhlNDEwMjlcIixcInB1aWRcIjpcIjEwMDNCRkZEOTc3QTM4REJcIixcInNtdHBcIjpcIm1hdHRlcmFkbWluQE1TbWF0dGVyLm9ubWljcm9zb2Z0LmNvbVwiLFwidXBuXCI6XCJtYXR0ZXJhZG1pbkBNU21hdHRlci5vbm1pY3Jvc29mdC5jb21cIixcInNjb3BlXCI6XCJQYXJlbnRJdGVtSWQ6QUFNa0FERm1NemhoTm1RMkxXRm1ZVFF0TkdFM1lTMWhPRGRpTFdRMk5HTXlOVGcwT0dZNVpnQkdBQUFBQUFBZlRVcEdlVzlZUTR1YzUzcVJjV3VvQndDdGc3ZFJGcGFZVHI3bm91RXBXK2M2QUFBQUFBRU1BQUN0ZzdkUkZwYVlUcjdub3VFcFcrYzZBQUFKZ1JvS0FBQT1cIn0ifQ.JHVTqrNjDmwaJ2mZyiZ17GkAqILQywSH6Ac2wfH8DcEvIpwAZ_SztjlGlRQ9dysIxEqQxeO5Enb2Lin_jl1490EDGpZ4pN_go9ank5NcIZzxJP8WegjUzhtIcEilGIJuAwXTPXPoA0MUzhQN9JF9fUo5E63GncDzOKKrlvDT1dZmtrBqikvM1llmeOfNWLkGA_2qxjLzWam8gv9PZDTCAF_0TPoy8RaEJ5mwwHFos0KlA5R6__GW5fayS_tt8Y4Wd62Oo1JF-fePErrYa8g_n9fB3J_NsR1pDPtPVXvVYtK4A42iPvkvYwIZjcCDx5f-OPn_QXkY_wTaTpIUOlTPug", Attachments = attachments, EwsUrl = new System.Uri("https://outlook.office365.com/EWS/Exchange.asmx"), DocumentLibraryName = "testerV123", FolderPath = foldePath, MailId = "AAMkADFmMzhhNmQ2LWFmYTQtNGE3YS1hODdiLWQ2NGMyNTg0OGY5ZgBGAAAAAAAfTUpGeW9YQ4uc53qRcWuoBwCtg7dRFpaYTr7nouEpW+c6AAAAAAEMAACtg7dRFpaYTr7nouEpW+c6AAAJgRoKAAA=", PerformContentCheck = false, Overwrite = false, Subject = "Test attachments.eml" }; var matterClient = new Client() { Url = "https://msmatter.sharepoint.com/sites/microsoft" }; var attachmentRequestVM = new AttachmentRequestVM() { ServiceRequest = serviceRequestVM, Client = matterClient }; #endregion using (var client = testServer.CreateClient().AcceptJson()) { var response = await client.PostAsJsonAsync("http://localhost:44323/api/v1/document/uploadmail", attachmentRequestVM); var result = response.Content.ReadAsStringAsync().Result; Assert.NotNull(result); } }
/// <summary> /// This method will check whether user exists in a sharepoint site or not /// </summary> /// <param name="clientUrl"></param> /// <param name="email"></param> /// <returns>bool</returns> public bool CheckUserPresentInMatterCenter(Client client) { return userDetails.CheckUserPresentInMatterCenter(client.Url, client.Name); }
/// <summary> /// This method will check whether login user is part of owner group or not /// </summary> /// <param name="client"></param> /// <returns></returns> public bool IsLoginUserOwner(Client client)=> userDetails.IsLoginUserOwner(client);
/// <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; }
/// <summary> /// Reverts the permission of users from matter, OneNote, Calendar libraries and matter landing page /// </summary> /// <param name="requestObject">Request object</param> /// <param name="client">Client object</param> /// <param name="matter">Matter object</param> /// <param name="clientContext">ClientContext object</param> /// <param name="matterRevertListObject">MatterRevertObjectList object</param> /// <param name="loggedInUserTitle">Logged-in user title</param> /// <param name="oldUserPermissions">Old library users</param> /// <param name="matterLandingPageId">List item id</param> /// <param name="isEditMode">Add/ Edit mode</param> /// <returns>Status of operation</returns> public bool RevertMatterUpdates(Client client, Matter matter, ClientContext clientContext, MatterRevertList matterRevertListObject, string loggedInUserTitle, IEnumerable<RoleAssignment> oldUserPermissions, int matterLandingPageId, bool isEditMode) { bool result = false; try { if (null != client && null != matter && null != clientContext && null != matterRevertListObject) { List<string> users = new List<string>(); users = matter.AssignUserNames.SelectMany(user => user).Distinct().ToList(); // Remove recently added users if (null != matterRevertListObject.MatterLibrary) { SPList.RemoveSpecificUsers(clientContext, users, loggedInUserTitle, false, matterRevertListObject.MatterLibrary, -1); } if (null != matterRevertListObject.MatterCalendar) { SPList.RemoveSpecificUsers(clientContext, users, loggedInUserTitle, false, matterRevertListObject.MatterCalendar, -1); } if (null != matterRevertListObject.MatterOneNoteLibrary) { SPList.RemoveSpecificUsers(clientContext, users, loggedInUserTitle, false, matterRevertListObject.MatterOneNoteLibrary, -1); } if (null != matterRevertListObject.MatterTask) { SPList.RemoveSpecificUsers(clientContext, users, loggedInUserTitle, false, matterRevertListObject.MatterTask, -1); } if (null != matterRevertListObject.MatterSitePages) { SPList.RemoveSpecificUsers(clientContext, users, loggedInUserTitle, true, matterRevertListObject.MatterSitePages, matterLandingPageId); } if (isEditMode) { Matter matterRevertUserPermission = PrepareUserPermission(oldUserPermissions); if (null != matterRevertListObject.MatterLibrary) { result = SPList.SetPermission(clientContext, matterRevertUserPermission.AssignUserNames, matterRevertUserPermission.Permissions, matterRevertListObject.MatterLibrary); } if (null != matterRevertListObject.MatterOneNoteLibrary) { result = SPList.SetPermission(clientContext, matterRevertUserPermission.AssignUserNames, matterRevertUserPermission.Permissions, matterRevertListObject.MatterOneNoteLibrary); } if (null != matterRevertListObject.MatterCalendar) { result = SPList.SetPermission(clientContext, matterRevertUserPermission.AssignUserNames, matterRevertUserPermission.Permissions, matterRevertListObject.MatterCalendar); } if (null != matterRevertListObject.MatterTask) { result = SPList.SetPermission(clientContext, matterRevertUserPermission.AssignUserNames, matterRevertUserPermission.Permissions, matterRevertListObject.MatterTask); } if (null != matterRevertListObject.MatterSitePages && 0 <= matterLandingPageId) { result = SPList.SetItemPermission(clientContext, matterRevertUserPermission.AssignUserNames, "Site Pages", matterLandingPageId, matterRevertUserPermission.Permissions); } } } return result; } catch (Exception exception) { //Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstants.LogTableName); } // To avoid the invalid symbol error while parsing the JSON, return the response in lower case return result; }
/// <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; }
private Dictionary<string, string> ContinueUpload(IFormFile uploadedFile, string fileExtension) { Dictionary<string, string> mailProperties = new Dictionary<string, string> { { ServiceConstants.MAIL_SENDER_KEY, string.Empty }, { ServiceConstants.MAIL_RECEIVER_KEY, string.Empty }, { ServiceConstants.MAIL_RECEIVED_DATEKEY, string.Empty }, { ServiceConstants.MAIL_CC_ADDRESS_KEY, string.Empty }, { ServiceConstants.MAIL_ATTACHMENT_KEY, string.Empty }, { ServiceConstants.MAIL_SEARCH_EMAIL_SUBJECT, string.Empty }, { ServiceConstants.MAIL_SEARCH_EMAIL_FROM_MAILBOX_KEY, string.Empty }, { ServiceConstants.MAIL_FILE_EXTENSION_KEY, fileExtension }, { ServiceConstants.MAIL_IMPORTANCE_KEY, string.Empty}, { ServiceConstants.MAIL_CONVERSATIONID_KEY, string.Empty}, { ServiceConstants.MAIL_CONVERSATION_TOPIC_KEY, string.Empty}, { ServiceConstants.MAIL_SENT_DATE_KEY, string.Empty}, { ServiceConstants.MAIL_HAS_ATTACHMENTS_KEY, string.Empty}, { ServiceConstants.MAIL_SENSITIVITY_KEY, string.Empty }, { ServiceConstants.MAIL_CATEGORIES_KEY, string.Empty }, { ServiceConstants.MailOriginalName, string.Empty} }; if (string.Equals(fileExtension, ServiceConstants.EMAIL_FILE_EXTENSION, StringComparison.OrdinalIgnoreCase)) { var client = new Client() { Url = generalSettings.CentralRepositoryUrl }; Users currentUserDetail = userRepository.GetLoggedInUserDetails(client); mailProperties[ServiceConstants.MAIL_SEARCH_EMAIL_FROM_MAILBOX_KEY] = currentUserDetail.Name; Stream fileStream = uploadedFile.OpenReadStream(); mailProperties = MailMessageParser.GetMailFileProperties(fileStream, mailProperties); // Reading properties only for .eml file } return mailProperties; }
/// <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; }
/// <summary> /// Sets the default content type based on user selection for the new matter that is getting created /// </summary> /// <param name="clientContext">SP client context</param> /// <param name="list">Name of the list</param> /// <param name="requestObject">Request Object</param> /// <param name="client">Client Object</param> /// <param name="matter">Matter Object</param> private void SetDefaultContentType(ClientContext clientContext, List list, Client client, Matter matter) { int contentCount = 0, contentSwap = 0; try { ContentTypeCollection currentContentTypeOrder = list.ContentTypes; clientContext.Load(currentContentTypeOrder); clientContext.ExecuteQuery(); IList<ContentTypeId> updatedContentTypeOrder = new List<ContentTypeId>(); foreach (ContentType contentType in currentContentTypeOrder) { if (0 == string.Compare(contentType.Name, matter.DefaultContentType, StringComparison.OrdinalIgnoreCase)) { contentSwap = contentCount; } if (0 != string.Compare(contentType.Name, contentTypesConfig.HiddenContentType, StringComparison.OrdinalIgnoreCase)) { updatedContentTypeOrder.Add(contentType.Id); contentCount++; } } if (updatedContentTypeOrder.Count > contentSwap) { ContentTypeId documentContentType = updatedContentTypeOrder[0]; updatedContentTypeOrder[0] = updatedContentTypeOrder[contentSwap]; updatedContentTypeOrder.RemoveAt(contentSwap); updatedContentTypeOrder.Add(documentContentType); } list.RootFolder.UniqueContentTypeOrder = updatedContentTypeOrder; list.RootFolder.Update(); list.Update(); clientContext.ExecuteQuery(); } catch (Exception exception) { customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable); throw; } }
/// <summary> /// Will check whether a url exists in the current site collection or not /// </summary> /// <param name="client">Contains the url in which we need to check whether a page exists or not</param> /// <param name="pageUrl">The page</param> /// <returns></returns> public bool UrlExists(Client client, string pageUrl) { bool pageExists = false; try { using (ClientContext clientContext = spoAuthorization.GetClientContext(client.Url)) { string[] requestedUrls = pageUrl.Split(new string[] { ServiceConstants.DOLLAR + ServiceConstants.PIPE + ServiceConstants.DOLLAR }, StringSplitOptions.RemoveEmptyEntries); if (1 < requestedUrls.Length) { foreach (string url in requestedUrls) { if (IsFileExists(clientContext, url)) { pageExists = true; break; } } } else { pageExists = IsFileExists(clientContext, pageUrl) ? true : false; } } return pageExists; } catch(Exception ex) { customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable); throw; } }
/// <summary> /// /// </summary> /// <param name="clientContext"></param> /// <returns></returns> public Users GetLoggedInUserDetails(Client client) => userDetails.GetLoggedInUserDetails(client);