예제 #1
0
        public ActionResult GetTreeItems(string organizationId, string materialType)
        {
            string jsonTree = string.Empty;

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

                RequestResult result = MaterialDataAccessor.GetTreeItems(organizationList, new Guid(organizationId), materialType, Session["Account"] as Account);

                if (result.IsSuccess)
                {
                    jsonTree = JsonConvert.SerializeObject((List <TreeItem>)result.Data);
                }
                else
                {
                    jsonTree = string.Empty;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(MethodBase.GetCurrentMethod(), ex);

                jsonTree = string.Empty;
            }

            return(Content(jsonTree));
        }
예제 #2
0
        public ActionResult InitTree()
        {
            try
            {
                var organizationList = HttpRuntime.Cache.GetOrInsert <List <Models.Shared.Organization> >("Organizations", () => OrganizationDataAccessor.GetAllOrganizations());

                var account = Session["Account"] as Account;

                RequestResult result = new RequestResult();

                if (account.RootOrganizationId == new Guid())
                {
                    result = MaterialDataAccessor.GetTreeItems(organizationList, account.RootOrganizationId, "", Session["Account"] as Account);
                }
                else
                {
                    result = MaterialDataAccessor.GetRootTreeItem(organizationList, account.RootOrganizationId, Session["Account"] as Account);
                }

                if (result.IsSuccess)
                {
                    return(PartialView("_Tree", JsonConvert.SerializeObject((List <TreeItem>)result.Data)));
                }
                else
                {
                    return(PartialView("_Error", result.Error));
                }
            }
            catch (Exception ex)
            {
                var err = new Error(MethodBase.GetCurrentMethod(), ex);

                Logger.Log(err);

                return(PartialView("_Error", err));
            }
        }