From 53476fdfcd3b9d404f030b2e05ac084d8f5450ec Mon Sep 17 00:00:00 2001 From: cesar liu Date: Thu, 20 Oct 2022 12:49:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=96=B7=E7=B7=9A=E7=87=88?= =?UTF-8?q?=E8=99=9F=2032=20-->=2034?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Setup1/Setup1.vdproj | 649 ++++++++++++++++++ .../Implement/PowerStationRepository.cs | 2 +- slnSolarPower.sln | 2 +- solarApp/Service/procSyncError.cs | 4 +- solarApp/fmArchive.Designer.cs | 39 +- solarWinService/App.config | 6 + solarWinService/Program.cs | 35 + solarWinService/ProjectInstaller.Designer.cs | 60 ++ solarWinService/ProjectInstaller.cs | 19 + solarWinService/ProjectInstaller.resx | 129 ++++ solarWinService/Properties/AssemblyInfo.cs | 36 + solarWinService/Service1.Designer.cs | 37 + solarWinService/Service1.cs | 87 +++ solarWinService/solarWinService.csproj | 83 +++ winService/Worker.cs | 23 + winService/winService.csproj | 8 +- 16 files changed, 1191 insertions(+), 28 deletions(-) create mode 100644 Setup1/Setup1.vdproj create mode 100644 solarWinService/App.config create mode 100644 solarWinService/Program.cs create mode 100644 solarWinService/ProjectInstaller.Designer.cs create mode 100644 solarWinService/ProjectInstaller.cs create mode 100644 solarWinService/ProjectInstaller.resx create mode 100644 solarWinService/Properties/AssemblyInfo.cs create mode 100644 solarWinService/Service1.Designer.cs create mode 100644 solarWinService/Service1.cs create mode 100644 solarWinService/solarWinService.csproj diff --git a/Setup1/Setup1.vdproj b/Setup1/Setup1.vdproj new file mode 100644 index 0000000..ac4fa3c --- /dev/null +++ b/Setup1/Setup1.vdproj @@ -0,0 +1,649 @@ +"DeployProject" +{ +"VSVersion" = "3:800" +"ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}" +"IsWebType" = "8:FALSE" +"ProjectName" = "8:Setup1" +"LanguageId" = "3:1028" +"CodePage" = "3:950" +"UILanguageId" = "3:1028" +"SccProjectName" = "8:" +"SccLocalPath" = "8:" +"SccAuxPath" = "8:" +"SccProvider" = "8:" + "Hierarchy" + { + } + "Configurations" + { + "Debug" + { + "DisplayName" = "8:Debug" + "IsDebugOnly" = "11:TRUE" + "IsReleaseOnly" = "11:FALSE" + "OutputFilename" = "8:Debug\\Setup1.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + } + "Release" + { + "DisplayName" = "8:Release" + "IsDebugOnly" = "11:FALSE" + "IsReleaseOnly" = "11:TRUE" + "OutputFilename" = "8:Release\\Setup1.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + } + } + "Deployable" + { + "CustomAction" + { + } + "DefaultFeature" + { + "Name" = "8:DefaultFeature" + "Title" = "8:" + "Description" = "8:" + } + "ExternalPersistence" + { + "LaunchCondition" + { + } + } + "File" + { + } + "FileType" + { + } + "Folder" + { + "{3C67513D-01DD-4637-8A68-80971EB9504F}:_1054C76661DF47EF93005EFFCC1316D4" + { + "DefaultLocation" = "8:[ProgramFilesFolder][Manufacturer]\\[ProductName]" + "Name" = "8:#1925" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:TARGETDIR" + "Folders" + { + } + } + "{1525181F-901A-416C-8A58-119130FE478E}:_4EB3D42B82CA48DBBF688AC7CF35887E" + { + "Name" = "8:#1919" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:ProgramMenuFolder" + "Folders" + { + } + } + "{1525181F-901A-416C-8A58-119130FE478E}:_F3FC0E033BFB4168947EFA3CEFEDDCAA" + { + "Name" = "8:#1916" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:DesktopFolder" + "Folders" + { + } + } + } + "LaunchCondition" + { + } + "Locator" + { + } + "MsiBootstrapper" + { + "LangId" = "3:1028" + "RequiresElevation" = "11:FALSE" + } + "Product" + { + "Name" = "8:Microsoft Visual Studio" + "ProductName" = "8:Setup1" + "ProductCode" = "8:{4256D268-A685-4836-8931-8937E374CB0B}" + "PackageCode" = "8:{F1A5CD59-0C56-4F85-9A29-BC7B5FEE9FFA}" + "UpgradeCode" = "8:{C7B7EACA-D902-44AC-B216-58A20F0933E4}" + "AspNetVersion" = "8:4.0.30319.0" + "RestartWWWService" = "11:FALSE" + "RemovePreviousVersions" = "11:FALSE" + "DetectNewerInstalledVersion" = "11:TRUE" + "InstallAllUsers" = "11:FALSE" + "ProductVersion" = "8:1.0.0" + "Manufacturer" = "8:cesarliu@outlook.com" + "ARPHELPTELEPHONE" = "8:" + "ARPHELPLINK" = "8:" + "Title" = "8:Setup1" + "Subject" = "8:" + "ARPCONTACT" = "8:cesarliu@outlook.com" + "Keywords" = "8:" + "ARPCOMMENTS" = "8:" + "ARPURLINFOABOUT" = "8:" + "ARPPRODUCTICON" = "8:" + "ARPIconIndex" = "3:0" + "SearchPath" = "8:" + "UseSystemSearchPath" = "11:TRUE" + "TargetPlatform" = "3:0" + "PreBuildEvent" = "8:" + "PostBuildEvent" = "8:" + "RunPostBuildEvent" = "3:0" + } + "Registry" + { + "HKLM" + { + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_86F42A271DFB4F02BD4732D6299723CA" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_32626E3FCE6A4A31804C92755B1D87C5" + { + "Name" = "8:[Manufacturer]" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + } + } + } + "Values" + { + } + } + } + } + "HKCU" + { + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_35406F7C435944ACB34D7E261FD877CC" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{60EA8692-D2D5-43EB-80DC-7906BF13D6EF}:_99E6D8E3E3F34706AEB05EACE02428D6" + { + "Name" = "8:[Manufacturer]" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + } + } + } + "Values" + { + } + } + } + } + "HKCR" + { + "Keys" + { + } + } + "HKU" + { + "Keys" + { + } + } + "HKPU" + { + "Keys" + { + } + } + } + "Sequences" + { + } + "Shortcut" + { + } + "UserInterface" + { + "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_2331AA920CB7405F8BD2691B5E22AAE7" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdBasicDialogs.wim" + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_3F63D9D89CE441FCA392E871651477E6" + { + "Name" = "8:#1902" + "Sequence" = "3:2" + "Attributes" = "3:3" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_D974CB1AA6FE4F84A782D89DBE4BA97D" + { + "Sequence" = "3:100" + "DisplayName" = "8:已經完成" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFinishedDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_43D153BC203F47D08A4B8028388D009F" + { + "Name" = "8:#1900" + "Sequence" = "3:1" + "Attributes" = "3:1" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_74B70B1ABB8245568BFBC4365B2DEFA9" + { + "Sequence" = "3:200" + "DisplayName" = "8:安裝資料夾" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFolderDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "InstallAllUsersVisible" + { + "Name" = "8:InstallAllUsersVisible" + "DisplayName" = "8:#1059" + "Description" = "8:#1159" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_9A02E262A8724FF5B746BDEDD5BAC56F" + { + "Sequence" = "3:300" + "DisplayName" = "8:確認安裝" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdConfirmDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_F94DD3E02ADF4E52A9C02BCAE6064C29" + { + "Sequence" = "3:100" + "DisplayName" = "8:歡迎" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdWelcomeDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_53F705CE669040E9B8F7B5EE1ABCE89D" + { + "Name" = "8:#1901" + "Sequence" = "3:1" + "Attributes" = "3:2" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_CD9BEB568D7E4A78958B102A7D433FF8" + { + "Sequence" = "3:100" + "DisplayName" = "8:進度" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdProgressDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_75EFF76CF5BF4545A6468843B2ACDD39" + { + "Name" = "8:#1901" + "Sequence" = "3:2" + "Attributes" = "3:2" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_658398D038924EE09431210D3440BA51" + { + "Sequence" = "3:100" + "DisplayName" = "8:進度" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminProgressDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_AA8D7CAF590C4E168FBF62E3AD2827E0" + { + "Name" = "8:#1900" + "Sequence" = "3:2" + "Attributes" = "3:1" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_1C31A5CDA3864F758EC9B97A256A04F5" + { + "Sequence" = "3:100" + "DisplayName" = "8:歡迎" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminWelcomeDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_29C5BDBBB2CA47B2AE364DF86A4C8A91" + { + "Sequence" = "3:200" + "DisplayName" = "8:安裝資料夾" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFolderDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_B343A7D1F79E410484175CD2A2AB2302" + { + "Sequence" = "3:300" + "DisplayName" = "8:確認安裝" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminConfirmDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_CD03FEDDC3F44ECC969CA8C7119FA815" + { + "Name" = "8:#1902" + "Sequence" = "3:1" + "Attributes" = "3:3" + "Dialogs" + { + "{688940B3-5CA9-4162-8DEE-2993FA9D8CBC}:_85F5142D797D4C5B961D04BD3717172B" + { + "Sequence" = "3:100" + "DisplayName" = "8:已經完成" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFinishedDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "UpdateText" + { + "Name" = "8:UpdateText" + "DisplayName" = "8:#1058" + "Description" = "8:#1158" + "Type" = "3:15" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1258" + "DefaultValue" = "8:#1258" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_DAC93DD120D94968A421FAA3D2294032" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdUserInterface.wim" + } + } + "MergeModule" + { + } + "ProjectOutput" + { + } + } +} diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index c64c5da..8a7a479 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -3222,7 +3222,7 @@ namespace SolarPower.Repository.Implement SUM(sub_inv.WH)/1000 AS KWH, MAX(sub_inv.TODAYKWH) AS TODAYKWH FROM {table_name} sub_inv - WHERE CrdTime BETWEEN '{stratDateTime}' AND '{inverterIds}' + WHERE CrdTime BETWEEN '{stratDateTime}' AND '{dateTime}' GROUP BY sub_inv.INVERTERID) s LEFT JOIN {db_name}.inverter i ON s.INVERTERID = REPLACE(i.InverterId, 's', '') where Deleted = 0 and enabled = 1 ;"; diff --git a/slnSolarPower.sln b/slnSolarPower.sln index 2e666c6..672742a 100644 --- a/slnSolarPower.sln +++ b/slnSolarPower.sln @@ -7,7 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SolarPower", "SolarPower\So EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "solarApp", "solarApp\solarApp.csproj", "{3D54E7DA-4EF8-42A3-85D3-39DD08AC9A0C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "winService", "winService\winService.csproj", "{132A1CF9-2C64-493D-8F8E-1F86AA595D14}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "winService", "winService\winService.csproj", "{132A1CF9-2C64-493D-8F8E-1F86AA595D14}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/solarApp/Service/procSyncError.cs b/solarApp/Service/procSyncError.cs index 3d95c3f..64777bc 100644 --- a/solarApp/Service/procSyncError.cs +++ b/solarApp/Service/procSyncError.cs @@ -162,8 +162,8 @@ namespace solarApp.Service site_id, alarmID, datestamp, HealthStatus from ( select site_id, datestamp, sourceState, id alarmID, - case when alarmClass = 31 then 3 # Network 控制盒斷線 - 紅燈 - when alarmClass != 31 then 2 end HealthStatus # inv, sensor 異常 黃燈 + case when alarmClass = 34 then 3 # Network 控制盒斷線 - 紅燈 + when alarmClass != 34 then 2 end HealthStatus # inv, sensor 異常 黃燈 from err_main where sourceState = 1 and left(site_id , 1) = '0' and datestamp > '{ System.DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd")}' diff --git a/solarApp/fmArchive.Designer.cs b/solarApp/fmArchive.Designer.cs index fc0ecf1..86aba0b 100644 --- a/solarApp/fmArchive.Designer.cs +++ b/solarApp/fmArchive.Designer.cs @@ -30,8 +30,8 @@ namespace solarApp private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); @@ -72,6 +72,7 @@ namespace solarApp this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.panel2 = new System.Windows.Forms.Panel(); + this.button1 = new System.Windows.Forms.Button(); this.lbReceiver = new System.Windows.Forms.Label(); this.tbReceiver = new System.Windows.Forms.TextBox(); this.gbox = new System.Windows.Forms.GroupBox(); @@ -88,7 +89,6 @@ namespace solarApp this.tbUserName = new System.Windows.Forms.TextBox(); this.btSendMail = new System.Windows.Forms.Button(); this.timer1 = new System.Windows.Forms.Timer(this.components); - this.button1 = new System.Windows.Forms.Button(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -393,8 +393,8 @@ namespace solarApp // this.gv_inv_detail.AllowUserToAddRows = false; this.gv_inv_detail.AllowUserToDeleteRows = false; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.gv_inv_detail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.gv_inv_detail.Dock = System.Windows.Forms.DockStyle.Fill; this.gv_inv_detail.Location = new System.Drawing.Point(768, 75); @@ -410,8 +410,8 @@ namespace solarApp // this.gv_rpt_invDay.AllowUserToAddRows = false; this.gv_rpt_invDay.AllowUserToDeleteRows = false; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2; this.gv_rpt_invDay.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.gv_rpt_invDay.Dock = System.Windows.Forms.DockStyle.Left; this.gv_rpt_invDay.Location = new System.Drawing.Point(0, 75); @@ -570,7 +570,6 @@ namespace solarApp // // richTextBox1 // - this.richTextBox1.Cursor = System.Windows.Forms.Cursors.Default; this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.richTextBox1.Location = new System.Drawing.Point(0, 321); this.richTextBox1.Name = "richTextBox1"; @@ -586,13 +585,22 @@ namespace solarApp this.panel2.Controls.Add(this.tbReceiver); this.panel2.Controls.Add(this.gbox); this.panel2.Controls.Add(this.btSendMail); - this.panel2.Cursor = System.Windows.Forms.Cursors.Default; this.panel2.Dock = System.Windows.Forms.DockStyle.Top; this.panel2.Location = new System.Drawing.Point(0, 0); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(1459, 321); this.panel2.TabIndex = 0; // + // button1 + // + this.button1.Location = new System.Drawing.Point(1288, 73); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(94, 29); + this.button1.TabIndex = 17; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click_1); + // // lbReceiver // this.lbReceiver.AutoSize = true; @@ -623,7 +631,6 @@ namespace solarApp this.gbox.Controls.Add(this.tbPassword); this.gbox.Controls.Add(this.lbUserName); this.gbox.Controls.Add(this.tbUserName); - this.gbox.Cursor = System.Windows.Forms.Cursors.Default; this.gbox.Location = new System.Drawing.Point(80, 30); this.gbox.Name = "gbox"; this.gbox.Size = new System.Drawing.Size(551, 246); @@ -745,16 +752,6 @@ namespace solarApp // this.timer1.Interval = 10000; // - // button1 - // - this.button1.Location = new System.Drawing.Point(1288, 73); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(94, 29); - this.button1.TabIndex = 17; - this.button1.Text = "button1"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click_1); - // // fmArchive // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F); @@ -762,7 +759,7 @@ namespace solarApp this.ClientSize = new System.Drawing.Size(1782, 953); this.Controls.Add(this.tabControl1); this.Name = "fmArchive"; - this.Text = "fmArchive 0910"; + this.Text = "fmArchive 1020"; this.Load += new System.EventHandler(this.fmArchive_Load); this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); diff --git a/solarWinService/App.config b/solarWinService/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/solarWinService/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/solarWinService/Program.cs b/solarWinService/Program.cs new file mode 100644 index 0000000..66d0fd6 --- /dev/null +++ b/solarWinService/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; +using System.Data; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.ServiceProcess; +using System.Text; +using System.Threading.Tasks; +using System.Timers; + +namespace solarWinService +{ + internal static class Program + { + //從App.config取出檔案路徑及名稱 + //private readonly string _FilePath = ConfigurationManager.AppSettings["FilePath"]; + + /// + /// 應用程式的主要進入點。 + /// + static void Main() + { + ServiceBase[] ServicesToRun; + ServicesToRun = new ServiceBase[] + { + new Service1() + }; + ServiceBase.Run(ServicesToRun); + } + + } +} diff --git a/solarWinService/ProjectInstaller.Designer.cs b/solarWinService/ProjectInstaller.Designer.cs new file mode 100644 index 0000000..bb28b53 --- /dev/null +++ b/solarWinService/ProjectInstaller.Designer.cs @@ -0,0 +1,60 @@ +namespace solarWinService +{ + partial class ProjectInstaller + { + /// + /// 設計工具所需的變數。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清除任何使用中的資源。 + /// + /// 如果應該處置受控資源則為 true,否則為 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 元件設計工具產生的程式碼 + + /// + /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 + /// 這個方法的內容。 + /// + private void InitializeComponent() + { + this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller(); + this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller(); + // + // serviceProcessInstaller1 + // + this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem; + this.serviceProcessInstaller1.Password = null; + this.serviceProcessInstaller1.Username = null; + // + // serviceInstaller1 + // + this.serviceInstaller1.Description = "FIC 太陽能資料歸檔服務"; + this.serviceInstaller1.DisplayName = "solar_archive"; + this.serviceInstaller1.ServiceName = "solar_archive_v2"; + this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic; + // + // ProjectInstaller + // + this.Installers.AddRange(new System.Configuration.Install.Installer[] { + this.serviceProcessInstaller1, + this.serviceInstaller1}); + + } + + #endregion + + private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1; + private System.ServiceProcess.ServiceInstaller serviceInstaller1; + } +} \ No newline at end of file diff --git a/solarWinService/ProjectInstaller.cs b/solarWinService/ProjectInstaller.cs new file mode 100644 index 0000000..3639602 --- /dev/null +++ b/solarWinService/ProjectInstaller.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration.Install; +using System.Linq; +using System.Threading.Tasks; + +namespace solarWinService +{ + [RunInstaller(true)] + public partial class ProjectInstaller : System.Configuration.Install.Installer + { + public ProjectInstaller() + { + InitializeComponent(); + } + } +} diff --git a/solarWinService/ProjectInstaller.resx b/solarWinService/ProjectInstaller.resx new file mode 100644 index 0000000..a2e4e56 --- /dev/null +++ b/solarWinService/ProjectInstaller.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 200, 17 + + + False + + \ No newline at end of file diff --git a/solarWinService/Properties/AssemblyInfo.cs b/solarWinService/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7e709cf --- /dev/null +++ b/solarWinService/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 組件的一般資訊是由下列的屬性集控制。 +// 變更這些屬性的值即可修改組件的相關 +// 資訊。 +[assembly: AssemblyTitle("solarWinService")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("solarWinService")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 將 ComVisible 設為 false 可對 COM 元件隱藏 +// 組件中的類型。若必須從 COM 存取此組件中的類型, +// 的類型,請在該類型上將 ComVisible 屬性設定為 true。 +[assembly: ComVisible(false)] + +// 下列 GUID 為專案公開 (Expose) 至 COM 時所要使用的 typelib ID +[assembly: Guid("1be88ea5-d194-4094-b955-d266bfc406c3")] + +// 組件的版本資訊由下列四個值所組成: +// +// 主要版本 +// 次要版本 +// 組建編號 +// 修訂編號 +// +// 您可以指定所有的值,也可以使用 '*' 將組建和修訂編號 +// 設為預設,如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/solarWinService/Service1.Designer.cs b/solarWinService/Service1.Designer.cs new file mode 100644 index 0000000..0077a4b --- /dev/null +++ b/solarWinService/Service1.Designer.cs @@ -0,0 +1,37 @@ +namespace solarWinService +{ + partial class Service1 + { + /// + /// 設計工具所需的變數。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清除任何使用中的資源。 + /// + /// 如果應該處置受控資源則為 true,否則為 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 元件設計工具產生的程式碼 + + /// + /// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改 + /// 這個方法的內容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.ServiceName = "Service1"; + } + + #endregion + } +} diff --git a/solarWinService/Service1.cs b/solarWinService/Service1.cs new file mode 100644 index 0000000..12b15b8 --- /dev/null +++ b/solarWinService/Service1.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Configuration; +using System.Data; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.ServiceProcess; +using System.Text; +using System.Threading.Tasks; +using System.Timers; +using System.Xml.Linq; + + +// ref: https://dotblogs.com.tw/BigCow/2020/09/17/104221 +namespace solarWinService +{ + public partial class Service1 : ServiceBase + { + // private readonly ILogger _logger; + System.Xml.Linq.XDocument xdoc; + public XDocument Xdoc { get => xdoc; set => xdoc = value; } + + getStationSvc stationSvc; + System.Timers.Timer _timer; + bool autoTask = false; //測試自動跑 irrDayHour 累計日照小時差異 + procSyncError svc; + DateTime doTimerTaskTime = DateTime.Now; + TimeSpan doTaskDuratin; + + public Service1() + { + InitializeComponent(); + // _logger = logger; + xdoc = XDocument.Load("../solarApp/App.config"); + string conStr = Xdoc.Element("configuration").Element("connectionStrings").Element("add").Attribute("connectionString").Value; + stationSvc = new getStationSvc(conStr); + svc = new procSyncError(conStr); // 常資料同步 + } + + protected override void OnStart(string[] args) + { + } + + protected override void OnStop() + { + } + + void archiveAllStation() + { + var site_list = stationSvc.get_station_list(); + procSensorSvc sensorSvc = new procSensorSvc(); + procInvSvc invSvc = new procInvSvc(); + procStationSvc siteSvc = new procStationSvc(); + string date1 = System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); + string date2 = System.DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); + + foreach (var item in site_list) + { + foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2))) + { + sensorSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); + invSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); + siteSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); + } + } + sensorSvc.isFirst = true; + foreach (var item in site_list) + { + //for sensor_history_hour + foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2))) + { + sensorSvc.archiveSensorHistoryHourData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); + sensorSvc.isFirst = false; + invSvc.report_invDay(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd")); + } + } + } + + public IEnumerable EachDay(DateTime from, DateTime thru) + { + for (var day = from.Date; day.Date <= thru.Date; day = day.AddDays(1)) + yield return day; + } + } +} diff --git a/solarWinService/solarWinService.csproj b/solarWinService/solarWinService.csproj new file mode 100644 index 0000000..752567c --- /dev/null +++ b/solarWinService/solarWinService.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {1BE88EA5-D194-4094-B955-D266BFC406C3} + WinExe + solarWinService + solarWinService + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Component + + + ProjectInstaller.cs + + + Component + + + Service1.cs + + + + + + + + + + ProjectInstaller.cs + + + + + {3d54e7da-4ef8-42a3-85d3-39dd08ac9a0c} + solarApp + + + {6c88bbd7-5a1f-47b8-bf46-9cbdc73ef2e9} + SolarPower + + + + \ No newline at end of file diff --git a/winService/Worker.cs b/winService/Worker.cs index 75465e8..b127080 100644 --- a/winService/Worker.cs +++ b/winService/Worker.cs @@ -1,11 +1,34 @@ using solarApp.Service; using System.Configuration; using System.Xml.Linq; +using System.Runtime.InteropServices; namespace winService { public class Worker : BackgroundService { + public enum ServiceState + { + SERVICE_STOPPED = 0x00000001, + SERVICE_START_PENDING = 0x00000002, + SERVICE_STOP_PENDING = 0x00000003, + SERVICE_RUNNING = 0x00000004, + SERVICE_CONTINUE_PENDING = 0x00000005, + SERVICE_PAUSE_PENDING = 0x00000006, + SERVICE_PAUSED = 0x00000007, + } + + [StructLayout(LayoutKind.Sequential)] + public struct ServiceStatus + { + public int dwServiceType; + public ServiceState dwCurrentState; + public int dwControlsAccepted; + public int dwWin32ExitCode; + public int dwServiceSpecificExitCode; + public int dwCheckPoint; + public int dwWaitHint; + }; private readonly ILogger _logger; XDocument xdoc; public XDocument Xdoc { get => xdoc; set => xdoc = value; } diff --git a/winService/winService.csproj b/winService/winService.csproj index b30ddec..b06c857 100644 --- a/winService/winService.csproj +++ b/winService/winService.csproj @@ -1,11 +1,13 @@ - + - net6.0 + net6.0-windows10.0.17763.0 enable enable dotnet-winService-78282A39-DE2D-4E5B-806B-31D6FE6D57E7 - SolarPower.Program + + WinExe + False