Click here to Skip to main content
15,883,938 members
Home / Discussions / C#
   

C#

 
GeneralRe: Error starting window service Pin
obrix_activex23-Jun-09 23:21
obrix_activex23-Jun-09 23:21 
GeneralRe: Error starting window service Pin
himanshu256123-Jun-09 23:39
himanshu256123-Jun-09 23:39 
GeneralRe: Error starting window service Pin
obrix_activex24-Jun-09 0:19
obrix_activex24-Jun-09 0:19 
GeneralRe: Error starting window service Pin
himanshu256124-Jun-09 0:43
himanshu256124-Jun-09 0:43 
AnswerRe: Error starting window service Pin
dan!sh 23-Jun-09 22:21
professional dan!sh 23-Jun-09 22:21 
GeneralRe: Error starting window service Pin
obrix_activex24-Jun-09 0:23
obrix_activex24-Jun-09 0:23 
AnswerRe: Error starting window service Pin
PIEBALDconsult24-Jun-09 4:58
mvePIEBALDconsult24-Jun-09 4:58 
GeneralRe: Error starting window service Pin
obrix_activex24-Jun-09 23:04
obrix_activex24-Jun-09 23:04 
ok..this is the whole code in service1.cs..error or time out comes inside the function LLPlusProcess for how many loops..i dont know if it uses too many thread..please help..tnx!!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OracleClient;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
//using System.Timers;
using System.Threading;
using System.Net.NetworkInformation;
using System.IO;

namespace LLPlus
{
public partial class Service1 : ServiceBase
{
Timer timer1;// enqueue

Service service;// = new Service();

string refIDEQ = null;
bool enqued = false;
string strconn;

OracleConnection conn;
OracleCommand cmd;

public Service1()
{
InitializeComponent();
}

public void InitializeConnection()
{
strconn = System.Configuration.ConfigurationManager.ConnectionStrings ["OracleConnection"].ToString();
conn = new OracleConnection(strconn);
cmd = new OracleCommand();
}

public void Start()
{

int intervalEnqueue;

try
{
InitializeConnection();
if (Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["enqueueDelay"]) > 0)

{
intervalEnqueue = Int32.Parse (System.Configuration.ConfigurationManager.AppSettings["enqueueDelay"]) * 1000;

timer1 = new Timer(new TimerCallback(LLPlusProcess), null, intervalEnqueue, intervalEnqueue);
}
else
{
AddToFile("Start...");
intervalEnqueue = 600;
timer1 = new Timer(new TimerCallback(LLPlusProcess), null, intervalEnqueue, intervalEnqueue);
}


}
catch (Exception e)
{

System.Diagnostics.Debug.Write("\r\n[Start] Error: " + e.Message);

}

}
protected override void OnStart(string[] args)
{
Start();
}

protected override void OnStop()
{
timer1.Dispose();
conn.Close();
}


public void LLPlusProcess(object state)
{
System.Diagnostics.Debug.Write(" LLPlus [ENQUEUE] : Service Started at " + DateTime.Now.ToString() + " \r\n");

if (!enqued)
{
try
{
enqued = true;


GetSMSResult getIncomingSMSResult = new GetSMSResult();
getIncomingSMSResult = null;
service = new Service();


service.Credentials = System.Net.CredentialCache.DefaultCredentials;
getIncomingSMSResult = service.GetSMS(System.Configuration.ConfigurationManager.AppSettings["clientAppKey"], System.Configuration.ConfigurationManager.AppSettings["enqueueStatus"], "Waiting", Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["enqueueRecord"]));

string getIncomingSMSResultResponse = getIncomingSMSResult.ResponseMessage;

System.Diagnostics.Debug.Write(getIncomingSMSResultResponse + "\r\n");

GetSMSResultMessage[] getIncomingSMSResultMessage = null;
getIncomingSMSResultMessage = getIncomingSMSResult.Message;

if (getIncomingSMSResultMessage != null)
{
System.Diagnostics.Debug.Write(getIncomingSMSResultMessage.Length + "\r\n");

for (int x = 0; x < getIncomingSMSResultMessage.Length; x++)
{
System.Diagnostics.Debug.Write(getIncomingSMSResultMessage[x].DateReceived + "\r\n");
System.Diagnostics.Debug.Write(getIncomingSMSResultMessage[x].Keyword + "\r\n");
System.Diagnostics.Debug.Write(getIncomingSMSResultMessage[x].MessageText + "\r\n");
System.Diagnostics.Debug.Write(getIncomingSMSResultMessage[x].ReferenceID + "\r\n");
System.Diagnostics.Debug.Write(getIncomingSMSResultMessage[x].Sender + "\r\n");
System.Diagnostics.Debug.Write("COUNTER " + x + "\r\n");

try
{

refIDEQ = getIncomingSMSResultMessage[x].ReferenceID;

string sql = "INSERT INTO PLP_ENQUE_DEQUE(ref_id,service_no,keyword,msg_in,status) "
+ " VALUES ('" + getIncomingSMSResultMessage[x].ReferenceID + "','" +
getIncomingSMSResultMessage[x].Sender + "','" +
getIncomingSMSResultMessage[x].Keyword + "','" +
getIncomingSMSResultMessage[x].MessageText + "','E')";

conn.Open();
cmd.Connection = conn;
cmd.CommandText = sql;
cmd.CommandType = CommandType.Text;
int recAffected = cmd.ExecuteNonQuery();
conn.Close();

if (recAffected > 0)
{
string updateSMS = service.UpdateSMSStatus(System.Configuration.ConfigurationManager.AppSettings["clientAppKey"], getIncomingSMSResultMessage[x].ReferenceID, System.Configuration.ConfigurationManager.AppSettings["enqueueSuccessMsg"]);
System.Diagnostics.Debug.Write(" UPDATE SMS : " + updateSMS + "\r\n");

}
else
{
string updateSMS = service.UpdateSMSStatus(System.Configuration.ConfigurationManager.AppSettings["clientAppKey"], getIncomingSMSResultMessage[x].ReferenceID, System.Configuration.ConfigurationManager.AppSettings["enqueueFailedMsg"]);
System.Diagnostics.Debug.Write(" UPDATE SMS : " + updateSMS + "\r\n");
}
}
catch (Exception icmsEx)
{
System.Diagnostics.Debug.Write("ENQUEUE [EX] 2: " + icmsEx.ToString());
if (icmsEx.Message.ToLower().StartsWith("unspecified error"))
{
InitializeConnection();
}
else
{
string updateSMS = service.UpdateSMSStatus(System.Configuration.ConfigurationManager.AppSettings["clientAppKey"], getIncomingSMSResultMessage[x].ReferenceID, icmsEx.Message);
System.Diagnostics.Debug.Write("ENQUEUE [ICMSEX] " + icmsEx.ToString());
}

}

}
}

}
catch (Exception ex)
{
System.Diagnostics.Debug.Write("ENQUEUE [EX] : " + ex.ToString());
}

System.Threading.Thread.Sleep(100);
enqued = false;

}
else
{
System.Diagnostics.Debug.Write("\r\n ---- ENQUEUE PROCESS ON GOING ----\r\n ");

}

}

}
}
GeneralRe: Error starting window service Pin
PIEBALDconsult25-Jun-09 4:23
mvePIEBALDconsult25-Jun-09 4:23 
QuestionHow to have a FileSystemWatcher fire only 1 change event? Pin
Super Lloyd23-Jun-09 20:56
Super Lloyd23-Jun-09 20:56 
AnswerRe: How to have a FileSystemWatcher fire only 1 change event? Pin
Super Lloyd23-Jun-09 21:14
Super Lloyd23-Jun-09 21:14 
AnswerRe: How to have a FileSystemWatcher fire only 1 change event? Pin
Luc Pattyn23-Jun-09 21:16
sitebuilderLuc Pattyn23-Jun-09 21:16 
GeneralRe: How to have a FileSystemWatcher fire only 1 change event? Pin
Super Lloyd23-Jun-09 21:25
Super Lloyd23-Jun-09 21:25 
QuestionError In Connection Pin
rhtbhegade23-Jun-09 20:40
rhtbhegade23-Jun-09 20:40 
AnswerRe: Error In Connection Pin
padmanabhan N23-Jun-09 20:56
padmanabhan N23-Jun-09 20:56 
GeneralRe: Error In Connection Pin
rhtbhegade23-Jun-09 21:00
rhtbhegade23-Jun-09 21:00 
GeneralRe: Error In Connection Pin
Philip.F23-Jun-09 21:29
Philip.F23-Jun-09 21:29 
GeneralRe: Error In Connection Pin
rhtbhegade23-Jun-09 22:55
rhtbhegade23-Jun-09 22:55 
QuestionHow to get active window event Pin
Jacobb Michael23-Jun-09 19:37
Jacobb Michael23-Jun-09 19:37 
AnswerRe: How to get active window event Pin
Anubhava Dimri23-Jun-09 19:50
Anubhava Dimri23-Jun-09 19:50 
GeneralRe: How to get active window event Pin
Jacobb Michael24-Jun-09 1:18
Jacobb Michael24-Jun-09 1:18 
AnswerRe: How to get active window event Pin
Anubhava Dimri24-Jun-09 2:11
Anubhava Dimri24-Jun-09 2:11 
GeneralRe: How to get active window event Pin
Jacobb Michael24-Jun-09 2:18
Jacobb Michael24-Jun-09 2:18 
GeneralRe: How to get active window event Pin
Anubhava Dimri24-Jun-09 2:32
Anubhava Dimri24-Jun-09 2:32 
QuestionIs there any learning docs for begines? Pin
behesht23-Jun-09 19:01
behesht23-Jun-09 19:01 

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.