/// <summary> /// 获取指定议程的附件信息 /// </summary> /// <param name="agendaID"></param> /// <param name="documents"></param> /// <returns></returns> public Status getAll(int agendaID, out List <Document> documents) { documents = new List <Document>(); Dictionary <string, object> wherelist = new Dictionary <string, object>(); FileDAO fileDao = Factory.getInstance <FileDAO>(); wherelist.Add("agendaID", agendaID); List <FileVO> fileVolist = fileDao.getAll <FileVO>(wherelist); if (fileVolist == null) { return(Status.NONFOUND); } foreach (FileVO fileVo in fileVolist) { documents.Add( new Document { documentID = fileVo.fileID, documentName = fileVo.fileName, documentSize = fileVo.fileSize + "KB", documentPath = fileVo.filePath, agendaID = fileVo.agendaID }); } return(Status.SUCCESS); }
public async Task <bool> Create(File File) { try { FileDAO FileDAO = new FileDAO(); FileDAO.Id = File.Id; FileDAO.Name = File.Name; FileDAO.Url = File.Url; FileDAO.AppUserId = File.AppUserId; //FileDAO.GroupId = File.GroupId; FileDAO.CreatedAt = StaticParams.DateTimeNow; FileDAO.UpdatedAt = StaticParams.DateTimeNow; DataContext.File.Add(FileDAO); await DataContext.SaveChangesAsync(); File.Id = FileDAO.Id; await SaveReference(File); return(true); } catch (Exception e) { return(true); } }
public ActionResult saveFile() { if (Request.Files["file"] != null) { var uniqueName = ""; FileDTO f = new FileDTO(); var file = Request.Files["file"]; if (file.FileName != "") { var ext = System.IO.Path.GetExtension(file.FileName); f.fileExt = ext; f.fileSizeInKb = file.ContentLength / 1000; f.uploadedOn = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); f.IsActive = true; f.parentFolderId = Convert.ToInt32(Session["pid"]); uniqueName = Guid.NewGuid().ToString() + ext; f.fileName = uniqueName; var rootPath = Server.MapPath("~/UploadedFiles"); var fileSavePath = System.IO.Path.Combine(rootPath, uniqueName); file.SaveAs(fileSavePath); // Session["image"] = uniqueName; } FileDAO.Save(f); } return(Redirect("~/Users/Folder")); }
public Object DownloadFile(int id) { var rootPath = HttpContext.Current.Server.MapPath("~/UploadedFiles"); var dao = new FileDAO(); var file = dao.GetById(id); if (file != null) { HttpResponseMessage resp = new HttpResponseMessage(HttpStatusCode.OK); var fileFullPath = Path.Combine(rootPath, file.Name + file.FileExt); byte[] fileStream = System.IO.File.ReadAllBytes(fileFullPath); System.IO.MemoryStream ms = new MemoryStream(fileStream); resp.Content = new ByteArrayContent(fileStream); resp.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); var type = MimeTypeMap.GetMimeType(file.FileExt); resp.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(type); resp.Content.Headers.ContentDisposition.FileName = file.Name.Substring(file.Name.IndexOf('-') + 1) + file.FileExt; return(resp); } else { HttpResponseMessage resp = new HttpResponseMessage(HttpStatusCode.NotFound); return(resp); } }
private void btnSave_Click(object sender, System.EventArgs e) { string error = Validation(); if (!string.IsNullOrEmpty(error)) { MessageBox.Show(error, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DialogResult r = MessageBox.Show("Do you want to save?", "Confirmation", MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { string fileName = DateTime.Now.Ticks.ToString() + "_" + openFileDialog.SafeFileName; tblPetDiary diary = new tblPetDiary { adopter = adopter.username, petId = (int)cboPetName.SelectedValue, diaryDetail = txtPetDiaryDetail.Text.Trim(), diaryImages = fileName, createDate = DateTime.Now, isRead = false }; bool result = TblPetDiaryDAO.Instance.CreatePetDiary(diary); if (result) { FileDAO.CopyImage(openFileDialog.FileName, fileName); MessageBox.Show("Saved successfully!", "Notification"); RefreshScreen(); } } }
public void DeleteFileWithVersionsTest(int fileID) { // FileDAO.DeleteFileWithVersions(DemoData.SampleFile.ID); var file = FileDAO.GetFile(DemoData.SampleFile.ID); Assert.IsNull(file, "Удаление прошло корректно"); }
private void DownloadDicom(FileListItem selectedFile, DataListItem dataListItem, string selectedDicomPackageLocalPath, 云数据类型Enum 云数据类型Enum) { DownloadFileWorker.Download( selectedFile, selectedDicomPackageLocalPath, delegate(string filename) { UIUtil.Invoke(this, delegate { try { //string tempPath = selectedDicomPackageLocalPath.Substring(0, selectedDicomPackageLocalPath.LastIndexOf(Path.DirectorySeparatorChar)); //System.Diagnostics.Process.Start(tempPath); //ResumeGUI(); while (!File.Exists(selectedDicomPackageLocalPath)) { } string destFileRAR = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(selectedDicomPackageLocalPath), System.IO.Path.GetFileNameWithoutExtension(selectedDicomPackageLocalPath) + ".zip"); File.Copy(selectedDicomPackageLocalPath, destFileRAR); File.Delete(selectedDicomPackageLocalPath); selectedDicomPackageLocalPath = destFileRAR; //System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(selectedDicomPackageLocalPath)); string destFolder = AirwayPatients.BaseDicomFolder + "\\" + dataListItem.PatientName + "_" + dataListItem.StudyInstanceUID; //解压缩并用dicomviewer打开 FileDAO.upZip(selectedDicomPackageLocalPath, destFolder); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }); }, delegate(string errMsg) { UIUtil.Invoke(this, delegate { MessageBox.Show("下载发生异常!", "提示"); }); }, delegate(Exception ex) { UIUtil.Invoke(this, delegate { Util.ShowExceptionMessage(ex); }); }, delegate(ProgressArgs progressArgs) { UIUtil.Invoke(this, delegate { Console.WriteLine(progressArgs.Percentage.Value); Progress.Value = progressArgs.Percentage.Value; tbPercent.Text = ((progressArgs.Percentage.Value * 100).ToString("F2")).ToString() + " %"; txtFileSize.Text = FileDAO.HumanReadableFilesize(progressArgs.Total - progressArgs.Remains) + " / " + FileDAO.HumanReadableFilesize(_selectedFile.FileSize); tbSpeed.Text = progressArgs.Speed.HasValue ? FileDAO.HumanReadableFilesize((long)progressArgs.Speed.Value) + "/s" : ""; Console.WriteLine(progressArgs); }); }, 云数据类型Enum); }
private void GetFile(DataListItem dataItem) { MESPDownloadUpload.UserId = dataItem.UserId; MESPDownloadUpload.OrderId = MESPDownloadUpload.OrderNo = dataItem.DataID; try { ThreadPool.QueueUserWorkItem(delegate { new MESPDownloadUpload().FetchFileListAsync( _云数据类型Enum, new EventHandler <ExceptionArgs>( delegate(Object senderInner, ExceptionArgs eInner) { ///MessageBox.Show("未找到文件!"); }), new EventHandler <FileListFinishedArgs>(delegate(Object senderInner, FileListFinishedArgs eInner) { Dispatcher.BeginInvoke(new Action(delegate() { _selectedFile = eInner.Result[0]; txtFileName.Text = _dataItem.PatientName; txtFileType.Text = _云数据类型Enum == 云数据类型Enum.Dicom数据压缩包 ? "DICOM" : "处理数据"; txtFileSize.Text = "0.00 / " + FileDAO.HumanReadableFilesize(_selectedFile.FileSize); //Progress.Maximum = selectedFile.FileSize; Progress.Maximum = 1; string filename = System.IO.Path.Combine(AirwayPatients.BaseDicomFolder, _selectedFile.FileName); filename = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), System.IO.Path.GetFileNameWithoutExtension(filename) + ".temp"); string selectedDicomPackageLocalPath = ""; try { selectedDicomPackageLocalPath = new FileInfo(filename).FullName; } catch (Exception) { //filename = @"C:\AirwayVE\CT\" + items.PatientName + ".zip"; //filename = Path.Combine(AirwayPatients.BaseDicomFolder, items.PatientName + ".zip"); selectedDicomPackageLocalPath = new FileInfo(filename).FullName; } ThreadPool.QueueUserWorkItem(delegate { DownloadDicom(_selectedFile, dataItem, selectedDicomPackageLocalPath, 云数据类型Enum.Dicom数据压缩包); }); } )); })); } ); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public PlaylistViewModel(FileDAO fileDAO, SettingDAO settingDAO) { this.fileDAO = fileDAO; this.GeneralSetting = settingDAO.SettingCache.General; this.CreateModels(); this.CreateCommands(); this.RegisterMessages(); }
public void Delete(int id) { FileDAO dao = new FileDAO(); var file = dao.GetById(id); file.IsActive = false; file.Update(); }
/// <summary> /// 为议程提供服务,删除议程下所有附件 /// </summary> /// <param name="agendaID"></param> /// <returns></returns> public Status deleteAll(int agendaID) { Dictionary <string, object> wherelist = new Dictionary <string, object>(); FileDAO fileDao = Factory.getInstance <FileDAO>(); wherelist.Add("agendaID", agendaID); fileDao.delete(wherelist);//删除数据库中附件对应的记录 return(Status.SUCCESS); }
public AllVideoViewModel(FolderDAO folderDAO, FileDAO fileDAO, SettingDAO settingDAO) { this.folderDAO = folderDAO; this.fileDAO = fileDAO; this.GeneralSetting = settingDAO.SettingCache.General; this.CreateModels(); this.CreateCommands(); this.RegisterMessages(); }
/// <summary> /// 文件转换 /// </summary> public Status convertFile(int agendaID) { FileDAO fileDao = Factory.getInstance <FileDAO>(); Dictionary <string, object> wherelist = new System.Collections.Generic.Dictionary <string, object>(); wherelist.Add("agendaID", agendaID); var files = fileDao.getAll <FileVO>(wherelist); try { if (files != null) { string saveDir = GetSaveDir(); string htmlDir = GetHtmlDir(); string htmlRelativeDir = GetHtmlRelativeDir(); foreach (var file in files) { string fileName = file.filePath; string sourcePath = saveDir + fileName; string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(fileName); string targetDir = htmlDir + fileNameWithoutExtension + separator; string targetPath = targetDir + fileNameWithoutExtension + ".html"; FileInfo fi = new System.IO.FileInfo(targetPath); if (fi.Exists) { continue; } if (!Directory.Exists(targetDir)) { Directory.CreateDirectory(targetDir); } string targetRelativeDirectory = htmlRelativeDir + fileNameWithoutExtension + separator; if (!FileConvert.run(sourcePath, targetPath, targetRelativeDirectory)) { fileDao.delete(file.fileID); throw new Exception("文件转换失败"); } } } } catch (System.Exception e) { Log.LogInfo("文件转换失败", e); return(Status.FILE_CONVERT_FAIL); } return(Status.SUCCESS); }
public List <Entities.File> GetAll(int userId, int parentFolderId = -1) { FileDAO fileDAO = new FileDAO(); var files = fileDAO.GetAll(); var activeAndRootFiles = (from file in files where file.IsActive == true && file.ParenFolderId == parentFolderId && file.CreatedBy == userId select file).ToList <Entities.File>(); return(activeAndRootFiles); }
public void publicarArquivo(Model.File oFile) { FileDAO oFileDAO = new FileDAO(); try { oFileDAO.publicarArquivo(oFile); } catch (Exception) { throw; } }
public Model.ListFile listaArquivoCircular(Model.File oFile) { ListFile oListFile = new ListFile(); FileDAO oFileDAO = new FileDAO(); try { return(oListFile = oFileDAO.listaArquivoCircular(oFile)); } catch (Exception) { throw; } }
public static bool isExistLocalDicom(DataListItem dataListItem) { string folder = Path.Combine(AirwayCT.Entity.AirwayPatients.BaseDicomFolder, dataListItem.PatientName + "_" + dataListItem.StudyInstanceUID); int count = FileDAO.GetFilesCount(folder); if (count < localDicomCount) { return(false); } else { return(true); } }
public string getOriginFileName(string filePath) { Dictionary <string, object> wherelist = new Dictionary <string, object>(); FileDAO fileDao = Factory.getInstance <FileDAO>(); wherelist.Add("filePath", filePath); var fileVo = fileDao.getOne <FileVO>(wherelist); if (fileVo != null) { return(fileVo.fileName); } return(""); }
private bool exist(string fileName, int agendaID) { FileDAO fileDao = Factory.getInstance <FileDAO>(); Dictionary <string, object> wherelist = new System.Collections.Generic.Dictionary <string, object>(); wherelist.Add("fileName", fileName); wherelist.Add("agendaID", agendaID); var file = fileDao.getOne <FileVO>(wherelist); if (file == null) { return(false); } return(true); }
public Dictionary <int, int> contaArquivoByMeses(Model.File oFile) { Dictionary <int, int> mesQtd; FileDAO oFileDAO = new FileDAO(); try { mesQtd = oFileDAO.contaArquivoByMeses(oFile); } catch (Exception) { throw; } return(mesQtd); }
public int validaCircular(Model.File oFile) { int quantidade = 0; FileDAO oFileDAO = new FileDAO(); try { quantidade = oFileDAO.validaCircular(oFile); } catch (Exception) { throw; } return(quantidade); }
public async Task <bool> Update(File File) { FileDAO FileDAO = DataContext.File.Where(x => x.Id == File.Id).FirstOrDefault(); if (FileDAO == null) { return(false); } FileDAO.Id = File.Id; FileDAO.Name = File.Name; FileDAO.Url = File.Url; FileDAO.AppUserId = File.AppUserId; //FileDAO.GroupId = File.GroupId; FileDAO.UpdatedAt = StaticParams.DateTimeNow; await DataContext.SaveChangesAsync(); await SaveReference(File); return(true); }
public async Task <bool> BulkMerge(List <File> Files) { List <FileDAO> FileDAOs = new List <FileDAO>(); foreach (File File in Files) { FileDAO FileDAO = new FileDAO(); FileDAO.Id = File.Id; FileDAO.Name = File.Name; FileDAO.Url = File.Url; FileDAO.AppUserId = File.AppUserId; //FileDAO.GroupId = File.GroupId; FileDAO.CreatedAt = StaticParams.DateTimeNow; FileDAO.UpdatedAt = StaticParams.DateTimeNow; FileDAOs.Add(FileDAO); } await DataContext.BulkMergeAsync(FileDAOs); return(true); }
public void Delete(int id) { FolderDAO dao = new FolderDAO(); var folder = dao.GetById(id); folder.IsActive = false; folder.Update(); FileDAO fileDAO = new FileDAO(); var allfiles = fileDAO.GetAll(); var files = (from file in allfiles where file.ParenFolderId == id select file).ToList <Entities.File>(); foreach (var file in files) { file.IsActive = false; file.Update(); } }
private void DownloadDicom(FileListItem selectedFile, DataListItem dataListItem, string selectedDicomPackageLocalPath, 云数据类型Enum 云数据类型Enum) { DownloadFileWorker.Download( selectedFile, selectedDicomPackageLocalPath, delegate(string filename) { UIUtil.Invoke(this, delegate { try { //string tempPath = selectedDicomPackageLocalPath.Substring(0, selectedDicomPackageLocalPath.LastIndexOf(Path.DirectorySeparatorChar)); //System.Diagnostics.Process.Start(tempPath); //ResumeGUI(); lbWaiting.Visibility = Visibility.Hidden; ResumeGUI(); while (!File.Exists(selectedDicomPackageLocalPath)) { } //System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(selectedDicomPackageLocalPath)); string destFolder = AirwayPatients.BaseDicomFolder + "\\" + dataListItem.PatientName + "_" + dataListItem.StudyInstanceUID; //解压缩并用dicomviewer打开 FileDAO.upZip(selectedDicomPackageLocalPath, destFolder); ImportDicomWindow3 dicomViewer = new ImportDicomWindow3(destFolder); dicomViewer.ShowDialog(); //Thread.Sleep(1000); //openPatientsMsgWindow(selectedDicomPackageLocalPath); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }); }, delegate(string errMsg) { UIUtil.Invoke(this, delegate { MessageBox.Show(errMsg); ResumeGUI(); }); }, delegate(Exception ex) { UIUtil.Invoke(this, delegate { Util.ShowExceptionMessage(ex); //Download(selectedFile, selectedDicomPackageLocalPath, 云数据类型Enum.处理结果); ResumeGUI(); }); }, delegate(ProgressArgs progressArgs) { UIUtil.Invoke(this, delegate { lbWaiting.Content = "正在下载,请稍候。" + progressArgs.ToString(); lbDownloadProgress.Content = progressArgs.ToString(); Console.WriteLine(progressArgs); }); }, 云数据类型Enum); }
public FileDAOIntegrationTests(String key) : base(key) { dao = new FileDAO(key); }
public FileDAOIntegrationTests() : base() { dao = new FileDAO(_conStringName); }
static void Main(string[] args) { #region Biranje kolona za ucitavanje List <int> indeksKolonaInputa = new List <int>(); /* * lotArea [4] * yearBuilt [19] * Neighborhood [12] * Bldgtype [15] */ indeksKolonaInputa.Add(4); indeksKolonaInputa.Add(19); indeksKolonaInputa.Add(12); indeksKolonaInputa.Add(15); List <int> indeksKolonaOutputa = new List <int>(); // SalePrice[80] indeksKolonaOutputa.Add(80); #endregion int velicinaBlokaValidacije = 25; // Blok predstavlja velicinu bloka u cross validaciji koju uzimamo za test podatke for (int blok = 0; blok <= 75; blok += velicinaBlokaValidacije) { FileDAO fileDAO = new FileDAO(indeksKolonaInputa, indeksKolonaOutputa, blok, blok + 25); #region Kreiranje neuronske mreze NeuralNetwork network = new NeuralNetwork(); network.Add(new NeuralLayer(indeksKolonaInputa.Count, 2, "sigmoid")); network.Add(new NeuralLayer(2, 1, "sigmoid")); #endregion #region Vektori za inpute List <List <double> > X = new List <List <double> >(); X = fileDAO.X; #endregion #region Vektori za outpute List <List <double> > Y = new List <List <double> >(); Y = fileDAO.Y; #endregion #region Fitovanje Console.WriteLine("Obuka pocela."); network.fit(X, Y, 0.1, 0.9, 500); Console.WriteLine("Kraj obuke."); #endregion #region Predikcija int ukupnoPogodjenih = 0; for (int i = 0; i < fileDAO.XTest.Count; ++i) { List <Double> prediction = network.predict(fileDAO.XTest[i]); //Console.WriteLine("Pravi rezultat u test podacima je: {0}, Po proracunu i predikciji dobijam {1}", fileDAO.YTest[i][0], prediction[0]); // Podesavam koliko tolerisem da cena ide gore dole [ posto sam u domenu [0-1] normalizovao , 0.1 je 10% , 0.2 je 20 % // voditi racuna da ako stavimo 0.2 da ce on tolerisati i za gore i za dole po 20%, sto je 40 % tolerancije double tolerancija = 0.1; if (prediction[0] <= fileDAO.YTest[i][0] + tolerancija && prediction[0] >= fileDAO.YTest[i][0] - tolerancija) { ++ukupnoPogodjenih; } } Console.Write("Pogodjeno {0} od {1} ", ukupnoPogodjenih, fileDAO.YTest.Count); Console.Write("Tacnost {0} % \n\n", ukupnoPogodjenih * 100 / fileDAO.YTest.Count); #endregion } Console.ReadLine(); }
public static int DeleteFile(int fid) { return(FileDAO.DeleteFile(fid)); }
public static FileDTO GetFileByUniqueName(string uniqueName) { return(FileDAO.GetFileByUniqueName(uniqueName)); }