예제 #1
0
        public HttpResponseMessage GetAlldeptAndusers()
        {
            BaseService baseservice = new BaseService();
             IList nhbdepts = baseservice.loadEntityList("select u from WkTDept u");
             IList nhbpersons = baseservice.loadEntityList("select u from WkTUser u ");
             List<DeptsandPerson> dplist = new List<DeptsandPerson>();

             foreach (WkTDept o in nhbdepts)
             {
                 DeptsandPerson dp = new DeptsandPerson();

                 Dept d = new Dept();

                 d.Id = o.Id.ToString();
                 d.DeptName = o.KdName.Trim();
                 dp.Dept = d;
                 List<PersonInfo> pers = new List<PersonInfo>();

                 foreach (WkTUser n in nhbpersons)
                 {
                     if (n.Kdid.Id == o.Id)
                     {
                         PersonInfo per = new PersonInfo();
                         per.Id = n.Id.ToString();
                         per.PersonName = n.KuName;
                         per.PersonPhone = n.KuPhone;
                         per.MD5code = n.ImgMD5Code;
                         //per.Base64img = n.Base64Img;
                         per.IMToken = n.IMToken;
                         per.PersonDept = d;
                         pers.Add(per);

                     }

                 }
                 dp.Persons = pers;

                 dplist.Add(dp);

             }
             DeptsandPersonlist l = new DeptsandPersonlist();

             l.List = dplist;

             string res = "成功";
             string data = JsonTools.ObjectToJson(l);

            var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + " \"data\":" + data + "}";
            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
            };
            return result;
        }
예제 #2
0
        public HttpResponseMessage toLoginMessage([FromBody]namepwd nn)
        {
            string res;
            string data = "1";

            string name = nn.Name; string orpwd = nn.Pwd;
            //string name = "mashi"; string orpwd = "186754";

            BaseService baseservice = new BaseService();
            IList pwd = baseservice.ExecuteSQL("select right(sys.fn_VarBinToHexStr(hashbytes('MD5', '" + orpwd.Trim() + "')),32)"); // 通过数据库加密
            if (pwd == null || pwd.Count <= 0)
            {
                res =  "登录异常!";
            }
            object[] pwdArray = (object[])pwd[0];
            //因为是共用表 选择是工作小秘书相关的角色
            IList userList = baseservice.loadEntityList("select u from WkTUser u right join u.UserRole role where role.KrDESC='工作小秘书角色' and u.KuLid='" + name.Trim() + "' and u.KuPassWD='" + pwdArray[0] + "'");
            if (userList == null || userList.Count <= 0)
            {
                res =  "用户名或密码错误!";
            }
            else if (userList.Count > 1)
            {
                res =  "用户异常,请联系管理员!";
            }
            else
            {

                Role role = new Role();
                WkTUser u = (WkTUser)userList[0];
                foreach (WkTRole r in u.UserRole)
                {
                    if (r.KrDESC.Trim().Equals("工作小秘书角色"))//是本系统的用户角色
                    {
                        role.RoleOrder = r.KrOrder.ToString();
                        role.RoleName = r.KrName;
                    }
                }

                Dept d = new Dept();
                d.Id = u.Kdid.Id.ToString();
                d.DeptName = u.Kdid.KdName.Trim();

                PersonInfo per = new PersonInfo();
                per.Id = u.Id.ToString();
                per.PersonName = u.KuName;
                per.PersonPhone = u.KuPhone;
                per.PersonDept = d;
                per.PersonRole = role;
                per.PersonAccount = u.KuLid;
                per.IMToken = u.IMToken;
                //if(u.im)
                per.MD5code = u.ImgMD5Code;
                per.Base64img = u.Base64Img;

                data =  JsonTools.ObjectToJson(per);

                res =  "登录成功";
            }

            var jsonStr = "{\"Message\":" + "\""+res+"\"" + ","+" \"data\":"+ data+"}";
            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
            };
            return result;
        }
예제 #3
0
        //签退
        public HttpResponseMessage GetsignExitInfo(int id)
        {
            string res = "";
            string timetxt = "";
            BaseService baseService = new BaseService();
            DateTime today;

            today = DateTime.Now;
            WkTUser user = new WkTUser();
            user = (WkTUser)baseService.loadEntity(user, id);

            if (CNDate.isworkDay(today.Date.Ticks))
            {
                IList attendanceList = baseService.loadEntityList("from Attendance where STATE=" + (int)IEntity.stateEnum.Normal + " and User="******" and SignDate=" + today.Date.Ticks);
                if (attendanceList != null && attendanceList.Count == 1)
                {
                    Attendance todaySignStart = (Attendance)attendanceList[0];
                    IList usuallyDayList = baseService.loadEntityList("from UsuallyDay where STATE=" + (int)IEntity.stateEnum.Normal + " and StartTime<=" + today.Date.Ticks + " order by StartTime desc");
                    if (usuallyDayList != null && usuallyDayList.Count == 1)
                    {
                        UsuallyDay u = (UsuallyDay)usuallyDayList[0];

                        if (u.WorkTimeEnd <= today.TimeOfDay.Ticks)//未早退
                        {
                            if (todaySignStart.LateOrLeaveEarly == (int)Attendance.lateOrLeaveEarlyEnum.LateAndEarly)  //登陆为LateAndEarly表示迟到
                            {
                                todaySignStart.LateOrLeaveEarly = (int)Attendance.lateOrLeaveEarlyEnum.Late; // 只是迟到
                            }
                            else
                            {
                                todaySignStart.LateOrLeaveEarly = (int)Attendance.lateOrLeaveEarlyEnum.Normal;  //  正常签到
                            }
                        }

                        else //早退
                        {
                            if (todaySignStart.LateOrLeaveEarly == (int)Attendance.lateOrLeaveEarlyEnum.LateAndEarly)
                            {
                                todaySignStart.LateOrLeaveEarly = (int)Attendance.lateOrLeaveEarlyEnum.LateAndEarly; //迟到并且早退
                            }
                            else
                            {
                                todaySignStart.LateOrLeaveEarly = (int)Attendance.lateOrLeaveEarlyEnum.Early; //只是早退
                            }
                        }

                    }
                    todaySignStart.SignEndTime = today.TimeOfDay.Ticks;
                    todaySignStart.SignDate = today.Date.Ticks;
                    todaySignStart.SignDay = today.Day;
                    todaySignStart.SignMonth = today.Month;
                    todaySignStart.SignYear = today.Year;
                    todaySignStart.State = (int)IEntity.stateEnum.Normal;
                    todaySignStart.TimeStamp = DateTime.Now.Ticks;
                    todaySignStart.User = user;
                    try
                    {
                        baseService.SaveOrUpdateEntity(todaySignStart);
                        res = "签退成功";
                    }
                    catch
                    {
                        res = "签退失败";

                    }
                    timetxt = CNDate.getTimeByTimeTicks(todaySignStart.SignStartTime) + "-" + CNDate.getTimeByTimeTicks(today.TimeOfDay.Ticks);
                }
            }

            var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + " \"data\":\"" + timetxt + "\"}";
            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
            };
            return result;
        }
예제 #4
0
        public HttpResponseMessage GetUserInfo(string uid)
        {
            string res = "错误";

            string data = "1";

            BaseService baseService = new BaseService();

            string perid = uid;
            long id = long.Parse(perid);
            WkTUser w = new WkTUser();
            w = (WkTUser)baseService.loadEntity(w, id);

            if (w.Id.ToString() == uid)
            {
                res = "成功";

                PersonInfo p = new PersonInfo();
                p.Id = w.Id.ToString();
                p.PersonName = w.KuName;
                if (w.KuPhone != null)
                {
                    p.PersonPhone = w.KuPhone.Trim();

                }
                p.MD5code = w.ImgMD5Code.Trim();

                Dept d = new Dept();
                d.Id = w.Kdid.Id.ToString();
                d.DeptName = w.Kdid.KdName.Trim();
                p.PersonDept = d;

                data = JsonTools.ObjectToJson(p);

            }

            var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + " \"data\":" + data + "}";
            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
            };
            return result;
        }
예제 #5
0
        public HttpResponseMessage GetRiZhi2(string userid, string seeid, string logtick)
        {
            string res = "";
            string sql1 = "select u from WkTUser u where u.KuName='" + userid + "'";
            string sql2 = "select u from WkTUser u where u.Id='" + seeid + "'";
            string sql3 = "select u.DeptId from Wktuser_M_Dept u where u.WktuserId=" + userid + " and u.State = " + (int)IEntity.stateEnum.Normal;
            BaseService baseservice = new BaseService();
            List<WkTDept> theDepts = new List<WkTDept>();
            IList theone = baseservice.loadEntityList(sql3);
            if (theone != null && theone.Count > 0)
            {
                List<RiZhiinfo> stafflist = new List<RiZhiinfo>();
                WkTUser user = new WkTUser();
                user = (WkTUser)baseservice.loadEntity(user, Convert.ToInt64(seeid));
                string m = user.Kdid.Id.ToString();
                int flog = 1;
                for (int i = 0; i < theone.Count; i++)
                {

                    string a = "";
                    a = ((WkTDept)theone[i]).Id.ToString();
                    if (a == m)
                    {
                        flog = 0;
                        string sqlstr = "";
                        if (logtick == "0")
                        {
                            sqlstr = "with cte as " +
                                        "( " +
                                        " select row=row_number()over(order by getdate()), * from LOG_T_STAFFLOG where WktUserId=" + seeid.ToString() + " and WriteTime > " + logtick.ToString() +
                                        ") " +
                                        " select * from cte where row between " + "1" + " and " + "10";
                        }
                        else
                        {
                            sqlstr = "with cte as " +
                                        "( " +
                                        " select row=row_number()over(order by getdate()), * from LOG_T_STAFFLOG where WktUserId=" + seeid.ToString() + " and WriteTime < " + logtick.ToString() +
                                        ") " +
                                        " select * from cte where row between " + "1" + " and " + "10";
                        }
                        IList one = baseservice.ExecuteSQL(sqlstr);

                        if (one != null && one.Count > 0)
                        {
                            for (int j = 0; j < one.Count; j++)
                            {
                                object[] sf = (object[])one[j];
                                RiZhiinfo st = new RiZhiinfo();
                                //// Personinfo p = new Personinfo();
                                st.PersonId = sf[4].ToString();//分享人的ID

                                WkTUser user1 = new WkTUser();
                                user1 = (WkTUser)baseservice.loadEntity(user1, Convert.ToInt64(st.PersonId));
                                st.PersonName = user1.KuLid;//分享人的姓名
                                //long mm = user1.Kdid.Id;
                                WkTDept dept = new WkTDept();
                                dept = (WkTDept)baseservice.loadEntity(dept, Convert.ToInt64(m));
                                st.PersonDept = dept.KdName;//分享人的部门
                                st.Logtick = sf[3].ToString();
                                st.PersonMD5code = user1.ImgMD5Code;
                                st.Contenttxt140 = HtmlToReguFormat140(sf[2].ToString());//日志内容去格式前140
                                ////st.ContenttxtAll = sf[5].ToString();//日志全部内容
                                st.RizhiTime = new DateTime(Convert.ToInt64(sf[3].ToString())).ToString("yyyy年MM月dd日 HH:mm:ss");//日志时间
                                st.RizhiId = sf[1].ToString(); //日志id
                                st.Imglist = HtmlToReguForimg(sf[2].ToString());//日志图片
                                List<Comments> q = new List<Comments>();
                                List<comm> ps = new List<comm>();
                                IList c = baseservice.loadEntityList("from StaffLog where State=" + (int)IEntity.stateEnum.Normal + "and Id=" + st.RizhiId);
                                if (c != null && c.Count > 0)
                                {
                                    foreach (StaffLog n in c)
                                    {
                                        IList<Comments> r = n.Comments;
                                        foreach (Comments s in r)
                                        {
                                            string sqql = "select u from WkTUser u where u.KuName='" + s.CommentPersonName.Trim() + "'";
                                            WkTUser ww = (WkTUser)baseservice.loadEntityList(sqql)[0];
                                            comm p = new comm();
                                            p.Id = ww.Id.ToString();
                                            p.Na = s.CommentPersonName;//评论人名字
                                            //IList d = baseservice.loadEntityList("from StaffLog where State=" + 758);
                                            //foreach(WkTUser d1 in d)
                                            //{
                                            //    p.Id = d1.Id;
                                            //}
                                            p.Co = s.Content;//评论内容
                                            p.Commtime = new DateTime(s.TimeStamp).ToString("yyyy年MM月dd日 HH:mm:ss");
                                            ps.Add(p);
                                        }
                                    }
                                }
                                st.Comments = ps;
                                stafflist.Add(st);
                            }
                        }
                    }
                }
                RiZhiAll l = new RiZhiAll();
                l.List = stafflist;
                res = "成功";
                string data = JsonTools.ObjectToJson(l);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;

                if(flog==1)
                {
                    return RiZhiYo(userid, seeid, logtick);

                }
            }
            else
            {
                return RiZhiYo(userid, seeid, logtick);

            }
        }
예제 #6
0
        /// <summary>
        /// 获得自己的日程
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="rctime"></param>
        /// <returns></returns>
        public HttpResponseMessage GetOwnRiCheng(string userid, string rctime)
        {
            string res = "";
            string data = "1";

            BaseService baseservice = new BaseService();
            //List<RCDayBag> list = new List<RCDayBag>();
            RCDayBagList rrll = new RCDayBagList();

            long startick;
            long endtick;

            if (rctime == "0")
            {
                string fstr = "select top 1 LOG_T_STAFFSCHEDULE.ScheduleTime  from LOG_T_STAFFSCHEDULE  where WkTUserId = " + userid + " and STATE = 0 order by LOG_T_STAFFSCHEDULE.ScheduleTime desc";

                IList firres = baseservice.ExecuteSQL(fstr);

                object[] obj;
                if (firres != null && firres.Count > 0)
                {
                    obj  = (object[])firres[0];
                    DateTime d = new DateTime(long.Parse(obj[0].ToString()));
                    string str = d.ToString("yyyy-MM-dd");
                    long daytick = d.Date.Ticks;
                    startick = d.AddDays(1).Ticks;//daytick;
                    endtick = d.Date.Ticks;

                    for (int i = 0; i < 10; i++)
                    {

                        RCDayBag rdb1 = new RCDayBag();
                        rdb1.DayString = str;
                        rdb1.DayTick = daytick.ToString();

                        string sql1 = "with cte as " +
                            "( " +
                            " select row=row_number()over(order by LOG_T_STAFFSCHEDULE.ScheduleTime DESC ), * from LOG_T_STAFFSCHEDULE where  ScheduleTime < " + startick.ToString() + " and ScheduleTime > " + endtick.ToString() + "  and  WkTUserId=" + userid.ToString() +
                            ") " +
                            " select * from cte ";
                        //where row between " + "1" + " and " + "10";

                        IList nbhstaff1 = baseservice.ExecuteSQL(sql1);

                        //List<RiChenginfo> info = new List<RiChenginfo>();
                        if (nbhstaff1.Count > 0 && nbhstaff1 != null)
                        {
                            long tick2 = 0;
                            for (int i1 = 0; i1 < nbhstaff1.Count; i1++)
                            {
                                object[] rc = (object[])nbhstaff1[i1];
                                RiChenginfo ric = new RiChenginfo();

                                ric.RichengId = rc[1].ToString();
                                ric.PersonId = rc[6].ToString();
                                ric.RichengContent = rc[2].ToString();
                                ric.RichengTime = new DateTime(Convert.ToInt64(rc[3])).ToString("yyyy年MM月dd日 HH:mm:ss");
                                WkTUser user = new WkTUser();
                                user = (WkTUser)baseservice.loadEntity(user, Convert.ToInt64(rc[6]));
                                ric.PersonName = user.KuName;
                                ric.PersonDeptName = user.Kdid.KdName.ToString().Trim();
                                ric.RichengSub = rc[4].ToString();
                                ric.ArrangeManId = rc[10].ToString();
                                ric.TimeTick = rc[3].ToString();
                                ric.DoState = getDostate(rc[3].ToString(), rc[11]);//rc[11] == null ? rc[11].ToString() : "null";
                                ric.IsRemind = rc[5].ToString();

                                    ric.RemindTime = new DateTime(Convert.ToInt64(rc[9])).ToString("yyyy年MM月dd日 HH:mm:ss");

                                rdb1.RichengDayList.Add(ric);

                                //info.Add(ric);
                                tick2 = long.Parse(rc[3].ToString());

                            }
                            rrll.List.Add(rdb1);
                            //list.Add(rdb1);
                            //rdb1.RichengDayList = info;
                            string str2 = "select top 1 LOG_T_STAFFSCHEDULE.ScheduleTime  from LOG_T_STAFFSCHEDULE  where WkTUserId = " + userid + " and STATE = 0 and ScheduleTime < " + tick2.ToString() + " order by LOG_T_STAFFSCHEDULE.ScheduleTime desc";
                            IList firtick2 = baseservice.ExecuteSQL(str2);

                            if (firtick2 != null && firtick2.Count > 0)
                            {
                                object[] obj2 = (object[])firtick2[0];
                                DateTime d2 = new DateTime(long.Parse(obj2[0].ToString()));

                                str = d2.ToString("yyyy-MM-dd");
                                daytick = d2.Date.Ticks;
                                startick = d2.AddDays(1).Ticks;
                                endtick = daytick;// d2.AddDays(-1).Ticks;

                            }
                            else
                            {
                                break;

                            }

                        }
                        else
                        {

                            break;

                        }

                    }

                    res = "成功";
                    //RCDayBagList rl = new RCDayBagList();
                    //rl.List = list;
                    data = JsonTools.ObjectToJson(rrll);

                }
                else
                {

                    res = "没有内容";
                    data = "1";

                }

                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };

                return result;
            }
            else
            {

                DateTime d = new DateTime(long.Parse(rctime));
                string str = d.ToString("yyyy-MM-dd");

                long daytick = 0;//d.Date.Ticks;
                startick = 0;// d.AddDays(1).Ticks;//daytick;
                endtick = 0;// d.Date.Ticks;

                string str3 = "select top 1 LOG_T_STAFFSCHEDULE.ScheduleTime  from LOG_T_STAFFSCHEDULE  where WkTUserId = " + userid + " and STATE = 0 and ScheduleTime < " + rctime.ToString() + " order by LOG_T_STAFFSCHEDULE.ScheduleTime desc";
                IList firtick3 = baseservice.ExecuteSQL(str3);

                if (firtick3 != null && firtick3.Count > 0)
                {
                    object[] obj3 = (object[])firtick3[0];

                    DateTime d3 = new DateTime(long.Parse(obj3[0].ToString()));

                    str = d3.ToString("yyyy-MM-dd");
                    daytick = d3.Date.Ticks;
                    startick = d3.AddDays(1).Ticks;
                    endtick = daytick;// d2.AddDays(-1).Ticks;
                }
                else
                {

                    res = "没有内容";
                    data = "1";

                    var jsonStr1 = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                    var result1 = new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StringContent(jsonStr1, Encoding.UTF8, "text/json")
                    };

                    return result1;

                }

                for (int i = 0; i < 10; i++)
                {

                    RCDayBag rdb1 = new RCDayBag();
                    rdb1.DayString = str;
                    rdb1.DayTick = daytick.ToString();

                    string sql1 = "with cte as " +
                        "( " +
                        " select row=row_number()over(order by LOG_T_STAFFSCHEDULE.ScheduleTime DESC ), * from LOG_T_STAFFSCHEDULE where  ScheduleTime < " + startick.ToString() + " and ScheduleTime > " + endtick.ToString() + "  and  WkTUserId=" + userid.ToString() +
                        ") " +
                        " select * from cte ";
                    //where row between " + "1" + " and " + "10";

                    IList nbhstaff1 = baseservice.ExecuteSQL(sql1);

                    //List<RiChenginfo> info = new List<RiChenginfo>();
                    if (nbhstaff1.Count > 0 && nbhstaff1 != null)
                    {
                        long tick2 = 0;
                        for (int i1 = 0; i1 < nbhstaff1.Count; i1++)
                        {
                            object[] rc = (object[])nbhstaff1[i1];
                            RiChenginfo ric = new RiChenginfo();

                            ric.RichengId = rc[1].ToString();
                            ric.PersonId = rc[6].ToString();
                            ric.RichengContent = rc[2].ToString();
                            ric.RichengTime = new DateTime(Convert.ToInt64(rc[3])).ToString("yyyy年MM月dd日 HH:mm:ss");
                            WkTUser user = new WkTUser();
                            user = (WkTUser)baseservice.loadEntity(user, Convert.ToInt64(rc[6]));
                            ric.PersonName = user.KuName;
                            ric.PersonDeptName = user.Kdid.KdName.ToString().Trim();
                            ric.RichengSub = rc[4].ToString();
                            ric.ArrangeManId = rc[10].ToString();
                            ric.DoState = getDostate(rc[3].ToString(), rc[11]);//rc[11]==null?rc[11].ToString():"null";
                            ric.TimeTick = rc[3].ToString();
                            //info.Add(ric);
                            rdb1.RichengDayList.Add(ric);

                            tick2 = long.Parse(rc[3].ToString());

                        }
                        //rdb1.RichengDayList = info;
                        rrll.List.Add(rdb1);
                        string str2 = "select top 1 LOG_T_STAFFSCHEDULE.ScheduleTime  from LOG_T_STAFFSCHEDULE  where WkTUserId = " + userid + " and STATE = 0 and ScheduleTime < " + tick2.ToString() + " order by LOG_T_STAFFSCHEDULE.ScheduleTime desc";
                        IList firtick2 = baseservice.ExecuteSQL(str2);

                        if (firtick2 != null && firtick2.Count > 0)
                        {
                            object[] obj = (object[])firtick2[0];
                            DateTime d2 = new DateTime(long.Parse(obj[0].ToString()));

                            str = d2.ToString("yyyy-MM-dd");
                            daytick = d2.Date.Ticks;
                            startick = d2.AddDays(1).Ticks;
                            endtick = daytick;// d2.AddDays(-1).Ticks;

                        }
                        else
                        {
                            break;

                        }

                    }
                    else
                    {

                        break;

                    }

                    //list.Add(rdb1);

                }

                res = "成功";
                //RCDayBagList rl = new RCDayBagList();
                //rl.List = list;
                data = JsonTools.ObjectToJson(rrll);

                //}
                //else
                //{

                //    res = "没有内容";
                //    data = "1";

                //}

                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };

                return result;

            }

            //string sqlstr = null;
            //if (rctime == "0")
            //{
            //    sqlstr = "with cte as " +
            //                "( " +
            //                " select row=row_number()over(order by getdate()), * from LOG_T_STAFFSCHEDULE where  ScheduleTime > " + rctime.ToString() + "and WkTUserId=" + userid.ToString() +
            //                ") " +
            //                " select * from cte where row between " + "1" + " and " + "10";
            //}
            //else
            //{
            //    sqlstr = "with cte as " +
            //                "( " +
            //                " select row=row_number()over(order by getdate()), * from LOG_T_STAFFSCHEDULE where  ScheduleTime < " + rctime.ToString() + "and WkTUserId=" + userid.ToString() +
            //                ") " +
            //                " select * from cte where row between " + "1" + " and " + "10";
            //}

            //IList nbhstaff = baseservice.ExecuteSQL(sqlstr);
            //List<RiChenginfo> info = new List<RiChenginfo>();
            //if (nbhstaff.Count > 0 && nbhstaff != null)
            //{
            //    for (int i = 0; i < nbhstaff.Count; i++)
            //    {
            //        object[] rc = (object[])nbhstaff[i];
            //        RiChenginfo ric = new RiChenginfo();

            //        ric.RichengId = rc[1].ToString();
            //        ric.PersonId = rc[6].ToString();
            //        ric.RichengContent = rc[2].ToString();
            //        ric.RichengTime = new DateTime(Convert.ToInt64(rc[3])).ToString("yyyy年MM月dd日 HH:mm:ss");
            //        WkTUser user = new WkTUser();
            //        user = (WkTUser)baseservice.loadEntity(user, Convert.ToInt64(rc[6]));
            //        ric.PersonName = user.KuName;
            //        ric.PersonDeptName = user.Kdid.KdName.ToString().Trim();
            //        ric.RichengSub = rc[4].ToString();
            //        ric.ArrangeManId = rc[10].ToString();
            //        ric.TimeTick = rc[3].ToString();
            //        info.Add(ric);
            //    }

            //    RiChengAll l = new RiChengAll();
            //    l.List = info;
            //    res = "成功";
            //    data = JsonTools.ObjectToJson(l);
            //    var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
            //    var result = new HttpResponseMessage(HttpStatusCode.OK)
            //    {
            //        Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
            //    };
            //    return result;
            //}
            //else
            //{
            //    res = "没有内容";
            //    data = "1";//JsonTools.ObjectToJson(l);
            //    var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
            //    var result = new HttpResponseMessage(HttpStatusCode.OK)
            //    {
            //        Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
            //    };
            //    return result;
            //}
        }
예제 #7
0
        public static List<long> getWorkDayNum(DateTime startDate, DateTime endDate)
        {
            BaseService baseService = new BaseService();
            IList workDays = new List<int>();
            IList holidayList = baseService.loadEntityList("from Holiday where STATE=" + (int)IEntity.stateEnum.Normal + " and StartTime<=" + startDate.Date.Ticks + " and EndTime>=" + endDate.Date.Ticks);
            if (holidayList == null || holidayList.Count == 0)
            {
                holidayList = new List<long>();
            }
            IList workDayList = baseService.loadEntityList("from WorkDay where STATE=" + (int)IEntity.stateEnum.Normal + " and WorkDateTime<=" + startDate.Date.Ticks + " and WorkDateTime>=" + endDate.Date.Ticks);
            if (workDayList == null || holidayList.Count == 0)
            {
                workDayList = new List<long>();
            }
            IList usuallyDayList = baseService.loadEntityList("from UsuallyDay where STATE=" + (int)IEntity.stateEnum.Normal + " and StartTime<=" + startDate.Date.Ticks + " order by StartTime desc");
            if (usuallyDayList != null && usuallyDayList.Count == 1)
            {
                UsuallyDay u = (UsuallyDay)usuallyDayList[0];
                char[] wd = u.WorkDay.ToCharArray();
                for (int i = 0; i < wd.Length; i++)
                {
                    if (wd[i].Equals((char)UsuallyDay.workDayEnum.WorkDay))
                    {
                        workDays.Add(i);
                    }
                }
            }
            List<long> dateList = new List<long>();
            long ticks = startDate.Date.Ticks;
            while (ticks <= endDate.Date.Ticks)
            {
                DateTime date = new DateTime(ticks);
                if (holidayList.Contains(ticks))
                {
                    ticks = new DateTime(ticks).AddDays(1).Date.Ticks;
                    continue;
                }
                if (workDayList.Contains(ticks))
                {
                    dateList.Add(ticks);
                    ticks = new DateTime(ticks).AddDays(1).Date.Ticks;
                    continue;
                }

                if (IsInWorkDay(date, workDays))
                {
                    dateList.Add(ticks);

                }
                //foreach (int dayOfWeek in workDays)
                //{
                //    if ((dayOfWeek + 1 == (int)date.DayOfWeek)||(dayOfWeek == 6 && (int)date.DayOfWeek == 0)) //一个星期中的第几天
                //    {
                //        ticks = new DateTime(ticks).AddDays(1).Date.Ticks;
                //        break;
                //        continue;
                //    }
                //}

                ticks = new DateTime(ticks).AddDays(1).Date.Ticks;

            }
            return dateList;
        }
예제 #8
0
        public HttpResponseMessage GetContentall([FromUri]string logid)
        {
            string res = "";

            BaseService baseservice = new BaseService();

            StaffLog sl = new StaffLog();

            sl = (StaffLog)baseservice.loadEntity(sl, Convert.ToInt64(logid));

            if (sl != null && sl.Id > 0)
            {

                res = "成功";

                string content = sl.Content;
                string data = JsonTools.ObjectToJson(content);

                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;
            }
            else
            {

                res = "错误";
                string data = "1";
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;

            }
        }
예제 #9
0
        /// <summary>
        /// 获得所有的日程
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="rctime"></param>
        /// <returns></returns>
        public HttpResponseMessage GetAllRiCheng(string userid, string rctime)
        {
            string sqlstr = null;
            if (rctime == "0")
            {
                sqlstr = "with cte as " +
                            "( " +
                            " select row=row_number()over(order by getdate()), * from LOG_T_STAFFSCHEDULE where  ScheduleTime > " + rctime.ToString() +
                            ") " +
                            " select * from cte where row between " + "1" + " and " + "10";
            }
            else
            {
                sqlstr = "with cte as " +
                            "( " +
                            " select row=row_number()over(order by getdate()), * from LOG_T_STAFFSCHEDULE where  ScheduleTime < " + rctime.ToString() +
                            ") " +
                            " select * from cte where row between " + "1" + " and " + "10";
            }
            string res = "";
            BaseService baseservice = new BaseService();
            IList nbhstaff = baseservice.ExecuteSQL(sqlstr);
            List<RiChenginfo> info = new List<RiChenginfo>();
            if (nbhstaff.Count > 0 && nbhstaff != null)
            {
                for (int i = 0; i < nbhstaff.Count; i++)
                {
                    object[] rc = (object[])nbhstaff[i];
                    RiChenginfo ric = new RiChenginfo();

                    ric.RichengId = rc[1].ToString();
                    ric.PersonId = rc[6].ToString();
                    ric.RichengContent = rc[2].ToString();
                    ric.RichengTime = new DateTime(Convert.ToInt64(rc[3])).ToString("yyyy年MM月dd日 HH:mm:ss");
                    WkTUser user = new WkTUser();
                    user = (WkTUser)baseservice.loadEntity(user, Convert.ToInt64(rc[6]));
                    ric.PersonName = user.KuName;
                    ric.PersonDeptName = user.Kdid.KdName.ToString().Trim();
                    ric.RichengSub = rc[4].ToString();
                    ric.ArrangeManId = rc[10].ToString();
                    info.Add(ric);
                }

                RiChengAll l = new RiChengAll();
                l.List = info;
                res = "成功";
                string data = JsonTools.ObjectToJson(l);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;
            }
            else
            {
                res = "没有内容";
                string data = "1";//JsonTools.ObjectToJson(l);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;
            }
        }
예제 #10
0
        public string Base64StringToImage(string base64Imgstring,int id)
        {
            string res;
            BaseService baseservice = new BaseService();
            String inputStr = "";
            string url = "";
            string md5code = "";
            try
            {
                                //FileStream ifs = new FileStream(txtFileName, FileMode.Open, FileAccess.Read);
                                //StreamReader sr = new StreamReader(ifs);
                                //byte[] buffer = Convert.FromBase64String(base64Imgstring);
                                //String textBase64 = Base64.encodeToString(textByte, Base64.DEFAULT);
                inputStr = base64Imgstring.Substring(22);
                byte[] arr = Convert.FromBase64String(inputStr);
                MemoryStream ms = new MemoryStream(arr);
                Bitmap bmp = new Bitmap(ms);

                                //bmp.Save(txtFileName + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                                //bmp.Save(txtFileName + ".bmp", ImageFormat.Bmp);
                                //bmp.Save(txtFileName + ".gif", ImageFormat.Gif);
                                //bmp.Save(txtFileName + ".png", ImageFormat.Png);

                ms.Close();

                url  = HttpContext.Current.Server.MapPath("/") +
                         @"\\Images\\Icons\\" + id + ".png";

                if (File.Exists(url))
                {
                 File.Delete(url);
                }

                bmp.Save(url,ImageFormat.Png);

                if (File.Exists(url))
                {
                    md5code =   GetMD5HashFromFile(url);

                   WkTUser w = new WkTUser();
                   w = (WkTUser)baseservice.loadEntity(w, id);

                   w.ImgMD5Code = md5code;
                   w.Base64Img = base64Imgstring;

                   baseservice.SaveOrUpdateEntity(w);

                }

                //sr.Close();
                //ifs.Close();
                //this.pictureBox2.Image = bmp;
                //if (File.Exists(txtFileName))
                //{
                    //File.Delete(txtFileName);
                //}
                res = "转换成功"; //+base64Imgstring.Length + "    " + md5code;
                //MessageBox.Show("转换成功!");
            }
            catch (Exception ex)
            {
                res = "Base64StringToImage 转换失败\nException:" + ex.Message; //+ "      00000" + md5code + inputStr;
                //MessageBox.Show("Base64StringToImage 转换失败\nException:" + ex.Message);
            }
            return res;
        }
예제 #11
0
        public HttpResponseMessage RiChengYo(string userid,string seeid,string rctime)
        {
            string res = null;
            string sqlstr = null;
            if (rctime == "0")
            {
                sqlstr = "with cte as " +
                            "( " +
                            " select row=row_number()over(order by getdate()), * from dbo.RiCheng where  ScheduleTime > " + rctime.ToString() + "and WkTUserId=" + userid.ToString() +"and SharePersonId="+seeid.ToString()+
                            ") " +
                            " select * from cte where row between " + "1" + " and " + "10";
            }
            else
            {
                sqlstr = "with cte as " +
                            "( " +
                            " select row=row_number()over(order by getdate()), * from dbo.RiCheng where  ScheduleTime < " + rctime.ToString() + "and WkTUserId=" + userid.ToString() + "and SharePersonId=" + seeid.ToString() +
                            ") " +
                            " select * from cte where row between " + "1" + " and " + "10";
            }
            BaseService baseservice = new BaseService();
            IList nbhstaff = baseservice.ExecuteSQL(sqlstr);
            List<RiChenginfo> info = new List<RiChenginfo>();
            if (nbhstaff.Count > 0 && nbhstaff != null)
            {
                for (int i = 0; i < nbhstaff.Count; i++)
                {
                    object[] rc = (object[])nbhstaff[i];
                    RiChenginfo ric = new RiChenginfo();
                    ric.RichengId = rc[9].ToString();//日程Id
                    ric.PersonId = rc[2].ToString();//分享人Id
                    ric.RichengContent = rc[5].ToString();//日程内容
                    ric.RichengTime = new DateTime(Convert.ToInt64(rc[4])).ToString("yyyy年MM月dd日 HH:mm:ss");//分享时间
                    ric.RemindTime = new DateTime(Convert.ToInt64(rc[7])).ToString("yyyy年MM月dd日 HH:mm:ss");//提醒时间
                    WkTUser user = new WkTUser();
                    user = (WkTUser)baseservice.loadEntity(user, Convert.ToInt64(rc[3]));
                    ric.PersonName = user.KuName;//分享人姓名
                    ric.PersonDeptName = user.Kdid.KdName.ToString();//分享人部门
                    ric.RichengSub = rc[6].ToString();//日程主题

                    ric.Logtick = rc[4].ToString();
                    //ric.Contenttxt140 = HtmlToReguFormat140(rc[2].ToString());//日志内容去格式前140

                    ric.TimeTick = rc[4].ToString();
                    ric.ArrangeManId = rc[11].ToString();
                    info.Add(ric);
                }

                RiChengAll l = new RiChengAll();
                l.List = info;
                res = "成功";
                string data = JsonTools.ObjectToJson(l);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;
            }
            else
            {
                res = "没有内容";
                string data = "1";//JsonTools.ObjectToJson(l);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;
            }
        }
예제 #12
0
        /// <summary>
        /// 上下级查看分享
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="seeid"></param>
        /// <param name="rctime"></param>
        /// <returns></returns>
        public HttpResponseMessage GetRiCheng2(string userid, string seeid, string rctime)
        {
            string res = "";
            string sql1 = "select u from WkTUser u where u.KuName='" + userid + "'";
            string sql2 = "select u from WkTUser u where u.Id='" + seeid + "'";
            string sql3 = "select u.DeptId from Wktuser_M_Dept u where u.WktuserId=" + userid + " and u.State = " + (int)IEntity.stateEnum.Normal;
            BaseService baseservice = new BaseService();
            List<WkTDept> theDepts = new List<WkTDept>();
            IList theone = baseservice.loadEntityList(sql3);
            if (theone != null && theone.Count > 0)
            {
                List<RiChenginfo> rlist = new List<RiChenginfo>();
                WkTUser user = new WkTUser();
                user = (WkTUser)baseservice.loadEntity(user, Convert.ToInt64(seeid));
                string m = user.Kdid.Id.ToString();
                int flog = 1;
                for (int i = 0; i < theone.Count; i++)
                {

                    string a = "";
                    a = ((WkTDept)theone[i]).Id.ToString();
                    if (a == m)
                    {
                        flog = 0;
                        string sqlstr = "";
                        if (rctime == "0")
                        {
                            sqlstr = "with cte as " +
                                        "( " +
                                        " select row=row_number()over(order by getdate()), * from LOG_T_STAFFSCHEDULE where WktUserId=" + seeid.ToString() + " and ScheduleTime > " + rctime.ToString() +
                                        ") " +
                                        " select * from cte where row between " + "1" + " and " + "10";
                        }
                        else
                        {
                            sqlstr = "with cte as " +
                                        "( " +
                                        " select row=row_number()over(order by getdate()), * from LOG_T_STAFFSCHEDULE where WktUserId=" + seeid.ToString() + " and ScheduleTime < " + rctime.ToString() +
                                        ") " +
                                        " select * from cte where row between " + "1" + " and " + "10";
                        }
                        IList one = baseservice.ExecuteSQL(sqlstr);

                        if (one != null && one.Count > 0)
                        {
                            for (int j = 0; j < one.Count; j++)
                            {
                                object[] sf = (object[])one[j];
                                RiChenginfo st = new RiChenginfo();
                                //// Personinfo p = new Personinfo();
                                st.PersonId = sf[6].ToString();//分享人的ID

                                WkTUser user1 = new WkTUser();
                                user1 = (WkTUser)baseservice.loadEntity(user1, Convert.ToInt64(st.PersonId));
                                st.PersonName = user1.KuName;//分享人的姓名
                                //long mm = user1.Kdid.Id;
                                WkTDept dept = new WkTDept();
                                dept = (WkTDept)baseservice.loadEntity(dept, Convert.ToInt64(m));
                                st.PersonDeptName = dept.KdName;//分享人的部门
                                st.Logtick = sf[3].ToString();
                                st.RichengTime = new DateTime(Convert.ToInt64(sf[3].ToString())).ToString("yyyy年MM月dd日 HH:mm:ss");//日程时间
                                st.RichengId = sf[1].ToString(); //日程id
                                st.RemindTime = new DateTime(Convert.ToInt64(sf[9].ToString())).ToString("yyyy年MM月dd日 HH:mm:ss");//提醒时间
                                st.RichengContent=sf[2].ToString();//日程内容
                                st.RichengSub=sf[4].ToString();//日程主题
                                st.ArrangeManId = sf[10].ToString();
                                st.TimeTick = sf[3].ToString();

                                rlist.Add(st);
                            }
                        }
                    }
                }
                RiChengAll l = new RiChengAll();
                l.List = rlist;
                res = "成功";
                string data = JsonTools.ObjectToJson(l);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;

                if (flog == 1)
                {
                    return RiChengYo(userid, seeid, rctime);

                }
            }
            else
            {
                return RiChengYo(userid, seeid, rctime);

            }
        }
예제 #13
0
        public HttpResponseMessage addRicheng([FromBody]jd jdata)
        {
            BaseService baseService = new BaseService();

            string res = "";

            string json = jdata.jsondata;
            JavaScriptSerializer js = new JavaScriptSerializer();
            RiChengData list = js.Deserialize<RiChengData>(json);

            try
            {

                WkTUser ww = new WkTUser();
                ww = (WkTUser)baseService.loadEntity(ww, long.Parse(list.Uid));

                List<WkTUser> sharedUser = new List<WkTUser>();

                foreach (PersonInfo p in list.Sharelist)
                {

                    WkTUser w = new WkTUser();
                    w = (WkTUser)baseService.loadEntity(w, long.Parse(p.Id));

                    sharedUser.Add(w);
                }

                StaffSchedule staffSchedule = new StaffSchedule();
                staffSchedule.IfRemind = list.Isre ? (int)StaffSchedule.IfRemindEnum.Renmind : (int)StaffSchedule.IfRemindEnum.NotRemind;
                //会议时间
                staffSchedule.ScheduleTime = (DateTime.Parse(list.Dotime)).Ticks; //this.dateTimePicker2.Value.Ticks;//scheduleDate.Date.Ticks + dateTimePicker1.Value.TimeOfDay.Ticks;
                //提醒时间
                staffSchedule.RemindTime = (DateTime.Parse(list.Retime)).Ticks;//this.dateTimePicker1.Value.Ticks;//scheduleDate.Date.Ticks + dateTimePicker2.Value.TimeOfDay.Ticks;
                staffSchedule.Staff = ww;
                staffSchedule.StaffScheduleStaffs = sharedUser;
                staffSchedule.Subject = list.Title;
                staffSchedule.TimeStamp = DateTime.Now.Ticks;
                staffSchedule.State = (int)IEntity.stateEnum.Normal;
                staffSchedule.Content = list.Content;
                staffSchedule.ArrangeMan = ww;//user;

                baseService.SaveOrUpdateEntity(staffSchedule);

                res = "成功";
                string data = "1"; //JsonTools.ObjectToJson(list); //jdata.jsondata;//ss.Content;//JsonTools.ObjectToJson(ss);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;

            }
            catch(Exception ex)
            {
                res = ex.Message;
                string data = "1"; //JsonTools.ObjectToJson(list); //jdata.jsondata;//ss.Content;//JsonTools.ObjectToJson(ss);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;

            }
        }
예제 #14
0
        //获得所有随笔
        public HttpResponseMessage GetALLSuiBi(string sbtime)
        {
            string res = "";
            BaseService baseservice = new BaseService();
            string sqlstr = "";
            if (sbtime == "0")
            {
                //sqlstr = "select row=row_number()over(order by getdate()), dbo.SuiBi.Contents, dbo.SuiBi.WkTUserId, dbo.WK_T_DEPT.KD_NAME, dbo.WK_T_USER.KD_ID, dbo.SuiBi.WriteTime, dbo.SuiBi.STATE, dbo.SuiBi.Id, dbo.WK_T_USER.KU_NAME" +
                //         " from  dbo.SuiBi INNER JOIN dbo.WK_T_USER ON dbo.SuiBi.WkTUserId = dbo.WK_T_USER.KU_ID INNER JOIN dbo.WK_T_DEPT ON dbo.WK_T_USER.KD_ID = dbo.WK_T_DEPT.KD_ID " +
                //          "where dbo.SuiBi.WkTUserId= "+ userid .ToString ()+"   and dbo.SuiBi.STATE= 0 and dbo.SuiBi.WriteTime> "+sbtime .ToString ()+"  order by dbo.SuiBi.WriteTime DESC";
                //Console.WriteLine (sqlstr);

                //sqlstr = "with cte as" +
                //          "(" +
                //          "select top 100 percent row=row_number()over(order by SuiBi.WriteTime()desc), dbo.SuiBi.Contents, dbo.SuiBi.WkTUserId, dbo.WK_T_DEPT.KD_NAME, dbo.WK_T_USER.KD_ID, dbo.SuiBi.WriteTime, dbo.SuiBi.STATE, dbo.SuiBi.Id, dbo.WK_T_USER.KU_NAME" +
                //          "from  dbo.SuiBi INNER JOIN dbo.WK_T_USER ON dbo.SuiBi.WkTUserId = dbo.WK_T_USER.KU_ID INNER JOIN dbo.WK_T_DEPT ON dbo.WK_T_USER.KD_ID = dbo.WK_T_DEPT.KD_ID " +
                //          "where dbo.SuiBi.WkTUserId=" + userid.ToString() + " and dbo.SuiBi.STATE= 0 and dbo.SuiBi.WriteTime> " + sbtime.ToString() + " order by dbo.SuiBi.WriteTime DESC" +
                //          ") " +
                //          "select * from cte where row between" + "1" + "and" + "10"  +"order by dbo.SuiBi.WriteTime desc";
                sqlstr = "with cte as" +
                    "(select top 100 percent row=row_number()over(order by(SuiBi.WriteTime)desc), dbo.SuiBi.Contents, dbo.SuiBi.WkTUserId, dbo.WK_T_DEPT.KD_NAME, dbo.WK_T_USER.KD_ID, dbo.SuiBi.WriteTime, dbo.SuiBi.STATE, dbo.SuiBi.Id, dbo.WK_T_USER.KU_NAME " +
                    " from  dbo.SuiBi INNER JOIN dbo.WK_T_USER ON dbo.SuiBi.WkTUserId = dbo.WK_T_USER.KU_ID INNER JOIN dbo.WK_T_DEPT ON dbo.WK_T_USER.KD_ID = dbo.WK_T_DEPT.KD_ID " +
                    " where  dbo.SuiBi.STATE= 0  and dbo.SuiBi.WriteTime> " + sbtime +
                    ")" +
                    "select * from cte where row >0 and row <11 order by WriteTime desc";
                Console.WriteLine(sqlstr);

                //sqlstr = "with cte as " +
                //           "( " +
                //           " select row=row_number()over(order by getdate()), * from SuiBiV where WkTUserId =  " + userid.ToString() + " and STATE = 0 and WriteTime > " + sbtime.ToString() +
                //           ") " +
                //           " select * from cte where row between " + "1" + " and " + "10";
            }
            else
            {
                sqlstr = "with cte as" +
                         "(select top 100 percent row=row_number()over(order by(SuiBi.WriteTime)desc), dbo.SuiBi.Contents, dbo.SuiBi.WkTUserId, dbo.WK_T_DEPT.KD_NAME, dbo.WK_T_USER.KD_ID, dbo.SuiBi.WriteTime, dbo.SuiBi.STATE, dbo.SuiBi.Id, dbo.WK_T_USER.KU_NAME " +
                         " from  dbo.SuiBi INNER JOIN dbo.WK_T_USER ON dbo.SuiBi.WkTUserId = dbo.WK_T_USER.KU_ID INNER JOIN dbo.WK_T_DEPT ON dbo.WK_T_USER.KD_ID = dbo.WK_T_DEPT.KD_ID " +
                         " where  dbo.SuiBi.STATE= 0 and dbo.SuiBi.WriteTime<" + sbtime +
                         ")" +
                         "select * from cte where row >0 and row <11 order by WriteTime desc";
                //sqlstr = "with cte as " +
                //           "( " +
                //           " select row_number()over(order by getdate()), * from SuiBiView where WkTUserId =  " + userid.ToString() + " and STATE = 0 and WriteTime < " + sbtime.ToString() +
                //           ") " +
                //           " select * from cte where row between " + "1" + " and " + "10";
            }
            IList nbhsuibi = baseservice.ExecuteSQL(sqlstr);
            List<SuiBiinfo> suibilist = new System.Collections.Generic.List<SuiBiinfo>();
            if (nbhsuibi != null && nbhsuibi.Count > 0)
            {

                for (int i = 0; i < nbhsuibi.Count; i++)
                {
                    SuiBiinfo st = new SuiBiinfo();
                    object[] o = (object[])nbhsuibi[i];
                    st.Suibicontent = o[1].ToString();
                    st.Personid = o[2].ToString();
                    st.Persondeptname = o[3].ToString().Trim();
                    st.Writetime = new DateTime(Convert.ToInt64(o[5].ToString())).ToString("yyyy年MM月dd日 HH:mm:ss");
                    st.TimeTick = o[5].ToString();
                    st.Suibiid = o[7].ToString();
                    st.Personname = o[8].ToString();
                    suibilist.Add(st);
                }
                //for (int i = 0; i < 9; i++)
                //{
                //    SuiBiinfo st = new SuiBiinfo();
                //    st.Suibitime = new DateTime(((Models.SuiBi)nbhsuibi[i]).WriteTime).ToString("yyyy年MM月dd日 HH:mm");
                //    st.Suibicontentbefor = Htmlsuibibefor(((Models.SuiBi)nbhsuibi[i]).Contents);
                //    st.Suibicontent = ((SuiBi)nbhsuibi[i]).Contents;
                //    st.Suibiid = ((Models.SuiBi)nbhsuibi[i]).Id.ToString();

                //    //List <com > own=new System.Collections.Generic.List<com>() ;

                //}
                worklogService.Controllers.SuiBiController.SuiBiinfo.SuiBiAll all = new worklogService.Controllers.SuiBiController.SuiBiinfo.SuiBiAll();
                all.List = suibilist;
                res = "成功";
                string data = JsonTools.ObjectToJson(all);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;
            }
            else if (nbhsuibi != null && nbhsuibi.Count > 0 && nbhsuibi.Count < 10)
            {
                for (int i = 0; i < nbhsuibi.Count; i++)
                {
                    SuiBiinfo st = new SuiBiinfo();
                    st.Writetime = new DateTime(((Models.SuiBi)nbhsuibi[i]).WriteTime).ToString("yyyy年MM月dd日 HH:mm:ss");
                    st.TimeTick = ((Models.SuiBi)nbhsuibi[i]).WriteTime.ToString();
                    // st.Suibicontentbefor = Htmlsuibibefor(((Models.SuiBi)nbhsuibi[i]).Contents);
                    st.Suibiid = ((Models.SuiBi)nbhsuibi[i]).Id.ToString();
                    suibilist.Add(st);

                }
                worklogService.Controllers.SuiBiController.SuiBiinfo.SuiBiAll all = new worklogService.Controllers.SuiBiController.SuiBiinfo.SuiBiAll();
                all.List = suibilist;
                res = "成功";
                string data = JsonTools.ObjectToJson(all);
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;
            }
            else
            {
                res = "没有内容";
                string data = "1";
                var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;
            }

            /* string res = "";
             BaseService baseservice = new BaseService();
             IList suibitext = baseservice.loadEntityList("from SuiBi where wktuserid= " + userid.ToString() + "");
             List<SuiBiinfo > ownsuibi=new System.Collections.Generic.List<SuiBiinfo>();
             if (ownsuibi != null && ownsuibi.Count > 0)
             {
                 for (int i = 0; i < ownsuibi.Count; i++)
                 {

                 }
             }*/
        }
예제 #15
0
 /// <summary>
 /// 判断是否是工作日,工作日为true
 /// </summary>
 /// <param name="ticks">Date的Ticks</param>
 /// <returns></returns>
 public static bool isworkDay(long ticks)
 {
     DateTime today = new DateTime(ticks);
     BaseService baseService = new BaseService();
     IList holidayList = baseService.loadEntityList("from Holiday where STATE=" + (int)IEntity.stateEnum.Normal + " and StartTime<=" + ticks + " and EndTime>=" + ticks);
     if (holidayList != null && holidayList.Count == 1)
     {
         return false;
     }
     IList workDayList = baseService.loadEntityList("from WorkDay where STATE=" + (int)IEntity.stateEnum.Normal + " and WorkDateTime=" + ticks);
     if (workDayList != null && workDayList.Count == 1)
     {
         return false;
     }
     IList usuallyDayList = baseService.loadEntityList("from UsuallyDay where STATE=" + (int)IEntity.stateEnum.Normal + " and StartTime<=" + ticks + " order by StartTime desc");
     if (usuallyDayList != null && usuallyDayList.Count == 1)
     {
         UsuallyDay u = (UsuallyDay)usuallyDayList[0];
         char[] workDays = u.WorkDay.ToCharArray();
         if (((int)today.DayOfWeek != 0 && workDays[(int)today.DayOfWeek - 1].Equals((char)UsuallyDay.workDayEnum.Holiday)) || ((int)today.DayOfWeek == 0 && workDays[6].Equals((char)UsuallyDay.workDayEnum.Holiday)))
         {
             return false;
         }
         else if (((int)today.DayOfWeek != 0 && workDays[(int)today.DayOfWeek - 1].Equals((char)UsuallyDay.workDayEnum.WorkDay)) || ((int)today.DayOfWeek == 0 && workDays[6].Equals((char)UsuallyDay.workDayEnum.WorkDay)))
         {
             return true;
         }
     }
     return true;
 }
예제 #16
0
        public IEnumerable<long> Get()
        {
            BaseService baseservice = new BaseService();

            IList i = baseservice.loadEntityList("select u from Comments u ");

            long[] b = new long[2000];
            int num = 0;
            foreach (Comments o in i)
            {
                b[num] = o.Id;

                num++;
            }
            return b;
            //return new string[] { "value1", "value2" };
        }
예제 #17
0
        public HttpResponseMessage GetAttenceInfo(int id)
        {
            BaseService baseService = new BaseService ();
            string res = "";

            string timetxt = "" ;

            WkTUser user = new WkTUser ()  ;
            user = (WkTUser)baseService.loadEntity(user, id);
                   DateTime today;

                   today = DateTime.Now;

                    if (CNDate.isworkDay(today.Date.Ticks))//工作日登录
                    {
                        //查询最近的工作起始时间安排
                        IList attendanceList = baseService.loadEntityList("from Attendance where STATE=" + (int)IEntity.stateEnum.Normal + " and User="******" and SignDate=" + today.Date.Ticks);

                        if (attendanceList != null && attendanceList.Count == 1)//今天登录过
                        {
                            res = "今天登录过";
                            Attendance atd = (Attendance)attendanceList[0];
                            timetxt += atd.SignStartTime != 0 ? CNDate.getTimeByTimeTicks(atd.SignStartTime) : "";
                            timetxt += "-";
                            timetxt += atd.SignEndTime != 0 ? CNDate.getTimeByTimeTicks(atd.SignEndTime) : "未签退";
                        }

                        else // 今天没有登陆过
                        {
                            Attendance todaySignStart = new Attendance();//用于记录考勤信息
                            IList usuallyDayList = baseService.loadEntityList("from UsuallyDay where STATE="
                                + (int)IEntity.stateEnum.Normal + " and StartTime<=" + today.Date.Ticks +
                                " order by StartTime desc"); //查询作息时间
                            if (usuallyDayList != null && usuallyDayList.Count == 1) //存在作息时间设置
                            {
                                UsuallyDay u = (UsuallyDay)usuallyDayList[0];
                                if (u.WorkTimeStart >= today.TimeOfDay.Ticks)
                                {
                                    todaySignStart.LateOrLeaveEarly = (int)Attendance.lateOrLeaveEarlyEnum.Early; // 正常签到
                                }
                                else
                                {
                                    todaySignStart.LateOrLeaveEarly = (int)Attendance.lateOrLeaveEarlyEnum.LateAndEarly; // 迟到
                                }
                            }
                            todaySignStart.SignStartTime = today.TimeOfDay.Ticks;
                            todaySignStart.SignDate = today.Date.Ticks;
                            todaySignStart.SignDay = today.Day;
                            todaySignStart.SignMonth = today.Month;
                            todaySignStart.SignYear = today.Year;
                            todaySignStart.State = (int)IEntity.stateEnum.Normal;

                                todaySignStart.TimeStamp = DateTime.Now.Ticks;

                            todaySignStart.User = user;
                            try
                            {
                                baseService.SaveOrUpdateEntity(todaySignStart);
                                res = "签到成功";
                            }
                            catch
                            {
                                res = "签到失败";

                            }
                            timetxt = CNDate.getTimeByTimeTicks(todaySignStart.SignStartTime) + "-"+"未签退";
                        }
                    }
                    else
                    {
                        timetxt = "今天是休息日";

                        //this.attendance_label.Text = "今天是休息日";

                    }

            //string data = JsonTools.ObjectToJson(l);

                    var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + " \"data\":\"" + timetxt + "\"}";
            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
            };
            return result;
        }
예제 #18
0
        //别人分享给自己的日志
        public HttpResponseMessage GetRiZhi1(int userid, int staffid)
        {
            string res = "";
            BaseService baseservice = new BaseService();
            IList nbhstaff = baseservice.ExecuteSQL("with cte as " +
                            "( " +
                            " select row=row_number()over(order by getdate()), * from WktuserShareUserId where SharePresonid =  " + userid.ToString() + " and WktuserShareUserId.STATE = 0 and Id > " + staffid.ToString() +
                            ") " +
                            " select * from cte where row between " + "1" + " and " + "10");

            List<StaffandPerson> stafflist = new List<StaffandPerson>();

            if (nbhstaff != null && nbhstaff.Count > 0)
            {
                for (int i = 0; i < nbhstaff.Count; i++)
                {
                    object[] sf = (object[])nbhstaff[i];
                    StaffandPerson st = new StaffandPerson();
                    st.HeaderId = int.Parse(sf[3].ToString());//谁分享的
                    st.Name = sf[6].ToString();//分享人的姓名
                    st.Contentext = HtmlToReguFormat(sf[5].ToString());
                    //st.Contentext = sf[5].ToString();//日志全部内容
                    st.TimeText = new DateTime(Convert.ToInt64(sf[4].ToString())).ToString("yyyy年MM月dd日 HH:mm:ss");
                    //st.Tag = sf[7]; //日志id
                    //st.ContentClicked += rizhi_ContentClicked;
                    //st.Parent = rz_flowLayoutPanel;
                    //rz_flowLayoutPanel.Tag = sf[1];//Id号;
                    stafflist.Add(st);
                }
                StaffAll l = new StaffAll();
                l.List = stafflist;
                res = "成功";
                string data = JsonTools.ObjectToJson(l);
                var jsonStr = "{\"Mseeage\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                };
                return result;
            }
            return null;
        }
예제 #19
0
        public HttpResponseMessage GetSendPhoneNum([FromUri]string phonenum,[FromUri]string uid)
        {
            BaseService baseService = new BaseService ();

            string res = "";
            string phoneNum = phonenum;
            string perid =uid;
            long id = long.Parse(perid);
            WkTUser w = new WkTUser();
            w = (WkTUser)baseService.loadEntity(w, id);

            w.KuPhone = phoneNum;
            try
            {
                baseService.SaveOrUpdateEntity(w);
                res = "成功";
            }
            catch(Exception ex)
            {
                res = ex.Message;
            }

            //string data = JsonTools.ObjectToJson(l);
            string data = "1";
            var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + " \"data\":" + data + "}";
            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
            };
            return result;
        }
예제 #20
0
        public HttpResponseMessage RiZhiYo(string userid,string seeid,string logtick)
        {
            string res = "";
            BaseService baseservice = new BaseService();
            string sqlstr = "";
                if (logtick == "0")
                {
                    sqlstr = "with cte as " +
                                "( " +
                                " select row=row_number()over(order by getdate()), * from WktuserShareUserId where SharePresonid =  " + userid.ToString() + "and WktUserId=" + seeid.ToString() + " and WktuserShareUserId.STATE = 0 and WriteTime > " + logtick.ToString() +
                                ") " +
                                " select * from cte where row between " + "1" + " and " + "10";
                }
                else
                {
                    sqlstr = "with cte as " +
                                "( " +
                                " select row=row_number()over(order by getdate()), * from WktuserShareUserId where SharePresonid =  " + userid.ToString() + "and WktUserId=" + seeid.ToString() + " and WktuserShareUserId.STATE = 0 and WriteTime < " + logtick.ToString() +
                                ") " +
                                " select * from cte where row between " + "1" + " and " + "10";

                }
                IList nbhstaff = baseservice.ExecuteSQL(sqlstr);
                List<RiZhiinfo> stafflist = new List<RiZhiinfo>();
                if (nbhstaff != null && nbhstaff.Count > 0)
                {
                    for (int i = 0; i < nbhstaff.Count; i++)
                    {
                        object[] sf = (object[])nbhstaff[i];
                        RiZhiinfo st = new RiZhiinfo();
                        // Personinfo p = new Personinfo();
                        st.PersonId = sf[3].ToString();//分享人的ID
                        st.PersonName = sf[6].ToString();//分享人的姓名
                        WkTUser user = new WkTUser();
                        user = (WkTUser)baseservice.loadEntity(user, Convert.ToInt64(st.PersonId));
                        long m = user.Kdid.Id;
                        WkTDept dept = new WkTDept();
                        dept = (WkTDept)baseservice.loadEntity(dept, m);
                        st.PersonDept = dept.KdName;//分享人的部门
                        st.Logtick = sf[4].ToString();
                        st.PersonMD5code = user.ImgMD5Code;
                        st.Contenttxt140 = HtmlToReguFormat140(sf[5].ToString());//日志内容去格式前140
                        //st.ContenttxtAll = sf[5].ToString();//日志全部内容
                        st.RizhiTime = new DateTime(Convert.ToInt64(sf[4].ToString())).ToString("yyyy年MM月dd日 HH:mm:ss");//日志时间
                        st.RizhiId = sf[7].ToString(); //日志id
                        st.Imglist = HtmlToReguForimg(sf[5].ToString());//日志图片
                        List<Comments> q = new List<Comments>();
                        List<comm> ps = new List<comm>();
                        IList c = baseservice.loadEntityList("from StaffLog where State=" + (int)IEntity.stateEnum.Normal + "and Id=" + st.RizhiId);
                        if (c != null && c.Count > 0)
                        {
                            foreach (StaffLog n in c)
                            {
                                IList<Comments> r = n.Comments;
                                foreach (Comments s in r)
                                {
                                    string sqql = "select u from WkTUser u where u.KuName='" + s.CommentPersonName.Trim() + "'";
                                    WkTUser ww = (WkTUser)baseservice.loadEntityList(sqql)[0];
                                    comm p = new comm();
                                    p.Id = ww.Id.ToString();
                                    p.Na = s.CommentPersonName;//评论人名字
                                    //IList d = baseservice.loadEntityList("from StaffLog where State=" + 758);
                                    //foreach(WkTUser d1 in d)
                                    //{
                                    //    p.Id = d1.Id;
                                    //}
                                    p.Co = s.Content;//评论内容
                                    p.Commtime = new DateTime(s.TimeStamp).ToString("yyyy年MM月dd日 HH:mm:ss");
                                    ps.Add(p);
                                }
                            }
                        }
                        st.Comments = ps;
                        stafflist.Add(st);
                    }
                    RiZhiAll l = new RiZhiAll();
                    l.List = stafflist;
                    res = "成功";
                    string data = JsonTools.ObjectToJson(l);
                    var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                    var result = new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                    };
                    return result;
                }
                else
                {
                    res = "没有内容";
                    string data = "1";//JsonTools.ObjectToJson(l);
                    var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
                    var result = new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
                    };
                    return result;
                }
        }
예제 #21
0
        public HttpResponseMessage GetChangeDoState([FromUri]string id)
        {
            string res = null;
            string data = null;

            BaseService baseService = new BaseService();

            StaffSchedule s = new StaffSchedule();
            s = (StaffSchedule)baseService.loadEntity(s,long.Parse(id));
            if (s != null && s.Id > 0)
            {
                if (s.ScheduleTime < DateTime.Now.Ticks)
                {
                    res = "已过期无法修改";
                    data = "1";

                }
                else
                {
                    if (s.DoState != null)
                    {

                        s.DoState = 1;
                        s.RemindTime = DateTime.Now.Ticks;
                        baseService.SaveOrUpdateEntity(s);
                        res = "修改成功";
                        data = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
                    }

                }
            }
            else
            {
                res = "出错";
                data = "1";
            }
            data = "1";

            var jsonStr = "{\"Message\":" + "\"" + res + "\"" + "," + "\"data\":" + data + "}";
            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
            };
            return result;
        }