Explorar el Código

build project

czt hace 1 mes
commit
3b8ac7c237

+ 63 - 0
.gitattributes

@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs     diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following 
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln       merge=binary
+#*.csproj    merge=binary
+#*.vbproj    merge=binary
+#*.vcxproj   merge=binary
+#*.vcproj    merge=binary
+#*.dbproj    merge=binary
+#*.fsproj    merge=binary
+#*.lsproj    merge=binary
+#*.wixproj   merge=binary
+#*.modelproj merge=binary
+#*.sqlproj   merge=binary
+#*.wwaproj   merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg   binary
+#*.png   binary
+#*.gif   binary
+
+###############################################################################
+# diff behavior for common document formats
+# 
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the 
+# entries below.
+###############################################################################
+#*.doc   diff=astextplain
+#*.DOC   diff=astextplain
+#*.docx  diff=astextplain
+#*.DOCX  diff=astextplain
+#*.dot   diff=astextplain
+#*.DOT   diff=astextplain
+#*.pdf   diff=astextplain
+#*.PDF   diff=astextplain
+#*.rtf   diff=astextplain
+#*.RTF   diff=astextplain

+ 261 - 0
.gitignore

@@ -0,0 +1,261 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+#*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc

+ 22 - 0
TimedUpload.sln

@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26430.14
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimedUpload", "TimedUpload\TimedUpload.csproj", "{54D76C85-4B6F-44D6-9B95-8B4BB411FC4D}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{54D76C85-4B6F-44D6-9B95-8B4BB411FC4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{54D76C85-4B6F-44D6-9B95-8B4BB411FC4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{54D76C85-4B6F-44D6-9B95-8B4BB411FC4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{54D76C85-4B6F-44D6-9B95-8B4BB411FC4D}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 42 - 0
TimedUpload/Model/LeakModel.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FlowAlert.Model
+{
+    public class LeakModel
+    {
+        public LeakModel()
+        {
+            Color = false;
+            ContinuousFlow = "0";
+            AvgFlow = "--";
+            MaxFlow = "--";
+            SuspectedLeakFlow = "--";
+            SuspectedLeakRate = "--";
+            NightAllowLeakFlow = "--";
+            WaterSupply = "--";
+            SalesWater = "--";
+            MinFlow = "--";
+            SysWaterSupply = "--";
+            SysSalesWater = "--";
+            CalMinFlow = "--";
+
+        }
+        public bool Color { get; set; }
+        public string ContinuousFlow { get; set; }
+        public string AvgFlow { get; set; }
+        public string SuspectedLeakFlow { get; set; }
+        public string SuspectedLeakRate { get; set; }
+        public string NightAllowLeakFlow { get; set; }
+        public string WaterSupply { get; set; }
+        public string SalesWater { get; set; }
+        public string MinFlow { get; set; }
+        public string MaxFlow { get; set; }
+        public string CalMinFlow { get; set; }
+        public string IntervalDays { get; set; }
+        public string SysWaterSupply { get; set; }
+        public string SysSalesWater { get; set; }
+    }
+}

+ 89 - 0
TimedUpload/Program.cs

@@ -0,0 +1,89 @@
+using FlowAlert.Model;
+using Quartz;
+using Quartz.Impl;
+using RDIFramework.Utilities;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Text;
+using Topshelf;
+
+namespace TimedUpload
+{
+    class Program
+    {
+        private static string programName = ConfigurationManager.AppSettings["serverName"];
+        static void Main(string[] args)
+        {
+            
+            log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
+            try
+            {
+                HostFactory.Run(x =>
+                {
+                    x.UseLog4Net();
+
+                    x.Service<ServiceRunner>();
+
+                    x.SetDescription(programName);
+                    x.SetDisplayName(programName);
+                    x.SetServiceName(programName);
+
+                    x.EnablePauseAndContinue();
+                });
+              
+
+            }
+            catch (Exception ex)
+            {
+                Console.Write(ex.Message);
+            }
+
+        }
+    }
+    public class DataUploadService
+    {
+        private readonly IScheduler scheduler;
+
+        public DataUploadService()
+        {
+            scheduler = StdSchedulerFactory.GetDefaultScheduler();
+        }
+
+        public bool Start()
+        {
+            scheduler.Start();
+            return true;
+        }
+
+        public bool Stop()
+        {
+            scheduler.Shutdown(false);
+            return true;
+        }
+
+        public bool Continue()
+        {
+            scheduler.ResumeAll();
+            return true;
+        }
+
+        public bool Pause()
+        {
+            scheduler.PauseAll();
+            return true;
+        }
+
+        public bool AddJobTrigger(IJobDetail jobDetail, ITrigger trigger)
+        {
+            if (scheduler != null)
+            {
+                scheduler.ScheduleJob(jobDetail, trigger);
+            }
+            return true;
+        }
+    }
+}

+ 36 - 0
TimedUpload/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("TimedUpload")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("TimedUpload")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("54d76c85-4b6f-44d6-9b95-8b4bb411fc4d")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 311 - 0
TimedUpload/QuartzJobs/DBDataUploadJob.cs

@@ -0,0 +1,311 @@
+using FlowAlert.Model;
+using log4net;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Quartz;
+using RDIFramework.Utilities;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Data.SqlClient;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Security.Cryptography;
+using System.Text;
+using System.Web.Security;
+
+namespace TimedUpload.QuartzJobs
+{
+    public class DBDataUploadJob : IJob
+    {
+        private readonly ILog log = LogManager.GetLogger(typeof(DBDataUploadJob));
+        private static DateTime timeStampStartTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+
+        static IDbProvider dbHelper
+        {
+            get
+            {
+                var DbDefine = DbFactoryProvider.GetProvider(CurrentDbType.SqlServer, Config.GetValue("DBDbConn"));
+                return DbDefine;
+            }
+        }
+
+        public void Execute(IJobExecutionContext context)
+        {
+            try
+            {
+
+                UploadDataInfo();
+
+
+            }
+            catch (Exception ex)
+            {
+                log.Error("上传数据错误:" + ex.Message);
+            }
+        }
+        /// <summary>
+        /// 上传数据
+        /// </summary>
+        public void UploadDataInfo()
+        {
+            String result;
+
+            try
+            {
+                string firstUpdateTime = ConfigurationManager.AppSettings["firstUpdateTime"];
+                string ids = ConfigurationManager.AppSettings["manageId"];
+                string historySql = "INSERT INTO UpdateHisHeZe (DevId, LastUpTime) SELECT a.ID,'" + firstUpdateTime + "' FROM 设备信息 a WHERE a.管理ID in ("+ ids + ") AND a.id NOT IN (SELECT DevId FROM UpdateHisHeZe)";
+                dbHelper.ExecuteNonQuery(historySql);
+
+                var sql = "SELECT a.*,LEFT(c.传输协议参数, CHARINDEX(',', c.传输协议参数) - 1) waterMeterNumber FROM dbo.UpdateHisHeZe a left join 设备信息 b on a.DevId = b.ID LEFT JOIN 传输设备 c on b.[传输设备ID] = c.ID ";
+                DataTable dt = dbHelper.Fill(sql);
+                for (int row = 0; row < dt.Rows.Count; row++)
+                {
+                    string waterMeterNumber = dt.Rows[row]["waterMeterNumber"].ToString(); //表身号
+                    string devId = dt.Rows[row]["DevId"].ToString();//表id
+                    string lastUpdateTime = dt.Rows[row]["LastUpTime"].ToString();//最后更新时间
+                    int year = Convert.ToDateTime(lastUpdateTime).Year;
+                    string strTableName = "历史记录_" + ("000000" + devId).Substring(devId.Length, 6) + "_" + year.ToString();
+                    if (!CheckTableExiste(strTableName))
+                    {
+                        //跨年判断
+                        int thisYear = DateTime.Now.Year;
+                        if (thisYear > year)
+                        {
+                            //跨年处理  记录表的更新时间   更新为新一年的 最初时间  例如"2019-01-01 00:00:00"
+                            string UpdateHisNanDanSql = "UPDATE UpdateHisHeZe SET LastUpTime = '" + thisYear + "-01-01 00:00:00.000" + "' WHERE DevId = " + devId;
+                            dbHelper.ExecuteNonQuery(UpdateHisNanDanSql);
+                        }
+                        continue;
+                    };
+                    string selSql = "Select * From " + strTableName + " Where 净累计流量<>-1 And 记录时间 is not null and 采集时间 is not null and 采集时间 > '" + lastUpdateTime + "'  Order By 采集时间 asc";
+
+                    DataTable dtDevHis = dbHelper.Fill(selSql);
+                    StringBuilder str_Param = new StringBuilder();//传递的消息内容
+
+                    if (dtDevHis == null || dtDevHis.Rows.Count == 0)
+                    {
+                        //跨年判断
+                        int nowYear = DateTime.Now.Year;
+                        if (nowYear > year)
+                        {
+                            //跨年处理  记录表的更新时间   更新为新一年的 最初时间  例如"2019-01-01 00:00:00"
+                            string UpdateHisNanDanSql = "UPDATE UpdateHisHeZe SET LastUpTime = '" + nowYear + "-01-01 00:00:00.000" + "' WHERE DevId = " + devId;
+                            dbHelper.ExecuteNonQuery(UpdateHisNanDanSql);
+                        }
+                        continue;
+                    }
+
+                    string now = lastUpdateTime;
+                    int sucessNum = 0;
+                    for (int hisRow = 0; hisRow < dtDevHis.Rows.Count; hisRow++)
+                    {
+                        try
+                        {
+                            str_Param.Clear();
+                            str_Param.Append("{ \"auto\":{");
+                            str_Param.Append("\"client_time\":" + getTimeStamp(DateTime.Now) + ",");
+                            str_Param.Append("\"uuid\":\"" + Guid.NewGuid().ToString() + "\",");
+                            str_Param.Append("\"cc\":\"山东微维\",");
+                            str_Param.Append("\"cv\":\"DB\",");
+                            str_Param.Append("\"proi\":\"DB\",");
+                            str_Param.Append("\"osversion\":\"\",");
+                            str_Param.Append("\"conn\":\"\",");
+
+                            str_Param.Append("\"client_ip\":\"\"");
+                            str_Param.Append("},");
+                            str_Param.Append("\"business\":\"REPORT_PROPERTY\",");
+                            str_Param.Append("\"business_info\":");
+                            str_Param.Append("{");
+                            str_Param.Append("\"CurrentNumber\":\"" + dtDevHis.Rows[hisRow]["净累计流量"] + "\",");
+                            str_Param.Append("\"currentForwardFlow\":\"" + dtDevHis.Rows[hisRow]["正累计流量"] + "\",");
+                            str_Param.Append("\"currentReverseFlow\":\"" + dtDevHis.Rows[hisRow]["负累计流量"] + "\",");
+                            str_Param.Append("\"timestamp\":" + getTimeStamp10(Convert.ToDateTime(dtDevHis.Rows[hisRow]["采集时间"])) + ",");
+                            str_Param.Append("\"Shuibiao_SN\":\"" + waterMeterNumber + "\",");
+                            str_Param.Append("\"companyId\":\"08\",");
+                            str_Param.Append("\"ICCID\":\"\",");
+                            str_Param.Append("\"CSQ\":\"\",");
+                            str_Param.Append("\"NB_IMEI\":\"\",");
+
+
+                            str_Param.Append("\"operators\":\"\",");
+                            str_Param.Append("\"CurrentVoltage\":\"" + dtDevHis.Rows[hisRow]["电池电压"] + "\",");
+                            str_Param.Append("\"instantaneousFlow\":\"" + dtDevHis.Rows[hisRow]["瞬时流量"] + "\",");
+                            str_Param.Append("\"temperature\":\"\"");
+                            str_Param.Append("}");
+                            str_Param.Append("}");
+                            result = postSend(Config.GetValue("UploadDataUrl"), str_Param.ToString());
+                            log.Debug("结果:" + devId + "," + result);
+                            var dicRes = JsonConvert.DeserializeObject<Result>(result);
+                            if (dicRes != null)
+                            {
+                                if (dicRes.state == "0")
+                                {
+
+                                    log.Debug(devId + "上传成功");
+                                    sucessNum++;
+
+                                }
+                                else
+                                {
+                                    log.Debug(devId + "上传失败");
+
+                                }
+                            }
+                            now = dtDevHis.Rows[hisRow]["采集时间"].ToString();
+                        }
+                        catch (Exception ex)
+                        {
+                            log.Error("上传抄表数据异常:【" + devId + "】" + str_Param.ToString());
+                            log.Error("异常信息:" + ex.StackTrace);
+                            continue;
+                        }
+                        //更新 记录表
+                        string UpdateHisNanDanSql = "UPDATE UpdateHisHeZe SET LastUpTime = '" + now + "' WHERE DevId = " + devId;
+                        dbHelper.ExecuteNonQuery(UpdateHisNanDanSql);
+                    }
+                    log.Info("上传抄表数据【" + devId + "】,共:【" + dtDevHis.Rows.Count + "】条,成功【" + sucessNum + "】条");
+
+                }
+
+            }
+            catch (Exception ex)
+            {
+
+                log.Debug("上传数据失败:" + ex.ToString());
+            }
+
+
+        }
+    
+        #region 请求接口
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="param"></param>
+        /// <param name="type"></param>
+        /// <param name="webHeader">请求头携带请求权限</param>
+        /// <returns></returns>
+        public string postSend(string url, string param, String type = "POST")
+        {
+            string strResult = "";
+            Encoding myEncode = Encoding.GetEncoding("UTF-8");
+            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
+            req.Method = type;
+            req.ContentType = "application/json; charset=utf-8";
+          
+            
+
+            if (param != null)
+            {
+                byte[] postBytes = Encoding.UTF8.GetBytes(param);
+                req.ContentLength = postBytes.Length;
+                using (Stream reqStream = req.GetRequestStream())
+                {
+                    reqStream.Write(postBytes, 0, postBytes.Length);
+                }
+            }
+
+
+            try
+            {
+
+                using (WebResponse res = req.GetResponse())
+                {
+                    using (StreamReader sr = new StreamReader(res.GetResponseStream(), myEncode))
+                    {
+                        strResult = sr.ReadToEnd();
+                        return strResult;
+                    }
+                }
+            }
+            catch (WebException ex)
+            {
+                log.Error("Post数据出错:" + ex.Message);
+                return "";
+            }
+        }
+        #endregion
+        public string md5Encript(String str) {
+            MD5 md5 = new MD5CryptoServiceProvider();
+            byte[] data = Encoding.UTF8.GetBytes(str);
+            byte[] result = md5.ComputeHash(data);
+            String md5Str = BitConverter.ToString(result).Replace("-","").ToLower();
+            return md5Str;
+
+        }
+        /// <summary>
+        /// 返回13位整数
+        /// </summary>
+        /// <param name="dateTime"></param>
+        /// <returns></returns>
+        public long getTimeStamp(DateTime dateTime) {
+            return (long)(dateTime.ToUniversalTime() - timeStampStartTime).TotalMilliseconds;
+        
+        }
+        public long getTimeStamp10(DateTime dateTime)
+        {
+            return (long)(dateTime.ToUniversalTime() - timeStampStartTime).TotalSeconds;
+
+        }
+
+        public static bool CheckTableExiste(string strTableName)
+        {
+
+            string strSql = "select * from sysobjects where name='" + strTableName + "'";
+            if (CreateDataSet(strSql).Tables[0].Rows.Count == 0)
+            {
+                return false;
+            }
+            return true;
+        }
+
+        public static DataSet CreateDataSet(string strSql)
+        {
+            DataSet dataSet = new DataSet();
+            try
+            {
+
+                dataSet = new DataSet();
+
+                dbHelper.Fill(dataSet, strSql, "checkTable");
+            }
+            catch (Exception exception)
+            {
+                //log.Error("checkTable:" + exception.Message);
+            }
+            return dataSet;
+        }
+
+        class Result {
+            public String state { get; set; }
+            public String data { get; set; }
+            public String msg { get; set; }
+
+
+        }
+      
+        class reResult {
+            public String execCode { get; set; }
+            public String execMsg { get; set; }
+            public String errCode { get; set; }
+
+        }
+
+
+
+    }
+
+
+}
+
+
+       
+
+     
+    

+ 244 - 0
TimedUpload/QuartzJobs/DataUploadJob.cs

@@ -0,0 +1,244 @@
+using FlowAlert.Model;
+using log4net;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Quartz;
+using RDIFramework.Utilities;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Data.SqlClient;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Security.Cryptography;
+using System.Text;
+using System.Web.Security;
+
+namespace TimedUpload.QuartzJobs
+{
+    public class DataUploadJob : IJob
+    {
+        private readonly ILog log = LogManager.GetLogger(typeof(DataUploadJob));
+        private static DateTime timeStampStartTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+
+
+        static IDbProvider dbHelper
+        {
+            get
+            {
+                var DbDefine = DbFactoryProvider.GetProvider(CurrentDbType.SqlServer, Config.GetValue("DbConn"));
+                return DbDefine;
+            }
+        }
+
+        public void Execute(IJobExecutionContext context)
+        {
+            try
+            {
+
+                UploadDataInfo();
+
+
+            }
+            catch (Exception ex)
+            {
+                log.Error("上传数据错误:" + ex.Message);
+            }
+        }
+        /// <summary>
+        /// 上传数据
+        /// </summary>
+        public void UploadDataInfo()
+        {
+            String result;
+
+            try
+            {
+                //CONVERT([int], [表读数])
+                StringBuilder stb = new StringBuilder();
+                String sql = "select * from dbo.V_WaterMeters where NowReading is not null  and CompanyID='" + SystemConfig.CompanyId + "'";
+            
+                DataTable dt = dbHelper.Fill(sql);
+                if (dt != null && dt.Rows.Count > 0)
+                {
+                    int num = 0;
+                    int i = 0;
+                   
+                    log.Debug("~~~~~~~~~~~开始上传数据~~~~~~~~~~~~~");
+                    foreach (DataRow row in dt.Rows) 
+                    {
+                        i += 1;
+                        StringBuilder dataStb = new StringBuilder();
+                        stb.Clear();
+                        stb.Append("{ \"auto\":{");
+                        stb.Append("\"client_time\":" + getTimeStamp(DateTime.Now) +",");
+                        stb.Append("\"uuid\":\"" + Guid.NewGuid().ToString() + "\",");
+                        stb.Append("\"cc\":\"山东微维\",");
+                        stb.Append("\"cv\":\"NB-IOT\",");
+                        stb.Append("\"proi\":\"NB-IOT\",");
+                        stb.Append("\"osversion\":\"\",");
+                        stb.Append("\"conn\":\"\",");
+
+                        stb.Append("\"client_ip\":\"\"");
+                        stb.Append("},");
+                        stb.Append("\"business\":\"REPORT_PROPERTY\",");
+                        stb.Append("\"business_info\":");
+                        stb.Append("{");
+                        stb.Append("\"CurrentNumber\":\"" + row["NowReading"] + "\",");
+                        stb.Append("\"currentForwardFlow\":\"" + row["Total_up"] +"\",");
+                        stb.Append("\"currentReverseFlow\":\"" + row["Total_down"] + "\",");
+                        stb.Append("\"timestamp\":" + getTimeStamp10(Convert.ToDateTime(row["NowRadingDT"])) +",");
+                        stb.Append("\"Shuibiao_SN\":\"" + row["ElecAddress"] +"\",");  
+                        stb.Append("\"companyId\":\"08\",");
+                        stb.Append("\"ICCID\":\""+row["ICCID"]+"\",");
+                        stb.Append("\"CSQ\":\""+row["Rsrp"]+"\",");
+                        stb.Append("\"NB_IMEI\":\""+row["IMEI"]+"\",");
+
+                        
+                        stb.Append("\"operators\":\"CTCC\",");
+                    //    stb.Append("\"CurrentVoltage\":\""+row["BatteryVoltage"])/100*3.6 +"\",");
+                        stb.Append("\"temperature\":\"\"");
+                        stb.Append("}");
+                        stb.Append("}");
+                        result = postSend(Config.GetValue("UploadDataUrl"), stb.ToString());
+                        log.Debug("结果:"+ row["ElecAddress"] +","+result);
+                        
+                        var dicRes = JsonConvert.DeserializeObject<Result>(result);
+                        if (dicRes !=null)
+                        {
+                            if (dicRes.state=="0")
+                            {
+
+                                log.Debug(row["ElecAddress"] + "上传成功" );
+                                num += 1;
+                            
+                            }
+                            else
+                            {
+                                log.Debug(row["ElecAddress"] + "上传失败");
+                              
+                            }
+                        }
+                        if (i==dt.Rows.Count)
+                        {
+                            
+                            log.Debug(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','总共" + dt.Rows.Count + "条,成功上传" + num + "条");
+                        }
+                       
+
+                    }
+                    Config.SetValue("uploadTime",DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
+
+                }
+
+            }
+            catch (Exception ex)
+            {
+
+                log.Debug("上传数据失败:" + ex.ToString());
+            }
+
+
+        }
+    
+        #region 请求接口
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="param"></param>
+        /// <param name="type"></param>
+        /// <param name="webHeader">请求头携带请求权限</param>
+        /// <returns></returns>
+        public string postSend(string url, string param, String type = "POST")
+        {
+            string strResult = "";
+            Encoding myEncode = Encoding.GetEncoding("UTF-8");
+            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
+            req.Method = type;
+            req.ContentType = "application/json; charset=utf-8";
+          
+            
+
+            if (param != null)
+            {
+                byte[] postBytes = Encoding.UTF8.GetBytes(param);
+                req.ContentLength = postBytes.Length;
+                using (Stream reqStream = req.GetRequestStream())
+                {
+                    reqStream.Write(postBytes, 0, postBytes.Length);
+                }
+            }
+
+
+            try
+            {
+
+                using (WebResponse res = req.GetResponse())
+                {
+                    using (StreamReader sr = new StreamReader(res.GetResponseStream(), myEncode))
+                    {
+                        strResult = sr.ReadToEnd();
+                        return strResult;
+                    }
+                }
+            }
+            catch (WebException ex)
+            {
+                log.Error("Post数据出错:" + ex.Message);
+                return "";
+            }
+        }
+        #endregion
+        public string md5Encript(String str) {
+            MD5 md5 = new MD5CryptoServiceProvider();
+            byte[] data = Encoding.UTF8.GetBytes(str);
+            byte[] result = md5.ComputeHash(data);
+            String md5Str = BitConverter.ToString(result).Replace("-","").ToLower();
+            return md5Str;
+
+        }
+        /// <summary>
+        /// 返回13位整数
+        /// </summary>
+        /// <param name="dateTime"></param>
+        /// <returns></returns>
+        public long getTimeStamp(DateTime dateTime) {
+            return (long)(dateTime.ToUniversalTime() - timeStampStartTime).TotalMilliseconds;
+        
+        }
+        public long getTimeStamp10(DateTime dateTime)
+        {
+            return (long)(dateTime.ToUniversalTime() - timeStampStartTime).TotalSeconds;
+
+        }
+
+        class Result {
+            public String state { get; set; }
+            public String data { get; set; }
+            public String msg { get; set; }
+
+
+        }
+      
+        class reResult {
+            public String execCode { get; set; }
+            public String execMsg { get; set; }
+            public String errCode { get; set; }
+
+        }
+
+
+
+    }
+
+
+}
+
+
+       
+
+     
+    

+ 45 - 0
TimedUpload/ServiceRunner.cs

@@ -0,0 +1,45 @@
+using Quartz;
+using Quartz.Impl;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Topshelf;
+
+namespace TimedUpload
+{
+    public class ServiceRunner : ServiceControl, ServiceSuspend
+    {
+        private readonly IScheduler scheduler;
+
+        public ServiceRunner()
+        {
+            scheduler = StdSchedulerFactory.GetDefaultScheduler();
+        }
+
+        public bool Start(HostControl hostControl)
+        {
+            scheduler.Start();
+            return true;
+        }
+
+        public bool Stop(HostControl hostControl)
+        {
+            scheduler.Shutdown(false);
+            return true;
+        }
+
+        public bool Continue(HostControl hostControl)
+        {
+            scheduler.ResumeAll();
+            return true;
+        }
+
+        public bool Pause(HostControl hostControl)
+        {
+            scheduler.PauseAll();
+            return true;
+        }
+
+    }
+}

+ 155 - 0
TimedUpload/TimedUpload.csproj

@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{54D76C85-4B6F-44D6-9B95-8B4BB411FC4D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>TimedUpload</RootNamespace>
+    <AssemblyName>ChargeDataUpload</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="aliyun-net-sdk-core">
+      <HintPath>..\..\TimedUpload\TimedUpload\bin\Debug\aliyun-net-sdk-core.dll</HintPath>
+    </Reference>
+    <Reference Include="aliyun-net-sdk-dybaseapi">
+      <HintPath>..\..\TimedUpload\TimedUpload\bin\Debug\aliyun-net-sdk-dybaseapi.dll</HintPath>
+    </Reference>
+    <Reference Include="aliyun-net-sdk-dysmsapi">
+      <HintPath>..\..\TimedUpload\TimedUpload\bin\Debug\aliyun-net-sdk-dysmsapi.dll</HintPath>
+    </Reference>
+    <Reference Include="Aliyun.MNS">
+      <HintPath>..\..\TimedUpload\TimedUpload\bin\Debug\Aliyun.MNS.dll</HintPath>
+    </Reference>
+    <Reference Include="cn.jpush.api">
+      <HintPath>..\..\TimedUpload\TimedUpload\bin\Debug\cn.jpush.api.dll</HintPath>
+    </Reference>
+    <Reference Include="Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
+      <HintPath>..\packages\Common.Logging.3.3.1\lib\net40\Common.Logging.dll</HintPath>
+    </Reference>
+    <Reference Include="Common.Logging.Core, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
+      <HintPath>..\packages\Common.Logging.Core.3.3.1\lib\net40\Common.Logging.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="log4net">
+      <HintPath>..\packages\log4net.2.0.8\lib\net40-full\log4net.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="Quartz, Version=2.6.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
+      <HintPath>..\packages\Quartz.2.6.0\lib\net40\Quartz.dll</HintPath>
+    </Reference>
+    <Reference Include="RDIFramework.Utilities">
+      <HintPath>..\..\TimedUpload\TimedUpload\bin\Debug\RDIFramework.Utilities.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Web.Extensions" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Topshelf">
+      <HintPath>..\..\TimedUpload\TimedUpload\bin\Debug\Topshelf.dll</HintPath>
+    </Reference>
+    <Reference Include="Topshelf.Log4Net">
+      <HintPath>..\..\TimedUpload\TimedUpload\bin\Debug\Topshelf.Log4Net.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Model\LeakModel.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="QuartzJobs\DataUploadJob.cs" />
+    <Compile Include="QuartzJobs\DBDataUploadJob.cs" />
+    <Compile Include="ServiceRunner.cs" />
+    <Compile Include="utils\Config.cs" />
+    <Compile Include="utils\SystemConfig.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="app.config">
+      <SubType>Designer</SubType>
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Include="job_scheduling_data_2_0.xsd">
+      <SubType>Designer</SubType>
+    </None>
+    <None Include="log4net.config">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+      <SubType>Designer</SubType>
+    </None>
+    <None Include="packages.config" />
+    <None Include="quartz.config">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+      <SubType>Designer</SubType>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="quartz_jobs.xml">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+      <SubType>Designer</SubType>
+    </Content>
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.0">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4 %28x86 和 x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
+      <Visible>False</Visible>
+      <ProductName>Windows Installer 4.5</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 43 - 0
TimedUpload/app.config

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <appSettings>
+    <add key="DbConn" value="Data Source=182.92.149.41;Initial Catalog=Mul_AMRS_NBManager;uid=sa;password=wwkj@2136807" />
+  
+    <add key="UploadDataUrl" value="http://36.134.204.94:50000/v1/public/inputData"/>
+    
+    <add key="CompanyId" value="29b11878-102f-43bf-80dd-ab14e48efc70" />
+ 
+    <add key="serverName" value="菏泽NB表和大表收费对接" />
+    <add key="uploadTime" value="2022-03-11 12:15" />
+	<add key="manageId" value="198,199" />
+	  
+	<add key="DBDbConn" value="Data Source=123.56.196.68;Initial Catalog=通用大表3;uid=sa;password=wwkj@2136816" />
+	<add key="firstUpdateTime" value="2023-01-01 00:00:00" />
+
+
+  </appSettings>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+  <system.web>
+    <membership defaultProvider="ClientAuthenticationMembershipProvider">
+      <providers>
+        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
+      </providers>
+    </membership>
+    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
+      <providers>
+        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
+      </providers>
+    </roleManager>
+  </system.web>
+</configuration>

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 364 - 0
TimedUpload/job_scheduling_data_2_0.xsd


+ 53 - 0
TimedUpload/log4net.config

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <configSections>
+    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
+  </configSections>
+
+  <log4net>
+    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
+      <!--日志路径-->
+      <param name= "File" value= "./logs/"/>
+      <!--是否是向文件中追加日志-->
+      <param name= "AppendToFile" value= "true"/>
+      <!--log保留天数-->
+      <param name= "MaxSizeRollBackups" value= "10"/>
+      <!--日志文件名是否是固定不变的-->
+      <param name= "StaticLogFileName" value= "false"/>
+      <!--日志文件名格式为:2008-08-31.log-->
+      <param name= "DatePattern" value= "yyyy-MM-dd&quot;.read.log&quot;"/>
+      <!--日志根据日期滚动-->
+      <param name= "RollingStyle" value= "Date"/>
+      <layout type="log4net.Layout.PatternLayout">
+        <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n %loggername" />
+      </layout>
+    </appender>
+
+    <!-- 控制台前台显示日志 -->
+    <appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
+      <mapping>
+        <level value="ERROR" />
+        <foreColor value="Red, HighIntensity" />
+      </mapping>
+      <mapping>
+        <level value="Info" />
+        <foreColor value="Green" />
+      </mapping>
+      <layout type="log4net.Layout.PatternLayout">
+        <conversionPattern value="%n%date{HH:mm:ss,fff} [%-5level] %m" />
+      </layout>
+
+      <filter type="log4net.Filter.LevelRangeFilter">
+        <param name="LevelMin" value="Info" />
+        <param name="LevelMax" value="Fatal" />
+      </filter>
+    </appender>
+
+    <root>
+      <!--(高) OFF > FATAL > ERROR > WARN > INFO > DEBUG > ALL (低) -->
+      <level value="all" />
+      <appender-ref ref="ColoredConsoleAppender"/>
+      <appender-ref ref="RollingLogFileAppender"/>
+    </root>
+  </log4net>
+</configuration>

+ 8 - 0
TimedUpload/packages.config

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Common.Logging" version="3.3.1" targetFramework="net40" />
+  <package id="Common.Logging.Core" version="3.3.1" targetFramework="net40" />
+  <package id="log4net" version="2.0.8" targetFramework="net40" />
+  <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net40" />
+  <package id="Quartz" version="2.6.0" targetFramework="net40" />
+</packages>

+ 21 - 0
TimedUpload/quartz.config

@@ -0,0 +1,21 @@
+# You can configure your scheduler in either <quartz> configuration section
+# or in quartz properties file
+# Configuration section has precedence
+
+quartz.scheduler.instanceName = QuartzTest
+
+# configure thread pool info
+quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool, Quartz
+quartz.threadPool.threadCount = 10
+quartz.threadPool.threadPriority = Normal
+
+# job initialization plugin handles our xml reading, without it defaults are used
+quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz
+quartz.plugin.xml.fileNames = ~/quartz_jobs.xml
+
+# export this server to remoting context
+#quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz
+#quartz.scheduler.exporter.port = 555
+#quartz.scheduler.exporter.bindName = QuartzScheduler
+#quartz.scheduler.exporter.channelType = tcp
+#quartz.scheduler.exporter.channelName = httpQuartz

+ 49 - 0
TimedUpload/quartz_jobs.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- This file contains job definitions in schema version 2.0 format -->
+
+<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
+
+  <processing-directives>
+    <overwrite-existing-data>true</overwrite-existing-data>
+  </processing-directives>
+
+  <schedule>
+	  <!--<job>
+		  <name>DataUploadJob</name>
+		  <group>DataUpload</group>
+		  <description>数据定时上传服务</description>
+		  <job-type>TimedUpload.QuartzJobs.DataUploadJob,ChargeDataUpload</job-type>
+		  <durable>true</durable>
+		  <recover>false</recover>
+	  </job>
+	  <trigger>
+		  <cron>
+			  <name>DataUploadJobTrigger</name>
+			  <group>DataUpload</group>
+			  <job-name>DataUploadJob</job-name>
+			  <job-group>DataUpload</job-group>
+			  <start-time>2018-03-30T00:00:00+08:00</start-time>
+			  <cron-expression>0 0 0 1/1 * ?</cron-expression>
+		  </cron>
+	  </trigger>-->
+	  <job>
+		  <name>DBDataUploadJob</name>
+		  <group>DBDataUpload</group>
+		  <description>菏泽大表数据定时上传服务</description>
+		  <job-type>TimedUpload.QuartzJobs.DBDataUploadJob,ChargeDataUpload</job-type>
+		  <durable>true</durable>
+		  <recover>false</recover>
+	  </job>
+	  <trigger>
+		  <cron>
+			  <name>DBDataUploadJobTrigger</name>
+			  <group>DBDataUpload</group>
+			  <job-name>DBDataUploadJob</job-name>
+			  <job-group>DBDataUpload</job-group>
+			  <start-time>2018-03-30T00:00:00+08:00</start-time>
+			  <cron-expression>0 0 0 1/1 * ?</cron-expression>
+		  </cron>
+	  </trigger>
+  </schedule>
+</job-scheduling-data>

+ 33 - 0
TimedUpload/utils/Config.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Web;
+
+namespace TimedUpload
+{
+    public class Config
+    {
+        /// <summary>
+        /// 根据Key取Value值
+        /// </summary>
+        /// <param name="key"></param>
+        public static string GetValue(string key)
+        {
+            return ConfigurationManager.AppSettings[key].ToString().Trim();
+        }
+        /// <summary>
+        /// 根据Key修改Value
+        /// </summary>
+        /// <param name="key">要修改的Key</param>
+        /// <param name="value">要修改为的值</param>
+        public static void SetValue(string key, string value)
+        {
+            var cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
+            cfg.AppSettings.Settings[key].Value = value;
+            cfg.Save();
+            ConfigurationManager.RefreshSection("appSettings");
+        }
+    }
+}

+ 17 - 0
TimedUpload/utils/SystemConfig.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+
+namespace TimedUpload
+{
+    public class SystemConfig
+    {
+        public static string NBMeterDb = ConfigurationManager.AppSettings["NBMeterDB"];
+       
+        public static string CompanyId = ConfigurationManager.AppSettings["CompanyId"];
+      
+        
+    }
+}