代码可能有些长,请各位兄弟耐住性子看看,感激不尽:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Configuration;
using System.Runtime.InteropServices;namespace 滁州移动服务评价系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} //引用dll部分
#region
Cls cls = new Cls();
[DllImport("centerm_i70.dll", EntryPoint = "GetPasswordFromKeypad", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetPasswordFromKeypad(ref Cls.COMMPARAMETER stComParam, ref string strPassword, int nLen, int nMode, double nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "SetEvaluatorInfo", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SetEvaluatorInfo(ref Cls.COMMPARAMETER stComParam, string strDepartment, string strPosition, string strID, int nStar);
[DllImport("centerm_i70.dll", EntryPoint = "GetEvaluationFromEvaluator", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetEvaluationFromEvaluator(ref Cls.COMMPARAMETER stComParam, ref string strEvaluation, int nEvaLen, ref string strReason, int nReaLen, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "GetValueFromInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetValueFromInfoviewer(ref Cls.COMMPARAMETER stComParam, ref string strValue, int nVLen, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "AppendToInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int AppendToInfoviewer(ref Cls.COMMPARAMETER stComParam, string strInfo, int nLen);
[DllImport("centerm_i70.dll", EntryPoint = "ClearInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ClearInfoviewer(ref Cls.COMMPARAMETER stComParam);
[DllImport("centerm_i70.dll", EntryPoint = "EnableInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int EnableInfoviewer(ref Cls.COMMPARAMETER stComParam);
[DllImport("centerm_i70.dll", EntryPoint = "SetInfoviewerText", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SetInfoviewerText(ref Cls.COMMPARAMETER stComParam, int fontsize, string fontcolor, string backcolor);
[DllImport("centerm_i70.dll", EntryPoint = "ListPictureBegin", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListPictureBegin(ref Cls.COMMPARAMETER stComParam, ref string listBuffer, ref int nSize, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "ListPictureEnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListPictureEnd(string listBuffer);
[DllImport("centerm_i70.dll", EntryPoint = "ListMP3AudioBegin", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListMP3AudioBegin(ref Cls.COMMPARAMETER stComParam, ref string listBuffer, ref int nSize, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "ListMP3AudioEnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListMP3AudioEnd(string listBuffer);
[DllImport("centerm_i70.dll", EntryPoint = "DownloadOperatorPicture", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int DownloadOperatorPicture(ref Cls.COMMPARAMETER stComParam, string strSrcFileName, string strDestFileName, int outtime);
[DllImport("centerm_i70.dll", EntryPoint = "PlayMP3Audio", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int PlayMP3Audio(ref Cls.COMMPARAMETER stComParam, string strFileName);
[DllImport(".\\centerm_i70.dll", EntryPoint = "isCommPortUsed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int isCommPortUsed(); //检测端口是否被占用
[DllImport(".\\centerm_i70.dll", EntryPoint = "ForceCloseCommPort", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ForceCloseCommPort(ref Cls.COMMPARAMETER stComParam);//关闭当前端口
[DllImport(".\\centerm_i70.dll", EntryPoint = "CloseApplication", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int CloseApplication(ref Cls.COMMPARAMETER stComParam); //关闭程序
#endregion //程序初始化
public DataSet ds = null;
public static string _tc = "";
public static string _pj = "";
public static string _pwd = "";
public static int ppstate = 0;
public static string loadhtml = "";
public static string loadurl = "";
private void Form1_Load(object sender, EventArgs e)
{
CSHLoad csh = new CSHLoad();
csh.label1.Text = "系统正在初始化中,请稍后...";
csh.ShowDialog();
string _text = ConfigurationSettings.AppSettings["title"].ToString();
string _pwdname = ConfigurationSettings.AppSettings["pwdname"].ToString();
string _telname = ConfigurationSettings.AppSettings["telname"].ToString();
string _submitname = ConfigurationSettings.AppSettings["submitname"].ToString();
string _frmname = ConfigurationSettings.AppSettings["frmname"].ToString();
Cls.bossurl = ConfigurationSettings.AppSettings["bossurl"].ToString();
_tc = ConfigurationSettings.AppSettings["tc"].ToString();
_pj = ConfigurationSettings.AppSettings["pj"].ToString();
_pwd = ConfigurationSettings.AppSettings["pwd"].ToString(); this.Text = "滁州移动综合业务系统(版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + ")";// _text;
if (_pwdname != "" && _submitname != "")
{
Cls.submitname = _submitname;
Cls.pwdname = _pwdname;
Cls.telname = _telname;
Cls.frmname = _frmname;
}
else
{ MessageBox.Show("程序初始化失败,请设置app.config文件"); }
toolStripLabel1.Text = Cls.usercode;
} //检验加载是否完毕
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
timer1.Start();
}
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Configuration;
using System.Runtime.InteropServices;namespace 滁州移动服务评价系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} //引用dll部分
#region
Cls cls = new Cls();
[DllImport("centerm_i70.dll", EntryPoint = "GetPasswordFromKeypad", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetPasswordFromKeypad(ref Cls.COMMPARAMETER stComParam, ref string strPassword, int nLen, int nMode, double nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "SetEvaluatorInfo", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SetEvaluatorInfo(ref Cls.COMMPARAMETER stComParam, string strDepartment, string strPosition, string strID, int nStar);
[DllImport("centerm_i70.dll", EntryPoint = "GetEvaluationFromEvaluator", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetEvaluationFromEvaluator(ref Cls.COMMPARAMETER stComParam, ref string strEvaluation, int nEvaLen, ref string strReason, int nReaLen, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "GetValueFromInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int GetValueFromInfoviewer(ref Cls.COMMPARAMETER stComParam, ref string strValue, int nVLen, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "AppendToInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int AppendToInfoviewer(ref Cls.COMMPARAMETER stComParam, string strInfo, int nLen);
[DllImport("centerm_i70.dll", EntryPoint = "ClearInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ClearInfoviewer(ref Cls.COMMPARAMETER stComParam);
[DllImport("centerm_i70.dll", EntryPoint = "EnableInfoviewer", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int EnableInfoviewer(ref Cls.COMMPARAMETER stComParam);
[DllImport("centerm_i70.dll", EntryPoint = "SetInfoviewerText", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SetInfoviewerText(ref Cls.COMMPARAMETER stComParam, int fontsize, string fontcolor, string backcolor);
[DllImport("centerm_i70.dll", EntryPoint = "ListPictureBegin", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListPictureBegin(ref Cls.COMMPARAMETER stComParam, ref string listBuffer, ref int nSize, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "ListPictureEnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListPictureEnd(string listBuffer);
[DllImport("centerm_i70.dll", EntryPoint = "ListMP3AudioBegin", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListMP3AudioBegin(ref Cls.COMMPARAMETER stComParam, ref string listBuffer, ref int nSize, int nTimeout);
[DllImport("centerm_i70.dll", EntryPoint = "ListMP3AudioEnd", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ListMP3AudioEnd(string listBuffer);
[DllImport("centerm_i70.dll", EntryPoint = "DownloadOperatorPicture", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int DownloadOperatorPicture(ref Cls.COMMPARAMETER stComParam, string strSrcFileName, string strDestFileName, int outtime);
[DllImport("centerm_i70.dll", EntryPoint = "PlayMP3Audio", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int PlayMP3Audio(ref Cls.COMMPARAMETER stComParam, string strFileName);
[DllImport(".\\centerm_i70.dll", EntryPoint = "isCommPortUsed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int isCommPortUsed(); //检测端口是否被占用
[DllImport(".\\centerm_i70.dll", EntryPoint = "ForceCloseCommPort", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ForceCloseCommPort(ref Cls.COMMPARAMETER stComParam);//关闭当前端口
[DllImport(".\\centerm_i70.dll", EntryPoint = "CloseApplication", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int CloseApplication(ref Cls.COMMPARAMETER stComParam); //关闭程序
#endregion //程序初始化
public DataSet ds = null;
public static string _tc = "";
public static string _pj = "";
public static string _pwd = "";
public static int ppstate = 0;
public static string loadhtml = "";
public static string loadurl = "";
private void Form1_Load(object sender, EventArgs e)
{
CSHLoad csh = new CSHLoad();
csh.label1.Text = "系统正在初始化中,请稍后...";
csh.ShowDialog();
string _text = ConfigurationSettings.AppSettings["title"].ToString();
string _pwdname = ConfigurationSettings.AppSettings["pwdname"].ToString();
string _telname = ConfigurationSettings.AppSettings["telname"].ToString();
string _submitname = ConfigurationSettings.AppSettings["submitname"].ToString();
string _frmname = ConfigurationSettings.AppSettings["frmname"].ToString();
Cls.bossurl = ConfigurationSettings.AppSettings["bossurl"].ToString();
_tc = ConfigurationSettings.AppSettings["tc"].ToString();
_pj = ConfigurationSettings.AppSettings["pj"].ToString();
_pwd = ConfigurationSettings.AppSettings["pwd"].ToString(); this.Text = "滁州移动综合业务系统(版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + ")";// _text;
if (_pwdname != "" && _submitname != "")
{
Cls.submitname = _submitname;
Cls.pwdname = _pwdname;
Cls.telname = _telname;
Cls.frmname = _frmname;
}
else
{ MessageBox.Show("程序初始化失败,请设置app.config文件"); }
toolStripLabel1.Text = Cls.usercode;
} //检验加载是否完毕
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
timer1.Start();
}
解决方案 »
- C# Winfrom ListView问题
- DataGridView高级应用 [高手牛人来]
- ◆ C#中用正则表达式\w怎么还能匹配中文?
- 一个不错的下载网站,觉得好的朋友帮忙给顶一下!
- 问一下,有人知道怎么解析NLC 文件格式吗【中国国家图书馆的电子图书格式】
- 怎么样在项目中查找项目引用那些dll ?
- 这种表达方式是什么意思?Attribute a = parse.GetTag()["HREF"];
- 运行DOS程序的问题
- 请问一下是不是一个webservice就只能有一个类?
- 在C#开发的WEB程序中这种访问格式支持吗?
- QQ农场外挂遇到了了问题,望高手给与指导
- 如何使用js通过gridview中checkbox是否被选择,改变textbox是否可输入
//号码输入后触发事件,如欢迎问候语,计时开始,目标客户查询
void telnum_LosingFocus(object sender, HtmlElementEventArgs e)
{
try
{
HtmlDocument hdoc = webBrowser1.Document.Window.Frames[Cls.frmname].Document;
HtmlElement telnum = hdoc.All[Cls.telname];
if (telnum != null)
{
string tel = telnum.GetAttribute("value");
if (tel.Trim() != "" && tel.Length == 11 && tel != Cls.telstr)
{
Cls.telstr = tel;
Cls.statime = DateTime.Now;
ppstate = 1;
string orastr = ConfigurationSettings.AppSettings["ppsql"].ToString();
orastr = orastr.Replace("$hm$", tel.Trim());
string pjcode = cls.ExecuteNonQueryOra(orastr);
string mp3 = pptype(pjcode);
Thread play = new Thread(new ParameterizedThreadStart(playmp3));
play.Start(mp3);
if (_tc.ToLower() == "true")
{
selectdata.RunWorkerAsync(tel);
}
}
}
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
ppstate = 0;
}
} private void selectdata_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
int k = (int)e.Result;
if (k == 0)
{
toolStripLabel1.Text = " 目标客户";
if (Cls.bosscode != "")
{
toolStripButton6.Visible = true;
}
toolStripLabel1.ForeColor = System.Drawing.Color.Red;
string stext = " 新业务推荐:\n";
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
stext += " " + (i + 1).ToString() + ":" + ds.Tables[0].Rows[i][4].ToString() + "\n";
}
showtext.RunWorkerAsync(stext);
}
else
{
toolStripLabel1.Text = " 非目标客户";
toolStripButton6.Visible = false;
toolStripLabel1.ForeColor = System.Drawing.Color.Black;
}
}
catch ( Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
}
}
private void selectdata_DoWork(object sender, DoWorkEventArgs e)
{
try
{
string hm = (string)e.Argument;
int k = sltdt(hm);
if (k > 0) { e.Result = 0; } else { e.Result = 1; }
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
}
}
private void showtext_DoWork(object sender, DoWorkEventArgs e)
{
try
{
string str = (string)e.Argument;
Cls.COMMPARAMETER stCommParam;
stCommParam.nPort = Cls._nport;
stCommParam.nBaudRate = Cls._nBaudRate;
stCommParam.nByteSize = Cls._nByteSize;
stCommParam.nParity = Cls._nparity;
stCommParam.nStopBits = Cls._nstopbits;
safeport();
string outovalue = "";
EnableInfoviewer(ref stCommParam);
SetInfoviewerText(ref stCommParam, 6, "FF0000", "FFFFFF");
AppendToInfoviewer(ref stCommParam, str, 500);
if (GetValueFromInfoviewer(ref stCommParam, ref outovalue, 16, 10) == 0)
{
e.Result = outovalue;
Thread.CurrentThread.Abort();
}
else
{ e.Result = 0; Thread.CurrentThread.Abort(); }
}
catch (Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
}
} private void showtext_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try
{
string k = e.Result.ToString();
if (k != "0")
{
if (k.ToUpper() == "B1F" && Cls.bosscode != "")
{
推荐 tj = new 推荐();
tj.Show(this);
}
}
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
}
}
protected string pptype(string pj)
{
try
{
switch (pj)
{
case "G00":
return "Hello_GoTone.mp3";
case "G30":
return "Hello_EasyOwn.mp3";
case "G40":
return "Hello_MZone.mp3";
default:
return "Hello_EasyOwn.mp3";
}
}
catch (Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
return "";
}
}
{
try
{
string haoma = tel;
string sql = "select hdid from tc_t_huodong where hdshow=0 and hdyxq>='" + DateTime.Today.ToShortDateString() + "' and hdarea in('00')";//,'" + Cls.deptcode + "'
string sqls = "";
SqlDataReader rs = cls.SqlDataReader(sql);
while (rs.Read())
{
string t_name = "tc_t_hm" + rs[0].ToString();
if (sqls == "")
{
sqls += "select haoma,state,date,hdid,hdname,hdinfo,hdyxq,hdorder,hdcode from " + t_name + " a left join tc_t_huodong b on b.hdid=" + rs[0].ToString() + " where haoma='" + haoma + "'";
}
else
{
sqls += " union select haoma,state,date,hdid,hdname,hdinfo,hdyxq,hdorder,hdcode from " + t_name + " a left join tc_t_huodong b on b.hdid=" + rs[0].ToString() + " where haoma='" + haoma + "'";
}
}
rs.Close();
rs.Dispose();
ds = cls.DataSet(sqls);
int k = ds.Tables[0].Rows.Count;
//ds.Dispose();
return k;
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
return -1;
}
}
//调用播放声音线程
protected void playmp3(object mp)
{
try
{
string _mp3 = (string)mp;
Cls.COMMPARAMETER stCommParam;
stCommParam.nPort = Cls._nport;
stCommParam.nBaudRate = Cls._nBaudRate;
stCommParam.nByteSize = Cls._nByteSize;
stCommParam.nParity = Cls._nparity;
stCommParam.nStopBits = Cls._nstopbits;
PlayMP3Audio(ref stCommParam, _mp3);
Thread.CurrentThread.Abort();
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
} } //密码输入功能
void inputpwd2_Focusing(object sender, HtmlElementEventArgs e)
{
try
{
Cls.COMMPARAMETER stCommParam;
stCommParam.nPort = Cls._nport;
stCommParam.nBaudRate = Cls._nBaudRate;
stCommParam.nByteSize = Cls._nByteSize;
stCommParam.nParity = Cls._nparity;
stCommParam.nStopBits = Cls._nstopbits;
HtmlDocument hdoc = webBrowser1.Document.Window.Frames[Cls.frmname].Document;
HtmlElement inputpwd = hdoc.All["password2"];
string pwdstr = "";
safeport();
if (GetPasswordFromKeypad(ref stCommParam, ref pwdstr, 6, 2, 20) == 0)
{
inputpwd.SetAttribute("value", pwdstr);
Thread.CurrentThread.Abort();
}
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
}
} //密码输入功能
void inputpwd1_Focusing(object sender, HtmlElementEventArgs e)
{
try
{
Cls.COMMPARAMETER stCommParam;
stCommParam.nPort = Cls._nport;
stCommParam.nBaudRate = Cls._nBaudRate;
stCommParam.nByteSize = Cls._nByteSize;
stCommParam.nParity = Cls._nparity;
stCommParam.nStopBits = Cls._nstopbits;
HtmlDocument hdoc = webBrowser1.Document.Window.Frames[Cls.frmname].Document;
HtmlElement inputpwd = hdoc.All["password1"];
string pwdstr = "";
safeport();
if (GetPasswordFromKeypad(ref stCommParam, ref pwdstr, 6, 2, 20) == 0)
{
inputpwd.SetAttribute("value", pwdstr);
Thread.CurrentThread.Abort();
}
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
}
} //密码输入功能
void inputpwd_Focusing(object sender, HtmlElementEventArgs e)
{
try
{
Cls.COMMPARAMETER stCommParam;
stCommParam.nPort = Cls._nport;
stCommParam.nBaudRate = Cls._nBaudRate;
stCommParam.nByteSize = Cls._nByteSize;
stCommParam.nParity = Cls._nparity;
stCommParam.nStopBits = Cls._nstopbits;
HtmlDocument hdoc = webBrowser1.Document.Window.Frames[Cls.frmname].Document;
HtmlElement inputpwd = hdoc.All["password"];
string pwdstr = "";
safeport();
if (GetPasswordFromKeypad(ref stCommParam, ref pwdstr, 6, 2, 10) == 0)
{
inputpwd.SetAttribute("value", pwdstr);
Thread.CurrentThread.Abort();
}
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
}
} //服务评价
void submit_Click(object sender, HtmlElementEventArgs e)
{
if (ppstate == 1)
{ }
}
protected void playjj()
{
try
{
//MessageBox.Show("评价完毕");
Cls.COMMPARAMETER stCommParam;
stCommParam.nPort = Cls._nport;
stCommParam.nBaudRate = Cls._nBaudRate;
stCommParam.nByteSize = Cls._nByteSize;
stCommParam.nParity = Cls._nparity;
stCommParam.nStopBits = Cls._nstopbits;
safeport();
string strEvaluation = "";
string strReason = "";
if (SetEvaluatorInfo(ref stCommParam, Cls.sitename, Cls.userpos, Cls.usercode, Cls.userstar) == 0)
{
if (GetEvaluationFromEvaluator(ref stCommParam, ref strEvaluation, 16, ref strReason, 16, 15) == 0)
{
Cls.endtime = DateTime.Now;
string sql = "insert into pj_t_log" + DateTime.Today.Year.ToString() + "(cltel,pjuser,pjcont,pjreason,pjtime,statime,endtime,ywys,ywname)values";
sql += "('" + Cls.telstr + "','" + Cls.usercode + "','" + strEvaluation + "','" + strReason + "','" + DateTime.Now + "','" + Cls.statime + "','" + Cls.endtime + "'," + difftime(Cls.statime, Cls.endtime) + ",'')";
cls.ExecuteNonQuery(sql);
if (strEvaluation == "B3F" && Cls.telstr != "" && Cls.telstr.Trim().Length == 11)
{
string smssql = "insert into df_duanxin(zangtai,haoma,neirong)values(0,'" + Cls.telstr + "','工号:" + Cls.usercode + " 被客户评为不满意,原因是" + ppreason(strReason) + "!')";
cls.ExecuteNonQuery(smssql);
}
}
}
ppstate = 0;
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
ppstate = 0;
}
finally
{
Thread.CurrentThread.Abort();
}
} //返回不满意的原因
protected string ppreason(string cd)
{
try
{
switch (cd)
{
case "BAF":
return "态度不好";
case "BBF":
return "业务不熟";
case "BCF":
return "效率不高";
case "BDF":
return "其他";
default:
return "";
}
}
catch(Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
return "";
} } //时间间隔,单位分钟
public int difftime(DateTime dt1, DateTime dt2)
{
try
{
TimeSpan ds = dt2.Subtract(dt1);
return ds.Minutes;
}
catch (Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
return 0;
}
} //系统登录
private void toolStripButton1_Click(object sender, EventArgs e)
{
login dl = new login();
dl.ShowDialog(this);
} //代开BOSS网址
private void toolStripButton5_Click(object sender, EventArgs e)
{
this.webBrowser1.Navigate(Cls.bossurl); }
//系统设置
private void toolStripButton4_Click(object sender, EventArgs e)
{
sysset ss = new sysset();
ss.Show();
} private void toolStripButton3_Click(object sender, EventArgs e)
{
if (MessageBox.Show("确定要关闭此窗口", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
this.Dispose();
Application.Exit();
}
} private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("确定要关闭此窗口", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.Dispose();
Application.Exit();
}
else
{ e.Cancel = true; }
} private void toolStripButton2_Click(object sender, EventArgs e)
{
MessageBox.Show("此功能正在开发中");
} private void timer1_Tick(object sender, EventArgs e)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete && webBrowser1.IsBusy == false)
{
try
{
timer1.Stop();
loadurl = "";
loadhtml = "";
HtmlDocument hdoc = webBrowser1.Document.Window.Frames[Cls.frmname].Document;
HtmlElement submit = hdoc.All[Cls.submitname];
HtmlElement qd1 = hdoc.All["yesBtn"];
HtmlElement rk = hdoc.All["btnSave"];
HtmlElement qd2 = hdoc.All["save"];
HtmlElement tj = hdoc.All["btnSubmit"];
string value = ConfigurationSettings.AppSettings["valuename"].ToString();
HtmlElement inputpwd = hdoc.All["password"];
HtmlElement inputpwd1 = hdoc.All["password1"];
HtmlElement inputpwd2 = hdoc.All["password2"];
HtmlElement telnum = hdoc.All[Cls.telname]; if (qd1 != null && qd1.GetAttribute("value") == "确定")
{ qd1.Click += new HtmlElementEventHandler(qd1_Click); }
else if (qd2 != null && qd2.GetAttribute("value") == "确定")
{ qd2.Click += new HtmlElementEventHandler(qd2_Click); }
else if (rk != null && rk.GetAttribute("value") == "入库(C)")
{ rk.Click += new HtmlElementEventHandler(rk_Click); }
else if (rk != null && rk.GetAttribute("value") == "入库")
{ rk.Click += new HtmlElementEventHandler(rk_Click); }
else if (tj != null && tj.GetAttribute("value") == "提交")
{ tj.Click += new HtmlElementEventHandler(tj_Click); } if (inputpwd != null && _pwd.ToLower() == "true")
{
inputpwd.Focusing += new HtmlElementEventHandler(inputpwd_Focusing);
}
if (inputpwd1 != null && _pwd.ToLower() == "true")
{ inputpwd1.Focusing += new HtmlElementEventHandler(inputpwd1_Focusing); } if (inputpwd2 != null && _pwd.ToLower() == "true")
{ inputpwd2.Focusing += new HtmlElementEventHandler(inputpwd2_Focusing); } if (telnum != null)
{
telnum.LosingFocus += new HtmlElementEventHandler(telnum_LosingFocus);
}
}
catch (Exception ee)
{
string errtext = DateTime.Now.ToString() + " 错误:" + ee.Message;
cls.log(errtext);
} }
else
{
loadhtml = webBrowser1.DocumentText;
loadurl = webBrowser1.Url.ToString();
}
} void tj_Click(object sender, HtmlElementEventArgs e)
{
if (ppstate == 1)
{
Thread qdpj = new Thread(new ThreadStart(playjj));
qdpj.Start();
} } void rk_Click(object sender, HtmlElementEventArgs e)
{
Thread qdpj = new Thread(new ThreadStart(playjj));
qdpj.Start();
} void qd2_Click(object sender, HtmlElementEventArgs e)
{
if (ppstate == 1)
{
Thread qdpj = new Thread(new ThreadStart(playjj));
qdpj.Start();
}
} void qd1_Click(object sender, HtmlElementEventArgs e)
{
if (ppstate == 1)
{
Thread qdpj = new Thread(new ThreadStart(playjj));
qdpj.Start();
}
} private void timer2_Tick(object sender, EventArgs e)
{ } private void toolStripButton6_Click(object sender, EventArgs e)
{
推荐 tj = new 推荐();
tj.Show(this);
} /// <summary>
/// 关闭程序和端口
/// </summary>
private void safeport()
{
if (isCommPortUsed() != 0)
{
Cls.COMMPARAMETER stCommParam;
stCommParam.nPort = Cls._nport;
stCommParam.nBaudRate = Cls._nBaudRate;
stCommParam.nByteSize = Cls._nByteSize;
stCommParam.nParity = Cls._nparity;
stCommParam.nStopBits = Cls._nstopbits;
CloseApplication(ref stCommParam);
ForceCloseCommPort(ref stCommParam);
Thread.Sleep(1000);
}
}
}
}
1、服务器端捕捉异常,加 try...catch... finally 或用 windbg 跟进检查;
2、查看服务器系统日志,看是否能有其他收获。ps: ApplicationSettings 最好加上 try...catch ,原因: web.config 或 App.config 中可能泄漏节点
【原创家庭记账簿1.2,简单实用,欢迎工薪阶层、家庭主妇下载使用
http://download.csdn.net/source/1894835】
你说的很有道理,我也这样提过问题,得到的答案就是仔细检查你的代码,可定哪有有问题,或让我加上try cacth ,很多还说没有代码无法帮分析,我也知道这么长的代码很难看,没有办法啊。
提供个代码,只供分析用,谢谢楼上的兄弟热情提示。