Exemple #1
0
        /// <summary>
        /// 回调函数
        /// </summary>
        /// <param name="rs"></param>
        public void SendCallBack(IAsyncResult rs)
        {
            if (rs.IsCompleted)
            {
                SendStateObject state = rs.AsyncState as SendStateObject;

                WebRequest rq = state.rq;
                try
                {
                WebResponse response = rq.GetResponse();
                Stream dataStream = state.str;
                dataStream = response.GetResponseStream();

                    sys_FrameWorkInfoTable Webfi = new BinaryFormatter().Deserialize(dataStream) as sys_FrameWorkInfoTable;
                    //CheckOk = true;
                    CheckReturn = Webfi;
                    if (Convert.ToDecimal(FrameSystemInfo.GetSystemInfoTable.S_FrameWorkInfo.S_Version.Replace(".","")) < Convert.ToDecimal(Convert.ToDecimal(Webfi.S_Version.Replace(".",""))))
                    {
                        CheckNewVer = true;
                    }
                    //更新Licensed验证字段
                    if (Webfi.S_Licensed == "False")
                        _CheckLicensed = false;
                }
                //catch (Exception ex)
                //{
                //    if (ex.InnerException != null) ex = ex.InnerException;
                //    if (Common.DispError == false)
                //        FileTxtLogs.WriteLog(ex.Source + " thrown " + ex.GetType().ToString() + "<br />" + ex.Message.Replace("\r", "").Replace("\n", "<br />") + "<br />" + ex.StackTrace.Replace("\r", "").Replace("\n", "<br />"));
                //}
                finally
                {
                    rq.Abort();
                    //response.Close();
                    //dataStream.Close();
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 发送接收返回方法
        /// </summary>
        public void SendDataWeb()
        {
            CheckOk = true;
            if (_CheckCount < 3)
            {
                _CheckCount++;
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(FrameSystemInfo.GetSystemInfoTable.S_FrameWorkInfo.S_UpdateUrl);
                request.Timeout = 6000;
                request.Method = "POST";
                byte[] byteArray = FrameSystemInfo.Serializable_sys_FrameWorkInfoTable(FrameSystemInfo.GetSystemInfoTable.S_FrameWorkInfo);
                request.ContentLength = byteArray.Length;
                try
                {
                    bool a = request.HaveResponse;

                    Stream dataStream = request.GetRequestStream();

                    //if (dataStream.CanWrite)
                    //{
                    //    SendStateObject state = new SendStateObject();
                    //    state.rq = request;
                    //    state.str = dataStream;
                    //     dataStream.BeginWrite(byteArray, 0, byteArray.Length, new AsyncCallback(SendCallBack), state);
                    //}
                    dataStream.Write(byteArray, 0, byteArray.Length);
                    //// Close the Stream object.
                    dataStream.Close();
                    //// Get the response.
                    WebResponse response = request.GetResponse();
                    //// Display the status.

                    ////Console.WriteLine(((HttpWebResponse)response).StatusDescription);
                    dataStream = response.GetResponseStream();

                    sys_FrameWorkInfoTable Webfi = new BinaryFormatter().Deserialize(dataStream) as sys_FrameWorkInfoTable;
                    //CheckOk = true;
                    CheckReturn = Webfi;
                    if (Convert.ToDecimal(FrameSystemInfo.GetSystemInfoTable.S_FrameWorkInfo.S_Version.Replace(".", "")) < Convert.ToDecimal(Convert.ToDecimal(Webfi.S_Version.Replace(".", ""))))
                    {
                        CheckNewVer = true;
                    }
                    //更新Licensed验证字段
                    if (Webfi.S_Licensed == "False")
                        _CheckLicensed = false;

                    //sys_FrameWorkInfoTable Webfi = new BinaryFormatter().Deserialize(dataStream) as sys_FrameWorkInfoTable;

                    //CheckOk = true;
                    //CheckReturn = Webfi;
                    //if (Convert.ToDecimal(FrameSystemInfo.GetSystemInfoTable.S_FrameWorkInfo.S_Version.Replace(".", "")) < Convert.ToDecimal(Webfi.S_Version.Replace(".", "")))
                    //{
                    //    CheckNewVer = true;
                    //}
                    dataStream.Close();
                    response.Close();
                    request.Abort();
                }
                catch
                {
                    request.Abort();
                    //if (ex.InnerException != null) ex = ex.InnerException;
                    //if (Common.DispError == false)
                    //    FileTxtLogs.WriteLog(ex.Source + " thrown " + ex.GetType().ToString() + "<br />" + ex.Message.Replace("\r", "").Replace("\n", "<br />") + "<br />" + ex.StackTrace.Replace("\r", "").Replace("\n", "<br />"));
                }
            }
        }
 /// <summary>
 /// 序列化sys_FrameWorkInfoTable类
 /// </summary>
 /// <param name="it">sys_FrameWorkInfoTable类</param>
 /// <returns>byte[]字节流</returns>
 public static byte[] Serializable_sys_FrameWorkInfoTable(sys_FrameWorkInfoTable it)
 {
     IFormatter formatter = new BinaryFormatter();
     MemoryStream ms = new MemoryStream();
     byte[] b;
     formatter.Serialize(ms, it);
     ms.Position = 0;
     b = new byte[ms.Length];
     ms.Read(b, 0, b.Length);
     ms.Close();
     return b;
 }