Esempio n. 1
0
        public void CopyFile(MetadataItem mdi)
        {
            OperationHasHappend = false;
            string copyPath = $@"{mdi.SavePath}\{mdi.FileName}";

            if (File.Exists(mdi._filePath))
            {
                File.Copy(mdi._filePath, copyPath);

                if (mdi._isRemoveFileEnabled == true)
                {
                    File.Delete(mdi._filePath);
                }

                OperationHasHappend = true;
            }
        }
        public List <MetadataItem> GetDocumentList()
        {
            List <MetadataItem> returnList = new List <MetadataItem>();

            foreach (var yearDirectory in Directory.GetDirectories(_documentPath))
            {
                foreach (var file in Directory.GetFiles(yearDirectory))
                {
                    if (file.EndsWith("_Metadata.xml"))
                    {
                        try
                        {
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(file);

                            Guid dokumentenGuid = Guid.Parse(xmlDocument.DocumentElement.GetAttribute("DokumentenGuid"));

                            string benutzer = xmlDocument.DocumentElement.GetAttribute("Benutzer");

                            string bezeichnung = xmlDocument.DocumentElement.GetAttribute("Bezeichnung");

                            DateTime erfassungsdatum = DateTime.Parse(xmlDocument.DocumentElement.GetAttribute("Erfassungsdatum"));

                            string selectedTypItem = xmlDocument.DocumentElement.GetAttribute("ItemTyp");

                            string stichwoerter = xmlDocument.DocumentElement.GetAttribute("Stickwoerter");

                            DateTime valutaDatum = DateTime.Parse(xmlDocument.DocumentElement.GetAttribute("ValutaDatum"));

                            string fileName = xmlDocument.DocumentElement.GetAttribute("FileName");

                            MetadataItem item = new MetadataItem(dokumentenGuid, benutzer, bezeichnung, erfassungsdatum, selectedTypItem, stichwoerter, valutaDatum, fileName);

                            returnList.Add(item);
                        }
                        catch (Exception e)
                        {
                            returnList = new List <MetadataItem>();
                            return(returnList);
                        }
                    }
                }
            }

            return(returnList);
        }
Esempio n. 3
0
        public async Task SaveMetadata(MetadataItem metadata, Guid id)
        {
            if (id == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            var savePath = _appSettings.RepositoryPath + @"\" + metadata.Valuta.Year + @"\";

            FileHandler.PathValidity(savePath);

            savePath += id + FileSuffix + FileEnding;

            await _serializationHandler.Serialize(metadata, savePath);
        }
Esempio n. 4
0
        public void Dateihinzufuegen(MetadataItem mdI, bool loeschungAktiv)
        {
            var repoDir      = _repoService.getRepo();
            var docId        = Guid.NewGuid();
            var jahr         = mdI._datum.Year;
            var dateityp     = Path.GetExtension(mdI._pfadAlt);
            var zielDir      = Path.Combine(repoDir, jahr.ToString());
            var dateiName    = _dateiService.getDateiName(docId, dateityp);
            var mdIDateiname = _dateiService.getDateiNamenMetaFile(docId);


            var xmlSeri     = new XmlSerializer(typeof(MetadataItem));
            var streamWrite = new StreamWriter(Path.Combine(zielDir, mdIDateiname));

            xmlSeri.Serialize(streamWrite, mdI);
            streamWrite.Flush();
            streamWrite.Close();



            if (!Directory.Exists(zielDir))
            {
                System.IO.Directory.CreateDirectory(zielDir);
                File.Copy(mdI._pfadAlt, Path.Combine(zielDir, dateiName));
            }
            else
            {
                File.Copy(mdI._pfadAlt, Path.Combine(zielDir, dateiName));
            }



            if (loeschungAktiv)
            {
                var task = Task.Factory.StartNew(() =>
                {
                    Task.Delay(500);
                    File.Delete(mdI._pfadAlt);
                });
            }
        }
Esempio n. 5
0
        private string creatFileFolder(MetadataItem obj)
        {
            if (obj.ValutaDatum != null)
            {
                var valutaYear = obj.ValutaDatum.Value.Year;
                var targetPath = repositoryDir + BACKSLASH + Convert.ToString(valutaYear);

                if (dir.Exists(targetPath))
                {
                    return(targetPath);
                }
                else
                {
                    dir.CreateDirectory(targetPath);
                    return(targetPath);
                }
            }
            else
            {
                return(repositoryDir + BACKSLASH);
            }
        }
Esempio n. 6
0
        public virtual void MoveFile(MetadataItem metadataItem, String targetDir, String contentFileName, bool deleteFile)
        {
            File.Copy(metadataItem.OriginalPath, Path.Combine(targetDir, contentFileName));

            if (deleteFile)
            {
                var task = Task.Factory.StartNew(
                    () =>
                {
                    Task.Delay(500);
                    File.Delete(metadataItem.OriginalPath);
                });
                try
                {
                    Task.WaitAll(task);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
        }
        public bool AddNewDocument(string benutzer, string bezeichnung, DateTime erfassungsdatum, string filePath, string selectedTypItem, string stichwoerter, DateTime valutaDatum, bool isRemoveFileEnabled)
        {
            if (!_fileService.IsDocumentExist(filePath))
            {
                return(false);
            }

            MetadataItem item = new MetadataItem(benutzer, bezeichnung, erfassungsdatum, selectedTypItem, stichwoerter, valutaDatum, filePath.Split('\\').Last());


            if (!_fileService.MoveFileToRepository(filePath, item.ValutaDatum, item.DokumentenGuid) || !_exportService.CreateXml(item))
            {
                return(false);
            }

            _documentList.Add(item);

            if (isRemoveFileEnabled)
            {
                _fileService.RemoveFile(filePath);
            }

            return(true);
        }
Esempio n. 8
0
 public void OpenFile(SerializeTestable serializeTestable, MetadataItem metadataItem)
 {
     serializeTestable.OpenFile(metadataItem);
 }
Esempio n. 9
0
 public virtual void OpenFile(MetadataItem metadataItem)
 {
     Process.Start(metadataItem.FilePath);
 }
Esempio n. 10
0
        public virtual String SerializeMetadataItem(SerializeTestable serializeTestable, MetadataItem metadataItem)
        {
            xmlserializer = new XmlSerializer(typeof(MetadataItem));
            StringWriter stringWriter = new StringWriter();
            XmlWriter    writer       = XmlWriter.Create(stringWriter);

            xmlserializer.Serialize(writer, metadataItem);

            var serializeXml = stringWriter.ToString();

            writer.Close();

            return(serializeXml);
        }
Esempio n. 11
0
        // LOGIK VERSCHOBBEN
        //
        //public String serealisieren(MetadataItem mdI)
        //{
        //    XmlSerializer xmlseri = new XmlSerializer(typeof(MetadataItem));
        //    StringWriter stringwrite = new StringWriter();
        //    XmlWriter xmlwrite = XmlWriter.Create(stringwrite);
        //    xmlseri.Serialize(xmlwrite, mdI);
        //    var seriXml = stringwrite.ToString();
        //    xmlwrite.Close();
        //    return seriXml;

        //}

        public String serealisiereMetaData(SerialisierenTestable seriTestable, MetadataItem mdI)
        {
            var resultat = seriTestable.SerialisiereMetadataItem(seriTestable, mdI);

            return(resultat);
        }
Esempio n. 12
0
 public void oeffneDatei(MetadataItem mdI)
 {
     Process.Start(mdI._pfadAlt);
 }
Esempio n. 13
0
 public void openFile(MetadataItem metadataItem)
 {
     Process.Start(metadataItem.FilePath);
 }
Esempio n. 14
0
        public String SerializeMetadataItem(SerializeTestable serializeTestable, MetadataItem metadataItem)
        {
            var result = serializeTestable.SerializeMetadataItem(serializeTestable, metadataItem);

            return(result);
        }
Esempio n. 15
0
 public virtual void Open(MetadataItem metaDataItem)
 {
     file.Open(metaDataItem.FilePath + metaDataItem.FileGuid + contentFileControl.GetFileEnding);
 }
        public virtual String SerialisiereMetadataItem(SerialisierenTestable seriTestable, MetadataItem mdI)
        {
            XmlSerializer xmlseri      = new XmlSerializer(typeof(MetadataItem));
            StringWriter  stringwriter = new StringWriter();
            XmlWriter     writer       = XmlWriter.Create(stringwriter);

            xmlseri.Serialize(writer, mdI);

            var seriXml = stringwriter.ToString();

            writer.Close();

            return(seriXml);
        }
 public virtual void OpenFile(MetadataItem mdI)
 {
     Process.Start(mdI._pfadNeu);
 }