コード例 #1
0
        protected override void OnStart(string[] args)
        {
            sTimeToSend = System.Configuration.ConfigurationManager.AppSettings["Hour"];

            //Initialize Timer
            iRippleWindowsServiceTimer          = new System.Timers.Timer(3600000);
            iRippleWindowsServiceTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.RippleWindowsServiceTimer_Tick);
            iRippleWindowsServiceTimer.Enabled  = true;

            RippleLogEvent.WriteEntry("Ripple Windows Service Started");
        }
コード例 #2
0
        private void UpdateTelemetry()
        {
            DataSet       telemetryData = new DataSet();
            XmlSerializer reader;
            StreamReader  telemetryFile = null;

            try
            {
                if (File.Exists(TelemetryFilePath))
                {
                    reader        = new XmlSerializer(typeof(DataSet));
                    telemetryFile = new StreamReader(TelemetryFilePath);
                    telemetryData = (DataSet)reader.Deserialize(telemetryFile);
                    telemetryFile.Close();
                    telemetryFile.Dispose();

                    //Insert in the Database
                    using (SqlConnection sqlConn = new SqlConnection(GetConnectionString()))
                    {
                        sqlConn.Open();
                        //Insert the new data
                        using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConn))
                        {
                            bulkCopy.DestinationTableName = TargetTableName;

                            bulkCopy.WriteToServer(telemetryData.Tables[0]);
                        }
                        sqlConn.Close();

                        //Successfull, hence delete the file
                        File.Delete(TelemetryFilePath);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                reader = null;
                if (telemetryFile != null)
                {
                    telemetryFile.Close();
                    telemetryFile.Dispose();
                }
                RippleLogEvent.WriteEntry(String.Format("Went wrong in uploading the telemetry data to teh database {0}", ex.Message));
            }
        }
コード例 #3
0
 protected override void OnStop()
 {
     RippleLogEvent.WriteEntry("Ripple Windows Service Stopped");
 }