Exemple #1
0
        public ActionResult Update(FunctionUpdateInput input)
        {
            if (!ModelState.IsValid)
            {
                return(ModelState.ToJsonResult());
            }
            AcDomain.Handle(input.ToCommand(AcSession));

            return(this.JsonResult(new ResponseData {
                id = input.Id, success = true
            }));
        }
Exemple #2
0
        public ActionResult ManageOrUnManageFunction()
        {
            String json = Request["data"];
            var    rows = (ArrayList)MiniJSON.Decode(json);

            foreach (Hashtable row in rows)
            {
                var id = new Guid(row["Id"].ToString());
                //根据记录状态,进行不同的增加、删除、修改功能
                String state = row["_state"] != null ? row["_state"].ToString() : "";

                //更新:_state为空或modified
                if (state == "modified" || state == "")
                {
                    bool isManaged = bool.Parse(row["IsManaged"].ToString());
                    var  entity    = GetRequiredService <IRepository <Function> >().GetByKey(id);
                    if (entity != null)
                    {
                        var input = new FunctionUpdateInput
                        {
                            Description = entity.Description,
                            DeveloperId = entity.DeveloperId,
                            IsEnabled   = entity.IsEnabled,
                            IsManaged   = entity.IsManaged,
                            SortCode    = entity.SortCode,
                            Code        = entity.Code,
                            Id          = entity.Id
                        };
                        input.IsManaged = isManaged;
                        AcDomain.Handle(input.ToCommand(AcSession));
                    }
                }
            }

            return(this.JsonResult(new ResponseData {
                success = true
            }));
        }
Exemple #3
0
        public ActionResult UnManage(string id)
        {
            string[] ids     = id.Split(',');
            var      idArray = new Guid[ids.Length];

            for (int i = 0; i < ids.Length; i++)
            {
                Guid tmp;
                if (Guid.TryParse(ids[i], out tmp))
                {
                    idArray[i] = tmp;
                }
                else
                {
                    throw new ValidationException("意外的功能标识" + ids[i]);
                }
            }
            foreach (var item in idArray)
            {
                var entity = GetRequiredService <IRepository <Function> >().GetByKey(item);
                var input  = new FunctionUpdateInput
                {
                    Id          = entity.Id,
                    Code        = entity.Code,
                    SortCode    = entity.SortCode,
                    IsManaged   = entity.IsManaged,
                    IsEnabled   = entity.IsEnabled,
                    DeveloperId = entity.DeveloperId,
                    Description = entity.Description
                };
                input.IsManaged = false;
                AcDomain.Handle(input.ToCommand(AcSession));
            }
            return(this.JsonResult(new ResponseData {
                id = id, success = true
            }));
        }
        public ActionResult AddOrRemoveButtons()
        {
            String json = Request["data"];
            var rows = (ArrayList)MiniJSON.Decode(json);
            foreach (Hashtable row in rows)
            {
                //根据记录状态,进行不同的增加、删除、修改操作
                String state = row["_state"] != null ? row["_state"].ToString() : "";

                //更新:_state为空或modified
                if (state == "modified" || state == "")
                {
                    string functionIdStr = row["FunctionId"] == null ? null : row["FunctionId"].ToString();
                    Guid? functionId = string.IsNullOrEmpty(functionIdStr) ? null : new Guid?(new Guid(functionIdStr));
                    if (functionId.HasValue)
                    {
                        FunctionState function;
                        if (!AcDomain.FunctionSet.TryGetFunction(functionId.Value, out function))
                        {
                            throw new ValidationException("意外的托管功能标识" + functionId.Value);
                        }
                    }
                    var inputModel = new UiViewButton
                    {
                        Id = new Guid(row["Id"].ToString()),
                        IsEnabled = int.Parse(row["IsEnabled"].ToString()),
                        ButtonId = new Guid(row["ButtonId"].ToString()),
                        UiViewId = new Guid(row["UiViewId"].ToString()),
                        FunctionId = functionId
                    };

                    if (bool.Parse(row["IsAssigned"].ToString()))
                    {
                        if (AcDomain.RetrieveRequiredService<IRepository<UiViewButton>>().AsQueryable().Any(a => a.Id == inputModel.Id))
                        {
                            var updateModel = new UiViewButtonUpdateInput()
                            {
                                Id = inputModel.Id,
                                IsEnabled = inputModel.IsEnabled,
                                FunctionId = inputModel.FunctionId
                            };
                            AcDomain.Handle(updateModel.ToCommand(AcSession));
                        }
                        else
                        {
                            var input = new UiViewButtonCreateInput()
                            {
                                Id = inputModel.Id,
                                ButtonId = inputModel.ButtonId,
                                IsEnabled = inputModel.IsEnabled,
                                FunctionId = inputModel.FunctionId,
                                UiViewId = inputModel.UiViewId
                            };
                            AcDomain.Handle(input.ToCommand(AcSession));
                        }
                    }
                    else
                    {
                        AcDomain.Handle(new RemoveUiViewButtonCommand(AcSession, inputModel.Id));
                    }
                    if (functionId.HasValue)
                    {
                        int functionIsEnabled = int.Parse(row["FunctionIsEnabled"].ToString());
                        FunctionState function;
                        if (!AcDomain.FunctionSet.TryGetFunction(functionId.Value, out function))
                        {
                            throw new AnycmdException("意外的功能标识" + functionId.Value);
                        }
                        var input = new FunctionUpdateInput
                        {
                            Id = function.Id,
                            Code = function.Code,
                            SortCode = function.SortCode,
                            IsManaged = function.IsManaged,
                            IsEnabled = function.IsEnabled,
                            DeveloperId = function.DeveloperId,
                            Description = function.Description
                        };
                        input.IsEnabled = functionIsEnabled;
                        AcDomain.Handle(input.ToCommand(AcSession));
                    }
                }
            }

            return this.JsonResult(new ResponseData { success = true });
        }
        public ActionResult Update(FunctionUpdateInput input)
        {
            if (!ModelState.IsValid)
            {
                return ModelState.ToJsonResult();
            }
            AcDomain.Handle(input.ToCommand(AcSession));

            return this.JsonResult(new ResponseData { id = input.Id, success = true });
        }
 public ActionResult UnManage(string id)
 {
     string[] ids = id.Split(',');
     var idArray = new Guid[ids.Length];
     for (int i = 0; i < ids.Length; i++)
     {
         Guid tmp;
         if (Guid.TryParse(ids[i], out tmp))
         {
             idArray[i] = tmp;
         }
         else
         {
             throw new ValidationException("意外的功能标识" + ids[i]);
         }
     }
     foreach (var item in idArray)
     {
         var entity = GetRequiredService<IRepository<Function>>().GetByKey(item);
         var input = new FunctionUpdateInput
         {
             Id = entity.Id,
             Code = entity.Code,
             SortCode = entity.SortCode,
             IsManaged = entity.IsManaged,
             IsEnabled = entity.IsEnabled,
             DeveloperId = entity.DeveloperId,
             Description = entity.Description
         };
         input.IsManaged = false;
         AcDomain.Handle(input.ToCommand(AcSession));
     }
     return this.JsonResult(new ResponseData { id = id, success = true });
 }
        public ActionResult ManageOrUnManageFunction()
        {
            String json = Request["data"];
            var rows = (ArrayList)MiniJSON.Decode(json);
            foreach (Hashtable row in rows)
            {
                var id = new Guid(row["Id"].ToString());
                //根据记录状态,进行不同的增加、删除、修改功能
                String state = row["_state"] != null ? row["_state"].ToString() : "";

                //更新:_state为空或modified
                if (state == "modified" || state == "")
                {
                    bool isManaged = bool.Parse(row["IsManaged"].ToString());
                    var entity = GetRequiredService<IRepository<Function>>().GetByKey(id);
                    if (entity != null)
                    {
                        var input = new FunctionUpdateInput
                        {
                            Description = entity.Description,
                            DeveloperId = entity.DeveloperId,
                            IsEnabled = entity.IsEnabled,
                            IsManaged = entity.IsManaged,
                            SortCode = entity.SortCode,
                            Code = entity.Code,
                            Id = entity.Id
                        };
                        input.IsManaged = isManaged;
                        AcDomain.Handle(input.ToCommand(AcSession));
                    }
                }
            }

            return this.JsonResult(new ResponseData { success = true });
        }
        public ActionResult AddOrRemoveButtons()
        {
            String json = Request["data"];
            var    rows = (ArrayList)MiniJSON.Decode(json);

            foreach (Hashtable row in rows)
            {
                //根据记录状态,进行不同的增加、删除、修改操作
                String state = row["_state"] != null ? row["_state"].ToString() : "";

                //更新:_state为空或modified
                if (state == "modified" || state == "")
                {
                    string functionIdStr = row["FunctionId"] == null ? null : row["FunctionId"].ToString();
                    Guid?  functionId    = string.IsNullOrEmpty(functionIdStr) ? null : new Guid?(new Guid(functionIdStr));
                    if (functionId.HasValue)
                    {
                        FunctionState function;
                        if (!AcDomain.FunctionSet.TryGetFunction(functionId.Value, out function))
                        {
                            throw new ValidationException("意外的托管功能标识" + functionId.Value);
                        }
                    }
                    var inputModel = new UiViewButton(new Guid(row["Id"].ToString()))
                    {
                        IsEnabled  = int.Parse(row["IsEnabled"].ToString()),
                        ButtonId   = new Guid(row["ButtonId"].ToString()),
                        UiViewId   = new Guid(row["UiViewId"].ToString()),
                        FunctionId = functionId
                    };

                    if (bool.Parse(row["IsAssigned"].ToString()))
                    {
                        if (AcDomain.RetrieveRequiredService <IRepository <UiViewButton, Guid> >().AsQueryable().Any(a => a.Id == inputModel.Id))
                        {
                            var updateModel = new UiViewButtonUpdateInput()
                            {
                                Id         = inputModel.Id,
                                IsEnabled  = inputModel.IsEnabled,
                                FunctionId = inputModel.FunctionId
                            };
                            AcDomain.Handle(updateModel.ToCommand(AcSession));
                        }
                        else
                        {
                            var input = new UiViewButtonCreateInput()
                            {
                                Id         = inputModel.Id,
                                ButtonId   = inputModel.ButtonId,
                                IsEnabled  = inputModel.IsEnabled,
                                FunctionId = inputModel.FunctionId,
                                UiViewId   = inputModel.UiViewId
                            };
                            AcDomain.Handle(input.ToCommand(AcSession));
                        }
                    }
                    else
                    {
                        AcDomain.Handle(new RemoveUiViewButtonCommand(AcSession, inputModel.Id));
                    }
                    if (functionId.HasValue)
                    {
                        int           functionIsEnabled = int.Parse(row["FunctionIsEnabled"].ToString());
                        FunctionState function;
                        if (!AcDomain.FunctionSet.TryGetFunction(functionId.Value, out function))
                        {
                            throw new GeneralException("意外的功能标识" + functionId.Value);
                        }
                        var input = new FunctionUpdateInput
                        {
                            Id          = function.Id,
                            Code        = function.Code,
                            SortCode    = function.SortCode,
                            IsManaged   = function.IsManaged,
                            IsEnabled   = function.IsEnabled,
                            DeveloperId = function.DeveloperId,
                            Description = function.Description
                        };
                        input.IsEnabled = functionIsEnabled;
                        AcDomain.Handle(input.ToCommand(AcSession));
                    }
                }
            }

            return(this.JsonResult(new ResponseData {
                success = true
            }));
        }