public bool handleUpdatePhysics(Attachable source, int priority, Transform t) { if (!attachedTable.Contains(source)) { return(false); } if (priority <= lastUpdatePriority) { if (source == lastUpdateSource) { lastUpdatePriority = priority; } else { return(false); } } lastUpdateSource = source; lastUpdatePriority = priority; AttachInfo info = (AttachInfo)(attachedTable[source]); this.transform.position = t.position + info.offsetPosition; this.transform.rotation = t.rotation /* info.offsetRotation*/; foreach (Attachable item in attachedTable.Keys) { item.handleUpdatePhysics(this, priority - 1, this.transform); } return(true); }
// Token: 0x06000011 RID: 17 RVA: 0x00002F40 File Offset: 0x00001140 protected override void View() { if (this.ispost) { if (this.action == "delete") { string @string = FPRequest.GetString("chkdel"); foreach (string text in @string.Split(new char[] { ',' })) { AttachInfo attachInfo = DbHelper.ExecuteModel <AttachInfo>(int.Parse(text)); if (DbHelper.ExecuteDelete <AttachInfo>(text) > 0) { if (File.Exists(FPUtils.GetMapPath(attachInfo.filename))) { File.Delete(FPUtils.GetMapPath(attachInfo.filename)); } } } } base.Response.Redirect(this.pagename); } this.attachlist = DbHelper.ExecuteList <AttachInfo>(this.pager); base.SaveRightURL(); }
//add attach //api 调用时,添加attach之前时没有note的 //fromApi表示是api添加的, updateNote传过来的, 此时不要incNote's usn, 因为updateNote会inc的 public bool AddAttach(AttachInfo attachInfo, bool fromApi, out string msg) { attachInfo.CreatedTime = DateTime.Now; var ok = InsertAttach(attachInfo); var note = NoteService.GetNoteById(attachInfo.NoteId); long?userId = 0L; if (note.NoteId != null) { userId = note.UserId; } else { userId = attachInfo.UploadUserId; } if (ok) { // 更新笔记的attachs num UpdateNoteAttachNum(attachInfo.NoteId, 1); } if (!fromApi) { // 增长note's usn NoteService.IncrNoteUsn(attachInfo.NoteId, attachInfo.UserId); } msg = ""; return(true); }
public async Task <AttachInfo> GetAttachAsync(long?attachId, long?userId) { var attach = dataContext.AttachInfo.Where(b => b.AttachId == attachId && b.UserId == userId); AttachInfo attachInfo = await attach.FirstOrDefaultAsync(); return(attachInfo); }
public AttachInfo Attach_Get(int AttachID, int ContentId, int UserId, bool WithSecurity) { AttachInfo ai = null; using (IDataReader dr = SqlHelper.ExecuteReader(connectionString, dbPrefix + "Attachments_Get", AttachID, ContentId, UserId, WithSecurity)) { while (dr.Read()) { ai = FillInfo(dr); } dr.Close(); } return(ai); }
public bool handleAttach(Attachable other, Slot thisSlot, Slot otherSlot) { if (attachedTable.Contains(other)) { return(false); } AttachInfo info = new AttachInfo(); info.offsetRotation = this.transform.rotation * Quaternion.Inverse(thisSlot.transform.rotation) * Quaternion.Inverse(otherSlot.transform.rotation) * /*Quaternion.Inverse*/ (other.transform.rotation); info.offsetPosition = 2 * (this.transform.position - thisSlot.transform.position); /*- Quaternion.Inverse(Quaternion.Inverse(thisSlot.transform.rotation) * /*Quaternion.Inverse*//*(otherSlot.transform.rotation)) * (otherSlot.transform.position - other.transform.position);*/ this.attachedTable.Add(other, info); return(true); }
// Token: 0x060002D8 RID: 728 RVA: 0x0000AE88 File Offset: 0x00009088 private void EditorFile() { HttpPostedFile httpPostedFile = FPRequest.Files["imgfile"]; if (httpPostedFile == null) { this.ShowErrMsg("请选择要上传文件!"); } else { UpLoad upLoad = new UpLoad(); string json = upLoad.FileSaveAs(httpPostedFile, this.dir, this.user); JsonData jsonData = JsonMapper.ToObject(json); string text = jsonData["error"].ToString(); if (text != "") { this.ShowErrMsg(text); } else { AttachInfo attachInfo = new AttachInfo(); attachInfo.uid = this.userid; attachInfo.sortid = this.sortid; attachInfo.filename = jsonData["filename"].ToString(); attachInfo.filesize = (long)FPUtils.StrToInt(jsonData["filesize"].ToString(), 0); attachInfo.originalname = jsonData["originalname"].ToString(); attachInfo.postdatetime = DbUtils.GetDateTime(); attachInfo.filetype = this.dir; if (DbHelper.ExecuteInsert <AttachInfo>(attachInfo) == 0) { this.ShowErrMsg("数据库更新失败。"); } else { Hashtable hashtable = new Hashtable(); hashtable["error"] = 0; hashtable["url"] = attachInfo.filename; hashtable["title"] = attachInfo.originalname; base.Response.AddHeader("Content-Type", "text/html; charset=UTF-8"); base.Response.Write(JsonMapper.ToJson(hashtable)); base.Response.End(); } } } }
//add attach //api 调用时,添加attach之前时没有note的 //fromApi表示是api添加的, updateNote传过来的, 此时不要incNote's usn, 因为updateNote会inc的 public static bool AddAttach(AttachInfo attachInfo, bool fromApi, out string msg) { attachInfo.CreatedTime = DateTime.Now; int a = 0; using (var db = new DataContext()) { db.AttachInfo.Add(attachInfo); var result = db.SaveChanges() > 0; // api调用时, 添加attach之前是没有note的 if (result) { UpdateNoteAttachNum(attachInfo.NoteId, 1); } if (!fromApi) { NoteService.IncrNoteUsn(attachInfo.NoteId, attachInfo.UserId); } msg = ""; return(true); } }
public static void UpdateClientAttaches(IBackgroundContext context, LpuExecParams args) { if (context.CancellationPending) return; context.ProgressSeparator(); context.ReportProgress(@"ОБНОВЛЕНИЕ СВЕДЕНИЙ О ПРИКРЕПЛЕНИИ ЗАСТРАХОВАННЫХ ЛИЦ К ЛПУ"); context.ReportProgress(""); using (var dataContext = new AttacherDataContext(context)) { var dupMiac = (from org in dataContext.VistaMed.Organisations where !string.IsNullOrEmpty(org.MiacCode) group org by org.MiacCode into g select g).Where(x => x.Count() > 1); if (dupMiac.Any()) { foreach (var dupGroup in dupMiac) { context.ReportError(@"В справочнике организаций найдено {0} записей с кодом МИАЦ = {1}", dupGroup.Count(), dupGroup.Key); } context.ReportProgress(@"Пожалуйста устраните указанные ошибки"); } else { dataContext.Load(context, Properties.Settings.Default.DataDir); // словарь организаций по коду МИАЦ var lpuDict = (from lpu in dataContext.VistaMed.Organisations where !lpu.Deleted && !string.IsNullOrEmpty(lpu.MiacCode) select lpu).ToDictionary(x => x.MiacCode); var idOrgDict = (from lpu in dataContext.VistaMed.Organisations where !lpu.Deleted select lpu).ToDictionary(x => x.Id); var errorMiacCodes = new HashSet<string>(); var updateStatements = new List<string>(); var insertStatements = new List<string>(); foreach (var smoData in dataContext.SmoPacients) { context.ReportProgress(@"Обрабатываем СМО {0} - {1} застрахованных лиц ...", smoData.Key, smoData.Value.Count); int smoClientIndex = 0; foreach (var smoPacient in smoData.Value.Where(x => !string.IsNullOrEmpty(x.MCOD))) { if (context.CancellationPending) break; if (lpuDict.ContainsKey(smoPacient.MCOD)) { // выбираем ЛПУ по колу МИАЦ var lpu = lpuDict[smoPacient.MCOD]; // по ДР var clients = dataContext.VistaMed.Clients.Where(x => x.BirthDate == smoPacient.DR).ToList(); // клиенты по фио clients = clients.Where( x => x.LastName.ToUpper() == smoPacient.FAM.ToUpper() && x.FirstName.ToUpper() == smoPacient.IM.ToUpper() && x.PatrName.ToUpper() == smoPacient.OT.ToUpper()) .ToList(); // по ключу clients = clients.Where(x => x.GetKey(dataContext.VistaMed) == smoPacient.Key).ToList(); foreach (var client in clients) { var attachInfo = new AttachInfo(smoPacient, dataContext.VistaMed, lpu); // крайняя по дате запись о прикреплении var attachRec = client.ClientAttaches.OrderByDescending(x => x.BegDate).FirstOrDefault(); // создаем новую запись о прикреплении когда var shouldCreateNew = attachRec == null /* битый ID организации ЛПУ */ || !idOrgDict.ContainsKey(attachRec.LPUId) /* не то ЛПУ и код миац не пустой (при пустом коде миац корректируем последнюю запись о привязке) */ || ((attachInfo.Lpu.Id != attachRec.LPUId) && !string.IsNullOrEmpty(idOrgDict[attachRec.LPUId].MiacCode)); if (shouldCreateNew) attachInfo.CreateAttachRecord(client, insertStatements); else attachInfo.UpdateAttachRecord(attachRec, updateStatements); } } else { if (!errorMiacCodes.Contains(smoPacient.MCOD)) { context.ReportError( @"Код МИАЦ {0} для ЛПУ не найден в справочнике организаций Виста-Мед. Привязка к этому ЛПУ не проводится", smoPacient.MCOD); errorMiacCodes.Add(smoPacient.MCOD); } } smoClientIndex++; if(smoClientIndex%50000 == 0) context.ReportProgress(@"Обработано {0} записей", smoClientIndex); } if (context.CancellationPending) break; else { context.ReportProgress("Записываем изменения в БД ..."); execInsertStatements(insertStatements, dataContext, context); execUpdateStatements(updateStatements, dataContext, context); insertStatements.Clear(); updateStatements.Clear(); } context.ProgressSeparator(); } } } context.ProgressSeparator('-'); }
// todo :上传附件 public bool uploadAttach(string name, long userId, long noteId, out string msg, out long serverFileId) { msg = ""; serverFileId = 0; var uploadDirPath = $"{RuntimeEnvironment.DirectorySeparatorChar}www/attachs/{userId.ToString("x")}/images/{DateTime.Now.ToString("yyyy_MM")}/"; if (RuntimeEnvironment.IsWindows) { uploadDirPath = $@"upload\{userId.ToString("x")}\attachs\{DateTime.Now.ToString("yyyy_MM")}\"; } var diskFileId = SnowFlake_Net.GenerateSnowFlakeID(); serverFileId = diskFileId; var httpFiles = _accessor.HttpContext.Request.Form.Files; //检查是否登录 if (userId == 0) { userId = GetUserIdBySession(); if (userId == 0) { msg = "NoLogin"; return(false); } } if (httpFiles == null || httpFiles.Count < 1) { return(false); } var httpFile = httpFiles[name]; var fileEXT = Path.GetExtension(httpFile.FileName).Replace(".", ""); if (!IsAllowAttachExt(fileEXT)) { msg = $"The_Attach_extension_{fileEXT}_is_blocked"; return(false); } var fileName = diskFileId.ToString("x") + "." + fileEXT; //判断合法性 if (httpFiles == null || httpFile.Length < 0) { return(false); } //将文件保存在磁盘 Task <bool> task = SaveUploadFileOnDiskAsync(httpFile, uploadDirPath, fileName); bool result = task.Result; if (result) { //将结果保存在数据库 AttachInfo attachInfo = new AttachInfo() { AttachId = diskFileId, UserId = userId, NoteId = noteId, UploadUserId = userId, Name = fileName, Title = httpFile.FileName, Size = httpFile.Length, Path = uploadDirPath + fileName, Type = fileEXT.ToLower(), CreatedTime = DateTime.Now //todo: 增加特性=图片管理 }; var AddResult = AttachService.AddAttach(attachInfo, true, out string AttachMsg); if (!AddResult) { msg = "添加数据库失败"; } return(AddResult); } else { msg = "磁盘保存失败"; return(false); } }
public async Task <IActionResult> UploadAttach(string noteId) { // var xxx= _accessor.HttpContext.Request.Form["noteId"]; var id = noteId.ToLongByHex(); long?fileId = idGenerator.NextId(); var resultMsg = "error"; // 错误信息 var userId = GetUserIdBySession(); var Ok = false; var re = new ResponseMessage() { Id = fileId.ToHex24(), Msg = resultMsg, Ok = Ok, }; if (id == null) { re.Msg = "noteId is null"; return(Json(re, MyJsonConvert.GetLeanoteOptions())); } //todo: 判断是否有权限为笔记添加附件 var note = noteService.GetNoteById(id); if (note == null || note.UserId != userId) { return(Json(re, MyJsonConvert.GetLeanoteOptions())); } var httpFiles = _accessor.HttpContext.Request.Form.Files; if (httpFiles == null || httpFiles.Count < 1) { return(Json(re, MyJsonConvert.GetLeanoteOptions())); } var httpFile = httpFiles["file"]; var uploadAttachMaxSizeByte = config.FileStoreConfig.UploadAttachMaxSizeMB * 1024 * 1024; if (httpFile.Length > uploadAttachMaxSizeByte) { resultMsg = $"The file's size is bigger than {config.FileStoreConfig.UploadAttachMaxSizeMB}M"; re.Msg = resultMsg; return(Json(re, MyJsonConvert.GetLeanoteOptions())); } //上传到对象储存 var fileName = httpFile.FileName; var nowTime = DateTime.Now; var ext = Path.GetExtension(fileName); var provider = new FileExtensionContentTypeProvider(); var memi = provider.Mappings[ext]; var filesize = httpFile.Length; var safeFileName = fileId.ToHex() + ext; var objectName = $"{userId.ToHex()}/attachments/{ nowTime.ToString("yyyy")}/{nowTime.ToString("MM")}/{safeFileName}"; bool result = await noteFileService.SaveFile(objectName, httpFile, memi); if (!result) { return(Json(re, MyJsonConvert.GetLeanoteOptions())); } var fileInfo = new AttachInfo() { AttachId = fileId, UserId = userId, Name = safeFileName, Title = fileName, NoteId = id, UploadUserId = userId, Path = objectName, Type = ext, Size = filesize }; re.Item = fileInfo; var message = string.Empty; result = attachService.AddAttach(fileInfo, false, out message); if (!result) { re.Msg = message; re.Ok = false; return(Json(re, MyJsonConvert.GetLeanoteOptions())); } re.Msg = "success"; re.Ok = true; return(Json(re, MyJsonConvert.GetLeanoteOptions())); }
public int Attach_Save(AttachInfo ai) { return(Convert.ToInt32(SqlHelper.ExecuteScalar(connectionString, dbPrefix + "Attachments_Save", ai.AttachID, ai.ContentId, ai.UserID, ai.Filename, ai.FileData, ai.ContentType, ai.FileSize, ai.AllowDownload, ai.DisplayInline, ai.ParentAttachId))); }
private AttachInfo FillInfo(IDataRecord dr) { var ai = new AttachInfo { AttachID = Convert.ToInt32(dr["AttachId"]) }; try { if (dr["ContentId"] == null) { ai.ContentId = -1; } else { ai.ContentId = Convert.ToInt32(dr["ContentId"]); } } catch (Exception ex) { ai.ContentId = -1; } try { ai.PostID = Convert.ToInt32(dr["PostId"]); } catch (Exception ex) { ai.PostID = -1; } ai.UserID = Convert.ToInt32(dr["UserId"]); ai.Filename = Convert.ToString(dr["FileName"]); ai.AllowDownload = Convert.ToBoolean(dr["AllowDownload"]); ai.DisplayInline = Convert.ToBoolean(dr["DisplayInline"]); ai.ParentAttachId = Convert.ToInt32(dr["ParentAttachId"]); try { ai.FileUrl = dr["FileURL"].ToString(); } catch (Exception ex) { ai.FileUrl = null; } try { ai.CanRead = dr["CanRead"].ToString(); } catch (Exception ex) { ai.CanRead = string.Empty; } if (dr["FileData"] != DBNull.Value) { ai.FileData = (Array)(dr["FileData"]); } else { ai.FileData = null; } ai.ContentType = Convert.ToString(dr["ContentType"]); ai.FileSize = Convert.ToInt32(dr["FileSize"]); return(ai); }
private AttachInfo FillInfo(IDataRecord dr) { var ai = new AttachInfo {AttachID = Convert.ToInt32(dr["AttachId"])}; try { if (dr["ContentId"] == null) { ai.ContentId = -1; } else { ai.ContentId = Convert.ToInt32(dr["ContentId"]); } } catch (Exception ex) { ai.ContentId = -1; } try { ai.PostID = Convert.ToInt32(dr["PostId"]); } catch (Exception ex) { ai.PostID = -1; } ai.UserID = Convert.ToInt32(dr["UserId"]); ai.Filename = Convert.ToString(dr["FileName"]); ai.AllowDownload = Convert.ToBoolean(dr["AllowDownload"]); ai.DisplayInline = Convert.ToBoolean(dr["DisplayInline"]); ai.ParentAttachId = Convert.ToInt32(dr["ParentAttachId"]); try { ai.FileUrl = dr["FileURL"].ToString(); } catch (Exception ex) { ai.FileUrl = null; } try { ai.CanRead = dr["CanRead"].ToString(); } catch (Exception ex) { ai.CanRead = string.Empty; } if (dr["FileData"] != DBNull.Value) { ai.FileData = (Array)(dr["FileData"]); } else { ai.FileData = null; } ai.ContentType = Convert.ToString(dr["ContentType"]); ai.FileSize = Convert.ToInt32(dr["FileSize"]); return ai; }
public int Attach_Save(AttachInfo ai) { return Convert.ToInt32(SqlHelper.ExecuteScalar(connectionString, dbPrefix + "Attachments_Save", ai.AttachID, ai.ContentId, ai.UserID, ai.Filename, ai.FileData, ai.ContentType, ai.FileSize, ai.AllowDownload, ai.DisplayInline, ai.ParentAttachId)); }
//插入AttachInfo private bool InsertAttach(AttachInfo attachInfo) { dataContext.AttachInfo.Add(attachInfo); return(dataContext.SaveChanges() > 0); }
protected bool UploadAttach(string name, long?userId, long?noteId, out string msg, out long?serverFileId) { msg = ""; serverFileId = 0; FileStoreConfig config = configFileService.WebConfig.FileStoreConfig; var diskFileId = idGenerator.NextId(); serverFileId = diskFileId; var httpFiles = _accessor.HttpContext.Request.Form.Files; //检查是否登录 if (userId == 0) { userId = GetUserIdBySession(); if (userId == 0) { msg = "NoLogin"; return(false); } } if (httpFiles == null || httpFiles.Count < 1) { return(false); } var httpFile = httpFiles[name]; var fileEXT = Path.GetExtension(httpFile.FileName).Replace(".", ""); if (!IsAllowAttachExt(fileEXT)) { msg = $"The_Attach_extension_{fileEXT}_is_blocked"; return(false); } var fileName = diskFileId.ToHex() + "." + fileEXT; //判断合法性 if (httpFiles == null || httpFile.Length < 0) { return(false); } //将文件保存在磁盘 // Task<bool> task = noteFileService.SaveUploadFileOnUPYunAsync(upyun, httpFile, uploadDirPath, fileName); //Task<bool> task = noteFileService.SaveUploadFileOnDiskAsync(httpFile, uploadDirPath, fileName); var ext = Path.GetExtension(fileName); var provider = new FileExtensionContentTypeProvider(); var memi = provider.Mappings[ext]; var nowTime = DateTime.Now; var objectName = $"{userId.ToHex()}/attachments/{ nowTime.ToString("yyyy")}/{nowTime.ToString("MM")}/{diskFileId.ToHex()}{ext}"; bool result = noteFileService.SaveFile(objectName, httpFile, memi).Result; if (result) { //将结果保存在数据库 AttachInfo attachInfo = new AttachInfo() { AttachId = diskFileId, UserId = userId, NoteId = noteId, UploadUserId = userId, Name = fileName, Title = httpFile.FileName, Size = httpFile.Length, Path = fileName, Type = fileEXT.ToLower(), CreatedTime = DateTime.Now //todo: 增加特性=图片管理 }; var AddResult = attachService.AddAttach(attachInfo, true, out string AttachMsg); if (!AddResult) { msg = "添加数据库失败"; } return(AddResult); } else { msg = "磁盘保存失败"; return(false); } }