Browse Source

mxg:添加配置文件,整理url地址

mengxiangge 5 years ago
parent
commit
2332ce00f4
27 changed files with 701 additions and 232 deletions
  1. 106 0
      PackageUpdater/PackageUploaderTests/PackageUploaderTests.csproj
  2. 36 0
      PackageUpdater/PackageUploaderTests/Properties/AssemblyInfo.cs
  3. 25 0
      PackageUpdater/PackageUploaderTests/UntilityTests.cs
  4. 5 0
      PackageUpdater/PackageUploaderTests/packages.config
  5. 10 0
      PackageUpdater/Update/App.config
  6. 0 86
      PackageUpdater/Update/Config/AppConfig.cs
  7. 36 0
      PackageUpdater/Update/Config/ConfigUtils.cs
  8. 11 59
      PackageUpdater/Update/Config/HostConfig.cs
  9. 37 0
      PackageUpdater/Update/Config/HttpUtils.cs
  10. 24 10
      PackageUpdater/Update/Const.cs
  11. 3 4
      PackageUpdater/Update/Core/Updater.Methods.cs
  12. 2 1
      PackageUpdater/Update/Program.cs
  13. 7 0
      PackageUpdater/Update/Readme.txt
  14. 3 1
      PackageUpdater/Update/Update.csproj
  15. 0 3
      PackageUpdater/WPFTestUpdate/App.config
  16. 0 34
      PackageUpdater/WPFTestUpdate/Const.cs
  17. BIN
      PackageUpdater/WPFTestUpdate/Dlls/SAGA.DotNetUtils.dll
  18. 1 0
      PackageUpdater/WPFTestUpdate/Extend.cs
  19. 26 0
      PackageUpdater/WPFTestUpdate/Http/FileContent.cs
  20. 118 0
      PackageUpdater/WPFTestUpdate/Http/PutFlieContent.cs
  21. 33 0
      PackageUpdater/WPFTestUpdate/Http/StreamProgressArgs.cs
  22. 7 5
      PackageUpdater/WPFTestUpdate/MainWindow.xaml
  23. 29 10
      PackageUpdater/WPFTestUpdate/MainWindow.xaml.cs
  24. 3 1
      PackageUpdater/WPFTestUpdate/PackageUploader.csproj
  25. 36 18
      PackageUpdater/WPFTestUpdate/Untility.cs
  26. 22 0
      PackageUpdater/WPFTestUpdate/WinMFMUploadProcress.xaml
  27. 121 0
      PackageUpdater/WPFTestUpdate/WinMFMUploadProcress.xaml.cs

+ 106 - 0
PackageUpdater/PackageUploaderTests/PackageUploaderTests.csproj

@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{119F175F-CACF-4A62-BD7B-21D45AB3A538}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>PackageUploaderTests</RootNamespace>
+    <AssemblyName>PackageUploaderTests</AssemblyName>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+    <IsCodedUITest>False</IsCodedUITest>
+    <TestProjectType>UnitTest</TestProjectType>
+    <TargetFrameworkProfile />
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <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' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+  </ItemGroup>
+  <Choose>
+    <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
+      <ItemGroup>
+        <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+      </ItemGroup>
+    </When>
+    <Otherwise />
+  </Choose>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="UntilityTests.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\WPFTestUpdate\PackageUploader.csproj">
+      <Project>{B01D2D18-A517-42DB-A454-6F477BC9C592}</Project>
+      <Name>PackageUploader</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Choose>
+    <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
+      <ItemGroup>
+        <Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+          <Private>False</Private>
+        </Reference>
+        <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+          <Private>False</Private>
+        </Reference>
+        <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+          <Private>False</Private>
+        </Reference>
+        <Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+          <Private>False</Private>
+        </Reference>
+      </ItemGroup>
+    </When>
+  </Choose>
+  <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.props'))" />
+    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.targets'))" />
+  </Target>
+  <Import Project="..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.18\build\net45\MSTest.TestAdapter.targets')" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 36 - 0
PackageUpdater/PackageUploaderTests/Properties/AssemblyInfo.cs

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

+ 25 - 0
PackageUpdater/PackageUploaderTests/UntilityTests.cs

@@ -0,0 +1,25 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using PackageUploader;
+/* ==============================================================================
+* 功能描述:UntilityTests  
+* 创 建 者:Garrett
+* 创建日期:2019/6/14 9:56:33
+* ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PackageUploader.Tests
+{
+    [TestClass()]
+    public class UntilityTests
+    {
+        [TestMethod()]
+        public void UploadCompressTest()
+        {
+            Assert.Fail();
+        }
+    }
+}

+ 5 - 0
PackageUpdater/PackageUploaderTests/packages.config

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MSTest.TestAdapter" version="1.1.18" targetFramework="net461" />
+  <package id="MSTest.TestFramework" version="1.1.18" targetFramework="net461" />
+</packages>

+ 10 - 0
PackageUpdater/Update/App.config

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <appSettings>
+    <add key="IsAutoUpdate" value="true"/>
+    <add key="URL" value="http://api.sagacloud.cn/dp-auxiliary/"/>
+    <add key="Key" value="FirmLib_Package"/>
+    <add key="RevitServiceId" value="revit"/>
+    <add key="RevitServiceSecret" value="63afbef6906c342b"/>
+  </appSettings>
+</configuration>

+ 0 - 86
PackageUpdater/Update/Config/AppConfig.cs

@@ -1,86 +0,0 @@
-using System;
-using System.IO;
-using System.Reflection;
-using System.Windows.Forms;
-using Update.Util;
-
-namespace Update.Config
-{
-    /// <summary>
-    /// 当前配置
-    /// </summary>
-    public static class AppConfig
-    {
-        private static string m_Temp;
-        /// <summary>
-        /// 获取系统临时目录 格式:C:\Users\Administrator\AppData\Local\Temp\
-        /// </summary>
-        public static string Temp
-        {
-            get
-            {
-                return m_Temp ?? (m_Temp = Path.GetTempPath());
-            }
-        }
-
-        private static string m_AssemblyPath;
-        /// <summary>
-        /// 获取当前代码程序集的路径 格式:D:\xx系统\update.exe
-        /// </summary>
-        public static string AssemblyPath
-        {
-            get
-            {
-                return m_AssemblyPath ?? (m_AssemblyPath = Assembly.GetExecutingAssembly().Location);
-            }
-        }
-
-        private static string m_ExecutablePath;
-        /// <summary>
-        /// 获取当前运行的exe的路径 格式:D:\xx系统\update.exe
-        /// </summary>
-        public static string ExecutablePath
-        {
-            get
-            {
-                return m_ExecutablePath ?? (m_ExecutablePath = Application.ExecutablePath);
-            }
-        }
-
-        private static string m_ExecutableDirectory;
-        /// <summary>
-        /// 获取当前运行的exe的目录 格式:D:\xx系统\
-        /// </summary>
-        public static string ExecutableDirectory
-        {
-            get
-            {
-                return m_ExecutableDirectory ?? (m_ExecutableDirectory = AppDomain.CurrentDomain.BaseDirectory);
-            }
-        }
-
-        private static string m_FileName;
-        /// <summary>
-        /// 获取当前运行的exe的名称 格式:update.exe
-        /// </summary>
-        public static string FileName
-        {
-            get
-            {
-                return m_FileName ?? (m_FileName = Path.GetFileName(ExecutablePath));
-            }
-        }
-
-        private static string m_ExpectExecutablePath;
-        /// <summary>
-        /// 获取期望启动路径 格式:C:\Users\Administrator\AppData\Local\Temp\update.exe
-        /// </summary>
-        public static string ExpectExecutablePath
-        {
-            get
-            {
-                return m_ExpectExecutablePath ?? (m_ExpectExecutablePath = FilePathUtil.GetAbsolutePath(FileName, Temp));
-            }
-        }
-    }
-}

+ 36 - 0
PackageUpdater/Update/Config/ConfigUtils.cs

@@ -0,0 +1,36 @@
+/* ==============================================================================
+ * 功能描述:ConfigUtils  
+ * 创 建 者:Garrett
+ * 创建日期:2019/9/16 15:26:04
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+
+namespace Update.Config
+{
+    /// <summary>
+    /// ConfigUtils
+    /// </summary>
+    class ConfigUtils
+    {
+        /// <summary>
+        /// 获取配置文件
+        /// </summary>
+        /// <param name="key"></param>
+        /// <returns></returns>
+        public static string GetAppSettingsConfig(string key)
+        {
+            string codeBase = Assembly.GetExecutingAssembly().CodeBase;
+            UriBuilder uri = new UriBuilder(codeBase);
+            string path = Uri.UnescapeDataString(uri.Path);
+            string addString = ConfigurationManager.OpenExeConfiguration(path).AppSettings.Settings[key].Value.ToString();
+
+            return addString;
+        }
+    }
+}

+ 11 - 59
PackageUpdater/Update/Config/HostConfig.cs

@@ -14,35 +14,27 @@ namespace Update.Config
     /// </summary>
     public static class HostConfig
     {
-        /// <summary>
-        /// 默认目标文件名
-        /// </summary>
-        public const string DEFAULT_NAME = "OutputDll/OutputDll/SAGA.MBI.exe";
-
-        private static string m_ExecutablePath;
-        /// <summary>
-        /// 获取目标文件路径 格式:D:\xx系统\wfy.exe
-        /// </summary>
-        public static string ExecutablePath
+        private static string m_DownLoadURL;
+        public static string DownLoadURL
         {
             get
             {
-                return m_ExecutablePath ?? (m_ExecutablePath = AppConfig.ExecutablePath);
+                if(m_DownLoadURL==null)
+                    m_DownLoadURL= HttpUtils.GetDownloadUrl(Const.Key);
+                return m_DownLoadURL;
             }
         }
 
-        private static string m_ExecutableConfigPath;
+
+        private static string m_ExecutablePath;
         /// <summary>
-        /// 获取目标配置文件路径 格式:D:\xx系统\wfy.exe.config
+        /// 获取目标文件路径 格式:D:\xx系统\wfy.exe
         /// </summary>
-        public static string ExecutableConfigPath
+        public static string ExecutablePath
         {
-            get
-            {
-                return m_ExecutableConfigPath ?? (m_ExecutableConfigPath = ExecutablePath + ".config");
-            }
+            get { return m_ExecutablePath; }
         }
-
+        
         private static string m_ExecutableDirectory;
         /// <summary>
         /// 获取目标文件的父文件夹 格式:D:\xx系统\
@@ -97,28 +89,6 @@ namespace Update.Config
             }
         }
 
-        private static string m_UpdateUrl;
-        /// <summary>
-        /// 获取目标进程配置文件中的 UpdateUrl 配置项,获取后会自动处理末尾,保证返回时以 '/' 结尾(如果没配置将返回 null)
-        /// </summary>
-        public static string UpdateUrl
-        {
-            get
-            {
-                if (m_UpdateUrl == null)
-                {
-                    string url = ReadHostConfig("UpdateUrl");
-                    if (string.IsNullOrWhiteSpace(url))
-                        return null;
-                    url = url.Trim();
-                    m_UpdateUrl = url.EndsWith("/") ? url : (url + "/");
-                }
-                return m_UpdateUrl;
-            }
-        }
-
-        public static string BaseUrl = Const.URL;
-
         /// <summary>
         /// 初始化目标文件配置
         /// </summary>
@@ -126,11 +96,9 @@ namespace Update.Config
         public static void Init(string executablePath)
         {
             m_ExecutablePath = executablePath;
-            m_ExecutableConfigPath = null;
             m_ExecutableDirectory = null;
             m_ExecutableName = null;
             m_CurrentVersion = null;
-            m_UpdateUrl = null;
         }
 
         /// <summary>
@@ -141,21 +109,5 @@ namespace Update.Config
             m_CurrentVersion = null;
         }
 
-        //读取配置
-        private static string ReadHostConfig(string key)
-        {
-            try
-            {
-                //Configuration config = ConfigurationManager.OpenExeConfiguration(ExecutablePath);
-                //KeyValueConfigurationCollection appSettings = config.AppSettings.Settings;
-                //KeyValueConfigurationElement add = appSettings.Cast<KeyValueConfigurationElement>().FirstOrDefault(element => string.Equals(element.Key, key, StringComparison.OrdinalIgnoreCase));
-                //return add == null ? null : add.Value;
-                return "http://localhost:8888/AutoUpdate/";
-            }
-            catch
-            {
-                return null;
-            }
-        }
     }
 }

+ 37 - 0
PackageUpdater/Update/Config/HttpUtils.cs

@@ -0,0 +1,37 @@
+/* ==============================================================================
+ * 功能描述:HttpUtils  
+ * 创 建 者:Garrett
+ * 创建日期:2019/9/16 17:43:45
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Update
+{
+    /// <summary>
+    /// HttpUtils
+    /// </summary>
+    public class HttpUtils
+    {
+        public static string GetDownloadUrl(string name)
+        {
+            var url = $"{Const.URL}/image-service/common/file_get/{name}?systemId={Const.RevitServiceId}";
+            return url;
+        }
+
+        public static string GetUploadUrl(string name)
+        {
+            var url = $"{Const.URL}/image-service/common/file_upload/?systemId={Const.RevitServiceId}&secret={Const.RevitServiceSecret}&key={name}&overwrite=true"; 
+            return url;
+        }
+
+
+        public static string DeleteUrl()
+        {
+            string url = $"{Const.URL}/image-service/common/files_delete?systemId={Const.RevitServiceId}&secret={Const.RevitServiceSecret}";
+            return url;
+        }
+    }
+}

+ 24 - 10
PackageUpdater/Update/Const.cs

@@ -4,6 +4,9 @@
  * 创建日期:2019/1/29 11:49:28
  * ==============================================================================*/
 
+using System;
+using Update.Config;
+
 namespace Update
 {
     /// <summary>
@@ -11,19 +14,30 @@ namespace Update
     /// </summary>
     public class Const
     {
-        public static  string URL => $"http://service.sagacloud.cn:28888/";
+        public static  string URL => ConfigUtils.GetAppSettingsConfig(nameof(Const.URL));
 
-        public static  string Key => "MBI_Package";
+        public static  string Key => ConfigUtils.GetAppSettingsConfig(nameof(Const.Key));
 
         //revit文件服务器id和密码
-        public static readonly string RevitServiceId = "revit";
-        public static readonly string RevitServiceSecret = "63afbef6906c342b";
-        public static readonly string OSSKeyPath = @"files/revit/";
-        //Oss相关
-        public static string AccessKeyId = "LTAIQVvCRivyl3Dd";
-        public static string AccessKeySecret = "hkGLC7RgWUntbAS2Zw5rWOVS8Xhj0G";
-        public static string Endpoint = "oss-cn-beijing.aliyuncs.com";
-        public static string BucketName = "saga-data";
+        public static readonly string RevitServiceId = ConfigUtils.GetAppSettingsConfig(nameof(Const.RevitServiceId));
+        public static readonly string RevitServiceSecret = ConfigUtils.GetAppSettingsConfig(nameof(Const.RevitServiceSecret));
+        //是否自动更新
+        public static readonly bool IsAutoUpdate= ConvertToBoolean(ConfigUtils.GetAppSettingsConfig(nameof(Const.IsAutoUpdate)));
+
+        private static bool ConvertToBoolean(string key)
+        {
+            bool result = false;
+            try
+            {
+                result= Convert.ToBoolean(key);
+
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+            }
 
+            return result;
+        }
     }
 }

+ 3 - 4
PackageUpdater/Update/Core/Updater.Methods.cs

@@ -29,14 +29,13 @@ namespace Update.Core
             OnCheckStarted(new CheckStartedEventArgs());
             try
             {
-                string url = $"{HostConfig.BaseUrl}/image-service/common/file_get/{PACKAGES}?systemId=revit";
+                string url = HttpUtils.GetDownloadUrl(Const.Key);
                 m_Client.DownloadStringAsync(new Uri(url));
             }
             catch (Exception e)
             {
                 return;
             }
-
         }
 
         /// <summary>
@@ -139,7 +138,7 @@ namespace Update.Core
             OnNotify(new NotifyEventArgs("正在下载 {0}。", package.FileName));
             try
             {
-                string url = $"{HostConfig.BaseUrl}/image-service/common/file_get/{package.FileName}?systemId=revit";
+                string url = HttpUtils.GetDownloadUrl(package.FileName);
                 m_Client.DownloadDataAsync(new Uri(url), package);
             }
             catch (Exception e)
@@ -230,7 +229,7 @@ namespace Update.Core
             Packages packages;
             try
             {
-                string url = $"{HostConfig.BaseUrl}/image-service/common/file_get/{PACKAGES}?systemId=revit";
+                string url = HostConfig.DownLoadURL;
                 var result = m_Client.DownloadString(new Uri(url));
                 packages = new Packages(result);
             }

+ 2 - 1
PackageUpdater/Update/Program.cs

@@ -29,7 +29,8 @@ namespace Update
 
                 Application.EnableVisualStyles();
                 Application.SetCompatibleTextRenderingDefault(false);
-                if (UpdateUtil.CheckUpdate())
+                //手动更新且需要更新
+                if (UpdateUtil.CheckUpdate()&&Const.IsAutoUpdate)
                 {
                     //需要更新
                     Application.Run(new FrmUpdate());

+ 7 - 0
PackageUpdater/Update/Readme.txt

@@ -20,3 +20,10 @@ Debug用于测试
 使用时,请使用Release模式
 
 
+程序集版本号自动生成
+AssemblyInfo.cs
+[assembly: AssemblyVersion("1.0.*")]
+
+IsAutoUpdate 是否自动更新,false不自动更新
+Key 存储安装所在的位置
+其它参数:主要用于上传下载

+ 3 - 1
PackageUpdater/Update/Update.csproj

@@ -1726,7 +1726,7 @@
     <Compile Include="..\SharpCompress\Writers\Zip\ZipWriterOptions.cs">
       <Link>SharpCompress\Writers\Zip\ZipWriterOptions.cs</Link>
     </Compile>
-    <Compile Include="Config\AppConfig.cs" />
+    <Compile Include="Config\ConfigUtils.cs" />
     <Compile Include="Config\HostConfig.cs" />
     <Compile Include="Const.cs" />
     <Compile Include="Controls\BaseForm.cs">
@@ -1759,6 +1759,7 @@
     <Compile Include="FrmUpdate.Designer.cs">
       <DependentUpon>FrmUpdate.cs</DependentUpon>
     </Compile>
+    <Compile Include="Config\HttpUtils.cs" />
     <Compile Include="Net\Events\DecompressDataCompletedEvent.cs" />
     <Compile Include="Net\Events\DecompressDataStartDelegate.cs" />
     <Compile Include="Net\Events\DecompressProgressChangedEvent.cs" />
@@ -1802,6 +1803,7 @@
     </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
+    <None Include="App.config" />
     <None Include="app.ico" />
     <None Include="Resources\background0.png" />
     <None Include="Resources\background1.png" />

+ 0 - 3
PackageUpdater/WPFTestUpdate/App.config

@@ -3,9 +3,6 @@
     <startup> 
         <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
     </startup>
-  <appSettings>
-    <add key="UpdateUrl" value="http://localhost:8888/AutoUpdate/" />
-  </appSettings>
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>

+ 0 - 34
PackageUpdater/WPFTestUpdate/Const.cs

@@ -1,34 +0,0 @@
-/* ==============================================================================
- * 功能描述:Const  
- * 创 建 者:Garrett
- * 创建日期:2019/1/29 11:49:28
- * ==============================================================================*/
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace PackageUploader
-{
-    /// <summary>
-    /// Const
-    /// </summary>
-    class Const
-    {
-        public static  string URL = Update.Const.URL;
-
-        public static readonly string Key = Update.Const.Key;
-
-        //revit文件服务器id和密码
-        public static readonly string RevitServiceId = "revit";
-        public static readonly string RevitServiceSecret = "63afbef6906c342b";
-        public static readonly string OSSKeyPath = @"files/revit/";
-        //Oss相关
-        public static string AccessKeyId = "LTAIQVvCRivyl3Dd";
-        public static string AccessKeySecret = "hkGLC7RgWUntbAS2Zw5rWOVS8Xhj0G";
-        public static string Endpoint = "oss-cn-beijing.aliyuncs.com";
-        public static string BucketName = "saga-data";
-
-    }
-}

BIN
PackageUpdater/WPFTestUpdate/Dlls/SAGA.DotNetUtils.dll


+ 1 - 0
PackageUpdater/WPFTestUpdate/Extend.cs

@@ -8,6 +8,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Update;
 
 namespace PackageUploader
 {

+ 26 - 0
PackageUpdater/WPFTestUpdate/Http/FileContent.cs

@@ -0,0 +1,26 @@
+/* ==============================================================================
+ * 功能描述:FileContent  
+ * 创 建 者:Garrett
+ * 创建日期:2019/9/16 19:25:15
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PackageUploader.Http
+{
+    /// <summary>
+    /// FileContent
+    /// </summary>
+    class FileContent
+    {
+        public int BufferLength { get; set; } = 1024 * 1024;
+        /// <summary>
+        /// 超时设置
+        /// </summary>
+        public int Timeout { get; set; } = 60000;
+        public EventHandler<StreamProgressArgs> TransferProgress { get; set; }
+    }
+}

+ 118 - 0
PackageUpdater/WPFTestUpdate/Http/PutFlieContent.cs

@@ -0,0 +1,118 @@
+/* ==============================================================================
+ * 功能描述:PutFlieContent  
+ * 创 建 者:Garrett
+ * 创建日期:2019/9/16 19:24:43
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PackageUploader.Http
+{
+    /// <summary>
+    /// PutFlieContent
+    /// </summary>
+    class PutFlieContent : FileContent
+    {
+        private string m_Url;
+        private Stream m_Stream;
+        public PutFlieContent(string url, Stream stream)
+        {
+            m_Url = url;
+            m_Stream = stream;
+        }
+        /// <summary>
+        /// 上传文件
+        /// </summary>
+        /// <returns></returns>
+        public virtual string PutContent()
+        {
+            var url = m_Url;
+            var stream = m_Stream;
+            if (stream == null)
+                throw new ArgumentNullException(nameof(stream));
+            var responseValue = string.Empty;
+            HttpWebRequest request = null;
+            try
+            {
+                var totalLength = stream.Length;
+                request = (HttpWebRequest)WebRequest.Create(url);
+                request.KeepAlive = true;
+                request.Timeout = Timeout;
+                request.Method = "POST";
+                request.ContentLength = totalLength;
+                request.ContentType = "multipart/form-data; ";
+                #region 请求数据
+
+                byte[] buffer = new byte[BufferLength];
+
+                var transLength = 0;
+                using (BinaryReader r = new BinaryReader(stream))
+                {
+                    Stream postStream = request.GetRequestStream();
+                    try
+                    {
+                        int size = 0;
+                        do
+                        {
+                            size = r.Read(buffer, 0, buffer.Length);
+                            postStream.Write(buffer, 0, size);
+                            transLength += size;
+
+                            #region 调用事件
+
+                            StreamProgressArgs args = new StreamProgressArgs(size, transLength, totalLength);
+                            args.TransCompleted = (size == (long)0);
+                            TransferProgress?.Invoke(this, args);
+
+                            #endregion
+                        } while (size > 0);
+                    }
+                    finally
+                    {
+                        postStream?.Close();
+                    }
+                }
+
+                #endregion
+
+                #region 相应数据
+
+                //返回数据
+                using (var response = (HttpWebResponse)request.GetResponse())
+                {
+                    if (response.StatusCode != HttpStatusCode.OK)
+                    {
+                        var message = String.Format("请求失败. 获得http状态 {0}", response.StatusCode);
+                        throw new ApplicationException(message);
+                    }
+
+                    using (var responseStream = response.GetResponseStream())
+                    {
+                        if (responseStream != null)
+
+                            using (var reader = new StreamReader(responseStream))
+                            {
+                                responseValue = reader.ReadToEnd();
+                            }
+                    }
+                }
+
+                #endregion
+            }
+            catch (Exception e)
+            {
+                throw;
+            }
+            finally
+            {
+                //request?.dis
+            }
+            return responseValue;
+        }
+    }
+}

+ 33 - 0
PackageUpdater/WPFTestUpdate/Http/StreamProgressArgs.cs

@@ -0,0 +1,33 @@
+/* ==============================================================================
+ * 功能描述:StreamProgressArgs  
+ * 创 建 者:Garrett
+ * 创建日期:2019/9/16 19:25:42
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PackageUploader.Http
+{
+    /// <summary>
+    /// StreamProgressArgs
+    /// </summary>
+    class StreamProgressArgs : EventArgs
+    {
+        public StreamProgressArgs(long incrementTransferred, long transferred, long total)
+        {
+            IncrementTransferred = incrementTransferred;
+            TransferredBytes = transferred;
+            TotalBytes = total;
+        }
+        public long IncrementTransferred { get; private set; }
+        public long TransferredBytes { get; private set; }
+        public long TotalBytes { get; private set; }
+        /// <summary>
+        /// 传输是否完成
+        /// </summary>
+        public bool TransCompleted { get; internal set; }
+    }
+}

+ 7 - 5
PackageUpdater/WPFTestUpdate/MainWindow.xaml

@@ -18,15 +18,17 @@
             <RowDefinition Height="30"/>
         </Grid.RowDefinitions>
         <StackPanel Grid.Row="0">
-            <dotuntils:SelectPath_Start Name="txtBasePath" Height="25" Text="{Binding Path=BasePath,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
-                                        BtnImage="/PackageUploader;Component/Image/folder.png"></dotuntils:SelectPath_Start>
+            <dotuntils:SelectFile_Hyperlink  Height="25" Text="{Binding Path=ExeFullPath,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
+                                         IsDisplayFullPath="True" ></dotuntils:SelectFile_Hyperlink>
+            <dotuntils:SelectPath Name="txtBasePath" Height="25" Text="{Binding Path=BasePath,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
+                                        BtnImage="/PackageUploader;Component/Image/folder.png"></dotuntils:SelectPath>
             <Grid Height="25">
                 <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="25"/>
                     <ColumnDefinition/>
+                    <ColumnDefinition Width="25"/>
                 </Grid.ColumnDefinitions>
-                <CheckBox x:Name="chk" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="True"></CheckBox>
-                <TextBox x:Name="txtDirs" Grid.Column="1" Text="{Binding Path=Dirs,UpdateSourceTrigger=PropertyChanged}"
+                <CheckBox Grid.Column="1" x:Name="chk" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="True"></CheckBox>
+                <TextBox x:Name="txtDirs" Grid.Column="0" Text="{Binding Path=Dirs,UpdateSourceTrigger=PropertyChanged}"
                          VerticalContentAlignment="Center"
                          IsEnabled="{Binding ElementName=chk,Path=IsChecked,Converter={StaticResource BoolToInverserConverter},UpdateSourceTrigger=PropertyChanged}"></TextBox>
             </Grid>

+ 29 - 10
PackageUpdater/WPFTestUpdate/MainWindow.xaml.cs

@@ -8,6 +8,7 @@ using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Threading;
 using SAGA.DotNetUtils.Extend;
+using Update;
 using WPFTestUpdate;
 using WPFTestUpdate.Utils;
 
@@ -30,6 +31,23 @@ namespace PackageUploader
 
 
         #region SavePath LoadPath
+        private string m_ExeFullPathKey = nameof(ExeFullPath);
+        private string m_BasePathKey = nameof(BasePath);
+        private string m_DirNameKey = nameof(Dirs);
+
+        private string m_ExeFullPath;
+
+        public string ExeFullPath
+        {
+            get { return m_ExeFullPath; }
+            set
+            {
+                m_ExeFullPath = value;
+                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(m_ExeFullPathKey));
+
+                FileStoreHandler.SaveData(m_ExeFullPathKey, value);
+            }
+        }
 
         private string m_BasePath;
 
@@ -59,20 +77,21 @@ namespace PackageUploader
             }
         }
 
-
-        private void SaveBasePath(Control uc, string path)
-        {
-        }
-
-        private string m_BasePathKey = nameof(BasePath);
-        private string m_DirNameKey = nameof(Dirs);
         private void LoadSetting()
         {
-            string value = FileStoreHandler.GetData(m_BasePathKey);
+            string value = FileStoreHandler.GetData(m_ExeFullPathKey);
+            if (value.IsNullOrEmpty())
+            {
+                value = @"D:\Revit\saga\MBI\OutputDll\SAGA.MBI.exe";
+            }
+            ExeFullPath = value;
+
+            value = FileStoreHandler.GetData(m_BasePathKey);
             if (value.IsNullOrEmpty())
             {
                 value = @"D:\Revit\saga\MBI";
             }
+
             BasePath = value;
 
             value = FileStoreHandler.GetData(m_DirNameKey);
@@ -87,7 +106,7 @@ namespace PackageUploader
 
         private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
         {
-            string exeBasePath = txtBasePath.Text;
+            string exeBasePath = BasePath;
             var dirList = new List<string>();
             #region 获取需要打包的文件夹列表
 
@@ -113,7 +132,7 @@ namespace PackageUploader
                 () =>
                 {
                     RefrushState("准备");
-                    string exePath = Path.Combine(exeBasePath, @"OutputDll\SAGA.MBI.exe");
+                    string exePath = ExeFullPath;
                     if (!File.Exists(exePath))
                     {
                         RefrushState("可执行的Exe文件不存在,请检查");

+ 3 - 1
PackageUpdater/WPFTestUpdate/PackageUploader.csproj

@@ -75,7 +75,9 @@
     </ApplicationDefinition>
     <Compile Include="Compress\CompressT.cs" />
     <Compile Include="Compress\CompressArgs.cs" />
-    <Compile Include="Const.cs" />
+    <Compile Include="Http\FileContent.cs" />
+    <Compile Include="Http\PutFlieContent.cs" />
+    <Compile Include="Http\StreamProgressArgs.cs" />
     <Compile Include="Untility.cs" />
     <Compile Include="Extend.cs" />
     <Compile Include="Utils\FileStoreHandler.cs" />

+ 36 - 18
PackageUpdater/WPFTestUpdate/Untility.cs

@@ -5,17 +5,23 @@
  * ==============================================================================*/
 
 using System;
+using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Reflection;
 using Aliyun.OSS;
 using Aliyun.OSS.Common;
+using Aliyun.OSS.Util;
 using ICSharpCode.SharpZipLib.Zip;
 using Newtonsoft.Json.Linq;
 using SAGA.DotNetUtils.FileOperate;
 using SAGA.DotNetUtils.Http;
 using Update.Core.Entities;
 using PackageUploader.Compress;
+using PackageUploader.Http;
+using SAGA.DotNetUtils.Others;
+using Update;
+using HttpUtils = Update.HttpUtils;
 
 namespace PackageUploader
 {
@@ -176,30 +182,42 @@ namespace PackageUploader
         {
             bool result = true;
             string fileName = Path.GetFileName(compressPath);
-            string key = $"{Const.OSSKeyPath}{fileName}";
             m_UploadAction = action;
-            OssClient client = new OssClient(Const.Endpoint, Const.AccessKeyId, Const.AccessKeySecret);
+            var url = HttpUtils.GetUploadUrl(fileName);
             try
             {
                 using (var fs = new MemoryStream(FileStreamOperate.ReadFile(compressPath)))
                 {
-                    string bucketName = Const.BucketName;
+                    PutFlieContent fileContent = new PutFlieContent(url, fs);
+                    #region 进度条管理
+                    fileContent.TransferProgress += (sender, args) =>
+                    {
+                        try
+                        {
+                            var currentData = Math.Round(args.TransferredBytes * 100d / args.TotalBytes, 3);
+                            Debug.WriteLine("ProgressCallback - TotalBytes:{0}M, TransferredBytes:{1}M,上传百分比:{2}%",
+                                args.TotalBytes / 1024 / 1024, args.TransferredBytes / 1024 / 1024, currentData);
+                            UploadProgressCallback(sender, args);
+                        }
+                        catch (Exception ex)
+                        {
 
-                    var putObjectRequest = new PutObjectRequest(bucketName, key, fs);
-                    putObjectRequest.StreamTransferProgress += UploadProgressCallback;
-                    client.PutObject(putObjectRequest);
+                            throw;
+                        }
+                    };
+                    #endregion
+                    var resultStr = fileContent.PutContent();
+                    JObject rj = JObject.Parse(resultStr);
+                    if (rj["Result"].ToString() == "success")
+                    {
+                        return true;
+                    }
+                    throw new Exception(rj["ResultMsg"].ToString());
                 }
-                Console.WriteLine("Put object:{0} succeeded", key);
-            }
-            catch (OssException ex)
-            {
-                Console.WriteLine(@"Failed with error code: {0}; Error info: {1}. \nRequestID:{2}\tHostID:{3}",
-                    ex.ErrorCode, ex.Message, ex.RequestId, ex.HostId);
-                result = false;
             }
             catch (Exception ex)
             {
-                Console.WriteLine($@"Failed with error info: { ex.Message}");
+                MessageShowBase.Infomation("Revit文件上传载失败!\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                 result = false;
             }
             return result;
@@ -209,7 +227,7 @@ namespace PackageUploader
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="args"></param>
-        private static void UploadProgressCallback(object sender, StreamTransferProgressArgs args)
+        private static void UploadProgressCallback(object sender, StreamProgressArgs args)
         {
             var currentData = Math.Round(args.TransferredBytes * 100d / args.TotalBytes, 3);
             m_UploadAction?.Invoke(string.Format("UploadCallback - TotalBytes:{0}M, TransferredBytes:{1}M,UploadPrecent:{2}%",
@@ -224,7 +242,7 @@ namespace PackageUploader
         /// <param name="md5"></param>
         public static string SaveVision(string key, string value)
         {
-            string url = $"{Const.URL}/image-service/common/file_upload?systemId={Const.RevitServiceId}&secret={Const.RevitServiceSecret}&key={key}&overwrite=true";
+            string url = HttpUtils.GetUploadUrl(key);
             RestClient client = new RestClient(url, HttpVerb.POST, value);
             string request = client.PostRequest();
             return request;
@@ -235,7 +253,7 @@ namespace PackageUploader
         public static void DeleteCompress()
         {
             string compressName = $"{ReadVision()}_{Const.Key}.zip";
-            string url = $"{Const.URL}/image-service/common/files_delete?systemId={Const.RevitServiceId}&secret={Const.RevitServiceSecret}";
+            string url =HttpUtils.DeleteUrl();
             JArray jArray = new JArray();
             jArray.Add(compressName);
             JObject jObject = new JObject
@@ -255,7 +273,7 @@ namespace PackageUploader
         /// <returns></returns>
         public static Version ReadVision()
         {
-            string url = $"{Const.URL}/image-service/common/file_get/{Const.Key}?systemId={Const.RevitServiceId}";
+            string url = HttpUtils.GetDownloadUrl(Update.Const.Key);
 
             Packages packages = null;
             try

+ 22 - 0
PackageUpdater/WPFTestUpdate/WinMFMUploadProcress.xaml

@@ -0,0 +1,22 @@
+<Window x:Class="PackageUploader.WinMFMUploadProcress"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        WindowStyle="None"
+        WindowStartupLocation="CenterScreen"
+             mc:Ignorable="d" 
+        Title="上传模型文件并处理"
+             Height="270" Width="600">
+    <Canvas>
+        <Label Name="txtFloorName" Canvas.Left="40" Canvas.Top="35" Content="{Binding Path=FloorName,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" FontSize="24"></Label>
+        <Label Canvas.Left="40" Canvas.Top="80">
+            <TextBlock x:Name="txtPath" Text="{Binding Path=LabelPath,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" FontSize="17" Width="490" TextWrapping="WrapWithOverflow">
+            </TextBlock>
+        </Label>
+        <Label Name="lblpresent" Canvas.Left="40" Width="521" Canvas.Top="188" Content="{Binding Path=Present,Mode=TwoWay}" FontSize="11"/>
+        <ProgressBar Name="progressBar" HorizontalAlignment="Left" Height="20" VerticalAlignment="Top" Width="465" Canvas.Left="40" Canvas.Top="167"
+                     Minimum="0" Maximum="100"/>
+        <Label x:Name="lblpresent_Total" Canvas.Left="505" Width="55" Canvas.Top="165" Content="(0/0)" FontSize="11"/>
+    </Canvas>
+</Window>

+ 121 - 0
PackageUpdater/WPFTestUpdate/WinMFMUploadProcress.xaml.cs

@@ -0,0 +1,121 @@
+using System;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Windows.Controls;
+using System.Windows.Threading;
+
+namespace PackageUploader
+{
+    /// <summary>
+    /// WinMFMUploadProcress.xaml 的交互逻辑
+    /// </summary>
+    public partial class WinMFMUploadProcress :INotifyPropertyChanged
+    {
+        private double m_ProgressLeft;
+        public WinMFMUploadProcress()
+        {
+            InitializeComponent();
+            m_ProgressLeft=Canvas.GetLeft(progressBar);
+            this.DataContext = this;
+            //var lblwidth = lblpresent.Width;
+            //Canvas.SetLeft(lblpresent, m_ProgressLeft - (lblwidth / 2.0));
+        }
+        private string m_FloorName;
+
+        public string FloorName
+        {
+            get { return m_FloorName; }
+            set
+            {
+                m_FloorName = value;
+                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("FloorName"));
+            }
+        }
+
+        private string m_LabelPath;
+
+        public string LabelPath
+        {
+            get { return m_LabelPath; }
+            set
+            {
+                m_LabelPath = value;
+                PropertyChanged?.Invoke(this,new PropertyChangedEventArgs("LabelPath"));
+            }
+        }
+        private string m_Present;
+
+        public string Present
+        {
+            get { return m_Present; }
+            set
+            {
+                m_Present = value;
+                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Present"));
+            }
+        }
+
+
+
+        //public string FloorName
+        //{
+        //    set { txtFloorName.Content = value; }
+        //}
+        //public string LabelPath
+        //{
+        //    set { txtPath.Text = value; }
+        //}
+
+        public int Count { get; set; }
+        public int Cur { get; set; }
+
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        public void Update(string currentData)
+        {
+            //lblpresent.Content = Present;
+            //Present = currentData;
+            this.Dispatcher.Invoke(() => { lblpresent.Content = currentData + "%"; }, DispatcherPriority.Background);
+
+            //DispatcherFrame nestedFrame = new DispatcherFrame();
+            //DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, exitFrameCallback, nestedFrame);
+            //Dispatcher.PushFrame(nestedFrame);
+            //if (exitOperation.Status !=
+            //    DispatcherOperationStatus.Completed)
+            //{
+            //    exitOperation.Abort();
+            //}
+
+            //lblpresent.Dispatcher.Invoke(() => { lblpresent.Content = currentData + "%"; },
+            //    DispatcherPriority.Background);
+            //this.Dispatcher.Invoke(() => { lblpresent.Content = currentData + "%"; }, DispatcherPriority.Background);
+            //var progresswidth = progressBar.Width;
+            //var progressleft = Canvas.GetLeft(progressBar);
+            //var lblwidth = lblpresent.Width;
+            ////Canvas.SetLeft(lblpresent, progressleft + progresswidth * (currentData / 100.0) - (lblwidth / 2.0))), DispatcherPriority.Background
+            //Dispatcher.Invoke(
+            //    new Action(() =>
+            //    {
+            //        lblpresent_Total.Content = $"({Cur}/{Count})";
+            //        lblpresent.Content = currentData + "%";
+            //    } ), DispatcherPriority.Background);
+            //Dispatcher.Invoke(
+            //    new Action(() => Canvas.SetLeft(lblpresent, progressleft + progresswidth * (currentData / 100.0) - (lblwidth / 2.0))),DispatcherPriority.Background);
+            //Canvas.SetLeft(lblpresent, progressleft+progresswidth*(currentData/100.0)-(lblwidth/2.0));
+            //Dispatcher.Invoke(
+            //    new Action<DependencyProperty, object>((db, value) => this.progressBar.SetValue(db, value)),
+            //    System.Windows.Threading.DispatcherPriority.Background,
+            //    RangeBase.ValueProperty, Convert.ToDouble(currentData));
+        }
+        private static DispatcherOperationCallback exitFrameCallback = new DispatcherOperationCallback(ExitFrame);
+        private static Object ExitFrame(Object state)
+        {
+            DispatcherFrame frame = state as
+                DispatcherFrame;
+            frame.Continue = false;
+            return null;
+        }
+
+
+    }
+}