473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to run console application on telnet window ?

I have created 1 console Application and it is running perfectly. In my project I have to take input string and from telnet specific window named as "telnet 192.168.x.x" and run my project and give output related to that string (i.e barcode code is all I have to receive on telnet window and give output (details of barcode code) related to that code in same telnet window). I am able to run this console app in cmd.exe and ConsoleApplication.exe but now I am passing barcode string manually then how to run this application on telnet window and receive barcode string automatically?
please help .

Expand|Select|Wrap|Line Numbers
  1. namespace ConsoleApplication2
  2. {
  3.     class Program
  4.     {
  5.         string path = @"text file path";
  6.  
  7.         SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["constring"].ToString());
  8.  
  9.         public void getConsoleInput()
  10.         {
  11.             try
  12.             {
  13.                 FileInfo fi = new FileInfo(path);
  14.  
  15.                 for (int i = 0; i <= 0; i++)
  16.                 {
  17.                     Console.WriteLine("");
  18.                     using (StreamWriter sw = new StreamWriter(path))
  19.                     {
  20.                         sw.WriteLine(Console.ReadLine());
  21.                         sw.Close();
  22.                     }
  23.                 }
  24.             }
  25.             catch (Exception e)
  26.             {
  27.                 Console.WriteLine(e.Message);
  28.             }
  29.         }
  30.  
  31.         public void ReadWriteIntoFile()
  32.         {
  33.             try
  34.             {
  35.                 string filename = @"txt file path";
  36.                 StringBuilder sb = new StringBuilder();
  37.  
  38.                 StreamReader sr = new StreamReader(path);
  39.                 string s = sr.ReadLine();
  40.                 sr.Close();
  41.  
  42.                 DataExport("Select * from PATIENT_TABLE where [BARCODE] = '" + s + "'", filename);
  43.             }
  44.             catch { }
  45.         }
  46.  
  47.         public void DataExport(string SelectQuery, string filename)
  48.         {
  49.             try
  50.             {
  51.                 using (var dt = new DataTable())
  52.                 {
  53.                     using (var da = new SqlDataAdapter(SelectQuery, con))
  54.                     {
  55.                         da.Fill(dt);
  56.                         var rows =
  57.                             from dr in dt.Rows.Cast<datarow>()
  58.                             select String.Join(
  59.                                 ",",
  60.                                 from dc in dt.Columns.Cast<datacolumn>()
  61.                                 let t1 = Convert.IsDBNull(dr[dc]) ? "" : dr[dc].ToString()
  62.                                 let t2 = t1.Contains(",") ? String.Format("\"{0}\"", t1) : t1
  63.                                 select t2);
  64.  
  65.                         using (var sw = new StreamWriter(filename))
  66.                         {
  67.                             // sw.WriteLine(header);
  68.                             foreach (var row in rows)
  69.                             {
  70.                                 sw.WriteLine(row);
  71.                             }
  72.                             sw.Close();
  73.                         }
  74.                     }
  75.                 }
  76.             }
  77.             catch (Exception e) { Console.WriteLine(e.Message); }
  78.         }
  79.  
  80.         public void WriteFileOutput()
  81.         {
  82.             string path = @"C:\Users\Priya\Desktop\Project\Data.txt";
  83.             if (File.Exists(path))
  84.             {
  85.                 string[] lines = File.ReadAllLines(path);
  86.  
  87.                 foreach (string line in lines)
  88.                 {
  89.                     Console.WriteLine(line);
  90.                 }
  91.  
  92.             }
  93.             Console.ReadLine();
  94.         }
  95.  
  96.         public static void Main(string[] args)
  97.         {
  98.             Program p = new Program();
  99.             p.getConsoleInput();
  100.             p.ReadWriteIntoFile();
  101.             p.WriteFileOutput();
  102.         }
  103.  
  104.         public void timerfor()
  105.         {
  106.             Timer t;
  107.             t = new System.Timers.Timer(10000);
  108.             // Hook up the Elapsed event for the timer. 
  109.             t.Elapsed += OnTimedEvent;
  110.             t.Enabled = true;
  111.         }
  112.  
  113.         private static void OnTimedEvent(Object source, ElapsedEventArgs e)
  114.         {
  115.             Console.WriteLine(ConsoleKey.Enter);          
  116.         }
  117.     }
  118. }
  119.  
  120.  
May 18 '15 #1
0 1236

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Gionni | last post by:
Hello everyone, I'm have a window application, but it is a console application too. I'll try to explain better: if I call the program without parameters the GUI starts. Otherwise it runs as a...
1
by: Reinier Beeckman | last post by:
I have made a simple console application which run through the Windows scheduled task. When the program is starten i get the console in the screen. Is it also possible to configure it that the...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
5
by: Klaus Löffelmann | last post by:
Hi, it may be a stupid question and maybe I'm not seeing the wood for the trees, but how do I let the console window remaining open after the app terminates? (Console.Readline as last code...
8
by: Alison | last post by:
Hi, Al I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window...
0
by: Maxwell | last post by:
Hello, I recently completed a MC++ (VS2003) DLL that wraps a non MFC C++ DLL and need to use it in a MC++ Console Application (no forms/guis of any kind just output to console). Trouble is...
0
by: suedasszyy | last post by:
Haiiii.... i'm new for VB.net. can someone help me to solve those question? is it possible to draw a graph such as Sin graph using console application? if not, how can i draw a graph...
3
by: Marcel Saucier | last post by:
I have written a Console Application then created a shortcut to it on my desktop. I was able to minimize the DOS window when I click my shortcut so I dont see anymore the DOS window But, using...
0
by: merco | last post by:
hi, i'm trying to write a console application using vbnet2005. It runs ok in a command prompt. Now, i have to use this console application via telnet (using w2003 server as telnet server) but i...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.