コード例 #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 static void log(string log_msg)
        {
            string strTempFileName = System.IO.Path.GetTempPath() + WeiboString.log_filename();

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(strTempFileName, true))
            {
                sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + log_msg);
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
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);
        }
コード例 #6
0
 protected override void OnStop()
 {
     WeiboString.log("CpuTempService Stop.");
     workerObject.RequestStop();
 }