Exemplo n.º 1
0
        public IHttpActionResult Putlogin_info(int id, login_info login_info)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != login_info.user_id)
            {
                return(BadRequest());
            }

            db.Entry(login_info).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!login_infoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public ActionResult btnCreate_Click([Bind(Include = "uuid,record_aj_no,record_jj_no,record_ky_no,bg_unit,ky_unit,ky_date,af_time,bj_time,bjr,bjr_sex,bjr_idcard,bjr_phoneNo,kyks_time,kyjs_time,dest_unit,xz,fs_loc,xc_loc,xc_locpt,weather_info,trend_info,temper_info,humidity_info,light_info,bh_flag,bhr,bhr_pos,bh_function,xc_info,bd_reason,jzr,jzr_sex,jzr_birth,jzr_address,zhr_name,zhr_unit_name,zhr_pos,bhr_name,blr_name,ztr_name,zxr_name,lxr_name,lyr_name,xc_disp,record_reason")] pbs_record record)
        {
            if (ModelState.IsValid)
            {
                //record.uuid = Guid.NewGuid().ToString();
                record.create_time  = DateTime.Now;
                record.creater_id   = Global.loginInfo.user_id;
                record.record_state = 1001;
                record.record_title = record.fs_loc + record.xc_loc + "-" + record.xz;
                db.pbs_record.Add(record);
                db.SaveChanges();
                string recNo = "440300 " + DateTime.Now.Year.ToString() + " 9";
                for (int i = 0; i < 5 - record.record_id.ToString().Length; i++)
                {
                    recNo += "0";
                }
                recNo           += record.record_id.ToString();
                record.record_no = recNo;
                db.pbs_record.Attach(record);
                var stateEntity = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(record);
                stateEntity.SetModifiedProperty("record_no");
                db.SaveChanges();
                // 关闭本窗体(触发窗体的关闭事件)
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }

            return(UIHelper.Result());
        }
Exemplo n.º 3
0
 private void initPrivData(int tgtId, string type)
 {
     try
     {
         var menuList = db.sys_menu;
         foreach (sys_menu menu in menuList)
         {
             if (dbForCond.privilege.Count(m => m.privilege_master.Equals(type) && m.privilege_value == tgtId &&
                                           m.privilege_access.Equals("menu") && m.privilege_access_value == menu.menu_id) == 0)
             {
                 privilege priv = new privilege();
                 priv.privilege_master       = type;
                 priv.privilege_value        = tgtId;
                 priv.privilege_access       = "menu";
                 priv.privilege_access_value = menu.menu_id;
                 priv.privilege_operation    = false;
                 db.privilege.Add(priv);
             }
         }
         db.SaveChanges();
         var buttonList = db.sys_button;
         foreach (sys_button button in buttonList)
         {
             if (dbForCond.privilege.Count(m => m.privilege_master.Equals(type) && m.privilege_value == tgtId &&
                                           m.privilege_access.Equals("button") && m.privilege_access_value == button.btn_id) == 0)
             {
                 privilege priv = new privilege();
                 priv.privilege_master       = type;
                 priv.privilege_value        = tgtId;
                 priv.privilege_access       = "button";
                 priv.privilege_access_value = button.btn_id;
                 priv.privilege_operation    = false;
                 db.privilege.Add(priv);
             }
         }
         db.SaveChanges();
         var dataList = db.sys_data;
         foreach (sys_data data in dataList)
         {
             if (dbForCond.privilege.Count(m => m.privilege_master.Equals(type) && m.privilege_value == tgtId &&
                                           m.privilege_access.Equals("data") && m.privilege_access_value == data.sid) == 0)
             {
                 privilege priv = new privilege();
                 priv.privilege_master       = type;
                 priv.privilege_value        = tgtId;
                 priv.privilege_access       = "data";
                 priv.privilege_access_value = data.sid;
                 priv.privilege_operation    = false;
                 db.privilege.Add(priv);
             }
         }
         db.SaveChanges();
     }catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 4
0
        public IHttpActionResult UpdateTraceInfo()
        {
            TraceInfoDetail tid = new TraceInfoDetail();

            try
            {
                HttpContextBase context  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                String          jsonBean = context.Request.Form["jsonBean"];
                if (jsonBean == null)
                {
                    tid.code = 101;
                    tid.msg  = "参数验证失败!";
                    return(Ok(tid));
                    //return BadRequest(ModelState);
                }
                view_trace_info ti = new view_trace_info();
                ti = JsonConvert.DeserializeObject <view_trace_info>(jsonBean);

                int id        = ti.sid;
                var traceInfo = db.trace_info.Find(id);
                if (traceInfo == null)
                {
                    tid.code = 102;
                    tid.msg  = "找不到痕迹记录!";
                    return(Ok(tid));
                }

                traceInfo.name       = ti.name;
                traceInfo.barcode    = ti.barcode;
                traceInfo.disp       = ti.disp;
                traceInfo.image1     = ti.image1;
                traceInfo.tqbw       = ti.tqbw;
                traceInfo.trace_type = ti.traceType;

                db.trace_info.Attach(traceInfo);
                var stateEntity = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(traceInfo);
                stateEntity.SetModifiedProperty("name");
                stateEntity.SetModifiedProperty("barcode");
                stateEntity.SetModifiedProperty("disp");
                stateEntity.SetModifiedProperty("image1");
                stateEntity.SetModifiedProperty("tqbw");
                stateEntity.SetModifiedProperty("trace_type");

                db.SaveChanges();

                tid.code = 100;

                return(Ok(tid));
            }
            catch (Exception e)
            {
                tid.code = 104;
                tid.msg  = "更新痕迹失败: " + e.Message;
                return(Ok(tid));
            }
        }
Exemplo n.º 5
0
        public IHttpActionResult UpdateRecordInfo()
        {
            RecordInfoDetail rsl = new RecordInfoDetail();

            try
            {
                HttpContextBase context  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                String          jsonBean = context.Request.Form["jsonBean"];
                if (jsonBean == null)
                {
                    rsl.code = 101;
                    rsl.msg  = "参数验证失败!";
                    return(Ok(rsl));
                    //return BadRequest(ModelState);
                }

                view_recordinfo record = new view_recordinfo();
                record = JsonConvert.DeserializeObject <view_recordinfo>(jsonBean);

                int id  = record.sid;
                var rec = db.record_info.Find(id);
                if (rec == null)
                {
                    rsl.code = 102;
                    rsl.msg  = "记录不存在!";
                    return(Ok(rsl));
                }

                rec.content     = record.title;
                rec.loc_disp    = record.locDisp;
                rec.loc_name    = record.locName;
                rec.record_loc  = record.recordLoc;
                rec.record_type = record.recordType;
                rec.type        = record.type;

                db.record_info.Attach(rec);
                var stateEntity = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(rec);
                stateEntity.SetModifiedProperty("content");
                stateEntity.SetModifiedProperty("loc_disp");
                stateEntity.SetModifiedProperty("loc_name");
                stateEntity.SetModifiedProperty("record_loc");
                stateEntity.SetModifiedProperty("record_type");
                stateEntity.SetModifiedProperty("type");
                db.SaveChanges();
            }
            catch (Exception e)
            {
                rsl.code = 103;
                rsl.msg  = e.Message;
                return(Ok(rsl));
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 6
0
 public ActionResult DeleteRole(JArray selectedRows, string userId, JArray Grid1_fields, JArray Grid2_fields)
 {
     foreach (string rowId in selectedRows)
     {
         sys_userrole tmp = db.sys_userrole.Find(Convert.ToInt32(rowId));
         db.sys_userrole.Remove(tmp);
     }
     db.SaveChanges();
     UpdateGrid(Grid1_fields, Grid2_fields, userId);
     //PageContext.RegisterStartupScript(ActiveWindow.HideRefresh());
     return(UIHelper.Result());
 }
Exemplo n.º 7
0
        public ActionResult btnCreate_Click([Bind(Include = "unit_name,is_top,father_unit_id")] sys_unit unit)
        {
            if (ModelState.IsValid)
            {
                db.sys_unit.Add(unit);
                db.SaveChanges();

                // 关闭本窗体(触发窗体的关闭事件)
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }

            return(UIHelper.Result());
        }
Exemplo n.º 8
0
        public ActionResult btnCreate_Click([Bind(Include = "role_name,role_disp")] sys_role sys_role)
        {
            if (ModelState.IsValid)
            {
                sys_role.create_time = DateTime.Now;
                sys_role.creator_id  = Global.loginInfo.user_id;
                db.sys_role.Add(sys_role);

                db.SaveChanges();

                // 关闭本窗体(触发窗体的关闭事件)
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }

            return(UIHelper.Result());
        }
Exemplo n.º 9
0
 public HttpResponseMessage GetNewestApk()
 {
     try
     {
         string     path     = HttpContext.Current.Server.MapPath("~/pbs_data/");
         var        sv       = db.sys_version.OrderByDescending(m => m.version_code).First();
         string     fileName = sv.apk_name;
         FileStream file     = new FileStream(path + fileName, FileMode.Open);
         if (!file.CanRead)
         {
             HttpResponseMessage rsl = new HttpResponseMessage(HttpStatusCode.NotFound);
             return(rsl);
         }
         sv.download_count = sv.download_count + 1;
         db.sys_version.Attach(sv);
         var stateEntity = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(sv);
         stateEntity.SetModifiedProperty("download_count");
         db.SaveChanges();
         //img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
         HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
         result.Content = new StreamContent(file);
         result.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
         result.Content.Headers.ContentDisposition.FileName = fileName;
         result.Content.Headers.ContentType   = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
         result.Content.Headers.ContentLength = new FileInfo(path + fileName).Length;
         return(result);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 10
0
        public ActionResult btnCreate_Click([Bind(Include = "file_url,file_name,file_hint,file_type,rec_uuid")] sys_upload_file upFiles)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var filePhoto = UIHelper.FileUpload("filePhoto");

                    if (upFiles.file_url == null)
                    {
                        filePhoto.MarkInvalid("请先上传图片!");
                        ShowNotify("请先上传图片!");
                    }
                    else
                    {
                        string path1 = Server.MapPath("~/pbs_data/tmp/") + upFiles.file_url;
                        string path2 = Server.MapPath("~/pbs_data/" + upFiles.rec_uuid + "/");
                        if (!Directory.Exists(path2))
                        {
                            Directory.CreateDirectory(path2);
                        }
                        System.IO.File.Copy(path1, path2 + upFiles.file_url);

                        upFiles.file_url         = upFiles.file_url;
                        upFiles.file_upload_time = DateTime.Now;
                        upFiles.file_uploader    = Global.loginInfo.user_id;

                        filePhoto.Reset();
                        db.sys_upload_file.Add(upFiles);
                        db.SaveChanges();

                        // 关闭本窗体(触发窗体的关闭事件)
                        PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                    }
                }

                return(UIHelper.Result());
            }catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 11
0
        public ActionResult btnCreate_Click([Bind(Include = "user_name,user_fullname,user_pwd,user_state,unit_id,user_zw")] sys_user user)
        {
            if (ModelState.IsValid)
            {
                user.create_time = DateTime.Now;
                user.user_pwd    = Md5Helper.Encrypt(user.user_pwd);
                db.sys_user.Add(user);
                db.SaveChanges();
                sys_userrole userRole = new sys_userrole();
                userRole.user_id     = user.user_id;
                userRole.role_id     = 2; //默认为普通用户
                userRole.create_time = DateTime.Now;
                db.sys_userrole.Add(userRole);
                db.SaveChanges();
                // 关闭本窗体(触发窗体的关闭事件)
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }

            return(UIHelper.Result());
        }
Exemplo n.º 12
0
        public IHttpActionResult Putpbs_record()
        {
            RecordDetailInfo rdi = new RecordDetailInfo();

            try
            {
                HttpContextBase context  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                String          jsonBean = context.Request.Form["jsonBean"];
                if (jsonBean == null)
                {
                    rdi.code = 101;
                    rdi.msg  = "参数验证失败!";
                    return(Ok(rdi));
                    //return BadRequest(ModelState);
                }

                RecordAddRequest rar    = new RecordAddRequest();
                pbs_record       record = new pbs_record();
                rar = JsonConvert.DeserializeObject <RecordAddRequest>(jsonBean);
                rar.entity.record_state = 1001;
                db.pbs_record.Attach(rar.entity);
                var stateEntity = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(rar.entity);
                stateEntity.SetModifiedProperty("record_title");
                stateEntity.SetModifiedProperty("record_ky_no");
                stateEntity.SetModifiedProperty("record_jj_no");
                stateEntity.SetModifiedProperty("record_aj_no");
                stateEntity.SetModifiedProperty("bg_unit");
                stateEntity.SetModifiedProperty("ky_unit");
                stateEntity.SetModifiedProperty("ky_date");
                stateEntity.SetModifiedProperty("af_time");
                stateEntity.SetModifiedProperty("bj_time");
                stateEntity.SetModifiedProperty("kyks_time");
                stateEntity.SetModifiedProperty("kyjs_time");
                stateEntity.SetModifiedProperty("xz");
                stateEntity.SetModifiedProperty("fs_loc");
                stateEntity.SetModifiedProperty("xc_loc");
                stateEntity.SetModifiedProperty("xc_locpt");
                stateEntity.SetModifiedProperty("weather_info");
                stateEntity.SetModifiedProperty("trend_info");
                stateEntity.SetModifiedProperty("temper_info");
                stateEntity.SetModifiedProperty("humidity_info");
                stateEntity.SetModifiedProperty("light_info");
                stateEntity.SetModifiedProperty("bh_flag");
                stateEntity.SetModifiedProperty("bhr");
                stateEntity.SetModifiedProperty("bhr_name");
                stateEntity.SetModifiedProperty("bhr_unit");
                stateEntity.SetModifiedProperty("bhr_unit_name");
                stateEntity.SetModifiedProperty("bhr_pos");
                stateEntity.SetModifiedProperty("bh_function");
                stateEntity.SetModifiedProperty("xc_info");
                stateEntity.SetModifiedProperty("bd_reason");
                stateEntity.SetModifiedProperty("jzr");
                stateEntity.SetModifiedProperty("jzr_sex");
                stateEntity.SetModifiedProperty("jzr_birth");
                stateEntity.SetModifiedProperty("jzr_address");
                stateEntity.SetModifiedProperty("zhr");
                stateEntity.SetModifiedProperty("zhr_name");
                stateEntity.SetModifiedProperty("zhr_unit");
                stateEntity.SetModifiedProperty("zhr_unit_name");
                stateEntity.SetModifiedProperty("zhr_pos");
                stateEntity.SetModifiedProperty("blr");
                stateEntity.SetModifiedProperty("blr_name");
                stateEntity.SetModifiedProperty("ztr");
                stateEntity.SetModifiedProperty("ztr_name");
                stateEntity.SetModifiedProperty("zxr");
                stateEntity.SetModifiedProperty("zxr_name");
                stateEntity.SetModifiedProperty("lxr");
                stateEntity.SetModifiedProperty("lxr_name");
                stateEntity.SetModifiedProperty("lyr");
                stateEntity.SetModifiedProperty("lyr_name");
                stateEntity.SetModifiedProperty("xc_disp");
                stateEntity.SetModifiedProperty("record_reason");
                stateEntity.SetModifiedProperty("east");
                stateEntity.SetModifiedProperty("west");
                stateEntity.SetModifiedProperty("south");
                stateEntity.SetModifiedProperty("north");
                //db.pbs_record.Add(rar.entity);
                string path    = HttpContext.Current.Server.MapPath("~/");
                string desPath = path + "pbs_data\\" + rar.entity.uuid;
                if (!Directory.Exists(desPath))
                {
                    Directory.CreateDirectory(desPath);
                }
                for (int i = 0; i < rar.fileList.Count; i++)
                {
                    sys_upload_file tmp = new sys_upload_file();
                    tmp          = rar.fileList[i];
                    tmp.rec_uuid = rar.entity.uuid;
                    db.sys_upload_file.Add(tmp);
                    string path1 = path + "upload\\" + tmp.file_url;
                    string path2 = desPath + "\\" + tmp.file_url;
                    File.Move(path1, path2);
                }
                string qmPicPath = path + "upload\\" + rar.entity.uuid + ".png";

                if (File.Exists(qmPicPath))
                {
                    sys_upload_file tmp = db.sys_upload_file.Where(p => p.file_name.Equals(rar.entity.uuid + ".png")).FirstOrDefault();
                    if (tmp == null)
                    {
                        tmp                  = new sys_upload_file();
                        tmp.rec_uuid         = rar.entity.uuid;
                        tmp.file_type        = 2005;
                        tmp.file_name        = rar.entity.uuid + ".png";
                        tmp.file_uploader    = rar.entity.creater_id;
                        tmp.file_url         = rar.entity.uuid + ".png";
                        tmp.file_upload_time = DateTime.Now;
                        tmp.file_hint        = "见证人签名";

                        db.sys_upload_file.Add(tmp);
                    }
                    else
                    {
                        tmp.file_uploader    = rar.entity.creater_id;
                        tmp.file_upload_time = DateTime.Now;
                        db.sys_upload_file.Attach(tmp);
                        var stateEntity2 = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(tmp);
                        stateEntity2.SetModifiedProperty("file_uploader");
                        stateEntity2.SetModifiedProperty("file_upload_time");
                    }
                    string path2 = desPath + "\\" + tmp.file_url;
                    if (File.Exists(path2))
                    {
                        File.Delete(path2);
                    }
                    File.Move(qmPicPath, path2);
                }
                string fwPicPath = path + "upload\\" + rar.entity.uuid + "_xct.jpeg";
                if (File.Exists(fwPicPath))
                {
                    sys_upload_file tmp = db.sys_upload_file.Where(p => p.file_name.Equals(rar.entity.uuid + "_xct.jpeg")).FirstOrDefault();
                    if (tmp == null)
                    {
                        tmp                  = new sys_upload_file();
                        tmp.rec_uuid         = rar.entity.uuid;
                        tmp.file_type        = 2004;
                        tmp.file_name        = rar.entity.uuid + "_xct.jpeg";
                        tmp.file_uploader    = rar.entity.creater_id;
                        tmp.file_url         = rar.entity.uuid + "_xct.jpeg";
                        tmp.file_upload_time = DateTime.Now;
                        tmp.file_hint        = "方位示意图";

                        db.sys_upload_file.Add(tmp);
                    }
                    else
                    {
                        tmp.file_uploader    = rar.entity.creater_id;
                        tmp.file_upload_time = DateTime.Now;
                        db.sys_upload_file.Attach(tmp);
                        var stateEntity2 = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(tmp);
                        stateEntity2.SetModifiedProperty("file_uploader");
                        stateEntity2.SetModifiedProperty("file_upload_time");
                    }

                    string path2 = desPath + "\\" + tmp.file_url;
                    if (File.Exists(path2))
                    {
                        File.Delete(path2);
                    }
                    File.Move(fwPicPath, path2);
                }

                string pmPicPath = path + "upload\\" + rar.entity.uuid + "_pmt.jpeg";
                if (File.Exists(pmPicPath))
                {
                    sys_upload_file tmp = db.sys_upload_file.Where(p => p.file_name.Equals(rar.entity.uuid + "_pmt.jpeg")).FirstOrDefault();
                    if (tmp == null)
                    {
                        tmp                  = new sys_upload_file();
                        tmp.rec_uuid         = rar.entity.uuid;
                        tmp.file_type        = 2004;
                        tmp.file_name        = rar.entity.uuid + "_pmt.jpeg";
                        tmp.file_uploader    = rar.entity.creater_id;
                        tmp.file_url         = rar.entity.uuid + "_pmt.jpeg";
                        tmp.file_upload_time = DateTime.Now;
                        tmp.file_hint        = "平面示意图";

                        db.sys_upload_file.Add(tmp);
                    }
                    else
                    {
                        tmp.file_uploader    = rar.entity.creater_id;
                        tmp.file_upload_time = DateTime.Now;
                        db.sys_upload_file.Attach(tmp);
                        var stateEntity2 = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(tmp);
                        stateEntity2.SetModifiedProperty("file_uploader");
                        stateEntity2.SetModifiedProperty("file_upload_time");
                    }
                    string path2 = desPath + "\\" + tmp.file_url;
                    if (File.Exists(path2))
                    {
                        File.Delete(path2);
                    }
                    File.Move(pmPicPath, path2);
                }

                db.SaveChanges();
                rdi.recNo = rar.entity.record_no;
                rdi.recNo = rdi.recNo.Substring(rdi.recNo.Length - 6);
                rdi.code  = 100;
                return(Ok(rdi));
            }
            catch (Exception e)
            {
                rdi.code = 104;
                rdi.msg  = "更新记录失败: " + e.Message;
                log.Error(e.Message + " -- " + e.InnerException.Message);
                return(Ok(rdi));
            }
        }