public void HelloWorldResult(IAsyncResult ar) { bool bval = false; WebService.Service ws = (WebService.Service)ar.AsyncState; try { string ip = ws.EndHelloWorld(ar); if (ip.IndexOf('.') > 0) { bval = true; if (bChkVersion == false) { WebService.Service wss = new hStore.WebService.Service(); AsyncCallback GetCurrentTimeCallBack = new AsyncCallback(GetCurrentTimeResult); wss.BeginGetCurrentTime(GetCurrentTimeCallBack, wss); //Thread td = new Thread(new ThreadStart(GetRemoteVersion)); //td.Start(); bChkVersion = true; } } Global.wwanConnected = bval; } catch (Exception e) { System.Diagnostics.Debug.WriteLine("HelloWorldResult Exception:" + e.Message); } finally { ws.Dispose(); } }
//private void GetRemoteVersion() //{ // WebService.Service ws = new WebService.Service(); // AsyncCallback GetVersionInfoNoneCallBack = new AsyncCallback(GetVersionInfoNoneResult); // ws.BeginGetVersionInfoNone(sFileNameL, GetVersionInfoNoneCallBack, ws); //} private void getUserInf() { frmMessage frmMessage = new frmMessage(); frmMessage.ShowDialog("是否更新用户资料库?", "提示", "确定", "取消"); if (frmMessage.ret == true) { WebService.Service ws = new WebService.Service(); AsyncCallback GetUserInfCallBack = new AsyncCallback(GetUserInfResult); ws.BegingetUserInf("3", GetUserInfCallBack, ws); } }
public void GetVersionInfo2Result(IAsyncResult ar) { WebService.Service ws = (WebService.Service)ar.AsyncState; try { DataTable dtRaw = new DataTable(); try { dtRaw = ws.EndGetVersionInfo2(ar); string fname = ""; for (int i = 0; i < dtRaw.Rows.Count; i++) { if (dtRaw.Rows[i]["FILEINFO"] != DBNull.Value) { fname = dtRaw.Rows[i]["FILENAME"].ToString(); if (File.Exists(sFilePathLu + fname)) { File.Delete(sFilePathLu + fname); } byte[] tmpFile = (byte[])dtRaw.Rows[i]["FILEINFO"]; FileStream fs = new FileStream(sFilePathLu + fname, FileMode.CreateNew); BinaryWriter bw = new BinaryWriter(fs); bw.Write(tmpFile, 0, tmpFile.Length); bw.Close(); fs.Close(); } } SetVersion(sVersionL + "+"); Business.SaveConfig(Global.appPath + @"\config.xml", sVersionL, sVersionR, sFileNameL); } catch { } finally { dtRaw.Dispose(); } } catch { } finally { ws.Dispose(); } }
public void GetVersionInfoNoneResult(IAsyncResult ar) { WebService.Service ws = (WebService.Service)ar.AsyncState; try { DataTable dt = new DataTable(); bool bUpdate = false; try { dt = ws.EndGetVersionInfoNone(ar); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["FILENAME"].ToString().ToUpper() == sFileNameL.ToUpper()) { sVersionR = dt.Rows[i]["VERSIONNO"].ToString(); break; } } } catch { } finally { dt.Dispose(); } bUpdate = CheckVersion(sVersionL, sVersionR); if (bUpdate) { WebService.Service ws2 = new WebService.Service(); AsyncCallback GetVersionInfo2CallBack = new AsyncCallback(GetVersionInfo2Result); ws.BeginGetVersionInfo2(sFileNameL, sVersionL, GetVersionInfo2CallBack, ws2); } } catch { } finally { ws.Dispose(); } }
private void aliveTimer_Tick(object sender, EventArgs e) { aliveTimer.Enabled = false; WebService.Service ws = new WebService.Service(); AsyncCallback HelloWorldCallBack = new AsyncCallback(HelloWorldResult); ws.BeginHelloWorld(HelloWorldCallBack, ws); if (Global.socketClient.Connected) { Global.socketClient.SendToSession("##0024ZDUA00alive;9999@@"); } Business.InvokeMethod(Global.frmCurrent, "showConnect", new object[] { }); aliveTimer.Enabled = true; }
public void GetUserInfResult(IAsyncResult ar) { WebService.Service ws = (WebService.Service)ar.AsyncState; try { string sql; string userid; string pwd; DataTable dt = new DataTable(); try { dt = ws.EndgetUserInf(ar); sql = "delete from userinf"; SqlCe.ExecuteNonQuery(sql); for (int i = 0; i < dt.Rows.Count; i++) { userid = dt.Rows[i]["USERID"].ToString(); pwd = dt.Rows[i]["PWD"].ToString(); sql = "insert into userinf (USERID,PWD) values('" + userid + "','" + pwd + "')"; SqlCe.ExecuteNonQuery(sql); } frmMessage frmMessage = new frmMessage(); frmMessage.ShowDialog("用户资料库已更新!", "提示", "确定"); frmMessage.Dispose(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } finally { dt.Dispose(); } } catch { } finally { ws.Dispose(); } }
public void GetCurrentTimeResult(IAsyncResult ar) { WebService.Service ws = (WebService.Service)ar.AsyncState; try { DateTime dt = ws.EndGetCurrentTime(ar); Business.SetCurrentTime(dt); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("GetCurrentTimeResult Exception:" + e.Message); } finally { ws.Dispose(); } }