Пример #1
0
        /// <summary>
        /// Creates an item in the specific list with the list of users to whom the matter will be shared.
        /// </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>
        /// <returns>true if success else false</returns>
        /// /// <summary>
        internal GenericResponseVM ShareMatter(MatterMetdataVM matterMetadata, string matterLandingFlag)
        {
            GenericResponseVM returnFlag = null;
            var matter               = matterMetadata.Matter;
            var matterDetails        = matterMetadata.MatterDetails;
            var client               = matterMetadata.Client;
            var matterConfigurations = matterMetadata.MatterConfigurations;

            if (null != client && null != matter && null != matterDetails)
            {
                try
                {
                    Uri mailListURL = new Uri(string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}", matterSettings.ProvisionMatterAppURL,
                                                            ServiceConstants.FORWARD_SLASH, ServiceConstants.LISTS, ServiceConstants.FORWARD_SLASH, matterSettings.SendMailListName));
                    string centralMailListURL = Convert.ToString(mailListURL, CultureInfo.InvariantCulture);
                    string mailSiteURL        = centralMailListURL.Substring(0, centralMailListURL.LastIndexOf(string.Concat(ServiceConstants.FORWARD_SLASH,
                                                                                                                             ServiceConstants.LISTS, ServiceConstants.FORWARD_SLASH), StringComparison.OrdinalIgnoreCase));
                    ///// Retrieve the specific site where the Mail List is present along with the required List Name
                    if (null != mailListURL && null != client.Url)
                    {
                        if (!string.IsNullOrWhiteSpace(mailSiteURL))
                        {
                            returnFlag = ShareMatterUtility(client, matter, matterDetails,
                                                            mailSiteURL, centralMailListURL, matterLandingFlag, matterConfigurations);
                        }
                    }
                }
                catch (Exception ex)
                {
                    customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                    throw;
                }
            }
            return(returnFlag);
        }
Пример #2
0
        public GenericResponseVM UpdateMatterMetadata(MatterMetdataVM matterMetadata)
        {
            var               matter        = matterMetadata.Matter;
            var               matterDetails = matterMetadata.MatterDetails;
            var               client        = matterMetadata.Client;
            ClientContext     clientContext = null;
            GenericResponseVM returnFlag    = null;

            try
            {
                clientContext = spoAuthorization.GetClientContext(matterMetadata.Client.Url);
                PropertyValues matterStampedProperties   = matterRepositoy.GetStampedProperties(clientContext, matter.Name);
                Dictionary <string, string> propertyList = SetStampProperty(client, matter, matterDetails);
                matterRepositoy.SetPropertBagValuesForList(clientContext, matterStampedProperties, matter.Name, propertyList);
                if (matterMetadata.MatterProvisionFlags.SendEmailFlag)
                {
                    returnFlag = ShareMatter(matterMetadata, matterMetadata.MatterProvisionFlags.MatterLandingFlag);
                }
                else
                {
                    ServiceUtility.GenericResponse("", "Matter Update Success");
                }
            }
            catch (Exception ex)
            {
                DeleteMatter(client, matter);
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
            return(returnFlag);
        }
Пример #3
0
        public async void Check_Matter_Exists()
        {
            var matterMetadataVM = new MatterMetdataVM()
            {
                Client = new Client()
                {
                    Url = "https://msmatter.sharepoint.com/sites/microsoft"
                },
                Matter = new Matter()
                {
                    Name       = "New Matter",
                    MatterGuid = "e224f0ba891492dc05bf97d73f8b2934"
                },
                HasErrorOccurred = false
            };

            using (var testClient = testServer.CreateClient().AcceptJson())
            {
                var response = await testClient.PostAsJsonAsync("http://localhost:58775/api/v1/matter/checkmatterexists", matterMetadataVM);

                var result = response.Content.ReadAsJsonAsync <GenericResponseVM>().Result;
                Assert.NotNull(result);
            }
        }
Пример #4
0
        /// <summary>
        /// Updates matter metadata - Stamps properties to the created matter.
        /// </summary>
        /// <param name="client">Client object containing Client data</param>
        /// <param name="details">Term Store object containing Term store data</param>
        /// <returns>Returns JSON object to the client</returns>        ///
        public IActionResult UpdateMetadata([FromBody] MatterMetdataVM matterMetdata)
        {
            string editMatterValidation = string.Empty;
            var    matter = matterMetdata.Matter;
            var    client = matterMetdata.Client;

            try
            {
                spoAuthorization.AccessToken = HttpContext.Request.Headers["Authorization"];
                #region Error Checking
                ErrorResponse errorResponse = null;
                if (matterMetdata.Client == null && matterMetdata.Matter == null &&
                    matterMetdata.MatterDetails == null && matterMetdata.MatterProvisionFlags == null)
                {
                    errorResponse = new ErrorResponse()
                    {
                        Message     = errorSettings.MessageNoInputs,
                        ErrorCode   = HttpStatusCode.BadRequest.ToString(),
                        Description = "No input data is passed"
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest));
                }
                #endregion

                #region Validations
                MatterInformationVM matterInfo = new MatterInformationVM()
                {
                    Client        = matterMetdata.Client,
                    Matter        = matterMetdata.Matter,
                    MatterDetails = matterMetdata.MatterDetails
                };
                GenericResponseVM genericResponse = validationFunctions.IsMatterValid(matterInfo,
                                                                                      int.Parse(ServiceConstants.ProvisionMatterUpdateMetadataForList),
                                                                                      matterMetdata.MatterConfigurations);
                if (genericResponse != null)
                {
                    matterProvision.DeleteMatter(client, matter);
                    errorResponse = new ErrorResponse()
                    {
                        Message   = genericResponse.Value,
                        ErrorCode = genericResponse.Code,
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest));
                }
                #endregion
                try
                {
                    genericResponse = matterProvision.UpdateMatterMetadata(matterMetdata);
                    if (genericResponse == null)
                    {
                        var result = new GenericResponseVM()
                        {
                            Code  = "200",
                            Value = "Update Success"
                        };
                        return(matterCenterServiceFunctions.ServiceResponse(result, (int)HttpStatusCode.OK));
                    }
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.NotModified));
                }
                catch (Exception ex)
                {
                    matterProvision.DeleteMatter(client, matter);
                    customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                    throw;
                }
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
Пример #5
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);
            }
        }