Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest rp = context.Request;
            DayLogManager manager = new DayLogManager();
            int currentPage = int.Parse(rp["pagenum"]);
            int pageSize = int.Parse(rp["pagesize"]);

            int count = 0, recordCount = 0;
            string personID = rp["PersonID"];
            WhereClip where = null;

            if (!string.IsNullOrEmpty(personID))
            {
                where = DayLog._.UserID == new Guid(personID);
            }
            else
                if (context.Session["UserID"] != null)
                {
                    where = DayLog._.UserID == new Guid(context.Session["UserID"].ToString());

                }

            if (!string.IsNullOrEmpty(context.Request["RQ1"]))
            {

                where.And(DayLog._.CreateDate >= DateTime.Parse(context.Request["RQ1"]));

            }
            if (!string.IsNullOrEmpty(context.Request["RQ2"]))
            {

                where.And(DayLog._.CreateDate <  DateTime.Parse(context.Request["RQ2"]).AddDays(1));

            }
            //if (!string.IsNullOrEmpty(context.Session["UserID"] as string))
            //{
            //    where = DayLog._.UserID == new Guid(context.Session["UserID"].ToString());
            //    //new Guid(context.Session["UserID"].ToString());

            //}
            //else
            //{
            //    where = DayLog._.UserID == "";

            //}

            DataTable dt = manager.GetDataTable(currentPage + 1, pageSize, where, DayLog._.WordDate.Desc, ref count, ref recordCount);
            string result = JsonConvert.Convert2Json(dt);
            context.Response.Write("{ \"totalRecords\":\"" + recordCount + "\",\"rows\":" + result + "}");
            context.Response.End();
        }
Пример #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest rp = context.Request;
            string msg = string.Empty;
            try
            {

                if (string.IsNullOrEmpty(rp["ID"]))
                {
                    msg = "请选择要删除的数据!";
                }
                else
                {
                    if (context.Session["UserName"].ToString().ToLower() != "admin")
                    {
                        msg = "只有管理员才可以删除!";

                    }
                    else
                    {
                        int i = new DayLogManager().DelateById(new Guid(rp["ID"]));
                        if (i > 0)
                        {
                            context.Response.Write("{\"success\":\"true\"}");
                        }
                        else
                        {
                            context.Response.Write("{\"success\":\"true\"}");
                            msg = "删除失败!";

                        }
                    }

                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;

            }
            if (!string.IsNullOrEmpty(msg))
            {
                byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>"));
                string encode = Convert.ToBase64String(bytes);
                context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");
            }
            context.Response.End();
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest rp = context.Request;
            string personID = rp["personid"];
            WhereClip where = null;

            if (!string.IsNullOrEmpty(personID))
            {
                where = DayLog._.UserID == new Guid(personID);
            }
            else
                if (context.Session["UserID"] != null)
                {
                    where = DayLog._.UserID == new Guid(context.Session["UserID"].ToString());

                }

            if (!string.IsNullOrEmpty(context.Request["rq1"]))
            {

                where.And(DayLog._.CreateDate >= DateTime.Parse(context.Request["rq1"]));

            }
            if (!string.IsNullOrEmpty(context.Request["rq2"]))
            {

                where.And(DayLog._.CreateDate < DateTime.Parse(context.Request["rq2"]).AddDays(1));

            }

            DataTable dt = new DayLogManager().GetDataTable(where);
            if (dt.Rows.Count > 0)
            {
                ExcelOperator eo = new ExcelOperator();

                IWorkbook work = eo.GenerateSheet(dt, "工作日志");
                string path = Guid.NewGuid() + ".xls";
                string dict = context.Server.MapPath("~\\upload\\") + "exportxml";
                if (Directory.Exists(dict))
                {
                    string[] fs = Directory.GetFileSystemEntries(dict);
                    foreach (string item in fs)
                    {
                        File.Delete(item);
                    }
                }

                while (!Directory.Exists(dict))
                {
                    Directory.CreateDirectory(dict);
                }

                string newpath = dict + "\\" + path; ;

                try
                {

                    using (Stream stream = File.Open(newpath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                    {
                        work.Write(stream);
                    }
                    context.Response.Write("{\"success\":\"true\",\"msg\":\"" + path + "\"}");
                }

                catch (Exception ex)
                {

                    path = "错误:" + ex.Message;
                    path = path.Replace("\r\n", "<br/>");
                    byte[] bytes = Encoding.UTF8.GetBytes(path);
                    string encode = Convert.ToBase64String(bytes);
                    context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");

                }
            }
            else
            {
                byte[] bytes = Encoding.UTF8.GetBytes("没有需要导出的日志信息");
                string encode = Convert.ToBase64String(bytes);
                context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");
            }
            context.Response.End();
        }
Пример #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest rp = context.Request;
            string msg = string.Empty;
            try
            {

                if (DateTime.Parse(rp["txtWordDate"]).Date != DateTime.Now.Date && context.Session["UserName"].ToString().ToLower() != "admin")
                {
                    msg = "已过填写日志时间,不能保存。当天日志只能当天完成(或者请系统管理员填写)。";

                }
                else
                {
                    if (string.IsNullOrEmpty(rp["txtID"]))
                    {
                        entity.ID = Guid.NewGuid();
                        if (!string.IsNullOrEmpty(context.Session["UserName"] as string))
                        {
                            entity.UserID = new Guid(context.Session["UserID"].ToString());
                            entity.UserName = context.Session["UserName"] as string;
                            entity.CreateDate = DateTime.Now;

                        }

                    }
                    else
                    {
                        entity.ID = new Guid(rp["txtID"]);
                        entity.RecordStatus = StatusType.update;

                    }
                    entity.WordDate = DateTime.Parse(rp["txtWordDate"]);
                    entity.Content = rp["txtContent"];
                    entity.GS = rp["txtGS"];

                    DayLogManager manager = new DayLogManager();
                    bool IsExit = manager.ExitDayLog(entity);//日期重复校验参考
                    if (IsExit)
                    {
                        msg = "今天已填写过工作日志!";
                    }
                    else
                    {
                        manager.Save(entity);
                        context.Response.Write("{\"success\":\"true\",\"ID\":\"" + entity.ID + "\"}");
                    }
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            if (!string.IsNullOrEmpty(msg))
            {
                byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>"));
                string encode = Convert.ToBase64String(bytes);
                context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}");
            }
            context.Response.End();
        }
Пример #5
0
 private void GerneraotrDayLog(string UserId)
 {
     string tem = @"   <tr class='{0}'>
                         <td align='center'>
                             {1}
                         </td>
                         <td>
                             {2}
                         </td>
                         <td align='center'>
                            {3}
                         </td>
                         <td align='center'>
                            {4}
                         </td>
                     </tr>";
     DayLogManager manager = new DayLogManager();
     int pageCount = 0, recordCount = 0;
     DataTable dt = manager.GetDataTable(1, 5, DayLog._.UserID == new Guid(Session["UserID"].ToString()), DayLog._.WordDate.Desc, ref pageCount, ref recordCount);
     StringBuilder sb = new StringBuilder();
     int i = 1;
     foreach (DataRow item in dt.Rows)
     {
         string temodd = odd_bg;
         if (i % 2 == 0)
         {
             temodd = "";
         }
         sb.AppendFormat(tem, temodd, i, item["Content"], ((DateTime)item["WordDate"]).ToString("yyyy-MM-dd"), item["GS"]);
     }
     DayLogStr = sb.ToString();
 }