public string fileUpload() { // 保存传来的文件 HttpPostedFileBase file = Request.Files["Filedata"]; // 在FileData里 FileInfo fi = new FileInfo(file.FileName); string fileID = Guid.NewGuid().ToString(); string uploadDir = WebConfigurationManager.AppSettings["uploadDir"]; file.SaveAs(Server.MapPath(uploadDir + fileID + fi.Extension)); using (MyDB mydb = new MyDB()) { EntityObjectLib.File f = new EntityObjectLib.File { ID = fileID, CreateDate = DateTime.Now, Name = file.FileName, Creator = mydb.Users.Find(HttpContext.User.Identity.Name), UploadPath = uploadDir, Suffix = fi.Extension }; mydb.Files.Add(f); mydb.SaveChanges(); } //System.Threading.Thread.Sleep(3000); //// 回传 Response.StatusCode = 200; //成功 return fileID; }
public ActionResult saveMemo() { string id = Request.Params["id"]; using (MyDB mydb = new MyDB()) { User user = mydb.Users.Find(this.User.Identity.Name); if (string.IsNullOrEmpty(id)) { Event ev = new Event { ID = Guid.NewGuid().ToString(), Name = Request.Params["Name"], Content = Request.Params["Content"], Type = "便笺", Master = user, Proctor = user, Creator = user, CreateTime = DateTime.Now }; mydb.Events.Add(ev); } else { Event ev = mydb.Events.Find(id); ev.Name = Request.Params["Name"]; ev.Content = Request.Params["Content"]; } mydb.SaveChanges(); } return Json(new { success = true }); }
public void Append() { using (MyDB mydb = new MyDB()) { #region "创建通讯录记录" AddressBook AddressBook = new AddressBook { ID = Guid.NewGuid().ToString(), Name = "陈宏伟", Sex = "男", BirthDay = new DateTime(1971, 9, 10), Company = "manbuit", Department = "R&D", Job = "developer", Creator = mydb.Users.First(s => s.Code.Equals("lilin")), Owner = mydb.Users.First(s => s.Code.Equals("lilin")), AddressBookShares = new AddressBookShare[] { new AddressBookShare { ID = Guid.NewGuid().ToString(), Subject = mydb.Subjects.OfType<User>().First(s=>s.Code.Equals("lilin")) }, new AddressBookShare { ID = Guid.NewGuid().ToString(), Subject = mydb.Subjects.OfType<User>().First(s=>s.Code.Equals("chw")) } } }; #endregion mydb.AddressBooks.Add(AddressBook); mydb.SaveChanges(); } }
public static void CheckALL() { using (MyDB mydb = new MyDB()) { // 检出需要提醒的事件 IQueryable<EventRemind> eventReminds = mydb.EventReminds .Where(er => er.SendTime == null && er.RemindTime <= DateTime.Now) .Select(er => er); foreach (EventRemind eventRemind in eventReminds) { string[] sendTypes = string.IsNullOrEmpty(eventRemind.ReceiverType) ? new string[]{} :eventRemind.ReceiverType.Split(",".ToArray()); foreach (string sendType in sendTypes) { switch (sendType) { case "责任人": if (eventRemind.Event.Master != null) { SendRemind(eventRemind.Event.Master, eventRemind.Event.Name, eventRemind.Event.Content, mydb); } break; case "督办人": if (eventRemind.Event.Master != null) { SendRemind(eventRemind.Event.Proctor, eventRemind.Event.Name, eventRemind.Event.Content, mydb); } break; case "共享人": foreach (Subject subject in eventRemind.Event.EventShares.Select(es => es.Subject).Distinct()) { if (subject is User) { SendRemind(subject as User, eventRemind.Event.Name, eventRemind.Event.Content, mydb); } if (subject is Organization) { foreach (User u in (subject as Organization).Users) { SendRemind(u, eventRemind.Event.Name, eventRemind.Event.Content, mydb); } } } break; default: break; } } eventRemind.SendTime = DateTime.Now; } mydb.SaveChanges(); return; } }
public ActionResult DeleteModule() { using (MyDB mydb = new MyDB()) { EntityObjectLib.Module p = mydb.Modules.Find(Request.Form["ID"]); mydb.Modules.Remove(p); mydb.SaveChanges(); } return Json(new { success = true }); }
public ActionResult UpdateResource() { using (MyDB mydb = new MyDB()) { EntityObjectLib.Resource p = getResource(Request, mydb); mydb.SaveChanges(); } return Json(new { success = true }); }
public ActionResult CreatePrivilege() { using (MyDB mydb = new MyDB()) { EntityObjectLib.Privilege p = getPrivilege(Request, mydb); p.ID = Guid.NewGuid().ToString(); mydb.Privileges.Add(p); mydb.SaveChanges(); } return Json(new { success = true }); }
public ActionResult UpdateUser() { using (MyDB mydb = new MyDB()) { EntityObjectLib.User p = getUser(Request, mydb); ////mydb.Modules.Attach(p); //mydb.Entry<EntityObjectLib.User>(p).State = System.Data.EntityState.Modified; //mydb.Entry<EntityObjectLib.Organization>(p.Organization).State = System.Data.EntityState.Modified; mydb.SaveChanges(); } return Json(new { success = true }); }
public void clear() { using (MyDB mydb = new MyDB()) { mydb.AddressBookShares.Load(); mydb.AddressBooks.Load(); mydb.AddressBookShares.Local.Clear(); mydb.AddressBooks.Local.Clear(); mydb.SaveChanges(); } }
public ActionResult save() { string userID = this.User.Identity.Name; using (MyDB mydb = new MyDB()) { EntityObjectLib.User user = mydb.Users.Find(userID); user.LayoutData = Request.Params["LayoutData"]; mydb.SaveChanges(); } return Json(new { success = true }); }
public void clear() { using (MyDB mydb = new MyDB()) { mydb.Files.Load(); mydb.Files.Local.Clear(); mydb.InfoFiles.Load(); mydb.InfoFiles.Local.Clear(); mydb.InfoInboxs.Load(); mydb.InfoInboxs.Local.Clear(); mydb.InfoSubscriptions.Load(); mydb.InfoSubscriptions.Local.Clear(); mydb.Infos.Load(); mydb.Infos.Local.Clear(); mydb.InfoBoards.Load(); mydb.InfoBoards.Local.Clear(); mydb.SaveChanges(); } }
public ActionResult CreateModule() { //将JSON格式转换为Module类型 //return Json(new { success = false, errors = new { clientCode = "", portOfLoading = "" } }); EntityObjectLib.Module p = getModule(Request); using (MyDB mydb = new MyDB()) { p.ID = Guid.NewGuid().ToString(); mydb.Modules.Add(p); mydb.SaveChanges(); } return Json(new { success = true }); }
public void clear() { using (MyDB mydb = new MyDB()) { mydb.WFInstNodeHandlers.Load(); mydb.WFInstNodeHandlers.Local.Clear(); mydb.WFInstNodes.Load(); mydb.WFInstNodes.Local.Clear(); mydb.WFInsts.Load(); mydb.WFInsts.Local.Clear(); mydb.WFInstNodeHandlers.Load(); mydb.WFInstNodeHandlers.Local.Clear(); mydb.WFNodeActions.Load(); mydb.WFNodeActions.Local.Clear(); mydb.WFNodeACLs.Load(); mydb.WFNodeACLs.Local.Clear(); mydb.WFNodeHandles.Load(); mydb.WFNodeHandles.Local.Clear(); mydb.WFNodeExpressions.Load(); mydb.WFNodeExpressions.Local.Clear(); mydb.WFNodeXORSplits.Load(); mydb.WFNodeXORSplits.Local.Clear(); mydb.WFNodeStarts.Load(); mydb.WFNodeStarts.Local.Clear(); mydb.WFNodeFinishs.Load(); mydb.WFNodeFinishs.Local.Clear(); mydb.WFNodes.Load(); mydb.WFNodes.Local.Clear(); mydb.WFTemplates.Load(); mydb.WFTemplates.Local.Clear(); mydb.SaveChanges(); } }
public void clear() { using (MyDB mydb = new MyDB()) { mydb.FWInfoFiles.Load(); mydb.FWInfoFiles.Local.Clear(); mydb.FWInfos.Load(); mydb.FWInfos.Local.Clear(); mydb.FWTemplates.Load(); mydb.FWTemplates.Local.Clear(); mydb.FWTypes.Load(); mydb.FWTypes.Local.Clear(); mydb.SaveChanges(); } }
public ActionResult saveEvent() { string ID = Request.Form["ID"]; string Name = Request.Form["Name"]; string Content = Request.Form["Content"]; string Type = Request.Form["Type"]; string Parent = Request.Form["Parent"]; string StartDate = Request.Form["StartDate"]; string StartTime = Request.Form["StartTime"]; string FinishDate = Request.Form["FinishDate"]; string FinishTime = Request.Form["FinishTime"]; string Master = Request.Form["Master"]; string Proctor = Request.Form["Proctor"]; using (MyDB mydb = new MyDB()) { EntityObjectLib.Event p = new Event { ID = Guid.NewGuid().ToString(), Name = Name, Content = Content, Type = Type, Parent = mydb.Events.Find(Parent), StartTime = DateTime.Parse(StartDate +" " + StartTime), FinishTime = DateTime.Parse(FinishDate + " " + FinishTime), Master = mydb.Users.Find(Master), Proctor = mydb.Users.Find(Proctor), Creator = mydb.Users.Find(this.User.Identity.Name), CreateTime = DateTime.Now }; mydb.Events.Add(p); mydb.SaveChanges(); return Json(new { success = true } ); } }
/// <summary> /// 创建联系人 /// </summary> /// <returns></returns> public ActionResult createAddress() { string Name = Request.Params["Name"]; string userID = this.User.Identity.Name; using (MyDB mydb = new MyDB()) { AddressBook ab = new AddressBook { ID = Guid.NewGuid().ToString(), Name = Name, Creator = mydb.Users.Find(this.User.Identity.Name), Owner = mydb.Users.Find(this.User.Identity.Name), CreateTime = DateTime.Now, LastUpdateTime = DateTime.Now }; mydb.AddressBooks.Add(ab); mydb.SaveChanges(); return Json(new { success = true }); } }
public ActionResult ReOrderModules() { string[] Ids = Request.Form["data"].Split(",".ToCharArray()); using (MyDB mydb = new MyDB()) { mydb.Modules.Load(); mydb.Resources.Load(); EntityObjectLib.Module last = null; int order = 0; foreach (string id in Ids) { order = order + 10; EntityObjectLib.Module p = mydb.Modules.Local.FirstOrDefault(m => m.ID.Equals(id)); if (p == null) { EntityObjectLib.Resource r = mydb.Resources.Local.FirstOrDefault(m => m.ID.Equals(id)); if (r == null) { continue; } else { r.orderNO = order; r.module = last; } } else { last = p; p.orderNO = order; } } mydb.SaveChanges(); } return Json(new { success = true }); }
public void Append() { using (MyDB mydb = new MyDB()) { #region "创建事件" Event myevent = new Event { ID = Guid.NewGuid().ToString(), Name = "我的事件B", Parent = null, Content = "我的事件BBBBBBBBBBBBBBBBBBBBBBBBBBBBB", Type = "任务", StartTime = new DateTime(2011, 4, 13, 11, 0, 0), FinishTime = new DateTime(2011, 5, 12, 12, 1, 1), Creator = mydb.Users.First(u => u.Code.Equals("chw")), CreateTime = DateTime.Now, Master = mydb.Users.First(u => u.Code.Equals("lilin")), Proctor = mydb.Users.First(u => u.Code.Equals("chw")), EventShares = new EventShare[] { new EventShare { ID = Guid.NewGuid().ToString(), Subject = mydb.Subjects.OfType<User>().First(s=>s.Code.Equals("lilin")), NeedRemind = true }, new EventShare { ID = Guid.NewGuid().ToString(), Subject = mydb.Subjects.OfType<User>().First(s=>s.Code.Equals("chw")), NeedRemind = true } }, EventStates = new EventState[]{ new EventState { ID = Guid.NewGuid().ToString(), StateTime = new DateTime(2011,3,12,12,1,1), PlanRadio = 0.3, AcutalRadio = 0.2, Description = "DescriptionDescriptionDescription", Creator = mydb.Users.First(u=>u.Code.Equals("chw")), CreateTime = DateTime.Now }, new EventState { ID = Guid.NewGuid().ToString(), StateTime = new DateTime(2011,3,18,12,1,1), PlanRadio = 0.5, AcutalRadio = 0.4, Description = "DescriptionDescriptionDescription", Creator = mydb.Users.First(u=>u.Code.Equals("lilin")), CreateTime = DateTime.Now } }, EventReminds = new EventRemind[]{ new EventRemind { ID = Guid.NewGuid().ToString(), RemindTime = new DateTime(2011,3,18,12,1,1), RemindContent = "dafsdfasdF", ReceiverType = "责任人", SendTime = new DateTime(2011,3,19,12,1,1) } , new EventRemind { ID = Guid.NewGuid().ToString(), RemindTime = new DateTime(2011,4,18,12,1,1), RemindContent = "2011,4,18,12,1,1", ReceiverType = "督办人,共享人", SendTime = null } } }; #endregion mydb.Events.Add(myevent); mydb.SaveChanges(); } }
public ActionResult saveWFTemplate() { string id = Request.Form["id"]; string Name = Request.Form["Name"]; string BuizCode = Request.Form["BuizCode"]; string BuizName = Request.Form["BuizName"]; using (MyDB mydb = new MyDB()) { WFNodeFinish finish = new WFNodeFinish { ID = Guid.NewGuid().ToString(), Name = "结束节点", PositionX = 200, PositionY = 40 }; WFTemplate wft = new WFTemplate { ID = Guid.NewGuid().ToString(), Name = Name, BuizCode = BuizCode, BuizName = BuizName, Creator = mydb.Users.Find(this.User.Identity.Name), CreateTime = DateTime.Now, Nodes = new WFNode[] { new WFNodeStart { ID = Guid.NewGuid().ToString(), PositionX = 100, PositionY = 40, Name = "开始节点", Next = finish }, finish } }; mydb.WFTemplates.Add(wft); mydb.SaveChanges(); return Json(new { success = true }); } }
public ActionResult UpdateModule() { EntityObjectLib.Module p = getModule(Request); using (MyDB mydb = new MyDB()) { //mydb.Modules.Attach(p); mydb.Entry<EntityObjectLib.Module>(p).State = System.Data.EntityState.Modified; mydb.SaveChanges(); } return Json(new { success = true }); }
public void TestMethod1() { using (MyDB mydb = new MyDB()) { Info info = new Info { ID = Guid.NewGuid().ToString(), Title = "这是一个测试", Content = "Content", Creator = mydb.Users.FirstOrDefault(u=>u.Code=="chw"), CreateDate = DateTime.Now, SendDate = DateTime.Now, SendTypes = "SMS,Msg,Email", InfoFiles = new InfoFile[] { new InfoFile { ID = Guid.NewGuid().ToString(), FileName = "WWW.doc", UploadDate = DateTime.Now, File = new File { ID = Guid.NewGuid().ToString(), Name = "XXX", Suffix = "doc", CreateDate = DateTime.Now, Creator = mydb.Users.FirstOrDefault(u=>u.Code=="chw"), UploadPath = "~/uploads" } }, new InfoFile { ID = Guid.NewGuid().ToString(), FileName = "XXX.jpg", UploadDate = DateTime.Now, File = new File { ID = Guid.NewGuid().ToString(), Name = "XXX", Suffix = "jpg", CreateDate = DateTime.Now, Creator = mydb.Users.FirstOrDefault(u=>u.Code=="chw"), UploadPath = "~/uploads" } } }, Receivers = new InfoInbox[] { new InfoInbox { ID=Guid.NewGuid().ToString(), Receiver = mydb.Users.FirstOrDefault(u=>u.Code=="chw"), ReadDate = DateTime.Now, ReceiveTypes = "SMS,Msg,Email" }, new InfoInbox { ID=Guid.NewGuid().ToString(), Receiver = mydb.Users.FirstOrDefault(u=>u.Code=="lilin"), ReadDate = DateTime.Now, ReceiveTypes = "SMS,Msg,Email" }, } }; InfoBoard board = new InfoBoard { ID = Guid.NewGuid().ToString(), Name = "dfadsfa", Administrator = mydb.Users.FirstOrDefault(u => u.Code == "lilin"), CreateDate = DateTime.Now, Infos = new []{info} }; InfoSubscription sub = new InfoSubscription { ID= Guid.NewGuid().ToString(), Owner = mydb.Users.FirstOrDefault(u => u.Code == "lilin"), Title = info, Name = "sdsss", Enable = true, CreateDate = DateTime.Now }; mydb.Infos.Add(info); mydb.InfoBoards.Add(board); mydb.InfoSubscriptions.Add(sub); mydb.SaveChanges(); } }
public ActionResult updateUserRoles() { IEnumerable<string> Ids = Request.Params["IDs"].Split(",".ToArray()).AsEnumerable(); //新的角色ID串 string userID = Request.Params["userID"]; using (MyDB mydb = new MyDB()) { EntityObjectLib.User user = mydb.Users.Find(userID); IQueryable<string> OriRoleIDs = user.Roles.Select(r => r.ID) == null ? null : user.Roles.Select(r => r.ID).AsQueryable(); OriRoleIDs.Load(); string[] removeIDS = OriRoleIDs.Except(Ids).ToArray(); foreach (string s in removeIDS) { user.Roles.Remove(mydb.Roles.Find(s)); } string[] appendIDS = Ids.Except(OriRoleIDs).ToArray(); foreach (string s in appendIDS) { user.Roles.Add(mydb.Roles.Find(s)); } mydb.SaveChanges(); } return Json(new { success = true }); }
public void InitData() { clear(); using (MyDB mydb = new MyDB()) { WFTemplate wft = new WFTemplate { ID = Guid.NewGuid().ToString(), Name = "费用申请流程", BuizCode = "ApplyExpense", BuizName = "费用申请", Creator = mydb.Users.First(u => u.Code.Equals("chw")), CreateTime = DateTime.Now, Nodes = new WFNode[] { new WFNodeStart { Name="开始", Next=null }, new WFNodeHandle { Name="创建申请", ViewCode="createForm", ViewName="创建表单", Actions = new [] { new WFNodeAction { Code="save", Name="保存", NextNode=null //为空表示仍在停留在此节点中 }, new WFNodeAction { Code="submit", Name="提交", NextNode=null //这个不应该为NULL,但所需的节点还未创建 }, }, Subjects = new [] { mydb.Users.First(u => u.Code.Equals("chw")), mydb.Users.First(u => u.Code.Equals("lilin")) } }, new WFNodeHandle { Name="部门确认", ViewCode="auditForm", ViewName="审核表单", Actions = new [] { new WFNodeAction { Code="pass", Name="确认", NextNode=null //为空表示仍在停留在此节点中 }, new WFNodeAction { Code="deny", Name="否决", NextNode=null //这个不应该为NULL,但所需的节点还未创建 }, }, Subjects = new [] { mydb.Users.First(u => u.Code.Equals("chw")) } }, new WFNodeHandle { Name="副总审核", ViewCode="auditForm", ViewName="审核表单", Actions = new [] { new WFNodeAction { Code="pass", Name="确认", NextNode=null //为空表示仍在停留在此节点中 }, new WFNodeAction { Code="deny", Name="否决", NextNode=null //这个不应该为NULL,但所需的节点还未创建 }, }, Subjects = new [] { mydb.Users.First(u => u.Code.Equals("chw")) } }, new WFNodeXORSplit { Name="费用金额分支", //Next = null, //缺省节点 WFNodeExpressions = new [] { new WFNodeExpression { Expression = "{费用金额}>10000", Description = "费用金额大于10000元时,需要总经理审核", Next = null, OrderNO = 1 }, new WFNodeExpression { Expression = "{费用金额}>5000", Description = "费用金额大于5000元时,需要通知监察科", Next = null, OrderNO = 3 } } }, new WFNodeHandle { Name="总经理审核", ViewCode="auditForm", ViewName="审核表单", Actions = new [] { new WFNodeAction { Code="pass", Name="同意", NextNode=null //为空表示仍在停留在此节点中 }, new WFNodeAction { Code="deny", Name="不同意", NextNode=null //这个不应该为NULL,但所需的节点还未创建 }, }, Subjects = new [] { mydb.Users.First(u => u.Code.Equals("lxx")) } }, new WFNodeFinish { ID = Guid.NewGuid().ToString(), Name="结束" } } }; mydb.WFTemplates.Add(wft); wft.Nodes.OfType<WFNodeStart>().First().Next = wft.Nodes.First(n => n.Name.Equals("创建申请")); wft.Nodes.OfType<WFNodeHandle>().First(n => n.Name.Equals("创建申请")).Actions.First(a => a.Code.Equals("submit")).NextNode = wft.Nodes.First(n => n.Name.Equals("部门确认")); wft.Nodes.OfType<WFNodeHandle>().First(n => n.Name.Equals("部门确认")).Actions.First(a => a.Code.Equals("pass")).NextNode = wft.Nodes.First(n => n.Name.Equals("副总审核")); wft.Nodes.OfType<WFNodeHandle>().First(n => n.Name.Equals("部门确认")).Actions.First(a => a.Code.Equals("deny")).NextNode = wft.Nodes.OfType<WFNodeFinish>().First(); wft.Nodes.OfType<WFNodeHandle>().First(n => n.Name.Equals("副总审核")).Actions.First(a => a.Code.Equals("pass")).NextNode = wft.Nodes.First(n => n.Name.Equals("费用金额分支")); wft.Nodes.OfType<WFNodeHandle>().First(n => n.Name.Equals("副总审核")).Actions.First(a => a.Code.Equals("deny")).NextNode = wft.Nodes.OfType<WFNodeFinish>().First(); //wft.Nodes.OfType<WFNodeXORSplit>().First(n => n.Name.Equals("费用金额分支")).Next = wft.Nodes.OfType<WFNodeFinish>().First(); wft.Nodes.OfType<WFNodeXORSplit>().First(n => n.Name.Equals("费用金额分支")).WFNodeExpressions.First(exp => exp.Expression.Equals("{费用金额}>10000")).Next = wft.Nodes.First(n => n.Name.Equals("总经理审核")); wft.Nodes.OfType<WFNodeXORSplit>().First(n => n.Name.Equals("费用金额分支")).WFNodeExpressions.First(exp => exp.Expression.Equals("{费用金额}>5000")).Next = wft.Nodes.First(n => n.Name.Equals("总经理审核")); wft.Nodes.OfType<WFNodeHandle>().First(n => n.Name.Equals("总经理审核")).Actions.First(a => a.Code.Equals("pass")).NextNode = wft.Nodes.OfType<WFNodeFinish>().First(); wft.Nodes.OfType<WFNodeHandle>().First(n => n.Name.Equals("总经理审核")).Actions.First(a => a.Code.Equals("deny")).NextNode = wft.Nodes.OfType<WFNodeFinish>().First(); try { mydb.SaveChanges(); } catch (Exception e) { } } }
public ActionResult updateMySubscriptions() { IEnumerable<string> Ids = Request.Params["IDs"].Split(",".ToArray()).AsEnumerable(); //新的角色ID串 string userID = this.User.Identity.Name; using (MyDB mydb = new MyDB()) { IQueryable<InfoSubscription> subscriptions = mydb.InfoSubscriptions.Where(s => s.Owner.ID.Equals(userID)); foreach (InfoSubscription s in subscriptions) { if(!Ids.Contains(s.Title.ID)) mydb.InfoSubscriptions.Remove(s); } string[] appendIDS = Ids.Except(subscriptions.Select(s=>s.Title.ID)).ToArray(); foreach (string s in appendIDS) { InfoSubscription sub = new InfoSubscription(); sub.ID = Guid.NewGuid().ToString(); sub.Owner = mydb.Users.Find(userID); sub.Title = mydb.Infos.Find(s); mydb.InfoSubscriptions.Add(sub); } mydb.SaveChanges(); } return Json(new { success = true }); }
/// <summary> /// 更新通讯录 /// </summary> /// <returns></returns> public ActionResult updateAddress() { string id = Request.Params["id"]; string field = Request.Params["field"]; string value = Request.Params["value"]; string userID = this.User.Identity.Name; using (MyDB mydb = new MyDB()) { AddressBook ab = mydb.AddressBooks.Find(id); Type type =ab.GetType().GetProperty(field).PropertyType; mydb.Entry<AddressBook>(ab).Property(field).CurrentValue = Convert.ChangeType(value, type); //需要类型转换 ab.LastUpdateTime = DateTime.Now; mydb.SaveChanges(); return Json(new { success = true }); } }
public ActionResult saveReceiverType() { string userID = this.User.Identity.Name; using (MyDB mydb = new MyDB()) { User user = mydb.Users.Find(userID); List<string> ss = new List<string>(); if (Request.Form["sms"] != null && Request.Form["sms"].Equals("on")) ss.Add("sms"); if (Request.Form["email"] != null && Request.Form["email"].Equals("on")) ss.Add("email"); user.InfoReceiveTypes = string.Join(",",ss.ToArray()); mydb.SaveChanges(); } return Json(new { success = true }); }
/// <summary> /// 显示消息 /// Request.QueryString["id"]: 消息id /// </summary> /// <returns></returns> public ActionResult MsgShow() { string id = Request.QueryString["id"]; string UserID = HttpContext.User.Identity.Name; using (MyDB mydb = new MyDB()) { Info info = mydb.Infos.Find(id); EntityObjectLib.InfoInbox mi = info.Receivers.FirstOrDefault(r => r.Receiver.ID.Equals(UserID)); if (mi != null) { info.Receivers.FirstOrDefault(r => r.Receiver.ID.Equals(UserID)).ReadDate = DateTime.Now; mydb.SaveChanges(); } ViewBag.IsSender = UserID.Equals(info.Creator.ID); ViewBag.info = info; ViewBag.Creator = info.Creator.Name; ViewBag.Receivers = string.Join(",", info.Receivers.Select(r => r.Receiver.Name).ToArray()); ViewBag.files = info.InfoFiles.Select(f => string.Format("<a href='/uploads/{1}' target='_blank'>{0}</a>", f.File.Name, f.File.ID + f.File.Suffix)).ToArray(); ViewBag.children = info.Children.Select(inf => string.Format("<a href=javascript:this.parent.addTab('/office/myOffice/MsgShow?ID={0}','消息:{3}') target='_blank'>[{1}]{2}:{3}</a>", inf.ID, inf.CreateDate, inf.Creator.Name, inf.Title)).ToArray(); } return View(); }
public ActionResult MsgSend() { // 如果字符串含双引号,则将截断双引号及后面的字符,但在其他表单里是没有的,可能与 // 该表单含文件上传有关 string Receivers = Request.Form["Receivers"]; string Title = Request.Form["Title"]; string Content = Request.Form["Content"].Replace("\r\n",""); //去掉回车 string ParentID = Server.HtmlEncode(Request.Form["ParentID"]); string hiddenFileIDs = Request.Form["hiddenFileIDs"]; string infoID = Guid.NewGuid().ToString(); using (MyDB mydb = new MyDB()) { EntityObjectLib.File[] files = mydb.Files.Where(f => hiddenFileIDs.Contains(f.ID)).ToArray(); EntityObjectLib.Info info = new Info { ID = infoID, Title = Title, Content = Content, CreateDate = DateTime.Now, SendDate = DateTime.Now, Creator = mydb.Users.Find(HttpContext.User.Identity.Name), SendTypes = "", Receivers = string.IsNullOrEmpty(Receivers) ? null : Receivers.Split(",".ToCharArray()).Select(r => new EntityObjectLib.InfoInbox { ID = Guid.NewGuid().ToString(), Receiver = mydb.Users.FirstOrDefault(u => r.Equals(u.Name + "(" + u.Code + ")")), ReceiveTypes = "" }).ToArray(), InfoFiles = files.Select(f => new InfoFile { ID = Guid.NewGuid().ToString(), File = f, FileName = f.Name, UploadDate = DateTime.Now } ).ToArray(), Parent = mydb.Infos.Find(ParentID)/*, Board = mydb.InfoBoards.First()*/ }; /* List<EntityObjectLib.File> files = new List<EntityObjectLib.File>(); for (int i = 0; i < Request.Files.Count; i++) { if (Request.Files[i].ContentLength > 0) { Request.Files[i].SaveAs(Server.MapPath("~/" + Request.Files[i].FileName)); EntityObjectLib.File file = new EntityObjectLib.File { ID = Guid.NewGuid().ToString(), CreateDate = DateTime.Now, Name = Request.Files[i].FileName, Creator = mydb.Users.Find(HttpContext.User.Identity.Name), UploadPath = "~/", Suffix = "" }; files.Add(file); } } */ mydb.Infos.Add(info); mydb.SaveChanges(); } Response.Clear(); return Json(new { success = true, ID = infoID }, "text/html"); }
public void TestMethod1() { using (MyDB mydb = new MyDB()) { FWType type1 = new FWType { ID = Guid.NewGuid().ToString(), Name = "发文类别一", FWPrefixes = "1A发,1B发,1C发", FWTemplates = new[]{ new FWTemplate { ID = Guid.NewGuid().ToString(), Name="发文模板1A", TemplateFile = mydb.Files.First() }, new FWTemplate { ID = Guid.NewGuid().ToString(), Name="发文模板1B", TemplateFile = mydb.Files.First() } } }; FWType type2 = new FWType { ID = Guid.NewGuid().ToString(), Name = "发文类别二", FWPrefixes = "2A发,2B发,2C发", FWTemplates = new[]{ new FWTemplate { ID = Guid.NewGuid().ToString(), Name="发文模板2A", TemplateFile = mydb.Files.First() }, new FWTemplate { ID = Guid.NewGuid().ToString(), Name="发文模板2B", TemplateFile = mydb.Files.First() } } }; FWInfo fw = new FWInfo { ID = Guid.NewGuid().ToString(), FWType = type1, FWTemplate = type1.FWTemplates.First(), FWPrefix = "1B发", FWYear = DateTime.Now.Year, FWNO = 10, Urgency = "普通", Secrecy = "保密", Title = "关于****项目实施的通知", Keywords = "项目,实施,通知", Summary = @"****项目已于某年某月某日测试完成,现已进入实施阶段,请各部门在信息部领导下积极参与实施.", Recipient = "各部门", Participator = "信息部", Drafter = mydb.Users.First(u => u.Code == "chw"), DraftTime = DateTime.Now, CopyAmount = 10, FWInfoFiles = new []{ new FWInfoFile { ID = Guid.NewGuid().ToString(), FileName="test.ddd", UploadDate = DateTime.Now, File = mydb.Files.First() } }, WFTemplate=mydb.WFTemplates.First(), // 参与流程后,创建业务实例一定要有流程模板 Creator = mydb.Users.First() }; mydb.FWTypes.Add(type1); mydb.FWTypes.Add(type2); //mydb.SaveChanges(); mydb.FWInfos.Add(fw); mydb.SaveChanges(); } }
public void Append() { using (MyDB mydb = new MyDB()) { WFTemplate template = new WFTemplate { ID = Guid.NewGuid().ToString(), BuizCode = "GenericBuiz", BuizName = "通用业务", Name = "通用业务模板一", Creator = mydb.Users.First(u => u.Code == "chw"), CreateTime = DateTime.Now }; mydb.WFTemplates.Add(template); GenericModel model = new GenericModel { Name = "test1", Model = @"[ {code:'ID',name:'ID',type:'string'}, {code:'amount',name:'申请金额(元)',type:'numeric'}, {code:'description',name:'申请说明',type:'string'}, {code:'applyTime',name:'申请时间',type:'date'}, {code:'detail',name:'明细',type:'array',ctype:[ {code:'ID',name:'ID',type:'string'}, {code:'item',name:'项目',type:'string'}, {code:'item',name:'费用(元)',type:'numeric'}, ] } ]", Views = new[] { new GenericView { Name="view1", Content=@"<script type='text/javascript'> var data={}; </script> <input type='hidden' name='ID' id='ID' value=''/> <table border='1'> <tr> <td><span>申请金额(元)</span></td><td><input type='text' name='amount' id='amount' value=''/></td></tr> <tr> <td><span>申请说明</span></td><td><input type='text' name='description' id='description' value=''/></td></tr> <tr> <td><span>申请时间</span></td><td><input type='text' name='applyTime' id='applyTime' value=''/></td> </tr> </table> <!--以下是明细-->" }, new GenericView { Name = "view2", Content="" } }, Buizs = new[] { new GenericBuiz { Name="业务实例1", Data="", Creator = mydb.Users.First(u => u.Code == "chw"), WFTemplate = template }, new GenericBuiz { Name="业务实例2", Data="", Creator = mydb.Users.First(u => u.Code == "chw"), WFTemplate = template } } }; mydb.GenericModels.Add(model); mydb.SaveChanges(); } }