Ejemplo n.º 1
0
 public void Test_Poke()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Poke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, Timeout);
             Assert.AreEqual(TestData, Encoding.ASCII.GetString(server.GetData(TopicName, ItemName, 1)));
         }
     }
 }
Ejemplo n.º 2
0
 public void Test_IsPaused_Variation_2()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Pause();
             Assert.IsTrue(client.IsPaused);
         }
     }
 }
Ejemplo n.º 3
0
 public void Test_Pause_After_Pause()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Pause();
             client.Pause();
         }
     }
 }
Ejemplo n.º 4
0
 public void Test_IsConnected_Variation_3()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Disconnect();
             Assert.IsFalse(client.IsConnected);
         }
     }
 }
Ejemplo n.º 5
0
 public void Test_Handle_Variation_3()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Disconnect();
             Assert.AreEqual(IntPtr.Zero, client.Handle);
         }
     }
 }
Ejemplo n.º 6
0
 public void Test_StopAdvise_Before_StartAdvise()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.StopAdvise(ItemName, Timeout);
         }
     }
 }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            // Wait for the user to press ENTER before proceding.
            Console.WriteLine("The Server sample must be running before the client can connect.");
            Console.WriteLine("Press ENTER to continue...");
            Console.ReadLine();
            try
            {
                // Create a client that connects to 'myapp|mytopic'.
                using (DdeClient client = new DdeClient("myapp", "mytopic"))
                {
                    // Subscribe to the Disconnected event.  This event will notify the application when a conversation has been terminated.
                    client.Disconnected += OnDisconnected;

                    // Connect to the server.  It must be running or an exception will be thrown.
                    client.Connect();

                    // Synchronous Execute Operation
                    client.Execute("mycommand", 60000);

                    // Synchronous Poke Operation
                    client.Poke("myitem", DateTime.Now.ToString(), 60000);

                    // Syncronous Request Operation
                    Console.WriteLine("Request: " + client.Request("myitem", 60000));

                    // Asynchronous Execute Operation
                    client.BeginExecute("mycommand", OnExecuteComplete, client);

                    // Asynchronous Poke Operation
                    client.BeginPoke("myitem", Encoding.ASCII.GetBytes(DateTime.Now.ToString() + "\0"), 1, OnPokeComplete, client);

                    // Asynchronous Request Operation
                    client.BeginRequest("myitem", 1, OnRequestComplete, client);

                    // Advise Loop
                    client.StartAdvise("myitem", 1, true, 60000);
                    client.Advise += OnAdvise;

                    // Wait for the user to press ENTER before proceding.
                    Console.WriteLine("Press ENTER to quit...");
                    Console.ReadLine();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Press ENTER to quit...");
                Console.ReadLine();
            }
        }
 public void Test_Resume_After_Dispose()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Pause();
             client.Dispose();
             Assert.Throws<ObjectDisposedException>(() => client.Resume());
         }
     }
 }
Ejemplo n.º 9
0
 public void Test_Disconnected_Variation_3()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     using var client = new DdeClient(ServiceName, TopicName);
     var listener = new EventListener();
     client.Disconnected += listener.OnEvent;
     client.Connect();
     client.Dispose();
     Assert.IsTrue(listener.Received.WaitOne(Timeout, false));
     var args = (DdeDisconnectedEventArgs) listener.Events[0];
     Assert.IsFalse(args.IsServerInitiated);
     Assert.IsTrue(args.IsDisposed);
 }
 public void Test_StartAdvise_After_StartAdvise()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.StartAdvise(ItemName, 1, false, Timeout);
             Assert.Throws<InvalidOperationException>(() => client.StartAdvise(ItemName, 1, false, Timeout));
         }
     }
 }
Ejemplo n.º 11
0
 public void Test_Request_Overload_2()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             string data = client.Request(ItemName, Timeout);
             Assert.AreEqual(TestData, data);
         }
     }
 }
 public void Test_IsPaused_Variation_3()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Pause();
             client.Resume();
             Assert.IsFalse(client.IsPaused);
         }
     }
 }
Ejemplo n.º 13
0
 public void Test_Pause()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Pause();
             IAsyncResult ar = client.BeginExecute(CommandText, null, null);
             Assert.IsFalse(ar.AsyncWaitHandle.WaitOne(Timeout, false));
         }
     }
 }
Ejemplo n.º 14
0
 public void Test_BeginRequest_After_Dispose()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Dispose();
             IAsyncResult ar = client.BeginRequest(ItemName, 1, null, null);
         }
     }
 }
 public void Test_BeginRequest_After_Dispose()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Dispose();
             Assert.Throws<ObjectDisposedException>(() => client.BeginRequest(ItemName, 1, null, null));
         }
     }
 }
Ejemplo n.º 16
0
 public void Test_TryExecute_Variation_2()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             int result = client.TryExecute(TestData, Timeout);
             Assert.AreEqual(0, result);
             Assert.AreEqual(TestData, server.Command);
         }
     }
 }
 public void Test_TryPoke_Variation_2()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             var result = client.TryPoke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, Timeout);
             Assert.AreEqual(0, result);
             Assert.AreEqual(TestData, Encoding.ASCII.GetString(server.GetData(TopicName, ItemName, 1)));
         }
     }
 }
Ejemplo n.º 18
0
 public void Test_Request_After_Dispose()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Dispose();
             byte[] data = client.Request(ItemName, 1, Timeout);
         }
     }
 }
Ejemplo n.º 19
0
 public void Test_BeginRequest()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             IAsyncResult ar = client.BeginRequest(ItemName, 1, null, null);
             Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
         }
     }
 }
Ejemplo n.º 20
0
 public void Test_EndPoke_After_Dispose()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             IAsyncResult ar = client.BeginPoke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, null, null);
             Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
             client.Dispose();
             client.EndPoke(ar);
         }
     }
 }
Ejemplo n.º 21
0
 public void Test_Abandon_After_Dispose()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Pause();
             IAsyncResult ar = client.BeginExecute(CommandText, null, null);
             client.Dispose();
             client.Abandon(ar);
         }
     }
 }
 public void Test_EndStartAdvise()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         server.SetData(TopicName, ItemName, 1, Encoding.ASCII.GetBytes(TestData));
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             var ar = client.BeginStartAdvise(ItemName, 1, true, null, null);
             Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
             client.EndStartAdvise(ar);
         }
     }
 }
Ejemplo n.º 23
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // Connect to the server.  It must be running or an exception will be thrown.
                client.Connect();

                // Advise Loop
                client.StartAdvise("myitem", 1, true, 60000);
            }
            catch (Exception ex)
            {
                displayTextBox.Text = "MainForm_Load: " + ex.Message;
            }
        }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            var client = new DdeClient("MT4", "QUOTE");

            beat = new QuoteBeat();

            writer = new LogDataWriter("EURUSD");

            client.Advise += client_Advise;
            client.Connect();
            client.StartAdvise("EURUSD", 1, true, 60000);

            Console.ReadLine();
            writer.Close();
        }
 public void Test_EndExecute()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             var ar = client.BeginExecute(TestData, null, null);
             Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
             client.EndExecute(ar);
             Assert.AreEqual(TestData, server.Command);
         }
     }
 }
 public void Test_EndPoke()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             var ar = client.BeginPoke(ItemName, Encoding.ASCII.GetBytes(TestData), 1, null, null);
             Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
             client.EndPoke(ar);
             Assert.AreEqual(TestData, Encoding.ASCII.GetString(server.GetData(TopicName, ItemName, 1)));
         }
     }
 }
 public void Test_Execute_TooBusy()
 {
     using var server = new TestServer(ServiceName);
     server.Register();
     using var client = new DdeClient(ServiceName, TopicName);
     client.Connect();
     try
     {
         client.Execute("#TooBusy", Timeout);
     }
     catch (DdeException e)
     {
         Assert.AreEqual(0x4001, e.Code);
     }
 }
 public void Test_EndExecute_After_Dispose()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             var ar = client.BeginExecute(TestData, null, null);
             Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
             client.Dispose();
             Assert.Throws<ObjectDisposedException>(() => client.EndExecute(ar));
         }
     }
 }
 public void Test_Abandon_After_Dispose()
 {
     using (var server = new TestServer(ServiceName))
     {
         server.Register();
         using (var client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             client.Pause();
             var ar = client.BeginExecute(CommandText, null, null);
             client.Dispose();
             Assert.Throws<ObjectDisposedException>(() => client.Abandon(ar));
         }
     }
 }
Ejemplo n.º 30
0
 public void Test_EndExecute_After_Dispose()
 {
     using (TestServer server = new TestServer(ServiceName))
     {
         server.Register();
         using (DdeClient client = new DdeClient(ServiceName, TopicName))
         {
             client.Connect();
             IAsyncResult ar = client.BeginExecute(TestData, null, null);
             Assert.IsTrue(ar.AsyncWaitHandle.WaitOne(Timeout, false));
             client.Dispose();
             client.EndExecute(ar);
         }
     }
 }
Ejemplo n.º 31
0
Archivo: DentX.cs Proyecto: mnisl/OD
		///<summary>Launches the program using the patient.Cur data.</summary>
		public static void SendData(Program ProgramCur, Patient pat){
			ArrayList ForProgram=ProgramProperties.GetForProgram(ProgramCur.ProgramNum);;
			if(pat==null){
				MessageBox.Show("Please select a patient first");
				return;
			}
			//Get the program path from the ini file
			string windir=Environment.GetEnvironmentVariable("windir");// C:\WINDOWS
			string iniFile=windir+"\\dentx.ini";
			if(!File.Exists(iniFile)){
				MessageBox.Show("Could not find "+iniFile);
				return;
			}
			//Make sure the program is running
			string proimagePath=ReadValue(iniFile,"imagemgt","MainFile");
			Process[] proImageInstances=Process.GetProcessesByName("ProImage");
			if(proImageInstances.Length==0){
				Process.Start(proimagePath);
				Thread.Sleep(TimeSpan.FromSeconds(10));
			}
			//command="Xray,PatientNo,FirstName,LastName,Birth Date,Sex,Address,City,State,Code"(zip)
			string command="Xray,";
			//PatientNo can be any string format up to 9 char
			ProgramProperty PPCur=ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");;
			if(PPCur.PropertyValue=="0"){
				command+=pat.PatNum.ToString()+",";
			}
			else{
				if(pat.ChartNumber==""){
					MessageBox.Show("ChartNumber for this patient is blank.");
					return;
				}
				command+=pat.ChartNumber.Replace(",","")+",";
			}
			command+=pat.FName.Replace(",","")+","
				+pat.LName.Replace(",","")+","
				+pat.Birthdate.ToShortDateString()+",";
			if(pat.Gender==PatientGender.Female)
				command+="F,";
			else
				command+="M,";
			command+=pat.Address.Replace(",","")+","
				+pat.City.Replace(",","")+","
				+pat.State.Replace(",","")+","
				+pat.Zip.Replace(",","");
			//MessageBox.Show(command);
			try {
				//Create a context that uses a dedicated thread for DDE message pumping.
				using(DdeContext context=new DdeContext()){
					//Create a client.
					using(DdeClient client=new DdeClient("ProImage","Image",context)){
						//Establish the conversation.
						client.Connect();
						//Start ProImage and open to the Xray Chart screen
						client.Execute(command,2000);//timeout 2 secs
					}
				}
			}
			catch{
				//MessageBox.Show(e.Message);
			}
		}
Ejemplo n.º 32
0
 ///<summary>Launches the program if necessary.  Then passes patient.Cur data using DDE.</summary>
 public static void SendData(Program ProgramCur, Patient pat)
 {
     ArrayList ForProgram=ProgramProperties.GetForProgram(ProgramCur.ProgramNum);;
     if(pat==null){
         MessageBox.Show("Please select a patient first");
         return;
     }
     if(!File.Exists(ProgramCur.Path)){
         MessageBox.Show("Could not find "+ProgramCur.Path);
         return;
     }
     //Make sure the program is running
     //Documentation says to include the -nostartup command line switch (to avoid optional program preference startup command).
     if(Process.GetProcessesByName("Vipersoft").Length==0){
         Process.Start(ProgramCur.Path,"-nostartup");
         Thread.Sleep(TimeSpan.FromSeconds(4));
     }
     //Data is sent to the Vipersoft DDE Server by use of the XTYP_EXECUTE DDE message only.
     //The format ot the XTYP_EXECUTE DDE message is"
     //command="\004hwnd|name|ID|Lastname|Firstname|MI|Comments|Provider|Provider Phone|Addrs1|Addrs2|City|State|Zip|Patient Phone|Practice Name|Patient SSN|restore server|"
     //\004 is one byte code for version 4. 0x04 or Char(4)
     //hwnd is calling software's windows handle.
     //name is for name of calling software (Open Dental)
     //ID is patient ID.  Required and must be unique.
     //Provider field is for provider name.
     //hwnd, ID, Lastname, Firstname, and Provider fields are required.  All other fields are optional.
     //All vertical bars (|) are required, including the ending bar.
     //The restore server flag is for a future release's support of the specialized capture/view commands (default is '1')
     //Visual Basic pseudo code:
     //Chan = DDEInitiate("Vipersoft", "Advanced IntraOral")
     //DDE_String$ = "" //etc
     //DDEExecute Chan, DDE_String$ //send XTYP_EXECUTE DDE command:
     //DDETerminate Chan
     Char char4=Convert.ToChar(4);
     string command=char4.ToString();//tested to make sure this is just one non-printable byte.
     IntPtr hwnd=Application.OpenForms[0].Handle;
     command+=hwnd.ToString()+"|"//hwnd
         +"OpenDental|";//name
     ProgramProperty PPCur=ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");;
     string patID;
     if(PPCur.PropertyValue=="0"){
         patID=pat.PatNum.ToString();
     }
     else{
         if(pat.ChartNumber==""){
             MessageBox.Show("ChartNumber for this patient is blank.");
             return;
         }
         patID=pat.ChartNumber;
     }
     command+=patID+"|";//ID
     command+=pat.LName+"|";//Lastname
     command+=pat.FName+"|";//Firstname
     command+=pat.MiddleI+"|";//
     command+="|";//Comments: blank
     Provider prov=Providers.GetProv(Patients.GetProvNum(pat));
     command+=prov.LName+", "+prov.FName+"|";//Provider
     command+="|";//Provider phone
     command+="|";//Addr
     command+="|";//Addr2
     command+="|";//City
     command+="|";//State
     command+="|";//Zip
     command+="|";//Phone
     command+="|";//Practice
     command+=pat.SSN+"|";//SSN
     command+="1|";//Restore Server
     //MessageBox.Show(command);
     try {
         //Create a context that uses a dedicated thread for DDE message pumping.
         using(DdeContext context=new DdeContext()){
             //Create a client.
             using(DdeClient client=new DdeClient("Vipersoft","Advanced IntraOral",context)){
                 //Establish the conversation.
                 client.Connect();
                 //Select patient
                 client.Execute(command,2000);//timeout 2 secs
                 client.Disconnect();
             }
         }
     }
     catch{
         //MessageBox.Show(e.Message);
     }
 }
Ejemplo n.º 33
0
		///<summary>Launches the program if necessary.  Then passes patient.Cur data using DDE.</summary>
		public static void SendData(Program ProgramCur, Patient pat){
			string path=Programs.GetProgramPath(ProgramCur);
			ArrayList ForProgram=ProgramProperties.GetForProgram(ProgramCur.ProgramNum);;
			if(pat==null){
				MessageBox.Show("Please select a patient first");
				return;
			}
			//The path is available in the registry, but we'll just make the user enter it.
			if(!File.Exists(path)){
				MessageBox.Show("Could not find "+path);
				return;
			}
			//Make sure the program is running
			if(Process.GetProcessesByName("DentalEye").Length==0){
				Process.Start(path);
				Thread.Sleep(TimeSpan.FromSeconds(4));
			}
			//command="[Add][PatNum][Fname][Lname][Address|Address2|City, ST Zip][phone1][phone2][mobile phone][email][sex(M/F)][birthdate (YYYY-MM-DD)]"
			ProgramProperty PPCur=ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");;
			string patID;
			if(PPCur.PropertyValue=="0"){
				patID=pat.PatNum.ToString();
			}
			else{
				if(pat.ChartNumber==""){
					MessageBox.Show("ChartNumber for this patient is blank.");
					return;
				}
				patID=pat.ChartNumber;
			}
			string command="[Add]["+patID+"]"
				+"["+pat.FName+"]"
				+"["+pat.LName+"]"
				+"["+pat.Address+"|";
			if(pat.Address2!=""){
				command+=pat.Address2+"|";
			}
			command+=pat.City+", "+pat.State+" "+pat.Zip+"]"
				+"["+pat.HmPhone+"]"
				+"["+pat.WkPhone+"]"
				+"["+pat.WirelessPhone+"]"
				+"["+pat.Email+"]";
			if(pat.Gender==PatientGender.Female)
				command+="[F]";
			else
				command+="[M]";
			command+="["+pat.Birthdate.ToString("yyyy-MM-dd")+"]";
			//MessageBox.Show(command);
			try {
				//Create a context that uses a dedicated thread for DDE message pumping.
				using(DdeContext context=new DdeContext()){
					//Create a client.
					using(DdeClient client=new DdeClient("DENTEYE","Patient",context)){
						//Establish the conversation.
						client.Connect();
						//Add patient or modify if already exists
						client.Execute(command,2000);//timeout 2 secs
						//Then, select patient
						command="[Search]["+patID+"]";
						client.Execute(command,2000);
					}
				}
			}
			catch{
				//MessageBox.Show(e.Message);
			}
		}