Blame view

Vrh.Log4Pro.MaintenanceConsole/Manager - MSMQManager.cs 2.31 KB
0cafa26d   Schwirg László   InstallManager lé...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Messaging;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace Vrh.Log4Pro.MaintenanceConsole
  {
  	class Manager___MSMQManager
  	{
  		void CreateQueue()
  		{
  			string ccs = @"localhost\private$\ljskskin";
  			string msmqservername = "";
  			bool msmqprivate = true;
  			string msmqname = "";
  			string msmqFullname = msmqservername + "\\" + (msmqprivate ? "private$\\" : msmqname);
  			if (!MessageQueue.Exists(ccs)) { MessageQueue.Create(msmqFullname); }
  		}
  		void DeleteQueue()
  		{
  			string ccs = @"localhost\private$\ljskskin";
  			if (MessageQueue.Exists(ccs)) { MessageQueue.Delete(ccs); }
  		}
  		void Purge()
  		{
  			string ccs = @"localhost\private$\ljskskin";
  			var msmq = new MessageQueue(ccs);
  			msmq.Purge();
  		}
  		void Peek() 
  		{
  			string ccs = @"localhost\private$\ljskskin";
  			var msmq = new MessageQueue(ccs);
  			
  			Message m = msmq.Peek(new TimeSpan(0));
  			m.BodyStream.Position = 0;
  			var sr = new System.IO.StreamReader(m.BodyStream);
  			var label = m.Label;
  			var body = sr.ReadToEnd().Replace(((char)0).ToString(), "");
  		}
  		void Read()
  		{
  			string ccs = @"localhost\private$\ljskskin";
  			var msmq = new MessageQueue(ccs);
  			var frmA = new System.Messaging.ActiveXMessageFormatter();
  			var frmB = new System.Messaging.BinaryMessageFormatter();
  			var frmX = new System.Messaging.XmlMessageFormatter();
  			msmq.Formatter = frmA;
  			
  			Message m = msmq.Receive(new TimeSpan(0));
  			m.BodyStream.Position = 0;
  
  			Encoding enc = System.Text.Encoding.UTF8;
  			enc = System.Text.Encoding.UTF7;
  			enc = System.Text.Encoding.UTF32;
  			enc = System.Text.Encoding.Unicode;
  			enc = System.Text.Encoding.BigEndianUnicode;
  			enc = System.Text.Encoding.ASCII;
  			enc = System.Text.Encoding.Default;
  			var sr = new System.IO.StreamReader(m.BodyStream, enc);
  			var label = m.Label;
  			var body = sr.ReadToEnd().Replace(((char)0).ToString(), "");
  		}
  		void Send()
  		{
  			string ccs = @"localhost\private$\ljskskin";
  
  			var frmA = new System.Messaging.ActiveXMessageFormatter();
  			var msmq = new MessageQueue(ccs);
  			msmq.Formatter = frmA;
  			
  			string messagetosend = "";
  			string messagelabel = "";
  
  			Encoding enc = System.Text.Encoding.UTF8;
  			byte[] encodedmessage = enc.GetBytes(messagetosend);
  
  			msmq.Send(encodedmessage, messagelabel);
  		}
  	}
  }