Browse Source

和同DMA演示数据推送

yinyujing 4 months ago
parent
commit
0c9238e7ea

+ 6 - 0
TimedUpload/Constants.cs

@@ -33,5 +33,11 @@ namespace TimedUpload
         public static string changLeWaterQualityId = ConfigurationManager.AppSettings["ChangLeWaterQualityId"];
         public static string changLeWaterQualityHisId = ConfigurationManager.AppSettings["ChangLeWaterQualityHisId"];
 
+        public static string UploadUrlHeTong = ConfigurationManager.AppSettings["UploadUrlHeTong"];
+        public static string UploadPortHeTong = ConfigurationManager.AppSettings["UploadPortHeTong"];
+        public static string UploadUserNameHeTong = ConfigurationManager.AppSettings["UploadUserNameHeTong"];
+        public static string UploadPasswordHeTong = ConfigurationManager.AppSettings["UploadPasswordHeTong"];
+        public static string VirtualHostHeTong = ConfigurationManager.AppSettings["VirtualHostHeTong"];
+        public static string DbMySQL = ConfigurationManager.AppSettings["DbMySQL"];
     }
 }

+ 310 - 0
TimedUpload/QuartzJobs/HeTongDataUploadJob.cs

@@ -0,0 +1,310 @@
+using log4net;
+using Quartz;
+using RabbitMQ.Client;
+using RDIFramework.Utilities;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.IO;
+using System.Text;
+using TimedUpload.utils;
+
+namespace TimedUpload.QuartzJobs
+{
+    [DisallowConcurrentExecution]
+    public class HeTongDataUploadJob : IJob
+    {
+        private readonly ILog log = LogManager.GetLogger(typeof(HeTongDataUploadJob));
+        MySqlHelper mySqlHelper = new MySqlHelper("DbMySQL");
+
+        public void Execute(IJobExecutionContext context)
+        {
+            string[] uploadUrls = Constants.UploadUrlHeTong.Split('|');
+            Dictionary<string, IConnection> connections = new Dictionary<string, IConnection>();
+            Dictionary<string, IModel> channels = new Dictionary<string, IModel>();
+            Dictionary<string, IBasicProperties> properties = new Dictionary<string, IBasicProperties>();
+
+            foreach (string uploadUrl in uploadUrls) 
+            {
+                ConnectionFactory factory = new ConnectionFactory();
+                factory.HostName = uploadUrl;//主机名,Rabbit会拿这个IP生成一个endpoint,这个很熟悉吧,就是socket绑定的那个终结点。
+                factory.UserName = Constants.UploadUserNameHeTong;//默认用户名,用户可以在服务端自定义创建,有相关命令行
+                factory.Password = Constants.UploadPasswordHeTong;//默认密码
+                factory.VirtualHost = Constants.VirtualHostHeTong;
+
+                factory.AutomaticRecoveryEnabled = true; // 链接断开会自动重连
+
+                IConnection connection = factory.CreateConnection();
+                IModel channel = connection.CreateModel();
+                channel.QueueDeclare("archives.dmaDevice.exchange", true, false, false, null);//创建一个名称为kibaqueue的消息队列
+                channel.QueueDeclare("data.dmaDeviceData.exchange", true, false, false, null);//创建一个名称为kibaqueue的消息队列
+
+                IBasicProperties property = channel.CreateBasicProperties();
+                property.ContentType = "text/plain";
+                property.DeliveryMode = 2; //持久化
+                connections.Add(uploadUrl, connection);
+                properties.Add(uploadUrl, property);
+                channels.Add(uploadUrl, channel);
+            }
+
+            if (channels.Count > 0) 
+            {
+                //SendZoneDevice(channels, properties);
+                SendZoneDeviceHis(channels, properties);
+            }
+
+            foreach (KeyValuePair<string, IConnection> item in connections)
+            {
+                IConnection connection = item.Value;
+                connection.Close();
+            }
+        }
+
+        /// <summary>
+        /// 大表设备添加
+        /// </summary>
+        /// <param name="channels"></param>
+        /// <param name="properties"></param>
+        private void SendZoneDevice(Dictionary<string, IModel> channels, Dictionary<string, IBasicProperties> properties)
+        {
+            try
+            {
+                Dictionary<string, string> devIdDic = GetDevIds();
+                string devIdsTmp = "";
+                foreach (KeyValuePair<string, string> item in devIdDic) 
+                {
+                    devIdsTmp += item.Key + ",";
+                }
+                string devIds = devIdsTmp.Substring(0, devIdsTmp.Length - 1);
+
+                log.Info("大表设备同步任务开始执行.................\r\n");
+                string sql = "SELECT MeterAssessmentName,MeterAssessmentCode,ICCID,LngAndLat,IsPressucre,IsFlow,isZoneMeter,isTradeMeter,isLargeUser FROM bs_meterassessmentbase WHERE MeterAssessmentId IN (" + devIds + ")";
+                DataTable dt = mySqlHelper.GetDataTable(sql);
+
+                StringBuilder message = new StringBuilder();
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    message.Clear();
+                    try
+                    {
+                        DataRow dr = dt.Rows[i];
+                        String iccid = "";
+                        if (!"".Equals(dr["ICCID"].ToString()))
+                        {
+                            iccid = dr["ICCID"].ToString().Split(',')[0];
+                        }
+
+                        String lngAndLat = "";
+                        if (!"".Equals(dr["LngAndLat"].ToString()))
+                        {
+                            lngAndLat = dr["LngAndLat"].ToString();
+                        }
+                        message.Append("{\"deviceAdd\":{");
+                        message.Append("\"meterAssessmentName\": \"").Append(dr["MeterAssessmentName"]).Append("\",");
+                        message.Append("\"iccId\": ").Append(iccid).Append(",");
+                        message.Append("\"lngAndLat\": \"").Append(lngAndLat).Append("\",");
+                        message.Append("\"isPressucre\": ").Append(dr["IsPressucre"]).Append(",");
+                        message.Append("\"isFlow\": ").Append(dr["IsFlow"]).Append(",");
+                        message.Append("\"isZoneMeter\": ").Append(dr["isZoneMeter"]).Append(",");
+                        message.Append("\"isTradeMeter\": ").Append(dr["isTradeMeter"]).Append(",");
+                        message.Append("\"isLargeUser\": ").Append(dr["isLargeUser"]).Append(",");
+                        message.Append("\"meterAssessmentCode\": \"").Append(dr["MeterAssessmentCode"]).Append("\",");
+                        message.Append("\"manufacturerCode\": \"ht\"");
+                        message.Append("}}");
+                        foreach (KeyValuePair<string, IModel> item in channels)
+                        {
+                            string key = item.Key;
+                            IModel channel = item.Value;
+                            IBasicProperties property = properties[key];
+                            channel.BasicPublish("archives.dmaDevice.exchange", "", property, Encoding.UTF8.GetBytes(message.ToString())); //生产消息
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        log.Info("大表设备同步任务数据推送失败:" + message.ToString() + "\r\n");
+                        log.Error(ex.Message + "===========" + ex.StackTrace + "\r\n");
+                    }
+                }
+                log.Info("大表设备同步任务执行结束.................\r\n");
+            }
+            catch (Exception ex)
+            {
+                log.Error("大表设备同步任务执行错误:" + ex.Message + "===========" + ex.StackTrace + "\r\n");
+            }
+        }
+
+        /// <summary>
+        /// 大表历史数据
+        /// </summary>
+        /// <param name="channels"></param>
+        /// <param name="properties"></param>
+        private void SendZoneDeviceHis(Dictionary<string, IModel> channels, Dictionary<string, IBasicProperties> properties)
+        {
+            try
+            {
+                log.Info("大表设备历史数据同步和同DMA任务开始执行.................\r\n");
+                Dictionary<String, String> uploadHis = GetDevIds();
+
+                Dictionary<String, String> uploadHisNew = new Dictionary<string, string>();
+                foreach (KeyValuePair<string, string> itemDev in uploadHis)
+                {
+                    string meterId = itemDev.Key;
+                    string lastTime = itemDev.Value;
+
+                    string sql = "SELECT MeterAssessmentCode,GetDateTime,NetCumulativeFlow,PositiveCumulativeFlow,NegativeCumulativeFlow,InstantaneousFlow,Pressure,BatteryVoltageValue FROM bs_meterassessmentbase_" + meterId + " a WHERE a.GetDateTime > '" + lastTime + "' ORDER BY GetDateTime ASC";
+
+                    try
+                    {
+                        DataTable dtMeterHis = mySqlHelper.GetDataTable(sql);
+
+                        StringBuilder message = new StringBuilder();
+                        for (int j = 0; j < dtMeterHis.Rows.Count; j++)
+                        {
+                            message.Clear();
+                            try
+                            {
+                                DataRow drMeterHis = dtMeterHis.Rows[j];
+                                String meterCode = drMeterHis["MeterAssessmentCode"].ToString();
+                                String getDateTime = Convert.ToDateTime(drMeterHis["GetDateTime"]).ToString("yyyy-MM-dd HH:mm:ss");
+                                message.Append("{");
+                                message.Append("\"meterAssessmentCode\": \"").Append(meterCode).Append("\",");
+                                message.Append("\"manufacturerCode\": \"ht\",");
+                                message.Append("\"getDateTime\": \"").Append(getDateTime).Append("\",");
+                                if (Convert.DBNull != drMeterHis["NetCumulativeFlow"])
+                                {
+                                    message.Append("\"netCumulativeFlow\": ").Append(Convert.ToDecimal(drMeterHis["NetCumulativeFlow"])).Append(",");
+                                }
+                                if (Convert.DBNull != drMeterHis["PositiveCumulativeFlow"])
+                                {
+                                    message.Append("\"positiveCumulativeFlow\": ").Append(Convert.ToDecimal(drMeterHis["PositiveCumulativeFlow"])).Append(",");
+                                }
+                                if (Convert.DBNull != drMeterHis["NegativeCumulativeFlow"])
+                                {
+                                    message.Append("\"negativeCumulativeFlow\": ").Append(Convert.ToDecimal(drMeterHis["NegativeCumulativeFlow"])).Append(",");
+                                }
+                                if (Convert.DBNull != drMeterHis["InstantaneousFlow"])
+                                {
+                                    message.Append("\"instantaneousFlow\": ").Append(Convert.ToDecimal(drMeterHis["InstantaneousFlow"])).Append(",");
+                                }
+                                if (Convert.DBNull != drMeterHis["Pressure"])
+                                {
+                                    message.Append("\"pressure\": ").Append(Convert.ToDecimal(drMeterHis["Pressure"])).Append(",");
+                                }
+                                if (Convert.DBNull != drMeterHis["BatteryVoltageValue"])
+                                {
+                                    message.Append("\"batteryVoltageValue\": ").Append(Convert.ToDecimal(drMeterHis["BatteryVoltageValue"])).Append(",");
+                                }
+                                message.Append("}");
+
+                                foreach (KeyValuePair<string, IModel> item in channels)
+                                {
+                                    string key = item.Key;
+                                    IModel channel = item.Value;
+                                    IBasicProperties property = properties[key];
+                                    channel.BasicPublish("data.dmaDeviceData.exchange", "", property, Encoding.UTF8.GetBytes(message.ToString())); //生产消息
+                                }
+                                lastTime = getDateTime;
+                            }
+                            catch (Exception ex)
+                            {
+                                log.Info("大表设备历史记录同步和同DMA任务数据推送失败:" + meterId + "," + message.ToString() + "\r\n");
+                                log.Error(ex.Message + "===========" + ex.StackTrace + "\r\n");
+                                continue;
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        log.Error(meterId + "," + ex.Message + "===========" + ex.StackTrace + "\r\n");
+                    }
+                    uploadHisNew[meterId] = lastTime;
+                }
+
+                SavaUploadHis(uploadHisNew);
+                log.Info("大表设备历史记录同步和同DMA任务执行结束.................\r\n");
+            }
+            catch (Exception ex)
+            {
+                log.Error("大表设备历史记录同步和同DMA任务执行错误:" + ex.Message + "===========" + ex.StackTrace + "\r\n");
+            }
+        }
+
+        private Dictionary<string, string> GetDevIds() 
+        {
+            Dictionary<String, String> uploadHis = new Dictionary<string, string>();
+            using (StreamReader sr = new StreamReader(@"TextFileHeTong.txt"))
+            {
+                String line = "";
+                while ((line = sr.ReadLine()) != null)
+                {
+                    if (!"".Equals(line))
+                    {
+                        String[] item = line.Split(',');
+                        uploadHis[item[0]] = item[1];
+                    }
+                }
+            }
+            return uploadHis;
+        }
+
+        /// <summary>
+        /// 更新配置文件中的值
+        /// </summary>
+        /// <param name="key">键</param>
+        /// <param name="value">值</param>
+        private void UpdateAppConfig(String key, String value)
+        {
+            var cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
+            cfg.AppSettings.Settings[key].Value = value;
+            cfg.Save();
+            ConfigurationManager.RefreshSection("appSettings");
+
+        }
+
+        /// <summary>
+        /// 判断历史记录表是否存在
+        /// </summary>
+        /// <param name="tablename"></param>
+        /// <returns></returns>
+        private bool CheckTableExist(string tablename)
+        {
+            DataTable table = dbHelper.Fill("select top 1 * from sysobjects where name='" + tablename + "' and xtype='u'");
+            if (table == null || table.Rows.Count == 0)
+            {
+                return false;
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// 保存每块块表的上传最后一条历史记录
+        /// </summary>
+        /// <param name="uploadHis"></param>
+        private void SavaUploadHis(Dictionary<String,String> uploadHis)
+        {
+            // 清除之前的内容
+            FileStream stream = File.Open(@"TextFileHeTong.txt", FileMode.OpenOrCreate, FileAccess.Write);
+            stream.Seek(0, SeekOrigin.Begin);
+            stream.SetLength(0);
+            stream.Close();
+
+            using (StreamWriter sw = new StreamWriter(@"TextFileHeTong.txt"))
+            {
+                foreach (var item in uploadHis)
+                {
+                    sw.WriteLine(item.Key + "," + item.Value);
+                }
+            }
+        }
+
+        static IDbProvider dbHelper
+        {
+            get
+            {
+                var DbDefine = DbFactoryProvider.GetProvider(CurrentDbType.SqlServer, Constants.DbConncetion);
+                return DbDefine;
+            }
+        }
+    }
+}

+ 147 - 0
TimedUpload/TextFileHeTong.txt

@@ -0,0 +1,147 @@
+1519478278723735552,2024-10-01
+1519478272230952960,2024-10-01
+1519478275523481603,2024-10-01
+1519478276240707592,2024-10-01
+1519478277935206404,2024-10-01
+1656207444029739008,2024-10-01
+1649216378621661184,2024-10-01
+1519478273677987841,2024-10-01
+1519478273875120128,2024-10-01
+1519478277868097538,2024-10-01
+1519478276639166469,2024-10-01
+1656207444130402304,2024-10-01
+1684116342510194688,2024-10-01
+1790917579804512256,2024-10-01
+1661535045132750848,2024-10-01
+1519478271899602945,2024-10-01
+1519478271966711809,2024-10-01
+1519478271966711810,2024-10-01
+1519478272168038402,2024-10-01
+1519478272168038405,2024-10-01
+1519478272885264384,2024-10-01
+1519478273153699844,2024-10-01
+1519478273153699849,2024-10-01
+1519478273220808706,2024-10-01
+1519478273942228994,2024-10-01
+1519478274994999298,2024-10-01
+1519478275322155011,2024-10-01
+1519478275452178434,2024-10-01
+1519478275523481600,2024-10-01
+1519478275783528454,2024-10-01
+1519478276110684160,2024-10-01
+1519478276374925314,2024-10-01
+1519478276437839872,2024-10-01
+1519478276437839875,2024-10-01
+1519478276437839879,2024-10-01
+1519478276572057604,2024-10-01
+1519478276639166467,2024-10-01
+1519478276836298754,2024-10-01
+1519478276836298755,2024-10-01
+1519478276903407619,2024-10-01
+1519478276966322178,2024-10-01
+1519478277360586755,2024-10-01
+1519478277805182976,2024-10-01
+1519478277998120960,2024-10-01
+1519478278065229824,2024-10-01
+1519478278132338689,2024-10-01
+1519478278132338693,2024-10-01
+1519478278392385537,2024-10-01
+1519478278857953283,2024-10-01
+1519478279185108996,2024-10-01
+1519478279382241280,2024-10-01
+1519478279382241283,2024-10-01
+1519478279382241284,2024-10-01
+1519478279512264704,2024-10-01
+1519478279512264707,2024-10-01
+1519478279512264708,2024-10-01
+1519478279575179265,2024-10-01
+1519478279839420417,2024-10-01
+1519478280036552704,2024-10-01
+1519478280627949568,2024-10-01
+1519478280695058435,2024-10-01
+1519478281089323011,2024-10-01
+1519478281089323012,2024-10-01
+1519478281483587586,2024-10-01
+1519478281483587588,2024-10-01
+1519478282012069890,2024-10-01
+1519478282074984450,2024-10-01
+1519478283194863620,2024-10-01
+1519478283786260481,2024-10-01
+1519478284578983939,2024-10-01
+1519478284709007360,2024-10-01
+1519478284843225089,2024-10-01
+1519478284906139649,2024-10-01
+1519478285304598529,2024-10-01
+1519478285631754241,2024-10-01
+1519478286286065664,2024-10-01
+1519478287275921408,2024-10-01
+1519478287405944835,2024-10-01
+1519478287733100545,2024-10-01
+1519478287863123969,2024-10-01
+1519478288785870851,2024-10-01
+1519478288852979712,2024-10-01
+1519478288983003138,2024-10-01
+1519478289113026561,2024-10-01
+1519478289180135425,2024-10-01
+1519478290362929153,2024-10-01
+1519478290761388032,2024-10-01
+1519478290828496897,2024-10-01
+1519478291021434882,2024-10-01
+1519478291285676035,2024-10-01
+1519478291679940613,2024-10-01
+1519478291881267204,2024-10-01
+1519478292141314048,2024-10-01
+1539425439670341649,2024-10-01
+1583377535121494017,2024-10-01
+1625379272103301120,2024-10-01
+1638702090844901376,2024-10-01
+1639102220647534592,2024-10-01
+1646672106005467136,2024-10-01
+1656864260996730880,2024-10-01
+1519478278723735553,2024-10-01
+1519478292405555204,2024-10-01
+1519478285371707394,2024-10-01
+1519478274860781570,2024-10-01
+1519478278660820992,2024-10-01
+1519478278857953284,2024-10-01
+1519478280099467264,2024-10-01
+1519478282599272448,2024-10-01
+1519478282670575618,2024-10-01
+1519478284578983940,2024-10-01
+1519478285698863105,2024-10-01
+1519478285761777665,2024-10-01
+1519478285895995392,2024-10-01
+1519478287338835969,2024-10-01
+1519478287535968261,2024-10-01
+1519478291285676036,2024-10-01
+1519478292934037506,2024-10-01
+1584733952847908868,2024-10-01
+1597855447669280768,2024-10-01
+1519478276437839878,2024-10-01
+1519478277738074114,2024-10-01
+1519478278262362113,2024-10-01
+1519478279315132416,2024-10-01
+1519478283652042752,2024-10-01
+1519478283719151617,2024-10-01
+1519478283849175040,2024-10-01
+1519478284776116227,2024-10-01
+1519478285434621952,2024-10-01
+1519478285434621956,2024-10-01
+1519478286613221379,2024-10-01
+1519478291218567172,2024-10-01
+1519478291612831749,2024-10-01
+1519478292996952067,2024-10-01
+1519478293126975491,2024-10-01
+1582280561244770304,2024-10-01
+1661570276598484992,2024-10-01
+1519478272428085249,2024-10-01
+1519478277557719041,2024-10-01
+1519478279969443841,2024-10-01
+1519478287405944833,2024-10-01
+1519478292074205189,2024-10-01
+1519478292338446340,2024-10-01
+1519478280233684996,2024-10-01
+1519478284448960515,2024-10-01
+1661555177557069824,2024-10-01
+1661560210717675520,2024-10-01
+1661625641579057152,2024-10-01

+ 4 - 2
TimedUpload/TimedUpload.csproj

@@ -56,7 +56,7 @@
     <GenerateManifests>true</GenerateManifests>
   </PropertyGroup>
   <PropertyGroup>
-    <SignManifests>true</SignManifests>
+    <SignManifests>false</SignManifests>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
@@ -113,6 +113,7 @@
     <Compile Include="QuartzJobs\ChangleWaterFactoryDataJob.cs" />
     <Compile Include="QuartzJobs\ChangleWorkmanshipDataUploadJob.cs" />
     <Compile Include="QuartzJobs\DABusinessDataJob.cs" />
+    <Compile Include="QuartzJobs\HeTongDataUploadJob.cs" />
     <Compile Include="QuartzJobs\jingshanDataUploadDataJob.cs" />
     <Compile Include="QuartzJobs\NoiseDataUploadJob.cs" />
     <Compile Include="QuartzJobs\TestJob.cs" />
@@ -125,6 +126,7 @@
     <Compile Include="ServiceRunner.cs" />
     <Compile Include="utils\BusinessEntity.cs" />
     <Compile Include="utils\CommonUtil.cs" />
+    <Compile Include="utils\MySqlHelper.cs" />
     <Compile Include="utils\OracleHelper.cs" />
     <Compile Include="WebHelper.cs" />
   </ItemGroup>
@@ -145,13 +147,13 @@
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
       <SubType>Designer</SubType>
     </None>
-    <None Include="TimedUpload_TemporaryKey.pfx" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="quartz_jobs.xml">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
       <SubType>Designer</SubType>
     </Content>
+    <Content Include="TextFileHeTong.txt" />
     <Content Include="TextFile1.txt" />
   </ItemGroup>
   <ItemGroup>

+ 9 - 1
TimedUpload/app.config

@@ -32,9 +32,17 @@
     <add key="WaterFactoryColumn" value="MeterCode,ReadTime,NetCumulativeFlow,InstantaneousFlow,Pressure,PH,Chlorine,Turbidity" />
 
     <add key="SecondaryPumpColumn" value="PumpCode,ReadTime,Frequency,Current,RunState,Power,Voltage" />
-    
+
 
     <add key="ServiceName" value="二供和水厂同步智慧水务系统" />
+    <!-- 和同智慧水务系统RabbitMQ信息 start -->
+    <add key="DbMySQL" value="data source=182.92.149.41;database=smartwater;user id=root;password=wwkj@2136807;pooling=false;charset=utf8" />
+    <add key="UploadUrlHeTong" value="47.104.100.143" />
+    <add key="UploadPortHeTong" value="5672" />
+    <add key="UploadUserNameHeTong" value="admin" />
+    <add key="UploadPasswordHeTong" value="Hetong@2022$05" />
+    <add key="VirtualHostHeTong" value="sw_vhost" />
+    <!-- 和同智慧水务系统RabbitMQ信息 end -->
   </appSettings>
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

+ 21 - 1
TimedUpload/quartz_jobs.xml

@@ -264,7 +264,7 @@
     </trigger>-->
 
     <!--荆山水厂分区计量数据定时上传数据-->
-    <job>
+    <!--<job>
       <name>jingshanDataUploadDataJob</name>
       <group>jingshanDataUploadData</group>
       <description>数据定时上传服务</description>
@@ -281,6 +281,26 @@
         <start-time>2017-08-08T00:00:00+08:00</start-time>
         <cron-expression>0 0/30 * * * ? *</cron-expression>
       </cron>
+    </trigger>-->
+
+    <!--和同分区计量数据定时上传数据-->
+    <job>
+      <name>HeTongDataUploadJob</name>
+      <group>HeTongDataUpload</group>
+      <description>数据定时上传服务</description>
+      <job-type>TimedUpload.QuartzJobs.HeTongDataUploadJob,TimedUpload</job-type>
+      <durable>true</durable>
+      <recover>false</recover>
+    </job>
+    <trigger>
+      <cron>
+        <name>HeTongDataUploadJobTrigger</name>
+        <group>HeTongDataUpload</group>
+        <job-name>HeTongDataUploadJob</job-name>
+        <job-group>HeTongDataUpload</job-group>
+        <start-time>2017-08-08T00:00:00+08:00</start-time>
+        <cron-expression>0 0/30 * * * ? *</cron-expression>
+      </cron>
     </trigger>
   </schedule>
 </job-scheduling-data>

+ 61 - 0
TimedUpload/utils/MySqlHelper.cs

@@ -0,0 +1,61 @@
+using MySql.Data.MySqlClient;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Text;
+
+namespace TimedUpload.utils
+{
+    public class MySqlHelper
+    {
+        private readonly string connStr;
+
+        public MySqlHelper(string configConnStrKey)
+        {
+            connStr = ConfigurationManager.AppSettings[configConnStrKey];
+        }
+
+        public DataTable GetDataTable(string sql)
+        {
+            MySqlCommand cmd;
+            MySqlConnection con = new MySqlConnection(connStr);
+            MySqlDataAdapter msa;
+            try
+            {
+                con.Open();
+                cmd = new MySqlCommand(sql, con);
+                msa = new MySqlDataAdapter(cmd);
+                DataTable dt = new DataTable();
+                msa.Fill(dt);
+                con.Close();
+                return dt;
+            }
+            catch (Exception ex)
+            {
+                con.Close();
+                return null;
+            }
+        }
+
+        public int ExecuteNonQuery(string sql)
+        {
+            MySqlCommand cmd;
+            MySqlConnection con = new MySqlConnection(connStr);
+            try
+            {
+                con.Open();
+                cmd = new MySqlCommand(sql, con);
+                int rs = cmd.ExecuteNonQuery();
+                con.Close();
+                return rs;
+            }
+            catch (Exception ex)
+            {
+                con.Close();
+                return 0;
+            }
+        }
+    }
+}