コード例 #1
0
        /// <summary>
        /// Retrieves a list of document categories
        /// </summary>
        /// <param name="email"></param>
        /// <param name="rooturl"></param>
        /// <param name="encodedId"></param>
        /// <returns></returns>
        public async Task <DocumentCategoryModels> GetDocumentCategories(string email, string rooturl, string encodedId)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(rooturl) || string.IsNullOrEmpty(encodedId))
            {
                return(null);
            }

            string queryname              = WebTasksTypeConstants.GetDocumentCategories;
            string queryterms             = WebApiServices.GetEmailJsonQuerySearchTerms(email);
            string url                    = $"{rooturl}api/webtasks?queryname={queryname}&queryterms={queryterms}";
            DocumentCategoryModels result = null;

            LoggingService service   = new LoggingService();
            var            stopwatch = new Stopwatch();

            try
            {
                var response = await new WebApiServices().GetData(url, encodedId);
                if (!string.IsNullOrEmpty(response))
                {
                    result = new SerializerServices()
                             .DeserializeObject <DocumentCategoryModels>(response.NormalizeJsonString());
                    result = this.CleanDocumentCategories(result);
                }
            }
            catch (Exception ex)
            {
                service.TrackException(ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                var properties = new Dictionary <string, string>
                {
                    { "UserEmail", email },
                    { "WebServicesEndpoint", rooturl },
                    { "EncodedId", encodedId }
                };
                service.TrackEvent(LoggingServiceConstants.GetDocumentCategories, stopwatch.Elapsed, properties);
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Fetch the menu items for the specified user
        /// </summary>
        /// <param name="useremail"></param>
        /// <param name="rooturl"></param>
        /// <param name="encodedId"></param>
        /// <returns></returns>
        public async Task <MainMenuModels> GetModulesItemsForUser(string useremail, string rooturl, string encodedId)
        {
            MainMenuModels result = null;

            if (string.IsNullOrEmpty(useremail) || string.IsNullOrEmpty(rooturl) ||
                string.IsNullOrEmpty(encodedId))
            {
                return(null);
            }

            string queryname  = WebTasksTypeConstants.GetAllMenuItemsForModuleByUser;
            string queryterms = WebApiServices.GetEmailJsonQuerySearchTerms(useremail);
            string url        = $"{rooturl}api/webtasks?queryname={queryname}&queryterms={queryterms}";

            LoggingService service   = new LoggingService();
            var            stopwatch = new Stopwatch();

            try
            {
                var response = await new WebApiServices().GetData(url, encodedId);
                if (!string.IsNullOrEmpty(response) && response.Length > 0)
                {
                    result = new SerializerServices().DeserializeObject <MainMenuModels>(response.NormalizeJsonString());
                }
            }
            catch (Exception ex)
            {
                service.TrackException(ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                var properties = new Dictionary <string, string>
                {
                    { "UserEmail", useremail },
                    { "WebServicesEndpoint", rooturl },
                    { "EncodedId", encodedId }
                };
                service.TrackEvent(LoggingServiceConstants.GetModulesItemsForUserWithoutParentId, stopwatch.Elapsed, properties);
            }
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Delete the specified user
        /// </summary>
        /// <param name="email"></param>
        /// <param name="encodedId"></param>
        /// <param name="rooturl"></param>
        /// <returns></returns>
        public async Task <bool> DeleteUser(string email, string encodedId, string rooturl)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(encodedId) || string.IsNullOrEmpty(rooturl))
            {
                return(false);
            }

            bool   result;
            string queryterms = WebApiServices.GetEmailJsonQuerySearchTerms(email);

            string url = $"{rooturl}api/webtasks?formname={RoutingTasksTypeConstants.DeleteUser}&queryterms={queryterms}";

            LoggingService service   = new LoggingService();
            var            stopwatch = new Stopwatch();

            try
            {
                var response = await new WebApiServices().DeleteData(url, encodedId);
                result = response.IsSuccessStatusCode;
            }

            catch (Exception ex)
            {
                service.TrackException(ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                var properties = new Dictionary <string, string>
                {
                    { "UserEmail", email },
                    { "EncodedId", encodedId },
                    { "WebServicesEndpoint", rooturl }
                };
                service.TrackEvent(LoggingServiceConstants.DeleteUser, stopwatch.Elapsed, properties);
            }
            return(result);
        }