コード例 #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 string IComboxService.ArticleType_ComboBox(QueryModel query)
 {
     string json = this.superService.FindList<ArticleTypeConfig>(query);
     List<ArticleTypeConfig> videoTypes = JsonConvert.DeserializeObject<List<ArticleTypeConfig>>(json);
     List<ComboItem> result = videoTypes.Select((videoType, index) => new ComboItem() { Text = videoType.DisplayName, Value = videoType.Id, Selected = (index == 0) ? true : false }).ToList<ComboItem>();
     return JsonConvert.SerializeObject(result);
 }
コード例 #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 string IComboxService.Organ_ComboBox(QueryModel query)
 {
     string json = this.superService.FindList<Organ>(query);
     List<Organ> organs = JsonConvert.DeserializeObject<List<Organ>>(json);
     List<ComboItem> result = organs.Select((organ, index) => new ComboItem() { Text = organ.OrganName, Value = organ.Id, Selected = (index == 0) ? true : false }).ToList<ComboItem>();
     return JsonConvert.SerializeObject(result);
 }
コード例 #3
0
        public JsonResult AjaxHandler(jQueryDataTableParamModel param, string parentId)
        {
            //http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part#Sorting
            QueryModel query = new QueryModel("RecordUser", base.CurrentLoginUser().UserName);
            string json = this.superService.FindList<AlbumTypeConfig>(query);// SuperManager.Instance.FindList<AlbumTypeConfig>(query);
            List<AlbumTypeConfig> AlbumTypeConfigs = JsonConvert.DeserializeObject<List<AlbumTypeConfig>>(json);
            //针对个人用户,需要加上用户过滤
            query = base.getAndQuery(param, "DisplayName", "like", param.sSearch, "RecordDate", "desc", new QueryInfo("ParentId", "=", parentId), new QueryInfo("RecordUser", "=", base.CurrentLoginUser().UserName));
            json = this.superService.FindPageList_JqueryTable<AlbumFolder>(param.iDisplayStart, param.iDisplayLength, query);// SuperManager.Instance.FindPageList_JqueryTable<Album>(param.iDisplayStart, param.iDisplayLength, query);

            JObject jobject = JObject.Parse(json);
            List<AlbumFolder> data = JsonConvert.DeserializeObject<List<AlbumFolder>>(jobject["result"].ToString());
            int i = param.iDisplayStart;
            var linq = from p in data
                       select new
                       {
                           RowId = ++i,
                           Id = p.Id,
                           ParentId = p.ParentId,
                           DisplayName = p.DisplayName,
                           Path = p.Path,
                           FolderType = p.FolderType,
                           RecordDate = p.RecordDate.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"),
                           AlbumType = GetDisplayName(p.AlbumType, AlbumTypeConfigs)
                       };
            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = (Int32)jobject["iTotalRecords"],
                iTotalDisplayRecords = (Int32)jobject["iTotalDisplayedRecords"],
                aaData = linq
            }, JsonRequestBehavior.AllowGet);
        }
コード例 #4
0
 public List<JqueryNote> GetJqueryNote(string search)
 {
     QueryModel queryModel = new QueryModel();
     if (!string.IsNullOrWhiteSpace(search))
         queryModel.AddAndQuery(new List<QueryInfo>() { new QueryInfo("NoteTitle", "like", search), new QueryInfo("NoteKeyWord", "like", search) });
     queryModel.AddSort("RecordDate","desc");
     string json = UnityInstance.Instance.GetObject<ISuperService>().FindList<JqueryNote>(queryModel);
     return JsonConvert.DeserializeObject<List<JqueryNote>>(json);
 }
コード例 #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 string IComboxService.Menu_ComboBox(QueryModel query)
 {
     //query.AddSort("MenuType", "asc");
     //query.AddQuery("Status", "=", true);
     //query.AddQuery(new List<QueryInfo>() { new QueryInfo("MenuType", "=", 0), new QueryInfo("MenuType", "=", 2), new QueryInfo("MenuType", "=", 3) });
     string json = this.superService.FindList<Menu>(query);
     List<Menu> menus = JsonConvert.DeserializeObject<List<Menu>>(json);
     List<ComboItem> result = menus.Select((menu, index) => new ComboItem() { Text = menu.Title, Value = menu.Id, Selected = (index == 0) ? true : false }).ToList<ComboItem>();
     return JsonConvert.SerializeObject(result);
 }
コード例 #6
0
        /// <summary>
        /// 查找角色下的菜单
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        string ITreeService.GetMenuInRole(string roleId)
        {
            if (roleId.Equals("#")) roleId = "Root";
            string json = this.superService.FindList<Role_Menu>(new QueryModel("RoleId", roleId));
            List<Role_Menu> result = JsonConvert.DeserializeObject<List<Role_Menu>>(json);

            var menuIds = from item in result select item.MenuId;
            QueryModel queryModel = new QueryModel();
            queryModel.AddAndQuery("_id", "in", String.Join(",", menuIds.ToArray<String>()) );
            json = this.superService.FindList<Menu>(queryModel);
            List<Menu> menus = JsonConvert.DeserializeObject<List<Menu>>(json);
            IEnumerable<TreeModel> collection = from item in result select new TreeModel() { id = item.MenuId, text = menus.FirstOrDefault(f => f.Id.Equals(item.MenuId)).Title, hasChildren = false };
            return JsonConvert.SerializeObject(collection.ToList<TreeModel>());
        }
コード例 #7
0
 /// <summary>
 /// 菜单树
 /// </summary>
 /// <param name="parentId"></param>
 /// <param name="excludeChild"></param>
 /// <returns></returns>
 string ITreeService.GetMenuTree(string parentId, bool excludeChild)
 {
     if (parentId.Equals("#")) parentId = "Root";
     QueryModel queryModel = new QueryModel();
     queryModel.AddSort("SortIndex", "asc");
     string json = this.superService.FindList<Menu>(queryModel);
     List<Menu> allMenus = JsonConvert.DeserializeObject<List<Menu>>(json);
     var collection = from item in allMenus
                      where item.IsEnabled = true & item.ParentId.Equals(parentId)
                      select new TreeModel()
                      {
                          id = item.Id,
                          text = item.Title,
                          hasChildren = allMenus.Count(f => f.ParentId.Equals(item.Id)) > 0 ? true : false,
                          children = excludeChild ? this.GetMenuTree_Child(item.Id, allMenus) : new List<TreeModel>()
                      };
     return JsonConvert.SerializeObject(collection);
 }
コード例 #8
0
        public string GetNotice(bool showAll)
        {
            QueryModel queryModel = new QueryModel();
            if (!showAll)
                queryModel.AddAndQuery("Status", "=", 0);
            queryModel.AddSort("NoticeDate", "asc");
            string json = UnityInstance.Instance.GetObject<ISuperService>().FindList<NoticeAnnouncement>(queryModel);
            List<NoticeAnnouncement> list = JsonConvert.DeserializeObject<List<NoticeAnnouncement>>(json);

            var linq = from p in list
                       select new
                       {
                           NoticeTitle = p.NoticeTitle,
                           NoticeDate = p.NoticeDate.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"),//p.NoticeDate.ToLocalTime().ToString("yyyy年MM月dd日 HH时mm分"),
                           NoticeContent = p.NoticeContent
                       };
            return JsonConvert.SerializeObject(linq);
        }
コード例 #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        string IAccountService.GetMenuByUserId(string userId)
        {
            //找到用户所属的角色集合
            QueryModel queryModel = new QueryModel("UserId", "=", userId);
            string json = this.superService.FindList<Role_User>(queryModel);
            List<Role_User> role_users = JsonConvert.DeserializeObject<List<Role_User>>(json);
            //找到字符串格式的角色ID集合
            List<string> roleIds = new List<string>();
            foreach (Role_User r_u in role_users)
            {
                roleIds.Add(r_u.RoleId);
            }
            queryModel = new QueryModel("RoleId", "in", String.Join(",", roleIds) );
            json = this.superService.FindList<Role_Menu>(queryModel);
            List<Role_Menu> role_menus = JsonConvert.DeserializeObject<List<Role_Menu>>(json);
            //找到字符串格式的角色ID集合
            List<string> menuIds = new List<string>();
            foreach (Role_Menu r_m in role_menus)
            {
                menuIds.Add(r_m.MenuId);
            }
            #region jstree的问题,不能选择半选状态的node,所以我们读取的时候要读取menu的父类
            List<Menu> all = JsonConvert.DeserializeObject<List<Menu>>(this.superService.FindAll<Menu>());
            List<string> temp = new List<string>();
            foreach (string menuid in menuIds)
            {
                GetMenuByUserId_child(menuid, all, temp);
            }
            foreach (string t in temp)
            {
                if (!menuIds.Contains(t))
                    menuIds.Add(t);
            }
            #endregion

            queryModel = new QueryModel();
            queryModel.AddAndQuery(new QueryInfo("IsEnabled", "=", true));
            queryModel.AddAndQuery(new QueryInfo("_id", "in", String.Join(",", menuIds) ));
            queryModel.AddSort("SortIndex", "asc");
            json = this.superService.FindList<Menu>(queryModel);
            return json;
        }
コード例 #10
0
 public string GetScheduleByDate(string dateKey)
 {
     DateTime date = Convert.ToDateTime(dateKey);//2016/1/29 0:00:00
     QueryModel queryModel = new QueryModel();
     queryModel.AddAndQuery("RecordUser", "=", base.CurrentLoginUser().UserName);
     //下面2个条件并不完善,因为对于(A||B)&&C的支持不到位
     queryModel.AddAndQuery("ScheduleEndDate", ">=", date);
     queryModel.AddAndQuery("ScheduleStartDate", "<=", date.AddDays(1));
     //    query.AddQuery(new List<QueryInfo>() { new QueryInfo(), new QueryInfo() });
     queryModel.AddSort("ScheduleStartDate", "asc");
     string json = UnityInstance.Instance.GetObject<ISuperService>().FindList<Schedule>(queryModel);
     List<Schedule> list = JsonConvert.DeserializeObject<List<Schedule>>(json);
     DateTime dt = Convert.ToDateTime(dateKey);
     var linq = from p in list
                where p.ScheduleStartDate.Date == dt.Date || p.ScheduleEndDate.Date == dt.Date || (p.ScheduleStartDate.Date < dt.Date && p.ScheduleEndDate.Date > dt.Date)
                select new
                {
                    content = p.ScheduleContent,
                    date = p.ScheduleStartDate.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "~" + p.ScheduleEndDate.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")
                };
     return JsonConvert.SerializeObject(linq);
 }
コード例 #11
0
        public JsonResult AjaxHandler(jQueryDataTableParamModel param)
        {
            //http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part#Sorting
            QueryModel queryModel = new QueryModel();
            if (!string.IsNullOrWhiteSpace(param.sSearch))
                queryModel = base.getQuery(param, "SendDate", "desc", new List<QueryInfo>() { new QueryInfo("SendUserDisplayName", "like", param.sSearch), new QueryInfo("RecUserDisplayName", "like", param.sSearch) });

            //    QueryModel query = base.getQuery(param, "SendUser", "like", param.sSearch, "SendDate", "desc");
            if (base.CurrentLoginUser().RoleLevel > 1)//管理员等级的可以看所有
                queryModel.AddAndQuery("RecUser", "=", base.CurrentLoginUser().UserName);
            string json = this.superService.FindPageList_JqueryTable<ChatMessage>(param.iDisplayStart, param.iDisplayLength, queryModel);// SuperManager.Instance.FindPageList_JqueryTable<UserMessage>(param.iDisplayStart, param.iDisplayLength, query);

            JObject jobject = JObject.Parse(json);
            List<ChatMessage> data = JsonConvert.DeserializeObject<List<ChatMessage>>(jobject["result"].ToString());
            int i = param.iDisplayStart;
            var linq = from p in data
                       select new
                       {
                           RowId = ++i,
                           Id = p.Id,
                           SendUser = p.SendUser,
                           RecUser = p.RecUser,
                           SendUserDisplayName = p.SendUserDisplayName,
                           RecUserDisplayName = p.RecUserDisplayName,
                           SendDate = p.SendDate.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"),
                           MessageContent = p.MessageContent,
                           ReceiveStatus = p.ReceiveStatus == 0 ? "<font color=red>未接收</font>" : "<font color=green>已接收</font>",
                           ChatMsgType = Enum.GetName(typeof(ChatMessageype), p.ChatMsgType)
                       };
            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = (Int32)jobject["iTotalRecords"],
                iTotalDisplayRecords = (Int32)jobject["iTotalDisplayedRecords"],
                aaData = linq
            }, JsonRequestBehavior.AllowGet);
        }
コード例 #12
0
        public JsonResult AjaxHandler(jQueryDataTableParamModel param)
        {
            //http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part#Sorting
            QueryModel queryModel = new QueryModel();
            if (!string.IsNullOrWhiteSpace(param.sSearch))
                queryModel = base.getQuery(param, "DebtDate", "desc", new List<QueryInfo>() { new QueryInfo("DebtFromUser", "like", param.sSearch), new QueryInfo("DebtToUser", "like", param.sSearch) });
            //针对个人用户,需要加上用户过滤
            queryModel.AddAndQuery("RecordUser", "=", base.CurrentLoginUser().UserName);
            string json = this.superService.FindPageList_JqueryTable<Debt>(param.iDisplayStart, param.iDisplayLength, queryModel);//DebtManager.Instance.FindPageList_JqueryTable<Debt>(param.iDisplayStart, param.iDisplayLength, query);

            JObject jobject = JObject.Parse(json);
            List<Debt> data = JsonConvert.DeserializeObject<List<Debt>>(jobject["result"].ToString());
            int i = param.iDisplayStart;
            var linq = from p in data
                       select new
                       {
                           RowId = ++i,
                           Id = p.Id,
                           DebtDate = p.DebtDate.ToLocalTime().ToString("yyyy-MM-dd"),
                           DebtFromUser = p.DebtFromUser,
                           DebtToUser = p.DebtToUser,
                           DebtType = p.DebtType,
                           DebtContent = p.DebtContent,
                           DebtProgress = p.DebtProgress,
                           DebtNum = p.DebtNum//,
                           //RecordUser = RobinCore.Instance.GetUserDisplayName(p.RecordUser)
                           //other field
                       };
            return Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = (Int32)jobject["iTotalRecords"],
                iTotalDisplayRecords = (Int32)jobject["iTotalDisplayedRecords"],
                aaData = linq
            }, JsonRequestBehavior.AllowGet);
        }
コード例 #13
0
 /// <summary>
 /// chart
 /// </summary>
 /// <returns></returns>
 public ViewResult Chart()
 {
     //link 和button
     ViewBag.breadCrumb = new List<ToolBar>() { base.GetHomeLink(), base.GetToolBar(DataCache.Instance.MenuCache[this.ServiceKey], "Index", "Money", "PersonTools", "insidecontent") };//link
     ViewBag.toolBars = new List<ToolBar>() { base.GetToolBar(GloablCultureCache.Instance.GetCulture("backbutton"), "Index", "Money", "PersonTools", "insidecontent") };//button
     //获取chart数据源,ajax请求那里返回的x。y数据,无法计算所有的数据支出平均值。
     QueryModel queryModel = new QueryModel();
     queryModel.AddSort("RecordDate", "asc");
     string info = string.Empty;
     string json = this.superService.FindList<Money>(queryModel);// SuperManager.Instance.FindList<Money>(query);.
     List<Money> list = JsonConvert.DeserializeObject<List<Money>>(json);
     if (list.Count > 0)
     {
         float total_in = list.Where(f => f.RecordType == 0).Sum(item => item.RecordNum);
         float total_out = list.Where(f => f.RecordType == 1).Sum(item => item.RecordNum);
         float total = total_in - total_out;
         DateTime d1 = list[list.Count - 1].RecordDate;
         DateTime d2 = list[0].RecordDate;
         int monthTotal = 12 * d1.Year + d1.Month - (12 * d2.Year + d2.Month) + 1;
         info = string.Format("{0}个月内共消费{1}元,平均每月{2}元。", monthTotal, total, total / monthTotal);
     }
     return View((object)info);
 }
コード例 #14
0
        /// <summary>
        /// 查找角色下的用户
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        string ITreeService.GetUserInRole(string roleId)
        {
            if (roleId.Equals("#")) roleId = "Root";
            string json = this.superService.FindList<Role_User>(new QueryModel("RoleId", roleId));
            List<Role_User> result = JsonConvert.DeserializeObject<List<Role_User>>(json);
            var userIds = from item in result select item.UserId;

            QueryModel queryModel = new QueryModel();
            queryModel.AddAndQuery("_id", "in", String.Join(",", userIds.ToArray<String>()) );
            json = this.superService.FindList<User>(queryModel);
            List<User> users = JsonConvert.DeserializeObject<List<User>>(json);

            var collection = from item in result select new TreeModel() { id = item.UserId, text = users.FirstOrDefault(f => f.Id.Equals(item.UserId)).DisplayName, hasChildren = false };
            return JsonConvert.SerializeObject(collection.ToList<TreeModel>());
        }
コード例 #15
0
        /// <summary>
        /// 用户树
        /// </summary>
        /// <param name="Id">支持过滤,参数名可能是跟前端jstree对应的,实际这里是过滤的字符</param>
        /// <returns></returns>
        string ITreeService.GetUserTree(string Id)
        {
            QueryModel queryModel = new QueryModel();
            if (!Id.Equals("#"))
                queryModel.AddAndQuery("DisplayName", "like", Id);
            string json = this.superService.FindList<User>(queryModel);

            List<User> result = JsonConvert.DeserializeObject<List<User>>(json);
            var collection = from item in result where item.IsEnabled = true select new TreeModel() { id = item.Id, text = item.DisplayName, hasChildren = false };
            return JsonConvert.SerializeObject(collection.ToList<TreeModel>());
        }
コード例 #16
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 string IComboxService.User_ComboBox(QueryModel query)
 {
     string json = this.superService.FindList<User>(query);
     List<User> users = JsonConvert.DeserializeObject<List<User>>(json);
     List<ComboItem> result = users.Select((user, index) => new ComboItem() { Text = user.DisplayName, Value = user.UserName, Selected = (index == 0) ? true : false }).ToList<ComboItem>();
     return JsonConvert.SerializeObject(result);
 }
コード例 #17
0
        /// <summary>
        /// 获取用户所属的机构
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        string ITreeService.GetOrganInUser(string userId)
        {
            string json = this.superService.FindList<Organ_User>(new QueryModel("UserId", userId));
            List<Organ_User> result = JsonConvert.DeserializeObject<List<Organ_User>>(json);

            var organIds = from item in result select item.OrganId;
            QueryModel queryModel = new QueryModel();
            queryModel.AddAndQuery("_id", "in", organIds.ToArray<String>()   );
            json = this.superService.FindList<Organ>(queryModel);
            List<Organ> organs = JsonConvert.DeserializeObject<List<Organ>>(json);

            var collection = from item in result select new TreeModel() { id = item.OrganId, text = organs.FirstOrDefault(f => f.Id.Equals(item.OrganId)).OrganName, hasChildren = false };
            return JsonConvert.SerializeObject(collection.ToList<TreeModel>());
        }
コード例 #18
0
        /// <summary>
        /// 复合查询,有and 有or
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static IMongoQuery GetMongoQuery(QueryModel query)
        {
            //没有查询条件
            if (query == null || (query.AndQueryCollections.Count == 0 && query.OrQueryCollections.Count == 0))
                return Query.Null;

            if (query.AndQueryCollections.Count > 0)
            {
                #region 外面是and,里面是or
                List<IMongoQuery> andQuerys = new List<IMongoQuery>();
                foreach (AndQueryInfoCollection qc in query.AndQueryCollections)//qc与qc之间是and关系
                {
                    List<IMongoQuery> orQuerys = new List<IMongoQuery>();
                    foreach (QueryInfo q in qc.Querys)//q与q之间是or关系
                    {
                        if (q.Key.Equals("id", StringComparison.OrdinalIgnoreCase)) q.Key = "_id";
                        IMongoQuery Iq;
                        #region switch
                        switch (q.Compare.ToLower())
                        {
                            case "=":
                                Iq = Query.EQ(q.Key, BsonValue.Create(q.Value));
                                break;
                            case "like":
                                Iq = Query.Matches(q.Key, q.Value.ToString());
                                break;
                            case "<":
                                Iq = Query.LT(q.Key, BsonValue.Create(q.Value));
                                break;
                            case "<=":
                                Iq = Query.LTE(q.Key, BsonValue.Create(q.Value));
                                break;
                            case ">":
                                Iq = Query.GT(q.Key, BsonValue.Create(q.Value));
                                break;
                            case ">=":
                                Iq = Query.GTE(q.Key, BsonValue.Create(q.Value));
                                break;
                            case "in":
                                List<BsonValue> inlist = new List<BsonValue>();
                                //var qs = System.Collections.ArrayList.Adapter(q.Value).ToArray(typeof(string));
                                //string[] f = (string[])ArrayList.Adapter((Array)q.Value).ToArray(typeof(string));
                                string qValue = q.Value.ToString();
                                foreach (string str in qValue.Split(','))
                                {
                                    inlist.Add(BsonValue.Create(str));
                                }
                                Iq = Query.In(q.Key, inlist);
                                break;
                            default:
                                Iq = Query.Null;
                                break;
                        }
                        #endregion
                        orQuerys.Add(Iq);
                    }
                    andQuerys.Add(Query.Or(orQuerys));
                }
                return Query.And(andQuerys);
                #endregion
            }
            else if (query.OrQueryCollections.Count > 0)
            {
                #region 外面是or,里面是and
                List<IMongoQuery> orQuerys = new List<IMongoQuery>();
                foreach (OrQueryInfoCollection qc in query.OrQueryCollections)//qc与qc之间是and关系
                {
                    List<IMongoQuery> andQuerys = new List<IMongoQuery>();
                    foreach (QueryInfo q in qc.Querys)//q与q之间是or关系
                    {
                        if (q.Key.Equals("id", StringComparison.OrdinalIgnoreCase)) q.Key = "_id";
                        IMongoQuery Iq;
                        #region switch
                        switch (q.Compare.ToLower())
                        {
                            case "=":
                                Iq = Query.EQ(q.Key, BsonValue.Create(q.Value));
                                break;
                            case "like":
                                Iq = Query.Matches(q.Key, q.Value.ToString());
                                break;
                            case "<":
                                Iq = Query.LT(q.Key, BsonValue.Create(q.Value));
                                break;
                            case "<=":
                                Iq = Query.LTE(q.Key, BsonValue.Create(q.Value));
                                break;
                            case ">":
                                Iq = Query.GT(q.Key, BsonValue.Create(q.Value));
                                break;
                            case ">=":
                                Iq = Query.GTE(q.Key, BsonValue.Create(q.Value));
                                break;
                            case "in":
                                List<BsonValue> inlist = new List<BsonValue>();
                                //     var qs = System.Collections.ArrayList.Adapter(q.Value).ToArray(typeof(string));
                                foreach (string str in (string[])q.Value)
                                {
                                    inlist.Add(BsonValue.Create(str));
                                }
                                Iq = Query.In(q.Key, inlist);
                                break;
                            default:
                                Iq = Query.Null;
                                break;
                        }
                        #endregion
                        andQuerys.Add(Iq);
                    }
                    orQuerys.Add(Query.And(andQuerys));
                }
                return Query.Or(orQuerys);
                #endregion
            }
            else
            {
                return Query.Null;
            }
        }
コード例 #19
0
        public string GetScheduleCalender(int year, int month, bool showAll)
        {
            //返回模型数据
            ScheduleCalender sc = new ScheduleCalender();
            //包装日历
            List<DateTime> allDays = this.ComputeMonth(year, month);
            //查询所有日程安排
            QueryModel queryModel = new QueryModel();
            queryModel.AddAndQuery("RecordUser", "=", base.CurrentLoginUser().UserName);
            //坐标的日历仍然 显示结束的日程,但是右边的列表不显示
            queryModel.AddAndQuery("ScheduleEndDate", ">=", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day));
            queryModel.AddSort("ScheduleStartDate", "asc");
            string json = UnityInstance.Instance.GetObject<ISuperService>().FindList<Schedule>(queryModel);
            List<Schedule> list = JsonConvert.DeserializeObject<List<Schedule>>(json);
            DateTime firstday = new DateTime(year, month, 1).Date;
            DateTime lastday = new DateTime(year, month, DateTime.DaysInMonth(year, month)).Date;
            foreach (Schedule sche in list)
            {
                sche.ScheduleStartDate = sche.ScheduleStartDate.ToLocalTime();
                sche.ScheduleEndDate = sche.ScheduleEndDate.ToLocalTime();

                if ((sche.ScheduleEndDate.Date > lastday && sche.ScheduleStartDate < firstday)
                    || (sche.ScheduleStartDate.Date >= lastday && sche.ScheduleStartDate <= firstday)
                    || (sche.ScheduleEndDate.Date <= lastday && sche.ScheduleEndDate >= firstday))
                {
                    ScheduleItem item = new ScheduleItem() { date = sche.ScheduleStartDate.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "~" + sche.ScheduleEndDate.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), content = sche.ScheduleContent };
                    sc.ScheduleItems.Add(item);
                }
            }

            foreach (DateTime dt in allDays)
            {
                CalenderDay day = new CalenderDay() { text = dt.Day.ToString(), tag = dt.Date.ToShortDateString(), isCurrentDay = dt.Date == DateTime.Now.Date ? true : false, isCurrentMonth = dt.Month == month ? true : false };
                List<Schedule> temp = list.FindAll(item => item.ScheduleStartDate.Date == dt.Date || item.ScheduleEndDate.Date == dt.Date || (item.ScheduleStartDate.Date < dt.Date && item.ScheduleEndDate.Date > dt.Date));

                day.isHasDetailPlan = temp != null && temp.Count > 0 ? true : false;
                sc.CalenderDays.Add(day);
            }
            return JsonConvert.SerializeObject(sc);
        }
コード例 #20
0
 /// <summary>
 /// 获取频道ID,若没有则新建,查询模型 有问题,暂时没解决(a&&b)||(c&&d),只解决了(a||b)&&(c||d)
 /// </summary>
 /// <param name="userId1"></param>
 /// <param name="userId2"></param>
 /// <returns></returns>
 string getChannelId(string userId1, string userId2)
 {
     //string json = this.superService.FindAll<ChatChannel>();
     //List<ChatChannel> channel = JsonConvert.DeserializeObject<List<ChatChannel>>(json);
     //ChatChannel chat = channel.FirstOrDefault<ChatChannel>(item => (item.ChatLeftUser == userId1 && item.ChatRightUser == userId2)
     //|| (item.ChatLeftUser == userId2 && item.ChatRightUser == userId1));
     QueryModel queryModel = new QueryModel();
     queryModel.AddOrQuery(new List<QueryInfo>() { new QueryInfo("ChatLeftUser", "=", userId1), new QueryInfo("ChatRightUser", "=", userId2) });
     queryModel.AddOrQuery(new List<QueryInfo>() { new QueryInfo("ChatLeftUser", "=", userId2), new QueryInfo("ChatRightUser", "=", userId1) });
     string json = this.superService.FindOne<ChatChannel>(queryModel);
     string ss = this.superService.FindList<ChatChannel>(queryModel);
     ChatChannel chat = JsonConvert.DeserializeObject<ChatChannel>(json);
     if (chat == null)
     {
         chat = new ChatChannel() { ChatLeftUser = userId1, ChatRightUser = userId2 };
         return this.superService.InsertWithIdBack<ChatChannel>(chat);
     }
     else
     {
         return chat.Id;
     }
 }
コード例 #21
0
 /// <summary>
 /// 双击用户打开tab后,聊天框模板通过这个action返回
 /// </summary>
 /// <param name="Id"></param>
 /// <param name="userName"></param>
 /// <param name="userDisplayName"></param>
 /// <returns></returns>
 public PartialViewResult _PartialChatPanel(string channelId)
 {
     //      ChatMessageSingleUserViewModel viewmodel = new ChatMessageSingleUserViewModel() { ChannelId = channelId,  UserDisplayName= sendUserDisplayName };
     //获取所有未读用户消息
     QueryModel queryModel = new QueryModel();
     queryModel.AddAndQuery("RecUser", "=", base.CurrentLoginUser().UserName);
     queryModel.AddAndQuery("ChannelId", "=", channelId);
     queryModel.AddAndQuery("ReceiveStatus", "=", 0);
     string json = this.superService.FindList<ChatMessage>(queryModel);
     List<ChatMessage> unreadMsgs = JsonConvert.DeserializeObject<List<ChatMessage>>(json);
     if (unreadMsgs != null && unreadMsgs.Count > 0)
     {
         //更新这用户消息的状态
         this.superService.UpdateFields<ChatMessage>(new Dictionary<string, object>() { { "ReceiveStatus", 1 } }, queryModel);
     }
      //   viewmodel.ChatMessages = unreadMsgs;
     return PartialView("_PartialChatPanel", unreadMsgs);
 }
コード例 #22
0
        /// <summary>
        /// 用户chat消息
        /// </summary>
        /// <returns></returns>
        public PartialViewResult _PartialChatMssage()
        {
            //头像设定,暂时放这里
            List<string> man = new List<string>() { "Images/defaultIcon/man1.png" };
            List<string> woman = new List<string>() { "Images/defaultIcon/woman1.png", "Images/defaultIcon/woman2.png", "Images/defaultIcon/woman3.png", "Images/defaultIcon/woman4.png", "Images/defaultIcon/woman5.png", "Images/defaultIcon/woman6.png" };
            //查找所有用户当联系人(默认应该是加的好友,暂时我们用所有的用户代替)
            string json = this.superService.FindAll<User>();
            List<User> list = JsonConvert.DeserializeObject<List<User>>(json);
            //获取所有未读用户消息
            QueryModel queryModel = new QueryModel();
            queryModel.AddAndQuery("RecUser", "=", base.CurrentLoginUser().UserName);
            queryModel.AddAndQuery("ReceiveStatus", "=", 0);
            json = this.superService.FindList<ChatMessage>(queryModel);
            List<ChatMessage> unreadMsgs = JsonConvert.DeserializeObject<List<ChatMessage>>(json);
            //左侧用户列表以及显示未读的消息条数
            Random dom = new Random();
            IEnumerable<SimpleUser> linq = from c in list
                                           where c.UserName != DataCache.Instance.LoginUser.UserName
                                           select new SimpleUser()
                                           {
                                               //  Id = c.Id,
                                               //  userName = c.UserName,
                                               userDisplayName = c.DisplayName,
                                               sex = c.Sex,
                                               channelId = this.getChannelId(DataCache.Instance.LoginUser.UserName, c.UserName),
                                               userIcon = c.Sex == 1 ? man[0] : woman[0], //c.Sex == 1 ? man[0] : woman[dom.Next(0, 6)],       //用户头像暂时随机抽取
                                               msgCount = unreadMsgs.Count(item => item.SendUser.Equals(c.UserName))
                                           };

            return PartialView("_PartialChatMssage", linq);
        }
コード例 #23
0
        public Task<bool> RunS(VideoFolder videoFolder)
        {
            return Task.Run(() =>
                  {
                      #region tongbu
                      string basePath = DataCache.Instance.LoginUser.UserFolderPath + videoFolder.Path;
                      string baseUrlPath = DataCache.Instance.LoginUser.UserFolderUrlPath + videoFolder.Path;
                      //get files in folder
                      DirectoryInfo dir = new DirectoryInfo(basePath);
                      List<FileInfo> files = dir.GetFiles().ToList<FileInfo>();
                      //get data in datatable
                      QueryModel query = new QueryModel("UploadUserName", DataCache.Instance.LoginUser.UserName);
                      query.AddAndQuery(new QueryInfo("FolderId", "=", videoFolder.Id));
                      string json = UnityInstance.Instance.GetObject<ISuperService>().FindList<Video>(query);
                      List<Video> videos = JsonConvert.DeserializeObject<List<Video>>(json);//

                      string[] filter = new string[] { ".wmv", ".mp4" };
                      foreach (FileInfo file in files)
                      {
                          if (!filter.Contains(file.Extension.ToLower())) continue;//只加载对应格式的
                          Video data = videos.FirstOrDefault(item => item.FileName.Equals(file.Name));
                          if (data == null)
                          {
                              Video record = new Video()
                              {
                                  FileName = file.Name,
                                  FolderId = videoFolder.Id,
                                  CreationTime = DateTime.Now,
                                  Evaluation = Convert.ToInt32(EvaluationType.一般),
                                  FileExtention = file.Extension.ToLower(),
                                  FilePath = "User\\" + DataCache.Instance.LoginUser.UserName + "\\" + videoFolder.Path + "\\" + file.Name,
                                  FileUrlPath = baseUrlPath + "\\" + file.Name,
                                  FileSize = file.Length,
                                  UploadDate = DateTime.Now,
                                  UploadUserDisplayName = DataCache.Instance.LoginUser.UserDisplayName,
                                  UploadUserName = DataCache.Instance.LoginUser.UserName,
                                  LastAccessTime = file.LastAccessTime
                              };
                              UnityInstance.Instance.GetObject<ISuperService>().Insert<Video>(record);// SuperManager.Instance.Create<Video>(record);
                          }
                          else
                          {
                              videos.Remove(data);
                          }
                      }
                      List<string> toDelete = new List<string>();
                      foreach (Video item in videos)
                      {
                          toDelete.Add(item.Id);
                      }
                      UnityInstance.Instance.GetObject<ISuperService>().DeleteByIds<Video>(String.Join(",", toDelete));
                      #endregion
                      return true;
                  });
        }
コード例 #24
0
 /// <summary>
 /// 同步子文件夹和子文件夹内的文件
 /// </summary>
 /// <param name="parentFolder"></param> 
 void SynchronizingChildFolderAndFile(AlbumFolder parentFolder)
 {
     QueryModel query = new QueryModel("RecordUser", base.CurrentLoginUser().UserName);
     query.AddAndQuery("ParentId", "=", parentFolder.Id);
     string json = this.superService.FindList<AlbumFolder>(query);
     List<AlbumFolder> subFolders = JsonConvert.DeserializeObject<List<AlbumFolder>>(json);//
     #region 同步文件夹
     DirectoryInfo dir = new DirectoryInfo(base.CurrentLoginUser().UserFolderPath + parentFolder.Path);
     DirectoryInfo[] folders = dir.GetDirectories();
     foreach (DirectoryInfo folder in folders)
     {
         //若数据库没有这个文件夹的记录,则新生成
         AlbumFolder record = subFolders.FirstOrDefault(item => item.DisplayName.Equals(folder.Name));
         if (record == null)
         {
             record = new AlbumFolder()
             {
                 AlbumType = parentFolder.AlbumType,
                 FolderType = 0,
                 DisplayName = folder.Name,
                 ParentId = parentFolder.Id,
                 RecordDate = DateTime.Now,
                 RecordUser = base.CurrentLoginUser().UserName,
                 Path = parentFolder.Path + "\\" + folder.Name
             };
             this.superService.Insert<AlbumFolder>(record);
         }
         this.SynchronizingFile(record);//太多了内存撑不住
     }
     #endregion
 }
コード例 #25
0
        public Task<bool> RunS(ArticleFolder articleFolder)
        {
            return Task.Run(() =>
            {
                #region tongbu
                string basePath = DataCache.Instance.LoginUser.UserFolderPath + articleFolder.Path;
                string baseUrlPath = DataCache.Instance.LoginUser.UserFolderUrlPath + articleFolder.Path;
                //get files in folder
                DirectoryInfo dir = new DirectoryInfo(basePath);
                if (!Directory.Exists(basePath))
                    Directory.CreateDirectory(basePath);
                List<FileInfo> files = dir.GetFiles().ToList<FileInfo>();
                //get data in datatable
                QueryModel query = new QueryModel("UploadUserName", DataCache.Instance.LoginUser.UserName);
                query.AddAndQuery(new QueryInfo("FolderId", "=", articleFolder.Id));
                string json = UnityInstance.Instance.GetObject<ISuperService>().FindList<Article>(query);
                List<Article> articles = JsonConvert.DeserializeObject<List<Article>>(json);//

                foreach (FileInfo file in files)
                {
                    Article data = articles.FirstOrDefault(item => item.FileName.Equals(file.Name));
                    if (data == null)
                    {
                        Article record = new Article()
                        {
                            FileName = file.Name,
                            FolderId = articleFolder.Id,
                            CreationTime = file.LastWriteTime,
                            CurrentIndex = 0,
                            Evaluation = Convert.ToInt32(EvaluationType.一般),
                            FileExtention = file.Extension.ToLower(),
                            FilePath = "User\\" + DataCache.Instance.LoginUser.UserName + "\\" + articleFolder.Path + "\\" + file.Name,
                            FileUrlPath = articleFolder.Path + "\\" + file.Name,
                            FileSize = file.Length,
                            UploadDate = DateTime.Now,
                            UploadUserDisplayName = DataCache.Instance.LoginUser.UserDisplayName,
                            UploadUserName = DataCache.Instance.LoginUser.UserName,
                            LastAccessTime = file.LastAccessTime
                        };
                        UnityInstance.Instance.GetObject<ISuperService>().Insert<Article>(record);// SuperManager.Instance.Create<Article>(record);
                    }
                    else
                    {
                        articles.Remove(data);
                    }
                }
                List<string> toDelete = new List<string>();
                foreach (Article item in articles)
                {
                    toDelete.Add(item.Id);
                }
                UnityInstance.Instance.GetObject<ISuperService>().DeleteByIds<Article>(String.Join(",", toDelete));
                #endregion

                return true;
            });
        }
コード例 #26
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 string IComboxService.Role_ComboBox(QueryModel query)
 {
     string json = this.superService.FindList<Role>(query);
     List<Role> roles = JsonConvert.DeserializeObject<List<Role>>(json);
     List<ComboItem> result = roles.Select((role, index) => new ComboItem() { Text = role.RoleName, Value = role.Id, Selected = (index == 0) ? true : false }).ToList<ComboItem>();
     return JsonConvert.SerializeObject(result);
 }
コード例 #27
0
 public JsonResult ChangePsd(User model)
 {
     try
     {
         var oldPsd = Request.Form["OldPassword"];
         Dictionary<string, object> updates = new Dictionary<string, object>() { { "Password", RobinCore.Instance.EncodePassword(Request.Form["Password"]) }, { "LastPasswordChangedDate", DateTime.Now } };
         QueryModel queryModel = new QueryModel();
         queryModel.AddAndQuery("id", "=", model.Id);
         queryModel.AddAndQuery("Password", "=", RobinCore.Instance.EncodePassword(oldPsd));
         bool jsonResult = UnityInstance.Instance.GetObject<IAccountService>().ChangePsd(updates, queryModel);//AccountManager.Instance.ChangePsd(update);
         BootstrapMvc2015GitHub.Framework.Log.Instance.RecordActionLog(new System.Diagnostics.StackFrame(0).GetMethod().Name, this.ServiceKey, "SystemDefine", jsonResult);
         return Json(new { result = jsonResult, text = jsonResult ? "The password updated successfully!" : "something was wrong!", callbackapi = "SystemDefine/User" });
     }
     catch (Exception ex)
     {
         BootstrapMvc2015GitHub.Framework.Log.Instance.RecordActionLog(new System.Diagnostics.StackFrame(0).GetMethod().Name, this.ServiceKey, "SystemDefine", false, ex.Message);
         throw ex;
     }
 }
コード例 #28
0
        /// <summary>
        /// 改变布局
        /// </summary>
        /// <returns></returns>
        public PartialViewResult _PartialChangeLayout()
        {
            //用户的
            string json = UnityInstance.Instance.GetObject<ISuperService>().FindList<UserMainPagePanel>(new QueryModel("UserName", DataCache.Instance.LoginUser.UserName));
            List<UserMainPagePanel> userPanels = JsonConvert.DeserializeObject<List<UserMainPagePanel>>(json);
            //系统默认的
            QueryModel queryModel = new QueryModel();
            queryModel.AddSort("Sindex", "asc");
            json = UnityInstance.Instance.GetObject<ISuperService>().FindList<DefaultMainPagePanel>(queryModel);
            List<DefaultMainPagePanel> panels = JsonConvert.DeserializeObject<List<DefaultMainPagePanel>>(json);

            foreach (DefaultMainPagePanel d in panels)
            {
                if (!d.Readonly)//readonly的默认是check的
                {
                    UserMainPagePanel panel = userPanels.FirstOrDefault(f => f.PanelId == d.Id);
                    if (panel != null)
                        d.Checked = true;
                    else
                        d.Checked = false;
                }
            }
            return PartialView("_PartialChangeLayout", panels);
        }
コード例 #29
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="updates"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 bool IAccountService.ChangePsd(Dictionary<string, object> updates, QueryModel query)
 {
     return this.superService.UpdateFields<User>(updates, query);
 }
コード例 #30
0
 public Task<bool> RunS(AlbumFolder albumFolder)
 {
     return Task.Run(() =>
       {
       #region 同步文件
       string basePath = DataCache.Instance.LoginUser.UserFolderPath + albumFolder.Path;
       //get files in folder
       DirectoryInfo dir = new DirectoryInfo(basePath);
       if (!Directory.Exists(basePath))
           Directory.CreateDirectory(basePath);
       FileInfo[] files = dir.GetFiles();
       //get data in datatable
       QueryModel query = new QueryModel("UploadUserName", DataCache.Instance.LoginUser.UserName);
       query.AddAndQuery(new QueryInfo("FolderId", "=", albumFolder.Id));
       string json = UnityInstance.Instance.GetObject<ISuperService>().FindList<Album>(query);
       List<Album> albums = JsonConvert.DeserializeObject<List<Album>>(json);//
                                                                             //清空cache文件
       if (Directory.Exists(basePath + "\\cache"))
           Directory.Delete(basePath + "\\cache", true);
       Directory.CreateDirectory(basePath + "\\cache");
       //循环每一个图片生成缩略图,如果数据库有了则只生成缩略图,若没 有则插入到数据库
       foreach (FileInfo file in files)
       {
           if (!FileExtention.Instance.CheckImg(file)) continue;
           int width, height;
           FileExtention.Instance.MakeThumbnail(basePath, file.Name, out width, out height);
           Album data = albums.FirstOrDefault(item => item.FileName.Equals(file.Name));
           if (data == null)
           {
               Album record = new Album()
               {
                   FileName = file.Name,
                   FolderId = albumFolder.Id,
                   CreationTime = DateTime.Now,
                   Evaluation = Convert.ToInt32(EvaluationType.一般),
                   FileExtention = file.Extension.ToLower(),
                   FilePath = "User\\" + DataCache.Instance.LoginUser.UserName + "\\" + albumFolder.Path + "\\" + file.Name,
                   FileUrlPath = albumFolder.Path + "\\" + file.Name,
                   ThumbnailUrlPath = albumFolder.Path + "\\cache\\" + file.Name,
                   FileSize = file.Length,
                   UploadDate = DateTime.Now,
                   UploadUserDisplayName = DataCache.Instance.LoginUser.UserDisplayName,
                   UploadUserName = DataCache.Instance.LoginUser.UserName,
                   LastAccessTime = file.LastAccessTime,
                   ThumblWidth = width,
                   ThumblHeight = height
               };
               UnityInstance.Instance.GetObject<ISuperService>().Insert<Album>(record);// SuperManager.Instance.Create<Album>(record);
           }
           else
           {
               albums.Remove(data);
           }
       }
       List<string> toDelete = new List<string>();
       foreach (Album item in albums)
           toDelete.Add(item.Id);
       if (toDelete.Count > 0)
           UnityInstance.Instance.GetObject<ISuperService>().DeleteByIds<Album>(String.Join(",", toDelete));
       #endregion
       return true;
       });
 }