//弃用,流式数据不能生成对应文件(包含上传参数) public string UpLoadStreamFile(Stream sr, string uploadpath, string filename) { try { int size = 1024; byte[] by = new byte[size]; int length = sr.Read(by, 0, size); if (!Directory.Exists(uploadpath)) { Directory.CreateDirectory(uploadpath); } FileStream fs = new FileStream(uploadpath + "//" + filename, FileMode.Create, FileAccess.Write); while (length > 0) { fs.Write(by, 0, by.Length); length = sr.Read(by, 0, size); } fs.Close(); sr.Close(); } catch (Exception e) { return(DataSwitch.HttpPostMsg(e.Message, 0)); } return(DataSwitch.HttpPostMsg("上传成功", 1)); }
public string GetNextNumber() { var q = dbSet.GetById(1); DateTime qrday = q.QRday.StrToDateTime(); DateTime nday = DateTime.Now.Date; int num = nday.CompareTo(qrday); if (num != 0) { q.QRday = nday.ToShortDateString(); q.QROrder = 1; } else { q.QROrder++; } bool count = dbSet.Update(q); int upd = count ? (int)q.QROrder : 0; string qrnum = nday.ToString("yyyyMMdd") + upd.ToString().PadLeft(3, '0'); qrnum = "CS" + qrnum.Substring(2); return(DataSwitch.HttpPostMsg(qrnum)); }
//public string GetCheckInMT(int customid,int stauts) //{ // List<CheckInMT> ciMT = CheckInMTDb.GetList( c => // c.delflag == false & c.CustomID == customid ).ToList(); // if (stauts == 0) // { // ciMT = ciMT.Where(e => e.ServerStauts == stauts).ToList(); // } // return DataSwitch.HttpPostList<CheckInMT>(ciMT); //} public string GetCustomidByQR(string qrcode) { CheckInMT mT = checkInMTSer.GetCheckInMTByQR(qrcode); string customid = General.strFail; if (mT.id != 0) { customid = mT.CustomID.ToString(); } return(DataSwitch.HttpPostMsg(customid)); }
public string GetNewSysVer(string programtype) { int count = dbSet.GetList(v => v.programtype == programtype).Count; if (count > 0) { var q = dbSet.GetList().OrderByDescending(v => v.id).First().id; var sysver = dbSet.GetById(q); return(DataSwitch.HttpPostEntity <SysVer>(sysver)); } return(DataSwitch.HttpPostMsg(General.strFail, General.intFail)); }
/// <summary> /// 删除数据 /// </summary> /// <param name="json">实体类json</param> /// <returns>postdata msg 1,0</returns> public string DeleteEntity(string json) { T entity = DataSwitch.JsonToObj <T>(json); if (entity == null) { return(General.strFail); } bool count = dbSet.Delete(entity); return(DataSwitch.HttpPostMsg(count ? General.strSucess : General.strFail)); }
/// <summary> /// 增加数据 /// </summary> /// <param name="json">实体类json</param> /// <returns>Postdata msg id</returns> public string AddEntity(string json) { T entity = DataSwitch.JsonToObj <T>(json); if (entity == null) { return(General.strFail); } int count = dbSet.InsertReturnIdentity(entity); return(DataSwitch.HttpPostMsg(count)); }
public string DeleteSysdic(string dic) { Sysdic sysDic = DataSwitch.JsonToObj <Sysdic>(dic); if (sysDic == null) { return(General.strFail); } bool count = cSDic.Del(sysDic); return(DataSwitch.HttpPostMsg(count ? General.strSucess : General.strFail)); }
public string UpdateDictionary(string dic) { Sysdic csDic = DataSwitch.JsonToObj <Sysdic>(dic); if (cSDic == null) { return(General.strFail); } bool count = cSDic.Update(csDic); return(DataSwitch.HttpPostMsg(count ? General.strSucess:General.strFail)); }
public string CopyAuth(string userid, string copyuserid) { var userauth = dbSet.GetList(u => u.UserID == userid.ToInt()); foreach (var u in userauth) { u.UserID = copyuserid.ToInt(); } bool check = dbSet.InsertRange(userauth.ToArray()); string str = check ? General.strSucess : General.strFail; return(DataSwitch.HttpPostMsg(str)); }
public string AddDictionary(string dic) { Sysdic csDic = DataSwitch.JsonToObj <Sysdic>(dic); if (cSDic == null) { return(General.strFail); } int count = cSDic.Add(csDic).id; if (count > 0) { return(DataSwitch.HttpPostMsg(count)); } return(DataSwitch.HttpPostMsg(General.strFail)); }
public string DeleteAuth(string userauthjson, string userid) { List <UserAuth> authlist = DataSwitch.JsonToList <UserAuth>(userauthjson); var user = dbSet.GetList(u => u.UserID == userid.ToInt()); foreach (var dbauth in user) { foreach (var auth in authlist) { if (auth.AuthID == dbauth.AuthID) { dbSet.Delete(dbauth); } } } return(DataSwitch.HttpPostMsg(General.strSucess)); }
public string InsertTable(string authlistjson, string userid) { List <UserAuth> auths = dbSet.GetList(u => u.UserID == userid.ToInt()); List <Authority> authlist = DataSwitch.JsonToList <Authority>(authlistjson); List <UserAuth> userAuths = new List <UserAuth>(); List <Authority> addauth = new List <Authority>(); foreach (var auth in authlist) { bool check = true; foreach (var au in auths) { if (auth.id == au.AuthID) { check = false; } } if (check) { UserAuth userAuth = new UserAuth { AuthID = auth.id, UserID = userid.ToInt() }; userAuths.Add(userAuth); addauth.Add(auth); } } if (userAuths.Count == 0) { return(DataSwitch.HttpPostList(addauth)); } bool insert = dbSet.InsertRange(userAuths.ToArray()); if (insert) { return(DataSwitch.HttpPostList(addauth)); } return(DataSwitch.HttpPostMsg(General.strFail)); }
public string UpLoadFile(HttpPostedFileBase filedata, string path) { if (filedata == null) { return(DataSwitch.HttpPostMsg("未提交上传文件", 0)); } try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string fileName = Path.GetFileName(filedata.FileName); // 原始文件名称 string fileExtension = Path.GetExtension(fileName); // 文件扩展名 string saveName = Guid.NewGuid().ToString("P") + fileExtension; // 保存文件名称 filedata.SaveAs(path + "/" + saveName); } catch (Exception e) { return(DataSwitch.HttpPostMsg(e.Message, 0)); } return(DataSwitch.HttpPostMsg("上传成功", 1)); }
public string FindSameCustomByTel(string tel) { int count = dbSet.Count(c => c.CTel == tel); return(DataSwitch.HttpPostMsg(count)); }