Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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"));
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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();
                }
            }
        }
Exemplo n.º 6
0
        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());
            }
        }
Exemplo n.º 9
0
        public PlaylistViewModel(FileDAO fileDAO, SettingDAO settingDAO)
        {
            this.fileDAO        = fileDAO;
            this.GeneralSetting = settingDAO.SettingCache.General;

            this.CreateModels();
            this.CreateCommands();
            this.RegisterMessages();
        }
Exemplo n.º 10
0
        public void Delete(int id)
        {
            FileDAO dao = new FileDAO();

            var file = dao.GetById(id);

            file.IsActive = false;
            file.Update();
        }
Exemplo n.º 11
0
        /// <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);
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
0
        /// <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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        public void publicarArquivo(Model.File oFile)
        {
            FileDAO oFileDAO = new FileDAO();

            try
            {
                oFileDAO.publicarArquivo(oFile);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 16
0
        public Model.ListFile listaArquivoCircular(Model.File oFile)
        {
            ListFile oListFile = new ListFile();
            FileDAO  oFileDAO  = new FileDAO();

            try
            {
                return(oListFile = oFileDAO.listaArquivoCircular(oFile));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 17
0
        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);
            }
        }
Exemplo n.º 18
0
        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("");
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        public int validaCircular(Model.File oFile)
        {
            int     quantidade = 0;
            FileDAO oFileDAO   = new FileDAO();

            try
            {
                quantidade = oFileDAO.validaCircular(oFile);
            }

            catch (Exception)
            {
                throw;
            }

            return(quantidade);
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
        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();
            }
        }
Exemplo n.º 25
0
        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);
        }
Exemplo n.º 26
0
 public FileDAOIntegrationTests(String key) : base(key)
 {
     dao = new FileDAO(key);
 }
Exemplo n.º 27
0
 public FileDAOIntegrationTests() : base()
 {
     dao = new FileDAO(_conStringName);
 }
Exemplo n.º 28
0
        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();
        }
Exemplo n.º 29
0
 public static int DeleteFile(int fid)
 {
     return(FileDAO.DeleteFile(fid));
 }
Exemplo n.º 30
0
 public static FileDTO GetFileByUniqueName(string uniqueName)
 {
     return(FileDAO.GetFileByUniqueName(uniqueName));
 }