Ejemplo n.º 1
0
        public ActionResult GetSceneData(GetSceneDataModel model)
        {
            _ilog.Info(string.Format("方法名:{0};参数:{1}", "GetSceneData", Serializer.ToJson(model)));

            var result = new StandardJsonResult <dynamic>();

            result.Value = new List <SceneItemDto>();
            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                int count = 0;
                ItemStatus sceneStatus = ItemStatus.All;
                bool f = Enum.TryParse <ItemStatus>(model.Status + "", out sceneStatus);
                if (!f)
                {
                    sceneStatus = ItemStatus.All;
                }
                List <SceneItemDto> list = service.GetAllByStatus(BCSession.User.UserID, BCSession.User.Device, model.SceneID, sceneStatus, model.PageSize, model.Time, out count);
                result.Value             = new { Count = count, Data = list };
            });

            _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "GetSceneData", Serializer.ToJson(result)));
            return(result);
        }
Ejemplo n.º 2
0
        public ActionResult Send(ChatMessageModel model)
        {
            _ilog.Info(string.Format("方法名:{0};参数:{1}", "SendChatMessage", Serializer.ToJson(model)));

            var result = new StandardJsonResult <dynamic>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var isSuccess = service.ProcessChatMessage(new ChatMessageDto()
                {
                    SendUserID = BCSession.User.UserID,
                    Recipients = model.Recipients,
                    SendTime   = model.SendTime,
                    Message    = model.Message,
                    MessageID  = model.MessageID
                });
                result.Value = new { isSend = isSuccess };
            });
            _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "SendChatMessage", Serializer.ToJson(result)));
            return(result);
        }
Ejemplo n.º 3
0
        public ActionResult AddUser(NewFrontUserModel model)
        {
            //NewUserModel tempModel = Serializer.FromJson<NewUserModel>(jsonstr);
            var result = new StandardJsonResult <string>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                if (model.Password == null || model.Password.Equals(""))
                {
                    throw new KnownException("密码为空!");
                }

                model.RegistDate     = DateTime.Now;
                model.UpdateTime     = DateTime.Now;
                model.LoginByDesktop = true;
                model.LoginByMobile  = true;


                string uid = _userService.AddFrontUser(model);
                var roles  = model.Roles;
                //processUserRoles(uid, roles);

                result.Value = !uid.Equals("0") + "";
            });
            return(result);
        }
Ejemplo n.º 4
0
        public ActionResult GetUser()
        {
            var result = new StandardJsonResult <List <UserTree> >();

            result.Try(() => {
                List <FrontUserDto> userlist = GetUserList();
                //List< FrontUserDto> my = userlist.Where(u => u.UserID == BCSession.User.UserID).ToList();
                //if (my.Count > 0)
                //{
                //    userlist.Remove(my[0]);
                //}
                List <UserTree> departmentlist = new List <UserTree>();
                departmentlist.Add(new UserTree()
                {
                    iconCls  = "icon-user",
                    children = new List <UserTree>(),
                    id       = "",
                    text     = "所有人",
                    type     = 3
                });
                departmentlist = departmentlist.Concat(GetDepartment(userlist)).ToList();
                //所有人标签

                if (departmentlist.Count > 0)
                {
                    result.Value = new List <UserTree>();
                    result.Value = departmentlist;
                }
            });
            if (!result.Success)
            {
                result.Value = new List <UserTree>();
            }
            return(Json(result.Value, JsonRequestBehavior.AllowGet));
        }
        //获取某项目的可用角色详单 todo
        public ActionResult GetRoleListOfProject(string ProjectID)
        {
            string _enterpriseID = BCSession.User.EnterpriseID;
            int?   _departmentID = BCSession.User.DepartmentID;
            string _userID       = BCSession.User.UserID;
            var    result        = new StandardJsonResult <List <RoleIdName> >();

            result.Value = new List <RoleIdName>();
            result.Try(() =>
            {
                //var list = new List<RoleIdName>();
                //var r = new RoleIdName
                //{
                //    RoleId = "1",
                //    RoleName = "施工员"
                //};
                //list.Add(r);
                //r.RoleId = "1";
                //r.RoleName = "质检员";
                //list.Add(r);
                //result.Value = list;
                var t = _sceneService.GetRoleUserListOfEnterprise(_enterpriseID, ProjectID);
                foreach (var roleUsers in t)
                {
                    RoleIdName item = roleUsers.Key;
                    if (item != null)
                    {
                        result.Value.Add(item);
                    }
                }
                result.Value = result.Value.Distinct().ToList();
            });

            return(result);
        }
        public ActionResult AddSceneItemComment(string SceneItemID, string comment)
        {
            string _enterpriseID = BCSession.User.EnterpriseID;
            int?   _departmentID = BCSession.User.DepartmentID;
            string _userID       = BCSession.User.UserID;
            var    result        = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                comment = comment.Replace("\n", " ");
                var cmt = new Comment
                {
                    CommentGuid = Guid.NewGuid(),
                    Content     = comment,
                    Time        = DateTime.Now,
                    UserID      = _userID,
                    UserName    = BCSession.User.UserName
                };
                try
                {
                    result.Value = !(_sceneItemService.AddCommentItem(SceneItemID, cmt, ItemStatus.Normal) == null);
                }
                catch (Exception e)
                {
                    result.Message = "信息:" + e.Message;
                    result.Value   = false;
                }
            });
            return(result);
        }
        public ActionResult Upload(AddMaterialListModel model)
        {
            if (!ModelState.IsValid)
            {
                throw new KnownException(ModelState.GetFirstError());
            }
            var result = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                var file      = Request.Files;
                int filecount = file.Count;
                for (int i = 0; i < filecount; i++)
                {
                    FileType ftype = FileType.All;
                    if (model.ext.ToLower().IndexOf("doc") >= 0)
                    {
                        ftype = FileType.Word;
                    }
                    else if (model.ext.ToLower().IndexOf("xls") >= 0)
                    {
                        ftype = FileType.Excel;
                    }
                    else if (model.ext.ToLower().IndexOf("ppt") >= 0)
                    {
                        ftype = FileType.PPT;
                    }
                    else if (model.ext.ToLower().IndexOf("pdf") >= 0)
                    {
                        ftype = FileType.PDF;
                    }
                    else
                    {
                        throw new KnownException("上传的格式不对");
                    }

                    var f        = file[i];
                    Stream sf    = f.InputStream;
                    result.Value = service.UpLoading(new KnowlegeDto()
                    {
                        Deleted       = false,
                        Name          = model.fileName == null ? f.FileName : model.fileName + "." + model.ext,
                        KnowledgeType = model.materialType,
                        DocumentType  = ftype,
                        FileStream    = sf,
                        EnterpriseID  = BCSession.User.EnterpriseID,
                        DocumentSize  = f.ContentLength,
                        ID            = DateTime.Now.ToFileTime().ToString() + "." + model.ext,
                        FileGUID      = model.guid,
                        FileAllSize   = model.byteLength,
                        FileNumber    = model.chunk,
                    });
                }
            });
            if (result.Value && result.Success)
            {
                result.Message = "添加成功";
            }
            return(result);
        }
        public StandardJsonResult UpdateDepartment(string funcJsonStr)
        {
            var res = new StandardJsonResult <bool>();

            res.Try(() =>
            {
                var model = Serializer.FromJson <DepartmentDto>(funcJsonStr);
                if (model.Name.Equals(""))
                {
                    res.Success = false;
                    res.Message = "参数不合法";
                    res.Value   = false;
                }
                else
                {
                    res.Value   = service.Update(model);
                    res.Message = "修改成功!";
                }
            });
            if (!res.Success)
            {
                res.Value   = false;
                res.Message = "修改失败";
            }
            return(res);
        }
Ejemplo n.º 9
0
        public ActionResult UpdateType(ScenesTypeModel model)
        {
            var result = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                SceneTypeDto scenetype = new SceneTypeDto
                {
                    ID           = model.id,
                    ParentID     = model._parentId,
                    Name         = model.Name,
                    Available    = model.Available,
                    EnterpriseID = BCSession.User.EnterpriseID
                };
                result.Value   = service.UpdateSceneType(scenetype);
                result.Message = "提示:修改成功!";
            });
            if (!result.Success)
            {
                result.Message = "提示:修改失败";
            }
            return(result);
        }
        public ActionResult GetFileType()
        {
            HasFunction(Functions.Root_DataManagement_DataListManagement_Download);
            var result = new StandardJsonResult <List <FileTypeModel> >();

            result.Try(() =>
            {
                result.Value = new List <FileTypeModel>();
                result.Value.Add(new FileTypeModel()
                {
                    text  = "Excel",
                    value = FileType.Excel
                });
                result.Value.Add(new FileTypeModel()
                {
                    text  = "Word",
                    value = FileType.Word
                });
                result.Value.Add(new FileTypeModel()
                {
                    text  = "PPT",
                    value = FileType.PPT
                });
                result.Value.Add(new FileTypeModel()
                {
                    text  = "PDF",
                    value = FileType.PDF
                });
            });
            return(Json(result.Value, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        public ActionResult GetList()
        {
            var result = new StandardJsonResult <ScenesTypeResultModel>();

            result.Try(() =>
            {
                List <ScenesTypeModel> ret = new List <ScenesTypeModel>();
                List <SceneTypeDto> list   = service.GetAllSceneTypeList(BCSession.User.EnterpriseID);
                foreach (var all in list)
                {
                    ret.Add(new ScenesTypeModel()
                    {
                        id        = all.ID,
                        Name      = all.Name,
                        _parentId = all.ParentID.Value,
                        Available = all.Available
                    });
                }
                result.Value       = new ScenesTypeResultModel();
                result.Value.rows  = ret;
                result.Value.total = ret.Count;
            });
            if (!result.Success)
            {
                result.Value = new ScenesTypeResultModel();
            }
            return(Json(result.Value, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetList(PropertyViewModel model)
        {
            var result = new StandardJsonResult <PropResultModel>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                int page     = model.page < 1 ? 1 : model.page;
                int pageSize = model.rows < 1 ? 15 : model.rows;

                int total;
                var list           = _service.SearchEnterprisePropertyByName("", pageSize, page, out total);
                result.Value       = new PropResultModel();
                result.Value.rows  = new List <EnterprisePropertyDto>();
                result.Value.rows  = list;
                result.Value.total = total;
            });
            if (result.Success == false)
            {
                result.Value = new PropResultModel();
            }
            return(new OringinalJsonResult <PropResultModel> {
                Value = result.Value
            });
        }
Ejemplo n.º 13
0
        //当前企业的角色列表
        public ActionResult GetRoleList()
        {
            string _enterpriseID = GetSession().User.EnterpriseID;
            var    result        = new StandardJsonResult <List <EnterpriseRoleViewModel> >();

            result.Try(() =>
            {
                List <EnterpriseRoleDto> list = _entRoleService.GetEnterpriseRoleByEnterpriseID(_enterpriseID);

                List <EnterpriseRoleViewModel> rlist = new List <EnterpriseRoleViewModel>();
                foreach (var role in list)
                {
                    var rvm = new EnterpriseRoleViewModel
                    {
                        RoleID   = role.RoleID + "",
                        RoleName = role.Name
                    };
                    rlist.Add(rvm);
                }
                result.Value = rlist;
            });
            if (result.Success)
            {
                return(new OringinalJsonResult <List <EnterpriseRoleViewModel> > {
                    Value = result.Value
                });
            }
            else
            {
                return(new OringinalJsonResult <List <EnterpriseRoleViewModel> > {
                    Value = new List <EnterpriseRoleViewModel>()
                });
            }
        }
        public ActionResult UpdateMaterialType(MaterialTypeModel model)
        {
            var result = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                MaterialTypeDto m = new MaterialTypeDto();
                m.Name            = model.Name;
                m.MaterialTypeID  = model.MaterialTypeID;
                m.Avaliable       = model.Avaliable;
                var mservice      = ML.BC.Infrastructure.Ioc.GetService <IMaterialTypeManagementService>();
                result.Value      = mservice.Update(m);
            });
            if (result.Success)
            {
                result.Message = "修改成功";
            }
            else
            {
                result.Message = "修改失败";
            }
            return(result);
        }
Ejemplo n.º 15
0
        public ActionResult GetList(string user)
        {
            var result = new StandardJsonResult <int []>();

            result.Try(() => {
                ScanCountModel list = service.GetScanCount(user);
                int[] ret           = new int[4];
                if (list != null)
                {
                    ret[0]       = list.ProjectNum;
                    ret[1]       = list.CheckProjectNum;
                    ret[2]       = list.SceneNum;
                    ret[3]       = list.CheckSceneNum;
                    result.Value = ret;
                }
                else
                {
                    result.Value = new int[4];
                }
            });
            if (!result.Success)
            {
                result.Value   = new int[4];
                result.Message = "获取数据失败!";
            }
            return(result);
        }
Ejemplo n.º 16
0
        public ActionResult UpdateUser(EnterpriseUserNewModel model)
        {
            string _enterpriseID = GetSession().User.EnterpriseID;

            var result = new StandardJsonResult <string>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                model.UpdateTime  = DateTime.Now;
                model.EnterpiseID = _enterpriseID;
                if (model.DepartmentID.Equals("0"))
                {
                    model.DepartmentID = null;
                }
                if (model.Roles == null)
                {
                    model.Roles = new List <int>();
                }
                model.EnterpiseID = _enterpriseID;
                var v             = _userService.UpdateUser(model);
                //processUserRoles(model.UserID, model.Roles);
                result.Value = v.ToString();
            });
            return(result);
        }
Ejemplo n.º 17
0
        public ActionResult Comment(CommentDataModel model)
        {
            _ilog.Info(string.Format("方法名:{0};参数:{1}", "Comment", Serializer.ToJson(model)));

            var result = new StandardJsonResult();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                ItemStatus status = (ItemStatus)model.Status;
                var user          = GetSession();
                var examine       = new Examine()
                {
                    UserID        = user.User.UserID,
                    UserName      = user.User.UserName,
                    ExamineStatus = status
                };
                var SN = GetSession();
                service.AddCommentItem(model.MessageID,
                                       new Comment()
                {
                    CommentGuid = model.Guid,
                    Content     = model.Content,
                    Time        = model.Time,
                    UserID      = SN.User.UserID,
                    UserName    = SN.User.UserName
                }, examine);
            });

            _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "Comment", Serializer.ToJson(result)));
            return(result);
        }
        public StandardJsonResult AddDepartment(string funcJsonStr)
        {
            var model  = Serializer.FromJson <DepartmentDto>(funcJsonStr);
            var result = new StandardJsonResult <int>();

            result.Try(() =>
            {
                if (model.Name == null)
                {
                    result.Success = false;
                    result.Message = "传递到服务器的参数不合法";
                    result.Value   = -1;
                }
                else
                {
                    //model.MyID = model.MyID.Replace(" ", "");
                    //model.FunctionID = model.ParentID + "." + model.MyID;
                    //res.Value = service.Add(model);
                    model.EnterpriseID = BCSession.User.EnterpriseID;
                    result.Value       = service.Add(model);
                    result.Message     = "添加成功!";
                }
            });
            if (!result.Success)
            {
                result.Message = "添加失败!";
                result.Value   = -1;
            }
            return(result);
        }
Ejemplo n.º 19
0
        public ActionResult UpdateStatus(UpdateStatusModel model)
        {
            _ilog.Info(string.Format("方法名:{0};参数:{1}", "UpdateStatus", Serializer.ToJson(model)));
            var result = new StandardJsonResult();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                ItemStatus status = (ItemStatus)model.Status;
                var user          = GetSession();
                var examine       = new Examine()
                {
                    ExamineStatus = status,
                    UserID        = user.User.UserID,
                    UserName      = user.User.UserName,
                };
                service.SetSceneItemStatus(model.MessageID, examine);
            });

            _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "UpdateStatus", Serializer.ToJson(result)));
            return(result);
        }
        public ActionResult CheckSceneItem(string SceneItemID, int status, string content)
        {
            string _enterpriseID = BCSession.User.EnterpriseID;
            int?   _departmentID = BCSession.User.DepartmentID;
            string _userID       = BCSession.User.UserID;

            var result = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                //result.Value = _sceneItemService.SetSceneItemStatus(SceneItemID, (ItemStatus)status, DateTime.Now);
                var comment = new Comment
                {
                    UserID  = _userID,
                    Content = (status == 1 ? "[审核通过]" : "[需要整改]") + content ?? "",
                };
                if (status == 1)
                {
                    result.Value = _sceneItemService.AddCommentItem(SceneItemID, comment, ItemStatus.Pass) != null;
                }
                else
                {
                    result.Value = _sceneItemService.AddCommentItem(SceneItemID, comment, ItemStatus.Redo) != null;
                }
            });
            return(result);
        }
Ejemplo n.º 21
0
        public ActionResult AddSceneData(AddSceneDataModel model)
        {
            _ilog.Info(string.Format("方法名:{0};参数:{1}", "AddSceneData", Serializer.ToJson(model)));

            var result = new StandardJsonResult <dynamic>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                var sceneModel = new EnterpriseData.Model.SceneItem()
                {
                    PictureGuid = model.Guid,
                    SceneID     = model.SceneID,
                    GPS         = model.Address,
                    Address     = GetAddressByGPS(model.Address),
                    CreateTime  = model.Time,
                    Description = model.Content,
                    Relation    = model.Relation,
                    Count       = model.Count,
                    Type        = (SceneItemType)model.Type,
                    IsExamine   = model.IsExamine,
                    UserID      = BCSession.User.UserID,
                };
                var _sceneModel = service.Add(sceneModel);

                result.Value = new { MessageID = _sceneModel == null ? "" : _sceneModel.Id, Address = _sceneModel.Address };
            });

            _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "AddSceneData", Serializer.ToJson(result)));
            return(result);
        }
Ejemplo n.º 22
0
        public ActionResult GetUserSyncMessages(ModelBase model)
        {
            _ilog.Info(string.Format("方法名:{0};参数:{1}", "GetUserSyncMessages", Serializer.ToJson(model)));

            var result = new StandardJsonResult <dynamic>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var messagelist = service.PopupUserMessageQueueItem(BCSession.User.UserID, BCSession.User.Device)
                                  .Select(n => (UserNotification)n);
                var resultList = messagelist.GroupBy(n => n, new UserNotification_Comparer())
                                 .Select(n => n.OrderByDescending(m => m.Time).First())
                                 .ToList();
                var appSyncService = Ioc.GetService <IAppSyncService>();
                result.Value       = new
                {
                    Data = resultList,
                    Time = appSyncService.GetWorkerTime()
                };
            });

            _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "GetUserSyncMessages", Serializer.ToJson(result)));
            return(result);
        }
Ejemplo n.º 23
0
        public ActionResult UploadImage(UploadImageModel model)
        {
            _ilog.Info(string.Format("方法名:{0};参数:{1}", "UploadImage", Serializer.ToJson(model)));

            var result = new StandardJsonResult();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                Picture pic     = new Picture();
                pic.PictureGuid = model.Guid;
                pic.PictureName = model.FileName;
                HttpFileCollectionBase files = HttpContext.Request.Files;
                if (files.Count > 0)
                {
                    pic.PictureStream = files[0].InputStream;
                    bool f            = service.SavePicture(pic);
                }
            });

            _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "UploadImage", Serializer.ToJson(result)));
            return(result);
        }
Ejemplo n.º 24
0
        public ActionResult SendMessage(string userid, string sendtext)
        {
            var result = new StandardJsonResult <bool>();

            result.Try(() => {
                Guid messageid    = Guid.NewGuid();
                userid            = userid.Replace(",", "|");
                userid            = userid + "|" + BCSession.User.UserID;
                ChatMessageDto cd = new ChatMessageDto()
                {
                    EnterpriseID = BCSession.User.EnterpriseID,
                    IsRead       = ReadStatus.NoRead,
                    Message      = sendtext,
                    MessageID    = messageid,
                    Recipients   = userid,
                    SendTime     = DateTime.Now,
                    SendUserID   = BCSession.User.UserID,
                    SendUserName = BCSession.User.UserName,
                };
                result.Value = serrvice.ProcessChatMessage(cd);
                if (!result.Value)
                {
                    result.Message = "发送失败";
                }
                result.Message = "发送成功";
            });
            if (!result.Success)
            {
                result.Message = "发送失败";
            }
            return(result);
        }
Ejemplo n.º 25
0
        public ActionResult GetOnlineList(string UserName, int rows, int page)
        {
            var result = new StandardJsonResult <OnlineUserResult>();

            result.Try(() => {
                result.Value = new OnlineUserResult();
                int amount   = 0;
                List <UserLoginStateDto> list = services.GetUserLoginStateList(UserName, page, rows, out amount)
                                                .OrderByDescending(n => n.LoginTime).ToList();
                List <OnlineCountModel> mylist = new List <OnlineCountModel>();
                foreach (var user in list)
                {
                    mylist.Add(new OnlineCountModel()
                    {
                        UserLoginStateID = user.UserLoginStateID,
                        Device           = user.Device,
                        LoginIP          = user.LoginIP,
                        LoginTime        = user.LoginTime.Value.ToString(),
                        LoginToken       = user.LoginToken,
                        UserID           = user.UserID,
                        UserName         = user.UserName
                    });
                }
                result.Value.rows  = mylist;
                result.Value.total = amount;
            });
            if (!result.Success)
            {
                result.Value = new OnlineUserResult();
            }
            return(Json(result.Value, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 获取简单的企业列表;下拉框用的
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult GetEnterpriseBySimpleList()
        {
            var result = new StandardJsonResult <List <SimpleModel> >();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var list = _ieIEnterprise.GetAllEnterpriseList();
                if (list != null && list.Count > 0)
                {
                    var resultlist = list.Select(m => new SimpleModel {
                        Id = m.EnterpriseID, Text = m.Name
                    });
                    result.Value = resultlist.ToList();
                }
                else
                {
                    result.Value = new List <SimpleModel>();
                }
            });
            // return result;
            return(Json(result.Value, JsonRequestBehavior.AllowGet));
        }
        protected StandardJsonResult Try(Action action)
        {
            var result = new StandardJsonResult();

            result.Try(action);
            return(result);
        }
        /// <summary>
        /// 获取简单的行业;下拉框用的
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult GetEnterpriseProfessionSimpleList()
        {
            var result = new StandardJsonResult <List <SimpleModel> >();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var list = service.GetAllEnterpriseProfession();
                if (list != null && list.Count > 0)
                {
                    var resultlist = list.Select(m => new SimpleModel {
                        Id = m.EnterpriseProfessionID, Text = m.Name
                    });
                    result.Value = resultlist.ToList();
                }
                else
                {
                    result.Value = new List <SimpleModel>();
                }
            });
            return(new OringinalJsonResult <List <SimpleModel> > {
                Value = result.Value
            });
        }
        public ActionResult GetList(string Name, int rows, int page)
        {
            var result = new StandardJsonResult <EnterpriseProfessionResultModel>();

            result.Try(() => {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                if (page < 1)
                {
                    page = 1;
                }
                if (rows < 10)
                {
                    rows = 10;
                }
                int amount;
                var list        = service.GetEnterpriseProfessionList(Name, rows, page, out amount);
                var viewModel   = new EnterpriseProfessionResultModel();
                viewModel.total = amount;
                viewModel.rows  = list;

                result.Value = viewModel;
            });
            if (!result.Success)
            {
                result.Value = new EnterpriseProfessionResultModel();
            }
            return(new OringinalJsonResult <EnterpriseProfessionResultModel> {
                Value = result.Value
            });
        }
        public ActionResult Update(EnterpriseProfessionModel model)
        {
            var result = new StandardJsonResult();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }

                var service   = Ioc.GetService <IEnterpriseProfessionManagementService>();
                var ad1       = new EnterpriseProfessionDto();
                ad1.Available = model.Available;
                ad1.EnterpriseProfessionID = model.EnterpriseProfessionID;
                ad1.Name = model.Name;
                service.UpdateEnterpriseProfession(model.EnterpriseProfessionID, model.Name, model.Available);
                result.Message = "系统提示:修改成功!";
            });
            if (!result.Success)
            {
                result.Message = "系统提示:修改成功!";
            }
            return(result);
        }
Ejemplo n.º 31
0
 public StandardJsonResult Update(string key, string value)
 {
     var result = new StandardJsonResult();
     result.Try(() =>
     {
         var service = Ioc.Get<ISettingService>();
         service.Update(key, value);
         SettingContext.Instance.Refresh();
     });
     return result;
 }
Ejemplo n.º 32
0
 public StandardJsonResult<string> Upload(ImageType type, Base64Image base64Image, bool cropCenter = false)
 {
     var result = new StandardJsonResult<string>();
     result.Try(() =>
     {
         var service = Ioc.Get<IImageService>();
         if (base64Image == null)
         {
             if (Request.Files.Count == 0 || Request.Files[0] == null)
             {
                 throw new KnownException("找不到文件");
             }
             var file = Request.Files[0];
             result.Value = service.SaveAndReturnKey(type, file, GetUserId(), cropCenter);
         }
         else
         {
             result.Value = service.SaveAndReturnKey(type, base64Image, GetUserId(), cropCenter);
         }
     });
     result.ContentType = "text/plain";
     return result;
 }