/// <summary> /// Sends a file to a queue of choise, the queue will be created if it does not yet exists. /// </summary> /// <param name="transaction">The transaction (string format)</param> /// <param name="queueName">The name of the queue</param> protected void SendToQueue(TransactionItem transaction, string queueName) { queueName = queueName.ToLower().Replace("service", ""); FxLog.Debug(GetType(), "Sending To Queue: {0}", queueName); // Create the transacted MSMQ queue if necessary. var queuePath = @".\private$\" + queueName; if (!MessageQueue.Exists(queuePath)) { FxLog.Debug(GetType(), "{0} does not yet exist", queuePath); var queue = MessageQueue.Create(queuePath, true); queue.Authenticate = false; queue.SetPermissions("EveryOne", MessageQueueAccessRights.FullControl); FxLog.Debug(GetType(), "{0} Created", queuePath); } // Create proxy for the MSMQ if necessary. if (!QueueProxyCollection.ContainsKey(queueName)) { var proxy = CreateProxyForQueue(queueName); QueueProxyCollection.Add(queueName, proxy); } //Get proxy to for MSMQ var msmqProxy = QueueProxyCollection[queueName]; msmqProxy.SendTransactionMessage(transaction); }
/// <summary> /// Handles the file in case of a zip File /// </summary> /// <param name="file">The File</param> /// <param name="fileName">Name of the zip file.</param> /// <returns>Returns true if the code should continue, false when the processing stops here</returns> protected virtual bool HandleZipFile(byte[] file, string fileName) { try { var stream = new MemoryStream(file); ZipHelper.Decompress(stream, fileName, TransactionConfigurationHelper.TemporaryPath); var files = Directory.GetFiles(TransactionConfigurationHelper.TemporaryPath); foreach (var tempFile in files) { File.Move(tempFile, Path.Combine(TransactionConfigurationHelper.InboxPath, new FileInfo(tempFile).Name)); } } catch (Exception ex) { FxLog.Debug(GetType(), ex.GetCombinedMessages()); throw; } return(false); }