static async Task Main(string[] args)
        {
            string content = string.Empty;

            DMS dms = new DMS();

            int[] docIds = new int[] { 1, 2, 3, 4, 5, 6, 7 };

            DMSDocumentBST dmsDocumentBST = dms.GetDMSDocumentBST(docIds);

            int key = 0;

            while (true)
            {
                Console.WriteLine("Please enter a document Id");

                key = Convert.ToInt32(Console.ReadLine());

                Console.Write("Search path: ");
                DMSDocument doc = (DMSDocument)dmsDocumentBST.FindDoc(key);
                Console.Write(key);

                Console.WriteLine();
                Console.WriteLine();

                if (doc != null)
                {
                    Console.WriteLine($"Document - {doc.Id} - has been found");
                    Console.WriteLine("Downloading document content...");

                    content = await doc.DownloadContent();

                    Console.Clear();

                    Console.WriteLine(doc.GetSerializedDocumentMetadata(DocumentMetaDataFormat.CSV));

                    Console.WriteLine();
                    Console.WriteLine();

                    Console.WriteLine(content);

                    Console.WriteLine();
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine($"Document, {key}, could not be found.");
                }
                if (!SearchDocsAgain())
                {
                    break;
                }

                Console.Clear();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a DMS-Document to the DFDoc
 /// </summary>
 /// <param name="dmsDocument"></param>
 /// <param name="content"></param>
 public void AddDmsDocument(DMSDocument dmsDocument, byte[] content)
 {
     if (dmsDocument == null)
     {
         throw new ArgumentNullException(nameof(dmsDocument));
     }
     if (content == null)
     {
         throw new ArgumentNullException(nameof(content));
     }
     _metadata.Documents.AddDMSDokument(dmsDocument);
     _files.Add(content);
 }
Ejemplo n.º 3
0
        private DFDoc CreateDoc()
        {
            var content      = CreateRandomFileContent();
            var progInfo     = new ProgramSystemInfo("DFDocTest", "0.0.0.1");
            var dfDoc        = DFDoc.CreateNew(progInfo);
            var creationDate = DateTime.UtcNow;
            var creator      = new CreatorInfo("DATAflor", creationDate, "ADR005648");
            var dmsInfo      = new DMSDocumentInfo("Testdokument", "Mustermann, Max", "Auftrag", "sonstiges", null, new ReferenceType(XRefType.Adresse, "OWNERDATA_ADR"));

            dmsInfo.AddAnotherReference(new ReferenceType(XRefType.Mitarbeiter, creator.MitarbeiterId));
            var dmsDoc = new DMSDocument("Test.data", creator, dmsInfo);

            dfDoc.AddDmsDocument(dmsDoc, content);
            return(dfDoc);
        }
Ejemplo n.º 4
0
        public void DocWithTwoFilesWithSameNameNotAllowedTest()
        {
            var dfDoc = CreateDoc();

            // create second document
            var content      = CreateRandomFileContent();
            var creationDate = DateTime.UtcNow;
            var creator      = new CreatorInfo("DATAflor", creationDate, "ADR005648");
            var dmsInfo      = new DMSDocumentInfo("Testdokument", "Mustermann, Max", "Auftrag", "sonstiges", null, new ReferenceType(XRefType.Adresse, "OWNERDATA_ADR"));

            dmsInfo.AddAnotherReference(new ReferenceType(XRefType.Mitarbeiter, creator.MitarbeiterId));
            var dmsDoc = new DMSDocument("Test.data", creator, dmsInfo); // There is already an item with the name Test.data

            Assert.Throws <InvalidFileformatException>(() => dfDoc.AddDmsDocument(dmsDoc, content));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds a DMS-Document to the DFDoc
        /// </summary>
        /// <param name="dmsDocument"></param>
        /// <param name="content"></param>
        public void AddDmsDocument(DMSDocument dmsDocument, Stream content)
        {
            if (dmsDocument == null)
            {
                throw new ArgumentNullException(nameof(dmsDocument));
            }
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }
            if (content.Length > int.MaxValue)
            {
                throw new ArgumentOutOfRangeException($"contentsize to large. Only {int.MaxValue} bytes are supported.");
            }
            _metadata.Documents.AddDMSDokument(dmsDocument);
            var data = new byte[content.Length];

            content.Read(data, 0, (int)content.Length);
            _files.Add(data);
        }
        protected AbstractDMSListener(ILogWriter writerParam, IDMSHandler handler)
        {
            this.Handler = handler;
            this.Writer  = writerParam ?? new ConsoleLogWriter()
            {
            };
            this.trWorker = new Thread(() =>
            {
                while (running)
                {
                    SessionDesc nextSessionDesc = sessions.RetrieveNextUnworkedSession();
                    if (nextSessionDesc != null)
                    {
                        IDictionary <string, dynamic> input_payload = nextSessionDesc.Payload;
                        IDictionary <string, object> ret            = nextSessionDesc.ReturnMap;
                        IDictionary <string, object> payload        = new Dictionary <string, object>();
                        ret[KEY_PAYLOAD] = payload;
                        try
                        {
                            switch (nextSessionDesc.Command)
                            {
                            case "insert":
                                {
                                    string filepath  = input_payload[KEY_FILEPATH];
                                    string originKey = input_payload[KEY_ORIGINKEY];
                                    IDictionary <String, String> metadata = ReadMetadata(input_payload);

                                    Writer.WriteMessage(String.Format("inserting; file '{0}', originkey: '{1}'", filepath, originKey));
                                    DMSDocument selDocument = Handler.InsertDocument(originKey, filepath, metadata);
                                    if (selDocument != null)
                                    {
                                        Writer.WriteMessage(String.Format("returned document '{0}'", selDocument));
                                        payload[KEY_DMSID]        = selDocument.Id;
                                        payload[KEY_DOCUMENTNAME] = selDocument.Name;
                                        payload[KEY_ORIGINKEY]    = originKey;
                                        ret[KEY_STATUS]           = KEY_STATUS_OK;
                                    }
                                    else
                                    {
                                        ret[KEY_STATUS] = KEY_STATUS_CANCEL;
                                    }
                                    nextSessionDesc.Status = SessionDesc.SessionStatus.DONE;
                                }
                                break;

                            case "attach":
                                {
                                    string originKey = input_payload[KEY_ORIGINKEY];
                                    IDictionary <String, String> metadata = ReadMetadata(input_payload);

                                    Writer.WriteMessage(String.Format("attaching; originkey: '{0}'", originKey));
                                    DMSDocument selDocument = Handler.AttachDocument(originKey, metadata);
                                    if (selDocument != null)
                                    {
                                        Writer.WriteMessage(String.Format("returned document '{0}'", selDocument));
                                        payload[KEY_DMSID]        = selDocument.Id;
                                        payload[KEY_DOCUMENTNAME] = selDocument.Name;
                                        payload[KEY_ORIGINKEY]    = originKey;
                                        ret[KEY_STATUS]           = KEY_STATUS_OK;
                                    }
                                    else
                                    {
                                        ret[KEY_STATUS] = KEY_STATUS_CANCEL;
                                    }
                                    nextSessionDesc.Status = SessionDesc.SessionStatus.DONE;
                                }
                                break;

                            case "show":
                                {
                                    string idOfFileInDMS_show  = input_payload[KEY_DMSID];
                                    string nameOfDMSDocument   = input_payload[KEY_DOCUMENTNAME];
                                    string originKey           = input_payload[KEY_ORIGINKEY];
                                    DMSDocument documentToShow = new DMSDocument(idOfFileInDMS_show, nameOfDMSDocument);
                                    Writer.WriteMessage(String.Format("show document '{0}'", documentToShow));
                                    Handler.ShowDocument(documentToShow);
                                    ret[KEY_STATUS]        = KEY_STATUS_OK;
                                    nextSessionDesc.Status = SessionDesc.SessionStatus.DONE;
                                }
                                break;

                            default:
                                {
                                }
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            LOG.Error("processing error on session " + nextSessionDesc.Key + ": " + ex.Message, ex);
                            Writer.WriteMessage("processing error on session " + nextSessionDesc.Key + ": " + ex.Message);
                            ret[KEY_STATUS]    = "FAIL";
                            ret[KEY_ERRORTEXT] = ex.Message;
                        }
                    }
                }
            }
                                       )
            {
                IsBackground = true
            };
            trWorker.Start();
        }