protected async void CreateOrEditClick() { // 변경 내용 저장 Model.Name = ModelEdit.Name; Model.Title = ModelEdit.Title; Model.Content = ModelEdit.Content; Model.Password = ModelEdit.Password; #region 일 업로드 관련 추가 코드 영역 if (selectedFiles != null && selectedFiles.Length > 0) { // 파일 업로드 var file = selectedFiles.FirstOrDefault(); var fileName = ""; int fileSize = 0; if (file != null) { //file.Name = $"{DateTime.Now.ToString("yyyyMMddhhmmss")}{file.Name}"; fileName = file.Name; fileSize = Convert.ToInt32(file.Size); //[A] byte[] 형태 //var ms = new MemoryStream(); //await file.Data.CopyToAsync(ms); //await FileStorageManager.ReplyAsync(ms.ToArray(), file.Name, "", true); //[B] Stream 형태 //string folderPath = Path.Combine(WebHostEnvironment.WebRootPath, "files"); await FileStorageManagerReference.UploadAsync(file.Data, file.Name, "Memos", true); Model.FileName = fileName; Model.FileSize = fileSize; } } #endregion if (!int.TryParse(parentId, out int newParentId)) { newParentId = 0; } Model.ParentId = newParentId; Model.ParentKey = Model.ParentKey; if (Model.Id == 0) { // Create await RepositoryReference.AddAsync(Model); CreateCallback?.Invoke(); } else { // Edit await RepositoryReference.EditAsync(Model); await EditCallback.InvokeAsync(true); } //IsShow = false; // this.Hide() }
protected async void CreateOrEditClick() { #region 일 업로드 관련 추가 var file = selectedFiles.FirstOrDefault(); var fileName = ""; int fileSize = 0; if (file != null) { //file.Name = $"{DateTime.Now.ToString("yyyyMMddHHmmss")}{file.Name}"; fileName = file.Name; fileSize = Convert.ToInt32(file.Size); //await FileUploadServiceReference.UploadAsync(file); //[A] 바이트 형태 //var ms = new MemoryStream(); //await file.Data.CopyToAsync(ms); // 파일 데이터를 메모리스트림으로 변환 //// upload 하기전 memorystream을 byte 배열로 다시변환 //await FileStorageManager.UploadAsync(ms.ToArray(), file.Name, "", true); //[B] Stream형태 //string folderPath = Path.Combine(WebHostEnvironment.WebRootPath, "files"); await FileStorageManager.UploadAsync(file.Data, file.Name, "", true); Model.FileName = fileName; Model.FileSize = fileSize; } #endregion if (!int.TryParse(parentId, out int newParentId)) { newParentId = 0; } Model.ParentId = newParentId; //Model.ParentKey = Model.ParentKey; if (Model.Id == 0) { // Create await NoticeRepositoryAsyncReference.AddAsync(Model); CreateCallback?.Invoke(); // -> EditCallback } else { // Edit await NoticeRepositoryAsyncReference.EditAsync(Model); await EditCallback.InvokeAsync(true); } //IsShow = false; }
/// <summary> /// 创建代码块 /// </summary> protected void CreateCodeBox() { TreeData td = (TreeData)XTreeView.SelectedItem; ///如果不是最终节点则退出 if (td.IsDataNode == false) { return; } CreateCallback?.Invoke(td.Data); }
protected async void CreateOrEditClick() { #region 일 업로드 관련 추가 var file = selectedFiles.FirstOrDefault(); var fileName = ""; int fileSize = 0; if (file != null) { //file.Name = $"{DateTime.Now.ToString("yyyyMMddHHmmss")}{file.Name}"; fileName = file.Name; fileSize = Convert.ToInt32(file.Size); await FileUploadServiceReference.UploadAsync(file); Model.FileName = fileName; Model.FileSize = fileSize; } #endregion if (!int.TryParse(parentId, out int newParentId)) { newParentId = 0; } Model.ParentId = newParentId; if (Model.Id == 0) { // Create await NoticeRepositoryAsyncReference.AddAsync(Model); CreateCallback?.Invoke(); // -> EditCallback } else { // Edit await NoticeRepositoryAsyncReference.EditAsync(Model); await EditCallback.InvokeAsync(true); } //IsShow = false; }
protected async void CreateOrEditClick() { // 변경 내용 저장 ModelSender.Active = true; ModelSender.Name = ModelEdit.Name; ModelSender.CreatedBy = UserName ?? "Anonymous"; if (ModelSender.Id == 0) { // Create ModelSender.CreatedAt = DateTime.UtcNow; await RepositoryReference.AddAsync(ModelSender); CreateCallback?.Invoke(); } else { // Edit await RepositoryReference.UpdateAsync(ModelSender); await EditCallback.InvokeAsync(true); } }
protected async void CreateOrEditClick() { if (!int.TryParse(parentId, out int newParentId)) { newParentId = 0; } Model.ParentId = newParentId; if (Model.Id == 0) { // Create await UploadRepositoryAsyncReference.AddAsync(Model); CreateCallback?.Invoke(); // -> EditCallback } else { // Edit await UploadRepositoryAsyncReference.EditAsync(Model); await EditCallback.InvokeAsync(true); } //IsShow = false; }