Provides the structure required to hold additional matter meta-data for default values from term store. It includes term store information for matter, client, practice group, area of law and sub area of law.
Esempio n. 1
0
 /// <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;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Function to get the WssID for all the managed columns that user has configured
 /// </summary>
 /// <param name="clientContext">SP client context</param>
 /// <param name="matterMetadata">Object containing meta data for Matter</param>
 /// <param name="fields">Field Collection object</param>
 /// <returns>An Object containing meta data for Matter</returns>
 private MatterMetadata GetWSSId(ClientContext clientContext, MatterMetadata matterMetadata, FieldCollection fields)
 {
     try
     {
         int levels = taxonomySettings.Levels;
         //For the number of levels that are configured, get the configured column name for each level and get the wssid and 
         //update the ManagedColumnTerms object with wssid
         for (int i = 1; i <= levels; i++)
         {
             string columnName = configuration.GetSection("ContentTypes").GetSection("ManagedColumns")["ColumnName" + i];
             ClientResult<TaxonomyFieldValue> managedColumnWSSId = clientContext.CastTo<TaxonomyField>
             (fields.GetByInternalNameOrTitle(columnName))
             .GetFieldValueAsTaxonomyFieldValue(matterMetadata.ManagedColumnTerms[columnName].Id);
             clientContext.ExecuteQuery();
             matterMetadata.ManagedColumnTerms[columnName].WssId = managedColumnWSSId.Value.WssId;
         }
         return matterMetadata;
     }
     catch(Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         throw ex;
     }
 }
Esempio n. 3
0
        public async void Create_Matter()
        {
            #region Create Matter Data
            string matterGuid = "1C0B1194EBF746DE829B8432A130EED3";

            var userIds = new List<string>();
            userIds.Add("txtAssign1");

            var blockUserNames = new List<string>();
            blockUserNames.Add("*****@*****.**");

            var assignUserNames = new List<IList<string>>();
            var userNames = new List<string>();
            userNames.Add("Premchand peddakotla");
            userNames.Add("");
            assignUserNames.Add(userNames);


            var assignUserEmails = new List<IList<string>>();
            var userEmails = new List<string>();
            userEmails.Add("*****@*****.**");
            userEmails.Add("");
            assignUserEmails.Add(userNames);

            var roles = new List<string>();
            roles.Add("Responsible Attorney");

            var folderNames = new List<string>();
            folderNames.Add("Emails");
            folderNames.Add("Documents");


            var matterMetaDataVM = new MatterMetdataVM()
            {
                Matter = new Matter()
                {
                    Name = "Matter For Debugging Unit",
                    Id = "Debug12341",
                    Description = "Matter for debugging Unit",
                    Conflict = new Conflict()
                    {
                        Identified = "True",
                        CheckBy = "*****@*****.**",
                        CheckOn = "05/03/2016",
                        SecureMatter = "True"
                    },
                    BlockUserNames = blockUserNames,
                    AssignUserNames = assignUserNames,
                    AssignUserEmails = assignUserEmails,
                    Roles = roles,
                    MatterGuid = matterGuid,
                    FolderNames = folderNames
                },
                Client = new Client()
                {
                    Id = "100001",
                    Name = "Microsoft",
                    Url = "https://msmatter.sharepoint.com/sites/microsoft"
                },
                MatterConfigurations = new MatterConfigurations()
                {
                    IsConflictCheck = true,
                    IsMatterDescriptionMandatory = true,
                    IsCalendarSelected = true,
                    IsTaskSelected = true
                },
                UserIds = userIds
            };
            #endregion

            #region Assign Content Type
            var contentTypes = new List<string>();
            contentTypes.Add("Copyright");
            contentTypes.Add("Patent");


            var assignContentTypeMetadata = new MatterMetadata()
            {
                Matter = new Matter()
                {
                    Name = "Matter For Debugging Unit",
                    Id = "Debug12341",
                    ContentTypes = contentTypes,
                    DefaultContentType = "Copyright",
                    MatterGuid =  matterGuid
                },
                Client = new Client()
                {
                    Url= "https://msmatter.sharepoint.com/sites/microsoft",
                    Name="Microsoft",
                    Id = "100001"
                },
                PracticeGroupTerm = new PracticeGroupTerm()
                {
                    TermName= "Litigation",
                    Id= "084887e6-3705-466c-823b-207563388464"
                },
                AreaTerm = new AreaTerm()
                {
                    TermName= "Intellectual Property",
                    Id= "162fb199-2f04-498d-a7ac-329a077bca9f"
                },
                SubareaTerm = new SubareaTerm()
                {
                    TermName = "Copyright",
                    Id = "15c5b16c-150b-4bf5-8470-59dfa951dcf8"
                }

            };

            #endregion

            #region Assign User Permission
            var permissions = new List<string>();
            permissions.Add("Full Control");


            var assignUserPermissionMetadataVM = new MatterMetdataVM()
            {
                Client = new Client()
                {
                    Url= "https://msmatter.sharepoint.com/sites/microsoft"
                },
                Matter = new Matter()
                {
                    Name= "Matter For Debugging Unit",
                    Permissions= permissions,
                    AssignUserNames= assignUserNames,
                    AssignUserEmails= assignUserEmails,
                    MatterGuid = matterGuid
                },
                MatterConfigurations = new MatterConfigurations()
                {
                    IsCalendarSelected = true,
                    IsTaskSelected = true
                }
            };
            #endregion

            #region Create Matter Landing Page
            var createMatterLandingPage = new MatterMetdataVM()
            {
                Client = new Client()
                {
                    Url = "https://msmatter.sharepoint.com/sites/microsoft"
                },
                MatterConfigurations = new MatterConfigurations()
                {
                    IsConflictCheck = true,
                    IsMatterDescriptionMandatory = true,
                    IsCalendarSelected = true,
                    IsRSSSelected = true,
                    IsTaskSelected = true
                },
                Matter = new Matter()
                {
                    Name = "Matter For Debugging Unit",                    
                    Description = "Matter for debugging Unit",
                    AssignUserNames = assignUserNames,
                    AssignUserEmails = assignUserEmails,
                    BlockUserNames = blockUserNames,
                    Conflict = new Conflict()
                    {
                        Identified = "True",
                        CheckBy = "*****@*****.**",
                        CheckOn = "05/03/2016",
                        SecureMatter = "True"
                    },
                    Permissions = permissions,
                    MatterGuid = matterGuid                    
                }
            };
            #endregion

            #region Update Matter Metadata
            
            var ct = new List<string>();
            ct.Add("Copyright");
            ct.Add("");

            var uploadBlockedUsers = new List<string>();
            var docTemplateCount = new List<string>();
            docTemplateCount.Add("1");

            var matterMetadata = new MatterMetdataVM()
            {
                Client = new Client()
                {
                    Id = "100001",
                    Name = "Microsoft",
                    Url = "https://msmatter.sharepoint.com/sites/microsoft"
                },
                Matter = new Matter()
                {
                    Name = "Matter For Debugging Unit",
                    Id = "Debug12341",
                    Description = "Matter for debugging Unit",
                    Conflict = new Conflict()
                    {
                        Identified = "True",
                        CheckBy = "*****@*****.**",
                        CheckOn = "05/03/2016",
                        SecureMatter = "True"
                    },
                    BlockUserNames = blockUserNames,
                    AssignUserNames = assignUserNames,
                    AssignUserEmails = assignUserEmails,
                    Roles = roles,
                    MatterGuid = matterGuid,
                    ContentTypes= ct,
                    DefaultContentType= "Copyright",
                    Permissions= permissions,
                    DocumentTemplateCount= docTemplateCount
                },
                MatterConfigurations = new MatterConfigurations()
                {
                    IsConflictCheck=true,
                    IsMatterDescriptionMandatory=true
                },
                MatterDetails = new MatterDetails()
                {
                    //PracticeGroup = "Litigation;",
                    //AreaOfLaw= "Intellectual Property;",
                    //SubareaOfLaw= "Copyright;",
                    ResponsibleAttorney= "SaiKiran Gudala;",
                    ResponsibleAttorneyEmail= "[email protected];",
                    UploadBlockedUsers= uploadBlockedUsers,
                    TeamMembers= "SaiKiran Gudala;",
                    RoleInformation= "{\"Responsible Attorney\":\"Venkat M([email protected])\"}"
                },
                MatterProvisionFlags = new MatterProvisionFlags()
                {
                    SendEmailFlag = true,
                    MatterLandingFlag = "true"
                }
            };
            #endregion

            using (var testClient = testServer.CreateClient().AcceptJson())
            {
                var response = await testClient.PostAsJsonAsync("http://localhost:58775/api/v1/matter/create", matterMetaDataVM);
                var result = response.Content.ReadAsJsonAsync<GenericResponseVM>().Result;
                if(result.IsError==false)
                {
                    //Call Assign Content Type API
                    response = await testClient.PostAsJsonAsync("http://localhost:58775/api/v1/matter/assigncontenttype", assignContentTypeMetadata);
                    result = response.Content.ReadAsJsonAsync<GenericResponseVM>().Result;
                }

                if (result.IsError == false)
                {
                    //Call Assign Content Type API
                    response = await testClient.PostAsJsonAsync("http://localhost:58775/api/v1/matter/assignuserpermissions", assignUserPermissionMetadataVM);
                    result = response.Content.ReadAsJsonAsync<GenericResponseVM>().Result;
                }

                if (result.IsError == false)
                {
                    //Call Assign Content Type API
                    response = await testClient.PostAsJsonAsync("http://localhost:58775/api/v1/matter/createlandingpage", createMatterLandingPage);
                    result = response.Content.ReadAsJsonAsync<GenericResponseVM>().Result;
                }

                if (result.IsError == false)
                {
                    //Call Assign Content Type API
                    response = await testClient.PostAsJsonAsync("http://localhost:58775/api/v1/matter/UpdateMetadata", matterMetadata);
                    result = response.Content.ReadAsJsonAsync<GenericResponseVM>().Result;
                }
                Assert.NotNull(result);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Assigns field values for specified content types to the specified matter (document library).
        /// </summary>
        /// <param name="clientContext">SP client context</param>
        /// <param name="contentTypeCollection">Collection of content types</param>
        /// <param name="matterList">List containing matters</param>
        /// <param name="matterMetadata">Object containing metadata for Matter</param>
        private void SetFieldValues(ClientContext clientContext, IList<ContentType> contentTypeCollection, List matterList, 
            MatterMetadata matterMetadata)
        {
            FieldCollection fields = GetContentType(clientContext, contentTypeCollection, matterList);
            if (null != fields)
            {
                matterMetadata = GetWSSId(clientContext, matterMetadata, fields);
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnClientId).DefaultValue = matterMetadata.Client.Id;
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnClientId).ReadOnlyField = true;
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnClientId).SetShowInDisplayForm(true);
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnClientId).Update();
                if(configuration.GetSection("General")["IsBackwardCompatible"].ToString().ToLower()=="false")
                {
                    fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnClientName).ReadOnlyField = true;
                    fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnClientName).SetShowInDisplayForm(true);
                    fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnClientName).DefaultValue = matterMetadata.Client.Name;
                    fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnClientName).Update();
                }    
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnMatterId).DefaultValue = matterMetadata.Matter.Id;
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnMatterId).ReadOnlyField = true;
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnMatterId).SetShowInDisplayForm(true);
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnMatterId).Update();
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnMatterName).DefaultValue = matterMetadata.Matter.Name;
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnMatterName).ReadOnlyField = true;
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnMatterName).SetShowInDisplayForm(true);
                fields.GetByInternalNameOrTitle(contentTypesConfig.ContentTypeColumnMatterName).Update();

                int levels = taxonomySettings.Levels;
                //For the number of levels that are configured, get the configured column name and 
                //update the wssid, termname and id for the managed field
                for (int i = 1; i <= levels; i++)
                {
                    string columnName = configuration.GetSection("ContentTypes").GetSection("ManagedColumns")["ColumnName" + i];
                    fields.GetByInternalNameOrTitle(columnName).SetShowInDisplayForm(true);
                    ManagedColumn managedColumn = matterMetadata.ManagedColumnTerms[columnName];
                    fields.GetByInternalNameOrTitle(columnName).DefaultValue =
                                string.Format(CultureInfo.InvariantCulture, ServiceConstants.MetadataDefaultValue,
                                managedColumn.WssId,
                                managedColumn.TermName,
                                managedColumn.Id);
                    fields.GetByInternalNameOrTitle(columnName).Update();
                }
            }
        }
Esempio n. 5
0
        public GenericResponseVM AssignContentType(MatterMetadata matterMetadata)
        {
            try
            {
                var client = matterMetadata.Client;
                var matter = matterMetadata.Matter;
                ClientContext clientContext = null;
                GenericResponseVM genericResponseVM = null;
                using (clientContext = spoAuthorization.GetClientContext(client.Url))
                {
                    IList<ContentType> contentTypeCollection = matterRepositoy.GetContentTypeData(clientContext, matter.ContentTypes, client, matter);                    
                    if (null != contentTypeCollection && matter.ContentTypes.Count == contentTypeCollection.Count && !string.IsNullOrWhiteSpace(matter.Name))
                    {
                        genericResponseVM = matterRepositoy.AssignContentTypeHelper(matterMetadata, clientContext, contentTypeCollection, client, matter);
                    }
                    else
                    {
                        genericResponseVM =
                                    new GenericResponseVM()
                                    {
                                        Code = errorSettings.ErrorCodeContentTypes,
                                        Value = errorSettings.ErrorMessageContentTypes,
                                        IsError = true
                                    };

                    }
                    return genericResponseVM;
                }
            }
            catch (Exception exception)
            {
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }

        }