Click here to Skip to main content
15,891,253 members
Home / Discussions / C#
   

C#

 
GeneralRe: Csharp Set text of a textbox from winforms Pin
candogu19-Feb-12 21:37
candogu19-Feb-12 21:37 
QuestionRecord Call Pin
Pawan Mehra15-Feb-12 18:54
Pawan Mehra15-Feb-12 18:54 
AnswerRe: Record Call Pin
Mycroft Holmes15-Feb-12 20:35
professionalMycroft Holmes15-Feb-12 20:35 
AnswerRe: Record Call Pin
Pete O'Hanlon15-Feb-12 22:21
mvePete O'Hanlon15-Feb-12 22:21 
QuestionMulti Lines Outgoing Calls Pin
felipeserra15-Feb-12 11:28
felipeserra15-Feb-12 11:28 
JokeRe: Multi Lines Outgoing Calls PinPopular
Peter_in_278015-Feb-12 12:13
professionalPeter_in_278015-Feb-12 12:13 
AnswerRe: Multi Lines Outgoing Calls Pin
Dave Kreskowiak15-Feb-12 12:51
mveDave Kreskowiak15-Feb-12 12:51 
GeneralRe: Multi Lines Outgoing Calls Pin
felipeserra24-Feb-12 6:42
felipeserra24-Feb-12 6:42 
I need to create Dialer using C# with 5 Data Modems, it`s code:

C#
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
using System.IO.Ports;
using System.Threading;

namespace ConsoleApplication4
{
    class Program
    {
        //use the function
        [STAThread]
        static void Main()
        {
            int Numero;
            Numero = 37924300;
            string classname = "Win32_POTSModem"; // for modems
            //Win32_Service use this as class name it will list the services 
            //Win32_Processor for CPU info
            // and many more are there 
            string strMachine = "."; //your machine name 

            System.Management.ObjectQuery oQuery;
            System.Management.ManagementScope oScope;
            System.Management.ManagementObjectSearcher oSearcher;
            string strSQL;
            //int I = 0;
            try
            {
                strSQL = "Select * from " + classname;
                oQuery = new ObjectQuery(strSQL);
                oScope = new ManagementScope(@"\\" + strMachine + @"\root\cimv2");
                oSearcher = new ManagementObjectSearcher(oScope, oQuery);
                foreach (ManagementObject oService in oSearcher.Get())
                {
                    if (!oService.GetPropertyValue("DeviceID").ToString().Contains("Modem"))
                    {
                        Console.WriteLine(oService.GetPropertyValue("AttachedTo"));
                        Console.WriteLine(oService.GetPropertyValue("Name"));
                        Console.WriteLine(oService.GetPropertyValue("DeviceID"));
                        // Console.WriteLine(oService.ToString());


                        SerialPort modem1 = new SerialPort(oService.GetPropertyValue("AttachedTo").ToString(), 9600, Parity.None, 8, StopBits.One);


                        Console.Write("Try call on modem " + oService.GetPropertyValue("Name").ToString());
                        //Console.ReadKey();
                        // Begin communications 
                        while (modem1.IsOpen)
                        {
                            modem1.Close();
                            Thread.Sleep(1000);
                        }
                        modem1.Open();

                        modem1.NewLine = "\n";
                        Console.WriteLine(modem1.ToString());
                        Console.WriteLine(modem1.PortName);
                        Console.WriteLine(modem1.NewLine.ToString());
                        Console.WriteLine(modem1.IsOpen.ToString());
                        Console.WriteLine(modem1.ReadExisting());

                        modem1.Open();
                        modem1.ReadTimeout = 100000;
                        modem1.NewLine = "\r";
                        modem1.WriteLine("ATZ"); // reset the modem
                        Console.Write("reset the modem");
                        //Console.ReadKey();
                        modem1.ReadTo("OK\r\n"); // wait for "OK" from modem
                        Console.Write("wait for OK from modem");
                        // Console.ReadKey();
                        modem1.WriteLine("ATHDT " + Numero + "@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1@1"); // dial number with dialtone
                        Console.Write("Discando para o numero " + Numero);
                        //Console.ReadKey();
                        string response = modem1.ReadTo("\r").Trim(); // read until first newline
                        Console.Write("Read status modem " + response);
                        //Enter an application loop to keep this thread alive
                        //Application.Run();
                        int i = 0;

                         // I need wait 15 minutes in call
                        while (i < 900000)
                        {
                            // Attach a method to be called when there	  // is data waiting in the port's buffer
                            //modem1.DataReceived += new SerialDataReceivedEventHandler();
                            Console.WriteLine(modem1.ReadExisting());
                            i++;
                        }
                        modem1.Close();

                        Console.WriteLine();
                        Console.Write("Disconnect call " + modem1.PortName);
                        Console.ReadKey();


                    }
                }
                Console.WriteLine("Write call number");
                Console.ReadKey();
           }
            catch (Exception ex)
            {
               Console.WriteLine(ex.Message);
               Console.ReadKey();
            }







            //public void port_DataReceived(object sender, SerialDataReceivedEventArgs e, String modem)
            //{
            //    // Show all the incoming data in the 7port's buffer
            //    Console.WriteLine(modem1.ReadExisting());
            //}
        }
    }

}

GeneralRe: Multi Lines Outgoing Calls Pin
Dave Kreskowiak24-Feb-12 9:13
mveDave Kreskowiak24-Feb-12 9:13 
QuestionValidation with Enterprise Library & WPF Pin
gegonzalez15-Feb-12 8:34
gegonzalez15-Feb-12 8:34 
QuestionOne PaintBackground Method for most Classes / Objects ? Pin
Thomas von Smolinski15-Feb-12 8:13
Thomas von Smolinski15-Feb-12 8:13 
AnswerRe: One PaintBackground Method for most Classes / Objects ? Pin
Richard Andrew x6415-Feb-12 12:38
professionalRichard Andrew x6415-Feb-12 12:38 
AnswerRe: One PaintBackground Method for most Classes / Objects ? Pin
Luc Pattyn15-Feb-12 13:16
sitebuilderLuc Pattyn15-Feb-12 13:16 
AnswerRe: One PaintBackground Method for most Classes / Objects ? Pin
BobJanova15-Feb-12 22:22
BobJanova15-Feb-12 22:22 
QuestionSQLCommandBuilder not working Pin
kruegs3515-Feb-12 6:26
kruegs3515-Feb-12 6:26 
AnswerRe: SQLCommandBuilder not working Pin
jschell15-Feb-12 8:45
jschell15-Feb-12 8:45 
AnswerRe: SQLCommandBuilder not working Pin
Thomas von Smolinski15-Feb-12 8:55
Thomas von Smolinski15-Feb-12 8:55 
GeneralRe: SQLCommandBuilder not working Pin
kruegs3515-Feb-12 9:22
kruegs3515-Feb-12 9:22 
GeneralRe: SQLCommandBuilder not working Pin
Shameel15-Feb-12 17:29
professionalShameel15-Feb-12 17:29 
AnswerRe: SQLCommandBuilder not working Pin
kruegs3515-Feb-12 9:35
kruegs3515-Feb-12 9:35 
Questioncrystal report Pin
sachin rathi15-Feb-12 3:04
sachin rathi15-Feb-12 3:04 
AnswerRe: crystal report Pin
Pete O'Hanlon15-Feb-12 5:54
mvePete O'Hanlon15-Feb-12 5:54 
AnswerRe: crystal report Pin
thatraja15-Feb-12 19:21
professionalthatraja15-Feb-12 19:21 
QuestionConsole Application In C# For Fetching Data From Live Website Pin
Muhammad Anwar Ul Haq Islam15-Feb-12 2:41
Muhammad Anwar Ul Haq Islam15-Feb-12 2:41 
QuestionDrawing Text on Panel Pin
Danzy8315-Feb-12 0:39
Danzy8315-Feb-12 0:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.