Example #1
0
        /// <summary>
        /// Retrieves a list of document events for the specified company, user or document.
        /// Pass a null as an argument where the argument should be ignored.
        /// </summary>
        /// <param name="documentId"></param>
        /// <param name="rooturl"></param>
        /// <param name="encodedId"></param>
        /// <param name="companyId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task <DocumentEventModels> GetDocumentEvents(string companyId, string userId, string documentId, string rooturl, string encodedId)
        {
            if (string.IsNullOrEmpty(rooturl) || string.IsNullOrEmpty(encodedId))
            {
                return(null);
            }

            string queryname           = WebTasksTypeConstants.GetDocumentEvents;
            string queryterms          = WebApiServices.GeDocumentEventsJsonQuerySearchTerms(companyId, userId, documentId);
            string url                 = $"{rooturl}api/webtasks?queryname={queryname}&queryterms={queryterms}";
            DocumentEventModels 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 <DocumentEventModels>(response.NormalizeJsonString());
                }
            }
            catch (Exception ex)
            {
                service.TrackException(ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                var properties = new Dictionary <string, string>
                {
                    { "CompanyId", companyId },
                    { "UserId", userId },
                    { "DocumentId", documentId },
                    { "WebServicesEndpoint", rooturl },
                    { "EncodedId", encodedId }
                };
                service.TrackEvent(LoggingServiceConstants.GetDocumentEvents, stopwatch.Elapsed, properties);
            }
            return(result);
        }
Example #2
0
        /// <summary>
        /// Retrieve the specified toolbar by its name
        /// </summary>
        /// <param name="useremail"></param>
        /// <param name="rooturl"></param>
        /// <param name="encodedId"></param>
        /// <param name="toolbarname"></param>
        public async Task <ToolbarModel> GetToolbar(string useremail, string rooturl, string encodedId, string toolbarname)
        {
            ToolbarModel result = null;

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

            string queryname  = WebTasksTypeConstants.GetToolbarByName;
            string queryterms = WebApiServices.GetJsonQuerySearchTermsToolbarname(useremail, toolbarname);
            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 <ToolbarModel>(response.NormalizeJsonString());
                }
            }
            catch (Exception ex)
            {
                service.TrackException(ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                var properties = new Dictionary <string, string>
                {
                    { "UserEmail", useremail },
                    { "WebServicesEndpoint", rooturl },
                    { "EncodedId", encodedId },
                    { "ToolbarName", toolbarname }
                };
                service.TrackEvent(LoggingServiceConstants.GetToolbar, stopwatch.Elapsed, properties);
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// Return company address(es)
        /// </summary>
        /// <param name="email"></param>
        /// <param name="rooturl"></param>
        /// <param name="encodedId"></param>
        /// <param name="companyId"></param>
        /// <param name="returnAll"></param>
        /// <returns></returns>
        public async Task <CompanyAddressModels> GetCompanyAddresses(string email, string rooturl, string encodedId, int companyId, bool returnAll)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(rooturl) || string.IsNullOrEmpty(encodedId) || companyId <= 0)
            {
                return(null);
            }

            string queryname            = WebTasksTypeConstants.GetCompanyAddresses;
            string queryterms           = WebApiServices.GetJsonQuerySearchTermsCompanyAddresses(companyId, returnAll);
            string url                  = $"{rooturl}api/webtasks?queryname={queryname}&queryterms={queryterms}";
            CompanyAddressModels 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 <CompanyAddressModels>(response.NormalizeJsonString());
                }
            }
            catch (Exception ex)
            {
                service.TrackException(ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                var properties = new Dictionary <string, string>
                {
                    { "UserEmail", email },
                    { "WebServicesEndpoint", rooturl },
                    { "EncodedId", encodedId },
                    { "CompanyId", companyId.ToString() },
                    { "ReturnAll", returnAll.ToString() }
                };
                service.TrackEvent(LoggingServiceConstants.GetCompanyAddresses, stopwatch.Elapsed, properties);
            }
            return(result);
        }
Example #4
0
        /// <summary>
        /// Fetch the menu items for the specified user and menu level
        /// </summary>
        /// <param name="useremail"></param>
        /// <param name="parentId"></param>
        /// <param name="rooturl"></param>
        /// <param name="encodedId"></param>
        /// <returns></returns>
        public async Task <MainMenuModels> GetModulesItemsForUser(string useremail, int parentId, string rooturl, string encodedId)
        {
            MainMenuModels result = null;

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

            string queryname  = WebTasksTypeConstants.GetMenuItemsForModuleByUser;
            string queryterms = WebApiServices.GetMenuItemsJsonQuerySearchTerms(useremail, parentId);
            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 },
                    { "ParentId", parentId.ToString() }
                };
                service.TrackEvent(LoggingServiceConstants.GetModulesItemsForUserForParentId, stopwatch.Elapsed, properties);
            }
            return(result);
        }
        /// <summary>
        /// Delete a role
        /// </summary>
        /// <param name="role"></param>
        /// <param name="encodedId"></param>
        /// <param name="rooturl"></param>
        /// <returns></returns>
        public async Task <bool> DeleteRole(RoleModel role, string encodedId, string rooturl)
        {
            if (string.IsNullOrEmpty(role?.Name) || role.Id < 0 || string.IsNullOrEmpty(encodedId) || string.IsNullOrEmpty(rooturl))
            {
                return(false);
            }

            bool   result;
            string queryterms = WebApiServices.GetRoleIdJsonQuerySearchTerms(role.Id.ToString());

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

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

            try
            {
                string      payload  = new SerializerServices().SerializeObject(role);
                HttpContent content  = new StringContent(payload, Encoding.UTF8, "application/json");
                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>
                {
                    { "Rolename", role.Name },
                    { "RoleId", role.Id.ToString() },
                    { "EncodedId", encodedId },
                    { "WebServicesEndpoint", rooturl }
                };
                service.TrackEvent(LoggingServiceConstants.DeleteRole, stopwatch.Elapsed, properties);
            }
            return(result);
        }
        /// <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);
        }