Exemple #1
0
        public ActionResult GetSelectPersonTreeItem(string organizationId)
        {
            string jsonTree = string.Empty;

            try
            {
                var organizations = HttpRuntime.Cache.GetOrInsert <List <Models.Shared.Organization> >("Organizations", () => OrganizationDataAccessor.GetAllOrganizations());

                RequestResult result = PersonDataAccessor.GetTreeItem(organizations, new Guid(organizationId), Session["Account"] as Account);

                if (result.IsSuccess)
                {
                    jsonTree = JsonConvert.SerializeObject((List <TreeItem>)result.Data);
                }
                else
                {
                    jsonTree = string.Empty;
                }
            }
            catch (Exception e)
            {
                jsonTree = string.Empty;

                Logger.Log(MethodBase.GetCurrentMethod(), e);
            }

            return(Content(jsonTree));
        }
Exemple #2
0
        public ActionResult InitTree()
        {
            try
            {
                var account       = Session["Account"] as Account;
                var organizations = HttpRuntime.Cache.GetOrInsert <List <Models.Shared.Organization> >("Organization", () => OrganizationDataAccessor.GetAllOrganizations());

                RequestResult requestResult = new RequestResult();

                if (account.RootOrganizationId == new Guid())
                {
                    requestResult = PersonDataAccessor.GetTreeItem(organizations, account.RootOrganizationId, account);
                }
                else
                {
                    requestResult = PersonDataAccessor.GetRootTreeItem(organizations, account);
                }

                if (requestResult.IsSuccess)
                {
                    return(PartialView("_Tree", JsonConvert.SerializeObject((List <TreeItem>)requestResult.Data)));
                }
                else
                {
                    return(PartialView("_Error", requestResult.Error));
                }
            }
            catch (Exception e)
            {
                var error = new Error(MethodBase.GetCurrentMethod(), e);
                Logger.Log(error);
                return(PartialView("_Error", error));
                //throw;
            }
        }