Exemplo n.º 1
0
        public override BulkInsertResult <string> InsertMany(IEnumerable <T> entities, InsertMode insertMode)
        {
            if (insertMode != InsertMode.db_implementation)
            {
                throw new NotImplementedException();
            }

            var insertResult = new BulkInsertResult <string>();

            var creationDate = NoSQLRepoHelper.DateTimeUtcNow();

            foreach (var entity in entities)
            {
                if (AutoGeneratedEntityDate)
                {
                    entity.SystemCreationDate = creationDate;
                }
                if (AutoGeneratedEntityDate)
                {
                    entity.SystemLastUpdateDate = creationDate;
                }

                NoSQLRepoHelper.SetIds(entity);

                var entityToStore = NewtonJsonHelper.CloneJson(entity, DateTimeZoneHandling.Utc);
                localDb[entity.Id] = entityToStore;
                config.ExpireAt(entity.Id, null);
                insertResult[entity.Id] = InsertResult.unknown;
            }
            SaveJSONFile();

            return(insertResult);
        }
        public override InsertResult InsertOne(T entity, InsertMode insertMode)
        {
            CheckOpenedConnection();

            var entitydomain = entity;

            NoSQLRepoHelper.SetIds(entitydomain);

            var updateddate = NoSQLRepoHelper.DateTimeUtcNow();
            var createdDate = NoSQLRepoHelper.DateTimeUtcNow();

            if (!string.IsNullOrEmpty(entity.Id) && localDb.ContainsKey(entity.Id))
            {
                // Document already exists
                switch (insertMode)
                {
                case InsertMode.error_if_key_exists:
                    throw new DupplicateKeyNoSQLException();

                case InsertMode.erase_existing:
                    createdDate = localDb[entity.Id].SystemCreationDate;
                    localDb.Remove(entity.Id);
                    break;

                case InsertMode.do_nothing_if_key_exists:
                    return(InsertResult.not_affected);

                default:
                    break;
                }
            }

            if (AutoGeneratedEntityDate)
            {
                entitydomain.SystemCreationDate   = createdDate;
                entitydomain.SystemLastUpdateDate = updateddate;
            }

            // Clone to not shared reference between App instance and repository persisted value
            // UTC : Ensure to store only utc datetime
            var entityToStore = NewtonJsonHelper.CloneJson(entitydomain, DateTimeZoneHandling.Utc);

            if (localDb.ContainsKey(entity.Id))
            {
                localDb[entity.Id] = entityToStore;
            }
            else
            {
                localDb.Add(entity.Id, entityToStore);
            }

            config.ExpireAt(entity.Id, null);

            SaveJSONFile();

            return(InsertResult.inserted);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <returns></returns>
        public object GetUserMess()
        {
            string        userName  = Tools.SessionHelper.GetSession <Base_UserInfo>(Tools.SessionHelper.SessinoName.CurUser).UserName;
            List <string> igorelist = new List <string>()
            {
                "Orgs", "Roles"
            };
            Base_UserInfo UserInfo = _userInfoBll.FindBy(t => t.UserName == userName).ToList <Base_UserInfo>().FirstOrDefault();

            if (UserInfo != null)
            {
                return(Common.NewtonJsonHelper.Deserialize <object>(NewtonJsonHelper.Serialize(UserInfo, igorelist), null));
            }
            return(Common.NewtonJsonHelper.Deserialize <object>(NewtonJsonHelper.Serialize("{}", null), null));
        }
Exemplo n.º 4
0
        public override InsertResult InsertOne(T entity, InsertMode keyExistsAction)
        {
            var insertResult = default(InsertResult);

            var date = NoSQLRepoHelper.DateTimeUtcNow();

            if (AutoGeneratedEntityDate)
            {
                entity.SystemCreationDate   = date;
                entity.SystemLastUpdateDate = date;
            }

            NoSQLRepoHelper.SetIds(entity);

            if (localDb.ContainsKey(entity.Id))
            {
                if (keyExistsAction == InsertMode.error_if_key_exists)
                {
                    throw new DupplicateKeyNoSQLException();
                }
                else if (keyExistsAction == InsertMode.do_nothing_if_key_exists)
                {
                    return(InsertResult.not_affected);
                }
                else if (keyExistsAction == InsertMode.erase_existing)
                {
                    entity.SystemCreationDate = localDb[entity.Id].SystemCreationDate; // keep the origin creation date of the entity
                    // Continue execution
                }
                insertResult = InsertResult.updated;
            }
            else
            {
                insertResult = InsertResult.inserted;
            }

            // Clone to not shared reference between App instance and repository persisted value
            // UTC : Ensure to store only utc datetime
            var entityToStore = NewtonJsonHelper.CloneJson(entity, DateTimeZoneHandling.Utc);

            localDb[entity.Id] = entityToStore;
            config.ExpireAt(entity.Id, null);

            SaveJSONFile();
            return(insertResult);
        }
Exemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User userFromCookie = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = userFromCookie.UserId;
                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);


                    string ui_students_name    = context.Request.Params["ui_students_name"] ?? "";
                    string ui_students_code    = context.Request.Params["ui_students_code"] ?? "";
                    string ui_students_cardnum = context.Request.Params["ui_students_cardnum"] ?? "";
                    string ui_students_status  = context.Request.Params["ui_students_status"] ?? "";
                    string ui_pay_status       = context.Request.Params["ui_pay_status"] ?? "";
                    string ui_students_period  = context.Request.Params["ui_students_period"] ?? "";


                    //string ui_user_userid = context.Request.Params["ui_user_userid"] ?? "";
                    //string ui_user_username = context.Request.Params["ui_user_username"] ?? "";
                    //string ui_user_isable = context.Request.Params["ui_user_isable"] ?? "";
                    //string ui_user_ifchangepwd = context.Request.Params["ui_user_ifchangepwd"] ?? "";
                    //string ui_user_description = context.Request.Params["ui_user_description"] ?? "";
                    //string ui_user_adddatestart = context.Request.Params["ui_user_adddatestart"] ?? "";
                    //string ui_user_adddateend = context.Request.Params["ui_user_adddateend"] ?? "";
                    strWhere += " and flag=1";
                    if (ui_students_name.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_students_name))       //防止sql注入
                    {
                        strWhere += string.Format(" and StudentsName like '%{0}%'", ui_students_name.Trim());
                    }
                    if (ui_students_code.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_students_code))
                    {
                        strWhere += string.Format(" and StudentCode like '%{0}%'", ui_students_code.Trim());
                    }
                    if (ui_students_cardnum.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_students_cardnum))
                    {
                        strWhere += string.Format(" and CardNum like '%{0}%'", ui_students_cardnum.Trim());
                    }
                    if (ui_students_status.Trim() != "select" && ui_students_status.Trim() != "")
                    {
                        strWhere += " and Status = '" + ui_students_status.Trim() + "'";
                    }
                    if (ui_pay_status.Trim() != "select" && ui_pay_status.Trim() != "")
                    {
                        strWhere += " and PayStatus = '" + ui_pay_status.Trim() + "'";
                    }
                    if (ui_students_period.Trim() != "select" && ui_students_period.Trim() != "")
                    {
                        strWhere += " and PeriodsID = '" + ui_students_period.Trim() + "'";
                    }


                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.RegistrationBLL().GetPager("V_StudentsBaseData", "*", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");

                    userOperateLog.OperateInfo = "查询学员";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "add":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "add", userFromCookie.Id))
                    {
                        string ui_registration_name_add    = context.Request.Params["ui_registration_name_add"] ?? "";
                        string ui_registration_cardnum_add = context.Request.Params["ui_registration_cardnum_add"] ?? "";
                        int    ui_registration_age_add     = Int32.Parse(context.Request.Params["ui_registration_age_add"] ?? "-1");
                        bool   ui_registration_sex_add     = context.Request.Params["ui_registration_sex_add"] == "0" ? false : true;
                        bool   ui_registration_islocal_add = context.Request.Params["ui_registration_islocal_add"] == "0" ? false : true;
                        int    ui_registration_period_add  = Int32.Parse(context.Request.Params["ui_registration_period_add"] ?? "-1");
                        string ui_registration_address_add = context.Request.Params["ui_registration_address_add"] ?? "";
                        string ui_registration_remark_add  = context.Request.Params["ui_registration_remark_add"] ?? "";
                        string fupPic_add = context.Request.Params["fupPic_add"] ?? "";
                        string ui_registration_phoneNum_add = context.Request.Params["ui_registration_phoneNum_add"] ?? "";

                        DriveMgr.Model.RegistrationModel registrationAdd = new Model.RegistrationModel();
                        registrationAdd.StudentsName = ui_registration_name_add;
                        registrationAdd.CardNum      = ui_registration_cardnum_add;
                        registrationAdd.Age          = ui_registration_age_add;
                        registrationAdd.Sex          = ui_registration_sex_add;
                        registrationAdd.IsLocal      = ui_registration_islocal_add;
                        registrationAdd.PeriodsID    = ui_registration_period_add;
                        registrationAdd.Address      = ui_registration_address_add;
                        registrationAdd.Remark       = ui_registration_remark_add;
                        registrationAdd.Status       = 0; //【0:在学 1:毕业 2:退学】
                        if (fupPic_add.Trim() == "")
                        {
                            registrationAdd.PicPath = "";
                        }
                        else
                        {
                            registrationAdd.PicPath = "/images/Pictures/" + fupPic_add;
                        }
                        registrationAdd.PhoneNum = ui_registration_phoneNum_add;

                        FormsIdentity             id      = (FormsIdentity)context.User.Identity;
                        FormsAuthenticationTicket tickets = id.Ticket;

                        //获取票证里序列化的用户对象(反序列化)
                        DriveMgr.Model.User userCheck = new JavaScriptSerializer().Deserialize <DriveMgr.Model.User>(tickets.UserData);

                        registrationAdd.Operater = userCheck.UserName;
                        DriveMgr.BLL.RegistrationBLL bll = new DriveMgr.BLL.RegistrationBLL();
                        bool result = bll.Add(registrationAdd);
                        if (result)
                        {
                            //RegistrationModel mod = bll.GetModel(result);
                            //string changeMsg = String.Empty;
                            //try
                            //{
                            //    string srcPath = context.Server.MapPath(mod.PicPath);
                            //    string extension = Path.GetFileNameWithoutExtension(srcPath);
                            //    string desPath = context.Server.MapPath("/admin/images/Pictures/" + mod.CardNum + ".jpg");
                            //    bool changeResult = FileHelpercs.ChangeFileName(srcPath, desPath);

                            //    if (changeResult)
                            //    {
                            //        changeMsg = "改变照片名称成功!从" + srcPath + "到" + desPath;
                            //    }
                            //    else
                            //    {
                            //        changeMsg = "改变照片名称失败!从" + srcPath + "到" + desPath;
                            //    }
                            //}
                            //catch
                            //{
                            //    changeMsg = "改变照片名称失败!";
                            //}

                            userOperateLog.OperateInfo = "添加学员";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,学员" + ui_registration_name_add;
                            context.Response.Write("{\"msg\":\"添加学员成功!" + "\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加学员";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加学员";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "edit", userFromCookie.Id))
                    {
                        int    id = Convert.ToInt32(context.Request.Params["id"]);
                        string ui_registration_name_edit     = context.Request.Params["ui_registration_name_edit"] ?? "";
                        string ui_registration_cardnum_edit  = context.Request.Params["ui_registration_cardnum_edit"] ?? "";
                        int    ui_registration_age_edit      = Int32.Parse(context.Request.Params["ui_registration_age_edit"] ?? "-1");
                        bool   ui_registration_sex_edit      = context.Request.Params["ui_registration_sex_edit"] == "0" ? false : true;
                        bool   ui_registration_islocal_edit  = context.Request.Params["ui_registration_islocal_edit"] == "0" ? false : true;
                        int    ui_registration_period_edit   = Int32.Parse(context.Request.Params["ui_registration_period_edit"] ?? "-1");
                        string ui_registration_address_edit  = context.Request.Params["ui_registration_address_edit"] ?? "";
                        string ui_registration_remark_edit   = context.Request.Params["ui_registration_remark_edit"] ?? "";
                        string ui_registration_phoneNum_edit = context.Request.Params["ui_registration_phoneNum_edit"] ?? "";

                        DriveMgr.Model.RegistrationModel registrationedit = new Model.RegistrationModel();
                        registrationedit.ID           = id;
                        registrationedit.StudentsName = ui_registration_name_edit;
                        registrationedit.CardNum      = ui_registration_cardnum_edit;
                        registrationedit.Age          = ui_registration_age_edit;
                        registrationedit.Sex          = ui_registration_sex_edit;
                        registrationedit.IsLocal      = ui_registration_islocal_edit;
                        registrationedit.PeriodsID    = ui_registration_period_edit;
                        registrationedit.Address      = ui_registration_address_edit;
                        registrationedit.Remark       = ui_registration_remark_edit;
                        //registrationedit.Status = 0; //【0:在学 1:毕业 2:退学】
                        registrationedit.PhoneNum = ui_registration_phoneNum_edit;      //手机号码

                        FormsIdentity             iid     = (FormsIdentity)context.User.Identity;
                        FormsAuthenticationTicket tickets = iid.Ticket;

                        //获取票证里序列化的用户对象(反序列化)
                        DriveMgr.Model.User userCheck = new JavaScriptSerializer().Deserialize <DriveMgr.Model.User>(tickets.UserData);

                        registrationedit.Operater = userCheck.UserName;

                        if (new DriveMgr.BLL.RegistrationBLL().Update(registrationedit))
                        {
                            userOperateLog.OperateInfo = "修改学员";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,学员主键:" + registrationedit.ID;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改学员";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改学员";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "delete", userFromCookie.Id))
                    {
                        string ids = context.Request.Params["id"].Trim(',');
                        if (new DriveMgr.BLL.RegistrationBLL().DeleteList(ids))
                        {
                            userOperateLog.OperateInfo = "删除学员";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,学员主键:" + ids;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除学员";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败";
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除学员";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "bindPeroid":
                    DataTable dt           = new DriveMgr.BLL.RegistrationBLL().BindPeroid();
                    string    peroidResult = NewtonJsonHelper.ToJson(dt);
                    context.Response.Write(peroidResult);
                    break;

                case "pay":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "paytuition", userFromCookie.Id))
                    {
                        bool payResult = DoTuition(context);
                        if (payResult)
                        {
                            userOperateLog.OperateInfo = "缴纳学费";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "交费成功。";
                            context.Response.Write("{\"msg\":\"交费成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "缴纳学费";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "交费失败";
                            context.Response.Write("{\"msg\":\"交费失败!\",\"success\":false}");
                        }
                    }
                    break;

                case "payExam":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "payExam", userFromCookie.Id))
                    {
                        bool payResult = PayExam(context);
                        if (payResult)
                        {
                            userOperateLog.OperateInfo = "缴纳考试费";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "交费成功。";
                            context.Response.Write("{\"msg\":\"交考试费成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "缴纳考试费";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "交考试费失败";
                            context.Response.Write("{\"msg\":\"交考试费失败!\",\"success\":false}");
                        }
                    }
                    break;

                case "exit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "exit", userFromCookie.Id))
                    {
                        bool exitResult = DropOut(context);
                        if (exitResult)
                        {
                            userOperateLog.OperateInfo = "退学";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "退学成功。";
                            context.Response.Write("{\"msg\":\"退学成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "退学";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "退学失败";
                            context.Response.Write("{\"msg\":\"退学失败!\",\"success\":false}");
                        }
                    }
                    break;

                case "getInfoByCard":
                    string infoResult = GetInfoByCard(context);
                    context.Response.Write(infoResult);
                    break;

                case "uploadPic":
                    string uploadResult = UploadPic(context);
                    context.Response.Write(uploadResult);
                    break;

                case "printApplyTable":
                    string printResult = PrintApplyTable(context);
                    context.Response.Write(printResult);
                    break;

                case "exportStudents":
                    string exportResult = DownloadExcel(context);
                    context.Response.Write(exportResult);
                    break;

                case "addByCard":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "byCard", userFromCookie.Id))
                    {
                        string ui_registration_name_byCard     = context.Request.Params["ui_registration_name_byCard"] ?? "";
                        string ui_registration_cardnum_byCard  = context.Request.Params["ui_registration_cardnum_byCard"] ?? "";
                        int    ui_registration_age_byCard      = Int32.Parse(context.Request.Params["ui_registration_age_byCard"] ?? "-1");
                        bool   ui_registration_sex_byCard      = context.Request.Params["ui_registration_sex_byCard"] == "0" ? false : true;
                        bool   ui_registration_islocal_byCard  = context.Request.Params["ui_registration_islocal_byCard"] == "0" ? false : true;
                        int    ui_registration_period_byCard   = Int32.Parse(context.Request.Params["ui_registration_period_byCard"] ?? "-1");
                        string ui_registration_address_byCard  = context.Request.Params["ui_registration_address_byCard"] ?? "";
                        string ui_registration_remark_byCard   = context.Request.Params["ui_registration_remark_byCard"] ?? "";
                        string ui_registration_phoneNum_byCard = context.Request.Params["ui_registration_phoneNum_byCard"] ?? "";

                        string fupPic_byCard = context.Request.Params["picPath"] ?? "";

                        DriveMgr.Model.RegistrationModel registrationAdd = new Model.RegistrationModel();
                        registrationAdd.StudentsName = ui_registration_name_byCard;
                        registrationAdd.CardNum      = ui_registration_cardnum_byCard;
                        registrationAdd.Age          = ui_registration_age_byCard;
                        registrationAdd.Sex          = ui_registration_sex_byCard;
                        registrationAdd.IsLocal      = ui_registration_islocal_byCard;
                        registrationAdd.PeriodsID    = ui_registration_period_byCard;
                        registrationAdd.Address      = ui_registration_address_byCard;
                        registrationAdd.Remark       = ui_registration_remark_byCard;
                        registrationAdd.Status       = 0; //【0:在学 1:毕业 2:退学】
                        if (fupPic_byCard.Replace("/images/Pictures/", "").Trim() == "")
                        {
                            registrationAdd.PicPath = "";
                        }
                        else
                        {
                            registrationAdd.PicPath = fupPic_byCard;
                        }
                        registrationAdd.PhoneNum = ui_registration_phoneNum_byCard;

                        FormsIdentity             id      = (FormsIdentity)context.User.Identity;
                        FormsAuthenticationTicket tickets = id.Ticket;

                        //获取票证里序列化的用户对象(反序列化)
                        DriveMgr.Model.User userCheck = new JavaScriptSerializer().Deserialize <DriveMgr.Model.User>(tickets.UserData);

                        registrationAdd.Operater = userCheck.UserName;
                        DriveMgr.BLL.RegistrationBLL bll = new DriveMgr.BLL.RegistrationBLL();
                        bool result = bll.Add(registrationAdd);
                        if (result)
                        {
                            userOperateLog.OperateInfo = "刷卡添加学员";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,学员" + ui_registration_name_byCard;
                            context.Response.Write("{\"msg\":\"添加学员成功!" + "\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "刷卡添加学员";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "刷卡添加学员";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "uploadPicByCard":
                    string uploadPicByCard = SavePicToServer(context);
                    context.Response.Write(uploadPicByCard);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "学员功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取报价表报价成功的数据
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="swhere"></param>
        /// <param name="sort"></param>
        /// <returns></returns>
        public object GetQuoteResultList(int page, int limit, string swhere, string sort)
        {
            string        user = Tools.SessionHelper.GetSession <Base_UserInfo>(Tools.SessionHelper.SessinoName.CurUser).UserName;
            List <String> IDs  = SessionFactory.GetCurrentSession().QueryOver <SupplierQuote>().Where(o => o.QuotationCompany == user).Select(t => t.InquiryTitle).List <string>().ToList(); //获取我参与过的项目的名称

            StringBuilder where = new StringBuilder();                                                                                                                                       //拼接查询条件(项目名称格式化)
            foreach (var ID in IDs)
            {
                where.Append("'" + ID + "',");
            }
            string ere   = where.ToString().TrimEnd(',');//得到字符串并去掉最后的逗号
            string temp  = "1";
            string temp1 = "1";

            try
            {
                if (swhere != null)
                {
                    int s = swhere.IndexOf("|");
                    int a = swhere.LastIndexOf("|");
                    temp  = swhere.Substring(0, s);
                    temp1 = swhere.Substring(a + 1, swhere.Length - a - 1);
                }
            }
            catch (Exception ee)
            {
                return("查询抛出异常" + ee);
            }
            try
            {
                List <SupplierQuote> upLoadList = Tools.ExecSqlHelp.ExecuteSql <SupplierQuote>("SELECT * FROM " +
                                                                                                                                                                                                                                       //"SupplierQuote WHERE quotestate=2 and InquiryTitle in (lists)", new List<SqlParameter>(){
                                                                                                                                                                                                                                       //     new SqlParameter(){ParameterName="lists",Value=ere}
                                                                                               "SupplierQuote WHERE quotestate=2 and " + temp + " like '%" + temp1 + "%' and InquiryTitle in (" + ere + ")", null);                    //拼接SQL进行查询
                return(Common.NewtonJsonHelper.Deserialize <object>("{\"curPage\":" + page + ",\"success\":true,\"total\":" + upLoadList.Count + ",\"QuoteResultList\":" + NewtonJsonHelper.Serialize(upLoadList, null) + "}", null)); //构造返回数据
            }
            catch (Exception ee)
            {
                return("查询抛出异常" + ee);
            }
#if debug
            //try
            //{
            //    string userName = Tools.SessionHelper.GetSession<Base_UserInfo>(Tools.SessionHelper.SessinoName.CurUser).UserName;//获取当前用户
            //    StringBuilder where = new StringBuilder();
            //    //swhere = swhere != null ? swhere.TrimStart(',') + ",STATE|int|0|=" : "STATE|int|0|=";
            //    //where.Append(swhere);


            //    where.Append(",InquiryTitle|string|");
            //    foreach (var ID in IDs)
            //    {
            //        where.Append("'" + ID + "',");
            //    }
            //    string ere = where.ToString().TrimEnd(',') + "|in";
            //    swhere = string.IsNullOrEmpty(swhere) ? ere : ere + "," + swhere;

            //    ////where.Append(",InquiryTitle in (@");
            //    //where.Append("InquiryTitle in (@");
            //    ////foreach (var ID in IDs)
            //    ////{
            //    ////    where.Append("'" + ID + "',");
            //    ////}
            //    //for (int i = 0; i < IDs.Count; i++)
            //    //{
            //    //    where.Append("'" + IDs[i] + "',");
            //    //}
            //    //string here = where.ToString().TrimEnd(',') + "@)";
            //    //swhere = string.IsNullOrEmpty(swhere) ? here : here + "," + swhere;
            //    ////where.Append("@)");
            //    ////where.AppendFormat(",InquiryTitle in (@{0}@)" , IDs);
            //    ////where.AppendFormat(",InquiryTitle|string|{0}|" + +"in" + ss);
            //    PageParameter pagePara = new PageParameter()
            //    {
            //        PageIndex = page,
            //        Limit = limit,
            //        //Swhere = where.ToString(),a
            //        Swhere = swhere,
            //        Sort = sort,
            //        ObjName = "QuoteResultList",
            //        Igorelist = new List<string>() { "Inquiries" }
            //    };
            //    QueryParameter query = new QueryParameter("SupplierQuote", pagePara.Swhere, pagePara, null);
            //    return this.GetAllPageList(query);
            //}
            //catch (Exception ee)
            //{

            //    return null;
            //}
            /***/
#endif
        }