Exemplo n.º 1
0
        private static void SendMessageToQueue(string quepath, DocuwareMigrationDataPointer dataPointer)
        {
            //Initisalize the Message Queue
            DefaultPropertiesToSend dpts = new DefaultPropertiesToSend();

            dpts.Label           = "Docuware 5.1b, Data Queued for Import into OpenKM Community 6.3.1";
            dpts.Recoverable     = true;
            dpts.UseJournalQueue = true;
            dpts.AttachSenderId  = true;
            MessageQueue msgq = null;

            if (!MessageQueue.Exists(quepath))
            {
                msgq = MessageQueue.Create(quepath);
                msgq.SetPermissions("Everyone", MessageQueueAccessRights.FullControl);
            }
            MessageQueue pQueue = new MessageQueue(quepath);
            //pQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(DocuwareMigrationDataPointer) });
            BinaryMessageFormatter formatter = new BinaryMessageFormatter();

            System.Messaging.Message message = new System.Messaging.Message(dataPointer, formatter);
            message.Recoverable            = true;
            pQueue.DefaultPropertiesToSend = dpts;

            //Send the message
            pQueue.Send(message);

            //REMOVE LATER
            //Receiving Message
            //Message Mymessage = pQueue.Receive();
            //Mymessage.Formatter = new BinaryMessageFormatter();
            //DocuwareMigrationDataPointer docuwareMigrationDataPointerReceiver = (DocuwareMigrationDataPointer) Mymessage.Body;
        }
Exemplo n.º 2
0
        private static void ProcessNonExistingFile(string path, Dictionary <string, string> metadata, string transformedPath)
        {
            //Queue the processing information required for each file that will be later uploaded to OpenKM

            DocuwareMigrationDataPointer docuwareMigrationDataPointer = new DocuwareMigrationDataPointer();

            docuwareMigrationDataPointer.Path            = path;
            docuwareMigrationDataPointer.Metadata        = metadata;
            docuwareMigrationDataPointer.TransformedPath = transformedPath;

            string quepath = @".\Private$\" + Path.GetFileName(Worker._path); // Path.GetFileName may not work with a Directory name having a trailing /

            //Send the message to the Microsoft MSMQ
            SendMessageToQueue(quepath, docuwareMigrationDataPointer);

            //Mark this message as already queued for processing. DO NOT PROCESS THIS MESSAGE AGAIN.
            keyValueCache.StringSet(path, transformedPath);

            Console.WriteLine("Queueing a message with data for uploading a file from '{0}' -> '{1}'.", path, transformedPath);
        }