Beispiel #1
0
        // GET: Base

        /// <summary>
        ///
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public StandardJsonResult StandardAction(Action action)
        {
            var result = new StandardJsonResult();

            result.StandardAction(action);
            return(result);
        }
Beispiel #2
0
        public ActionResult Login(LoginModel model)
        {
            var result = new StandardJsonResult <dynamic>();

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

                var service = Ioc.GetService <IEnterpriseAccountService>();
                if (!service.CanLogin(model.UserName, model.Password))
                {
                    throw new KnownException("用户名/密码错误,登录失败");
                }
                BCSession.Login(model.UserName);

                result.Value = new
                {
                    UserID         = BCSession.User.UserID,
                    UserName       = BCSession.User.UserName,
                    EnterpriseID   = BCSession.User.EnterpriseID,
                    EnterpriseName = BCSession.User.EnterpriseName,
                    DepartmentID   = BCSession.User.DepartmentID,
                    HeadImage      = BCSession.User.Picture,
                    FunctionIDs    = BCSession.User.FunctionIDs.Where(n => n.StartsWith("Root.AppPermission")).ToArray(),
                    RoleIDs        = BCSession.User.RoleIDs,
                    Token          = BCSession.User.Token
                };
            });
            return(result);
        }
Beispiel #3
0
        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);
                Examine examine = new Examine()
                {
                    UserID        = BCSession.User.UserID,
                    UserName      = BCSession.User.UserName,
                    ExamineStatus = (ItemStatus)status,
                };
                var comment = new Comment
                {
                    UserID  = _userID,
                    Content = (status == 1 ? "通过:" : "整改:") + content ?? "",
                };
                result.Value = _sceneItemService.AddCommentItem(SceneItemID, comment, examine) != null;
            });
            return(result);
        }
Beispiel #4
0
        public StandardJsonResult Try(Action action)
        {
            var result = new StandardJsonResult();

            result.Try(action);
            return(result);
        }
Beispiel #5
0
        public ActionResult ArchiveSceneItem(string SceneItemID)
        {
            string _enterpriseID = BCSession.User.EnterpriseID;
            int?   _departmentID = BCSession.User.DepartmentID;
            string _userID       = BCSession.User.UserID;
            var    result        = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                var comment = new Comment
                {
                    UserID  = _userID,
                    Content = "归档了该条目.",
                    Time    = DateTime.Now
                };
                var user    = GetSession();
                var examine = new Examine()
                {
                    UserID        = user.User.UserID,
                    UserName      = user.User.UserName,
                    ExamineStatus = ItemStatus.Final,
                };
                //_sceneItemService.AddCommentItem(SceneItemID, comment,ItemStatus.Final);
                result.Value = _sceneItemService.SetSceneItemStatus(SceneItemID, examine);
            });
            return(result);
        }
        public ActionResult GetList()
        {
            var result = new StandardJsonResult <ReportCountModel>();

            result.Try(() =>
            {
                InfoStatisticsDto info = service.GetBackInfoStatistics();
                if (info != null)
                {
                    result.Value = new ReportCountModel()
                    {
                        ItemStatus = info.ItemStatus,
                        Pictures   = info.Pictures,
                        Projects   = info.Projects,
                        Scenes     = info.Scenes,
                        Users      = info.Users
                    };
                }
            });
            if (!result.Success)
            {
                result.Value = new ReportCountModel();
            }
            return(Json(result.Value, JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
        //获取某项目的可用角色详单 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);
        }
Beispiel #8
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();

                result.Value = resultList;
            });

            _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "GetUserSyncMessages", Serializer.ToJson(result)));
            return(result);
        }
        public ActionResult GetDepartment()
        {
            var result = new StandardJsonResult <List <DepartmentTree> >();

            result.Try(() =>
            {
                var service = ML.BC.Infrastructure.Ioc.GetService <IEnterpriseDepartmentManagementService>();
                List <DepartmentDto> list = new List <DepartmentDto>();
                if (HasFunction(Functions.Root_SystemSetting_OrganizationManagement_ShowAll))
                {
                    list = service.GetMyDepartment(BCSession.User.EnterpriseID);
                }
                else if (BCSession.User.DepartmentID.HasValue)
                {
                    list = service.GetMyDepartment(BCSession.User.EnterpriseID, BCSession.User.DepartmentID);
                }
                if (list != null && list.Count > 0)
                {
                    List <DepartmentManageModel> mylist = new List <DepartmentManageModel>();
                    foreach (var l in list)
                    {
                        if (l.Available)
                        {
                            DepartmentManageModel m = new DepartmentManageModel()
                            {
                                DepartmentID = l.DepartmentID,
                                Description  = l.Description,
                                _parentId    = l.ParentID,
                                Deleted      = l.Deleted,
                                Available    = l.Available,
                                EnterpriseID = l.EnterpriseID,
                                Name         = l.Name,
                                ParentID     = l.ParentID
                            };
                            mylist.Add(m);
                        }
                    }
                    mylist[0]._parentId       = 0;//不在根节点部门下的管理者不能显示
                    List <DepartmentTree> all = new List <DepartmentTree>();
                    foreach (var rot in mylist)
                    {
                        if (rot._parentId == 0)
                        {
                            DepartmentTree root = new DepartmentTree();
                            root.id             = rot.DepartmentID;
                            root.text           = rot.Name;
                            root.children       = new List <DepartmentTree>();
                            root.children       = process2TreeModel(mylist, root);
                            all.Add(root);
                        }
                    }

                    result.Value = new List <DepartmentTree>();
                    result.Value = all;
                }
            });

            return(Json(result.Value, JsonRequestBehavior.AllowGet));
        }
Beispiel #10
0
        public ActionResult UpdateScene(SceneUpdateModdel model)
        {
            var result = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new KnownException(ModelState.GetFirstError());
                }
                if (model.EndDate < model.BeginDate)
                {
                    throw new KnownException("结束时间需要大于开始时间");
                }
                if (model.SceneTypestring != "")
                {
                    model.SceneType = model.SceneTypestring;
                }
                var dto = (ScenesDto)model;
                if (dto.Address == null || dto.Address.Equals(""))
                {
                    dto.LatitudeAndLongitude = "";
                }
                else
                {
                    Geocoding gd = new Geocoding(new GeocodingParam()
                    {
                        address  = dto.Address,
                        ak       = "",
                        callback = "",
                        city     = "",
                        output   = "json",
                        sn       = ""
                    });
                    GeocoderResultModel gdresult = gd.GetGeocoderResult();
                    double[] ss = GetLocation(gdresult);
                    dto.LatitudeAndLongitude = ss[0] + "|" + ss[1];
                }
                if (model.RoleWorkers == null)
                {
                    dto.Wokers = new List <GroupedUser>();
                }
                else
                {
                    List <GroupedUser> list = new List <GroupedUser>();
                    foreach (var u in model.RoleWorkers)
                    {
                        list.Add(u);
                    }
                    dto.Wokers = list;
                }
                result.Value = _sceneService.UpdateScene(dto);
            });
            if (!result.Value && result.Message == null)
            {
                result.Message = "没有内容更新";
            }
            return(result);
        }
Beispiel #11
0
        protected StandardJsonResult JsonError(string errorMessage)
        {
            var result = new StandardJsonResult();

            result.AddError(errorMessage);

            return(result);
        }
 protected StandardJsonResult <T> Try <T>(Action action, StandardJsonResult <T> result)
 {
     result.Try(() =>
     {
         action();
     });
     return(result);
 }
        public ActionResult GetList(string keyword, BackUserViewModel model)
        {
            var result = new StandardJsonResult <UserJsonResultModel>();

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

                if (model.page < 1)
                {
                    model.page = 1;
                }
                if (model.rows < 1)
                {
                    model.rows = 10;
                }
                if (keyword == null)
                {
                    keyword = "";
                }
                int amount;
                var list = _userManageService.SearchUserByName(keyword, model.page, model.rows, out amount);

                List <UserJsonItemModel> listr = new List <UserJsonItemModel>();
                foreach (var dto in list)
                {
                    UserJsonItemModel item = dto;
                    item.Roles             = new List <String>();
                    var service            = new UserRolesServerce();
                    var listi       = service.GetAllRolesByUserId(dto.UserID);
                    List <string> t = new List <string>();
                    foreach (var iit in listi)
                    {
                        t.Add(iit + "");
                    }
                    item.Roles = t;
                    listr.Add(item);
                }
                result.Value       = new UserJsonResultModel();
                result.Value.total = amount;    //赋值
                result.Value.rows  = listr;
            });
            if (result.Success == true)
            {
                return(new OringinalJsonResult <UserJsonResultModel> {
                    Value = result.Value
                });
            }
            else
            {
                return(new OringinalJsonResult <UserJsonResultModel> {
                    Value = new UserJsonResultModel()
                });
            }
        }
        public ActionResult UploadSmall(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;
                    string fileformat = file[i].FileName.Split('.')[file[i].FileName.Split('.').Count() - 1].ToLower();
                    if (fileformat.IndexOf("doc") >= 0)
                    {
                        ftype = FileType.Word;
                    }
                    else if (fileformat.IndexOf("xls") >= 0)
                    {
                        ftype = FileType.Excel;
                    }
                    else if (fileformat.IndexOf("ppt") >= 0)
                    {
                        ftype = FileType.PPT;
                    }
                    else if (fileformat.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 + "." + fileformat,
                        KnowledgeType = model.materialType,
                        DocumentType  = ftype,
                        FileStream    = sf,
                        EnterpriseID  = BCSession.User.EnterpriseID,
                        DocumentSize  = f.ContentLength,
                        ID            = DateTime.Now.ToFileTime().ToString() + "." + fileformat
                    });
                }
            });
            if (result.Value && result.Success)
            {
                result.Message = "添加成功";
            }
            return(result);
        }
Beispiel #15
0
        protected StandardJsonResult JsonErrorAllowGet(string errorMessage)
        {
            var json = new StandardJsonResult();

            json.AddError(errorMessage);
            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            json.MaxJsonLength       = 1000000;
            return(json);
        }
        public ActionResult GetDepartmentlist()
        {
            #region
            var result = new StandardJsonResult <DepartmentManageResultModel>();
            result.Try(() =>
            {
                var userservice           = ML.BC.Infrastructure.Ioc.GetService <IFrontUserManagementService>();
                List <DepartmentDto> list = new List <DepartmentDto>();
                if (HasFunction(Functions.Root_SystemSetting_OrganizationManagement_ShowAll))
                {
                    list = service.GetMyDepartment(BCSession.User.EnterpriseID);
                }
                else if (BCSession.User.DepartmentID.HasValue)
                {
                    list = service.GetMyDepartment(BCSession.User.EnterpriseID, BCSession.User.DepartmentID);
                }
                if (list != null && list.Count > 0)
                {
                    List <DepartmentList> jsonlist = new List <DepartmentList>();
                    foreach (var d in list)
                    {
                        var dlist          = new DepartmentList();
                        dlist.Available    = d.Available;
                        dlist.Deleted      = d.Deleted;
                        dlist.DepartmentID = d.DepartmentID;
                        dlist.Name         = d.Name;
                        dlist.Description  = d.Description;
                        dlist.ParentID     = d.ParentID;
                        dlist.id           = d.DepartmentID;
                        dlist._parentId    = d.ParentID;
                        dlist.EnterpriseID = d.EnterpriseID;
                        jsonlist.Add(dlist);
                        //dlist.id = _helper.processSID(fun.FunctionID);
                        //dlist._parentId = _helper.processSID(fun.ParentID);
                    }
                    jsonlist[0]._parentId = 0;
                    result.Value          = new DepartmentManageResultModel();
                    result.Value.total    = list.Count;
                    result.Value.rows     = jsonlist;
                }
                else
                {
                    result.Value       = new DepartmentManageResultModel();
                    result.Value.total = 0;
                    result.Value.rows  = new List <DepartmentList>();
                }
            });
            if (!result.Success)
            {
                result.Value = new DepartmentManageResultModel();
            }

            return(Json(result.Value, JsonRequestBehavior.AllowGet));

            #endregion
        }
        /// <summary>
        /// 标准数据返回
        /// </summary>
        /// <typeparam name="T">返回参数</typeparam>
        /// <param name="func">func</param>
        /// <returns></returns>
        protected StandardJsonResult <T> StandardAction <T>(Func <T> func)
        {
            var result = new StandardJsonResult <T>();

            result.StandardAction(() =>
            {
                result.Data = func();
            });
            return(result);
        }
Beispiel #18
0
        public ActionResult DeleteOnlineUser(string UserID)
        {
            var result = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                result.Value = services.DeleteUserLoginState(UserID);
            });
            return(result);
        }
        public ActionResult KeepSession(string timeSpan)
        {
            var result = new StandardJsonResult();

            result.Try(() => {
                var service = Ioc.GetService <IEnterpriseAccountService>();
                service.RefreshUserLoginState(BCSession.User.UserID, BCSession.User.Device);
            });
            return(result);
        }
        public ActionResult GetMessageCount()
        {
            var result = new StandardJsonResult <int>();

            result.Try(() => {
                var services = ML.BC.Infrastructure.Ioc.GetService <IChatMessageService>();
                result.Value = services.GetMessageCount(BCSession.User.UserID);
            });
            return(result);
        }
Beispiel #21
0
        public ActionResult ClearLog()
        {
            var result = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                result.Value = _logService.ClearLog();
            });
            return(result);
        }
Beispiel #22
0
        public FileResult downPickture(string SceneID, string FileName)
        {
            var result = new StandardJsonResult <byte[]>();

            result.Try(() => {
                byte[] ret   = _sceneItemService.DownloadPicturePack(SceneID);
                result.Value = ret;
            });
            return(File(result.Value, "text/plain", FileName + ".zip"));
        }
        public ActionResult DeleteSceneItem(string SceneItemID)
        {
            var result = new StandardJsonResult <bool>();

            result.Try(() =>
            {
                result.Value = _sceneItemService.DeleteSceneItem(SceneItemID);
            });
            return(result);
        }
        public StandardJsonResult <T> Try <T>(Func <T> action)
        {
            var result = new StandardJsonResult <T>();

            result.Try(() =>
            {
                result.Value = action();
            });
            return(result);
        }
        protected StandardJsonResult JsonValidationError()
        {
            var result = new StandardJsonResult();

            foreach (var validationError in ModelState.Values.SelectMany(v => v.Errors))
            {
                result.AddError(validationError.ErrorMessage);
            }
            return(result);
        }
Beispiel #26
0
        public StandardJsonResult <T> StandardAction <T>(Func <T> action)
        {
            var result = new StandardJsonResult <T>();

            result.StandardAction(() =>
            {
                result.Data = action();
            });
            return(result);
        }
Beispiel #27
0
        protected StandardJsonResult JsonError(string errorMessage, JsonRequestBehavior behavior = JsonRequestBehavior.DenyGet)
        {
            var result = new StandardJsonResult {
                JsonRequestBehavior = behavior
            };

            result.AddError(errorMessage);

            return(result);
        }
Beispiel #28
0
        public StandardJsonResult <bool> Add(PropellingMovementManagerDto dto)
        {
            StandardJsonResult <bool> result =
                base.StandardAction <bool>(() =>
            {
                return(PropellingMovementManagerService.Add(dto));
            });

            return(result);
        }
 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;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public StandardJsonResult <PageResult <AdminUserDto> > List(SearchAdminUserParam request)
        {
            StandardJsonResult <PageResult <AdminUserDto> > result =
                base.StandardAction <PageResult <AdminUserDto> >(() =>
            {
                PageResult <AdminUserDto> pageResult = adminUserService.GetAdminUserDtos(request);
                return(pageResult);
            });

            return(result);
        }
Beispiel #31
0
        /// <summary>
        /// SSO系统管理列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public StandardJsonResult <PageResult <OAuthServiceDto> > List(SearchOAuthParam request)
        {
            StandardJsonResult <PageResult <OAuthServiceDto> > result =
                base.StandardAction <PageResult <OAuthServiceDto> >(() =>
            {
                PageResult <OAuthServiceDto> pageResult = oauthService.GetOAuthServersDtos(request);
                return(pageResult);
            });

            return(result);
        }
 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;
 }