Exemplo n.º 1
0
        public ActionResult GetTreeItem(string organizationId)
        {
            string jsonTree = string.Empty;

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

                RequestResult result = CheckpointDataAccessor.GetTreeItems(organizations, new Guid(organizationId), 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));
        }
Exemplo n.º 2
0
        public ActionResult DeleteSelected(string checkItemId, string pageStates)
        {
            RequestResult result = new RequestResult();

            try
            {
                List <string> pageStateList = JsonConvert.DeserializeObject <List <string> >(pageStates);

                if ((Define.EnumFormAction)Session["ControlPointFormAction"] == Define.EnumFormAction.Create)
                {
                    var model = Session["ControlPointCreateFormModel"] as CreateFormModel;

                    result = CheckpointDataAccessor.SavePageState(model.CheckItemModels, pageStateList);

                    if (result.IsSuccess)
                    {
                        model.CheckItemModels = result.Data as List <CheckItemModel>;

                        model.CheckItemModels.Remove(model.CheckItemModels.First(x => x.CheckItemId == checkItemId));

                        Session["ControlPointCreateFormModel"] = model;

                        result.Success();
                    }
                }
                else if ((Define.EnumFormAction)Session["ControlPointFormAction"] == Define.EnumFormAction.Edit)
                {
                    var model = Session["ControlPointEditFormModel"] as EditFormModel;

                    result = CheckpointDataAccessor.SavePageState(model.CheckItemModels, pageStateList);

                    if (result.IsSuccess)
                    {
                        model.CheckItemModels = result.Data as List <CheckItemModel>;

                        model.CheckItemModels.Remove(model.CheckItemModels.First(x => x.CheckItemId == checkItemId));

                        Session["ControlPointEditFormModel"] = model;

                        result.Success();
                    }
                }
                else
                {
                    result.ReturnFailedMessage(Resources.Resource.UnKnownOperation);
                }
            }
            catch (Exception ex)
            {
                Error err = new Error(MethodBase.GetCurrentMethod(), ex);

                Logger.Log(err);

                result.ReturnError(err);
            }

            return(Content(JsonConvert.SerializeObject(result)));
        }
Exemplo n.º 3
0
        public ActionResult Detail(string checkpointId)
        {
            RequestResult result = CheckpointDataAccessor.GetDetailViewModel(checkpointId, Session["Account"] as Account);

            if (result.IsSuccess)
            {
                return(PartialView("_Detail", result.Data));
            }
            else
            {
                return(PartialView("_Error", result.Error));
            }
        }
Exemplo n.º 4
0
        public ActionResult Query(QueryParameters queryParameters)
        {
            RequestResult result = CheckpointDataAccessor.Query(queryParameters, Session["Account"] as Account);

            if (result.IsSuccess)
            {
                return(PartialView("_List", result.Data));
            }
            else
            {
                return(PartialView("_Error", result.Error));
            }
        }
Exemplo n.º 5
0
        public ActionResult Copy(string checkpointId)
        {
            RequestResult result = CheckpointDataAccessor.GetCopyFormModel(checkpointId);

            if (result.IsSuccess)
            {
                Session["ControlPointFormAction"]      = Define.EnumFormAction.Create;
                Session["ControlPointCreateFormModel"] = result.Data;

                return(PartialView("_Create", result.Data));
            }
            else
            {
                return(PartialView("_Error", result.Error));
            }
        }
Exemplo n.º 6
0
        public ActionResult Delete(string selecteds)
        {
            RequestResult result = new RequestResult();

            try
            {
                var selectedList = JsonConvert.DeserializeObject <List <string> >(selecteds);

                result = CheckpointDataAccessor.Delete(selectedList);
            }
            catch (Exception ex)
            {
                var err = new Error(MethodBase.GetCurrentMethod(), ex);

                Logger.Log(err);

                result.ReturnError(err);
            }

            return(Content(JsonConvert.SerializeObject(result)));
        }
Exemplo n.º 7
0
        public ActionResult Create(CreateFormModel createFormModel, string pageStates)
        {
            RequestResult result = new RequestResult();

            try
            {
                var model = Session["ControlPointCreateFormModel"] as CreateFormModel;

                var pageStateList = JsonConvert.DeserializeObject <List <string> >(pageStates);

                result = CheckpointDataAccessor.SavePageState(model.CheckItemModels, pageStateList);

                if (result.IsSuccess)
                {
                    model.FormInput       = createFormModel.FormInput;
                    model.CheckItemModels = result.Data as List <CheckItemModel>;

                    result = CheckpointDataAccessor.Create(model);

                    if (result.IsSuccess)
                    {
                        Session.Remove("ControlPointFormAction");
                        Session.Remove("ControlPointCreateFormModel");
                    }
                }
            }
            catch (Exception ex)
            {
                var err = new Error(MethodBase.GetCurrentMethod(), ex);

                Logger.Log(err);

                result.ReturnError(err);
            }

            return(Content(JsonConvert.SerializeObject(result)));
        }
Exemplo n.º 8
0
        public ActionResult InitTree()
        {
            try
            {
                var organizations = 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 = CheckpointDataAccessor.GetTreeItems(organizations, account.RootOrganizationId, Session["Account"] as Account);
                }
                else
                {
                    result = CheckpointDataAccessor.GetRootTreeItems(organizations, 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));
            }
        }