예제 #1
0
        protected override void OnStart(string[] args)
        {
            WeiboString.log("CpuTempService Start.");
            Thread workerThread = new Thread(workerObject.DoWork);

            // Start the worker thread.
            workerThread.Start();
        }
예제 #2
0
 private void HardwareRemoved(IHardware hardware)
 {
     WeiboString.log(hardware.Name);
     foreach (IHardware subHardware in hardware.SubHardware)
     {
         // System.Console.WriteLine(subHardware.Name);
     }
 }
예제 #3
0
        public void VisitHardware(IHardware hardware)
        {
            hardware.Update();
            WeiboString.log(WeiboString.creator(hardware));
            WeiboService weibo = new WeiboService();

            weibo.Statuses_Update(WeiboString.creator(hardware));
            foreach (IHardware subHardware in hardware.SubHardware)
            {
                subHardware.Accept(this);
            }
        }
예제 #4
0
        public virtual string HttpPost(string url, string param)
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);

            request.Method            = "POST";
            request.ContentType       = "application/x-www-form-urlencoded";
            request.Accept            = "*/*";
            request.Timeout           = 15000;
            request.AllowAutoRedirect = false;

            StreamWriter requestStream = null;
            WebResponse  response      = null;
            string       responseStr   = null;

            try
            {
                requestStream = new StreamWriter(request.GetRequestStream());
                requestStream.Write(param);
                requestStream.Close();

                response = request.GetResponse();
                if (response != null)
                {
                    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
                    responseStr = reader.ReadToEnd();
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                // throw;
                WeiboString.log(ex.Message);
            }
            finally
            {
                request       = null;
                requestStream = null;
                response      = null;
            }

            return(responseStr);
        }
예제 #5
0
 protected override void OnStop()
 {
     WeiboString.log("CpuTempService Stop.");
     workerObject.RequestStop();
 }