public ActionResult ChangeStatusQuery([Bind(Include = "QueryId,DateOut,DateIn,DateModification,DeadLine,Text,StateId,PersonId,PersonSpId")] jQuery jQuery) { if (ModelState.IsValid) { db.Entry(jQuery).State = EntityState.Modified; if (jQuery.StateId == db.hState.First(m => m.Description == "Выполнена").StateId || jQuery.StateId == db.hState.First(m => m.Description == "Отклонена").StateId) { jQuery.DateOut = DateTime.Parse(DateTime.Today.ToShortDateString()); } if (Convert.ToInt32(TempData["oldState"]) != jQuery.StateId) { jJournal jJur = new jJournal(); jJur.Date = DateTime.Now; jJur.EventTypeId = db.hEventType.First(m => m.Description == "Смена статуса заявки").EventTypeId; jJur.WorkListId = null; jJur.PersonId = User.Identity.GetUserId(); jJur.QueryID = jQuery.QueryId; hState oldst = db.hState.Find(Convert.ToInt32(TempData["oldState"])); hState newst = db.hState.Find(jQuery.StateId); jJur.Description = "c " + oldst.Description + " на " + newst.Description; db.jJournal.Add(jJur); } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PersonId = new SelectList(db.AspNetUsers, "Id", "Fio", jQuery.PersonId); ViewBag.PersonSpId = new SelectList(db.AspNetUsers, "Id", "Fio", jQuery.PersonSpId); ViewBag.StateId = new SelectList(db.hState, "StateId", "Description", jQuery.StateId); return(View(jQuery)); }
/// <summary> /// 清理已经结束的线程 /// </summary> /// <returns></returns> private void ColseThread() { bool Result; //获取线程状态 hState sThread = WaitThreadSignal(); if (sThread != hState.WAIT_OBJECT_0) { Result = false; } else { //获取线程退出码 IntPtr ExitCode = GetExitCode(); //释放线程资源 Result = ResourcesFree(ExitCode); } try { //运行回调函数 if (UserFun == null) { return; } IAsyncResult uResult = UserFun.BeginInvoke(Result, delegate(IAsyncResult ar) { UserFun.EndInvoke(ar); }, null); // 执行50毫秒后超时 uResult.AsyncWaitHandle.WaitOne(50, true); } catch (Exception) { } }
public void CloseQuery(int idQury) { var workByQuery = db.jWorkList.Where(m => m.QueryId == idQury); Boolean close = true; foreach (jWorkList work in workByQuery) { if (work.StateWorkId != db.hStateWork.First(m => m.Description == "Выполнена").StateWorkId) { close = false; } } if (close) { jQuery jQuery = db.jQuery.Find(idQury); string oldst = db.hState.Find(jQuery.StateId).Description; jQuery.StateId = db.hState.First(m => m.Description == "Выполнена").StateId; jQuery.DateOut = DateTime.Parse(DateTime.Today.ToShortDateString()); jJournal jJur = new jJournal(); jJur.Date = DateTime.Now; jJur.EventTypeId = db.hEventType.First(m => m.Description == "Смена статуса заявки").EventTypeId; jJur.WorkListId = null; jJur.PersonId = User.Identity.GetUserId(); jJur.QueryID = jQuery.QueryId; hState newst = db.hState.Find(jQuery.StateId); jJur.Description = "c " + oldst + " на " + newst.Description; db.jJournal.Add(jJur); db.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { hState hState = db.hState.Find(id); db.hState.Remove(hState); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "StateId,Description")] hState hState) { if (ModelState.IsValid) { db.Entry(hState).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hState)); }
public ActionResult Create([Bind(Include = "StateId,Description")] hState hState) { if (ModelState.IsValid) { db.hState.Add(hState); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hState)); }
// GET: hStates/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } hState hState = db.hState.Find(id); if (hState == null) { return(HttpNotFound()); } return(View(hState)); }
/// <summary> /// 释放线程资源 /// </summary> /// <returns>返回结果表示此程序运行结果\n不表示资源释放成功</returns> private bool ResourcesFree(IntPtr ExitCode) { //释放内存 //MEM_RELEASE = 0x8000;//释放申请的全部内存 bool MemoryFree = VirtualFreeEx(hProcess, Memory, 0, 0x8000); //获取模块句柄 IntPtr mHandle = GetModuleHandle("kernel32"); if (mHandle == IntPtr.Zero) { return(false); } //获取函数入口 IntPtr hack = GetProcAddress(mHandle, "FreeLibrary"); if (hack == IntPtr.Zero) { return(false); } //创建远程线程,卸载模块 IntPtr handle = CreateRemoteThread(hProcess, 0, 0, hack, ExitCode, 0, 0);; //创建远程线程失败 if (handle == IntPtr.Zero) { return(false); } //等待线程有信号 hState sThread = WaitThreadSignal(); if (sThread != hState.WAIT_OBJECT_0) { return(false); } //关闭句柄 CloseHandle(hThread); CloseHandle(handle); return(true); }