diff --git a/BBWYB.Client/App.xaml.cs b/BBWYB.Client/App.xaml.cs index 9b29706..826b4a8 100644 --- a/BBWYB.Client/App.xaml.cs +++ b/BBWYB.Client/App.xaml.cs @@ -32,7 +32,10 @@ namespace BBWYB.Client #if DEBUG //齐越山鸡 - userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNjk0NjY5NjkxfQ.cSwro-7bGwOu92YejH9JhMenTai7Mvf99i2paQCmxIw"; + //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNzI2MzAwNjY0fQ.hPSbgJEuTt0MLy_7YkSJX4rRG3drJAfso-5IS8ZlOkY"; + + //议价2组 + userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxMzk1NzA4MjA4NjU1MzcyMjg4IiwidGVhbUlkIjoiMTYyMDM0MjAxNDcwNjk3ODgxNiIsInNvblRlYW1JZHMiOiIxNzYwOTcxNjg4OTY0NTI2MDgwIiwiZXhwIjoxNzQyNjMwODk0fQ.Vtq2MU1Qd9Oo192udkA01ZAwiQgQxj2m-pkayGZ1d3I"; //拳探店铺 陈默 //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNjI0OTUxNjgzNTc2NTAwMjI0IiwidGVhbUlkIjoiMTYyMDM0MjAxNDcwNjk3ODgxNiIsInNvblRlYW1JZHMiOiIxNjIwMzQyMDE0NzA2OTc4ODE2LDE2MjAzNDM4Mjc0NzI1ODQ3MDQsMTYyMDM0NDAzMzczNTg3MjUxMiwxNjIwMzQ0MDkyODI5NDIxNTY4LDE2MjAzNDQxNDA4NTAwMDgwNjQiLCJleHAiOjE3MjA3NjQzMjV9.Q8fiKXCHgvzbm7NDEre-MeoSju_AmC6Ae6eDY22rUAw"; diff --git a/BBWYB.Client/BBWYB.Client.csproj b/BBWYB.Client/BBWYB.Client.csproj index 91a07a9..5fca9cb 100644 --- a/BBWYB.Client/BBWYB.Client.csproj +++ b/BBWYB.Client/BBWYB.Client.csproj @@ -53,17 +53,4 @@ - - - Code - - - - - - $(DefaultXamlRuntime) - Designer - - - diff --git a/BBWYB.Client/GlobalContext.cs b/BBWYB.Client/GlobalContext.cs index 1471516..e35f704 100644 --- a/BBWYB.Client/GlobalContext.cs +++ b/BBWYB.Client/GlobalContext.cs @@ -2,7 +2,6 @@ using BBWYB.Client.Helpers; using BBWYB.Client.Models; using BBWYB.Client.Views.PackPurchaseTaska; -using BBWYB.Client.Views.WebB; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.DependencyInjection; @@ -21,7 +20,7 @@ namespace BBWYB.Client { public GlobalContext() { - BBWYBApiVersion = "10038"; + BBWYBApiVersion = "10041"; } private User user; @@ -119,7 +118,6 @@ namespace BBWYB.Client UpdatePurchaseTaskWindow packTask = new(res.Data, originShopName, orderSku); if (!packTask.IsClosed) packTask.Show(); - WeakReferenceMessenger.Default.Send(new Message_WebB_RefreshPack(null)); // } #endregion diff --git a/BBWYB.Client/ViewModels/MainViewModel.cs b/BBWYB.Client/ViewModels/MainViewModel.cs index 4903cbf..a3b73a8 100644 --- a/BBWYB.Client/ViewModels/MainViewModel.cs +++ b/BBWYB.Client/ViewModels/MainViewModel.cs @@ -1,7 +1,6 @@ using BBWYB.Client.APIServices; using BBWYB.Client.Models; using BBWYB.Client.Views.SelectShop; -using BBWYB.Client.Views.WebB; using BBWYB.Common.Extensions; using BBWYB.Common.Models; using CommunityToolkit.Mvvm.Input; @@ -233,10 +232,6 @@ namespace BBWYB.Client.ViewModels vm.OrderVM.Refresh(); if (vm.IsCreateWareManager) vm.WareManager.Refresh(); - if (SelectedMenuModel?.Name == "订单列表Bata") - { - WeakReferenceMessenger.Default.Send(new Message_WebB_Refresh(null)); - } } } catch (Exception ex) diff --git a/BBWYB.Client/ViewModels/WebVM.cs b/BBWYB.Client/ViewModels/WebVM.cs index 9e5b38c..a6eeee8 100644 --- a/BBWYB.Client/ViewModels/WebVM.cs +++ b/BBWYB.Client/ViewModels/WebVM.cs @@ -17,6 +17,7 @@ namespace BBWYB.Client.ViewModels private MdsApiService mdsApiService; private MenuModel selectedMenuModel; private bool isLoading; + private IList managerDepartment; ShopService shopService; public GlobalContext GlobalContext { get; set; } public bool IsLoading { get => isLoading; set { SetProperty(ref isLoading, value); } } @@ -28,6 +29,7 @@ namespace BBWYB.Client.ViewModels this.mdsApiService = mdsApiService; this.GlobalContext = globalContext; this.shopService = shopService; + this.managerDepartment = new List() { "董事办", "财务部", "技术部", "总经办" }; Task.Factory.StartNew(Login); } @@ -47,36 +49,50 @@ namespace BBWYB.Client.ViewModels if (mdsUserResponse.Data.SonDepartmentList != null && mdsUserResponse.Data.SonDepartmentList.Count > 0) GlobalContext.User.SonDepartmentNames = string.Join(',', mdsUserResponse.Data.SonDepartmentList.Select(sd => sd.DepartmentName)); - var res = shopService.GetDepartmentList(); - if (!res.Success) - throw new Exception(res.Msg); - var allDepartmentList = res.Data.Map>(); + IList departmentList = null; - var shopList = new List(); - foreach (var d in allDepartmentList) - shopList.AddRange(d.ShopList); - GlobalContext.User.ShopList = shopList; + if (managerDepartment.Contains(GlobalContext.User.TeamName) || + managerDepartment.Any(m => GlobalContext.User.SonDepartmentNames.Contains(m))) + { + var res = shopService.GetDepartmentList(); + if (!res.Success) + throw new Exception(res.Msg); + var allDepartmentList = res.Data.Map>(); - IList departmentList = null; + var shopList = new List(); + foreach (var d in allDepartmentList) + shopList.AddRange(d.ShopList); + GlobalContext.User.ShopList = shopList; + departmentList = allDepartmentList.Where(d => d.Name.Contains("供应链")).ToList(); + } + else + { + var response = mdsApiService.GetShopDetailList(); + if (!response.Success) + throw new Exception(response.Msg); + departmentList = response.Data.Where(d => d.Name.Contains("供应链")).ToList(); + } - //var response = mdsApiService.GetShopDetailList(); - //if (!response.Success) - // throw new Exception(response.Msg); - departmentList = allDepartmentList.Where(d => d.Name.Contains("供应链")).ToList(); if (departmentList.Count == 0) throw new Exception("缺少有效的部门数据"); - var shopIds = new List(); - foreach (var d in departmentList) - { - if (d.ShopList != null && d.ShopList.Count > 0) - { - foreach (var s in d.ShopList) - shopIds.Add(s.ShopId.ToString()); - } - } + + //departmentList = allDepartmentList.Where(d => d.Name.Contains("供应链")).ToList(); + //if (departmentList.Count == 0) + // throw new Exception("缺少有效的部门数据"); + + //var shopIds = new List(); + //foreach (var d in departmentList) + //{ + // if (d.ShopList != null && d.ShopList.Count > 0) + // { + // foreach (var s in d.ShopList) + // shopIds.Add(s.ShopId.ToString()); + // } + //} + GlobalContext.User.DepartmentList = departmentList; WeakReferenceMessenger.Default.Send(new Message_WebB_LoginCompleted(null)); diff --git a/BBWYB.Client/Views/PackPurchaseTask/UpdatePurchaseTaskWindow.xaml.cs b/BBWYB.Client/Views/PackPurchaseTask/UpdatePurchaseTaskWindow.xaml.cs index 715c23c..1bb322d 100644 --- a/BBWYB.Client/Views/PackPurchaseTask/UpdatePurchaseTaskWindow.xaml.cs +++ b/BBWYB.Client/Views/PackPurchaseTask/UpdatePurchaseTaskWindow.xaml.cs @@ -1,24 +1,11 @@ using BBWYB.Client.Models; using BBWYB.Client.Models.APIModel.Response.PackPurchaseTask; using BBWYB.Client.ViewModels; -using BBWYB.Client.Views.Ware; -using BBWYB.Client.Views.WebB; using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging.Messages; using SJ.Controls; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace BBWYB.Client.Views.PackPurchaseTaska { diff --git a/BBWYB.Client/Views/Web.xaml.cs b/BBWYB.Client/Views/Web.xaml.cs index 19ed019..62e6121 100644 --- a/BBWYB.Client/Views/Web.xaml.cs +++ b/BBWYB.Client/Views/Web.xaml.cs @@ -43,7 +43,9 @@ namespace BBWYB.Client.Views private void initWebView() { #if DEBUG - var url = "http://192.168.1.2:8080"; + var url = "http://qtbbwy.qiyue666.com"; + //var registerName = "webContext"; + //var url = "http://192.168.1.2:8080"; var registerName = "webTestContext"; //var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html"); #else diff --git a/BBWYB.Client/Views/WebB/WebB.xaml b/BBWYB.Client/Views/WebB/WebB.xaml deleted file mode 100644 index 9131a20..0000000 --- a/BBWYB.Client/Views/WebB/WebB.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - diff --git a/BBWYB.Client/Views/WebB/WebB.xaml.cs b/BBWYB.Client/Views/WebB/WebB.xaml.cs deleted file mode 100644 index b365133..0000000 --- a/BBWYB.Client/Views/WebB/WebB.xaml.cs +++ /dev/null @@ -1,105 +0,0 @@ -using CommunityToolkit.Mvvm.Messaging; -using CommunityToolkit.Mvvm.Messaging.Messages; -using Microsoft.Extensions.DependencyInjection; -using System.Windows; -using System.Windows.Controls; - -namespace BBWYB.Client.Views.WebB -{ - /// - /// WebB.xaml 的交互逻辑 - /// - public partial class WebB : Page - { - private WebView2Manager w2m; - private bool isNavigated; - - private GlobalContext globalContext; - - public WebB() - { - InitializeComponent(); - this.Loaded += WebB_Loaded; - this.Unloaded += WebB_Unloaded; - - WeakReferenceMessenger.Default.Register(this, (o, x) => - { - this.Dispatcher.Invoke(() => - { - _ = w2m.wb2.ExecuteScriptAsync("window.location.reload();"); - }); - }); - - WeakReferenceMessenger.Default.Register(this, (o, x) => - { - this.Dispatcher.Invoke(() => - { - _ = w2m.wb2.ExecuteScriptAsync("window.BBWY_B_WebContex('PACK_CONFIG_SUCCESS');"); - }); - }); - } - - private void WebB_Unloaded(object sender, RoutedEventArgs e) - { - grid.Children.Remove(w2m.wb2); - //w2m.wb2.Dispose(); - w2m.Close(); - WeakReferenceMessenger.Default.UnregisterAll(this); - } - - private void WebB_Loaded(object sender, System.Windows.RoutedEventArgs e) - { - var sp = (App.Current as App).ServiceProvider; - using (var s = sp.CreateScope()) - { - w2m = s.ServiceProvider.GetRequiredService(); - globalContext = s.ServiceProvider.GetRequiredService(); - } - -#if DEBUG - var url = "http://192.168.1.8:8080"; - var registerName = "webTestContext"; - //var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html"); -#else - var url = "http://qtbbwy.qiyue666.com"; - var registerName = "webContext"; -#endif - //var url = "http://qtbbwy.qiyue666.com"; - w2m.CoreWebView2InitializationCompleted = (e) => - { - w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext); - isNavigated = true; - w2m.wb2.CoreWebView2.Navigate(url); - }; - - - w2m.Init("bbwyb_web"); - w2m.wb2.SetValue(Grid.RowProperty, 1); - w2m.wb2.Margin = new Thickness(1, 0, 1, 0); - //grid.Children.Clear(); - grid.Children.Add(w2m.wb2); - - if (w2m.IsInitializationCompleted && !isNavigated) - { - w2m.wb2.CoreWebView2.Navigate(url); - //w2m.wb2.CoreWebView2.NavigateToString(content); - isNavigated = true; - } - } - } - - - public class Message_WebB_Refresh : ValueChangedMessage - { - public Message_WebB_Refresh(object value) : base(value) - { - } - } - - public class Message_WebB_RefreshPack : ValueChangedMessage - { - public Message_WebB_RefreshPack(object value) : base(value) - { - } - } -} diff --git a/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml b/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml deleted file mode 100644 index 8df7144..0000000 --- a/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - diff --git a/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml.cs b/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml.cs deleted file mode 100644 index d4b329c..0000000 --- a/BBWYB.Client/Views/WebB/WebB_GoodsSource.xaml.cs +++ /dev/null @@ -1,104 +0,0 @@ -using CommunityToolkit.Mvvm.Messaging; -using CommunityToolkit.Mvvm.Messaging.Messages; -using Microsoft.Extensions.DependencyInjection; -using System.Windows; -using System.Windows.Controls; - -namespace BBWYB.Client.Views.WebB -{ - /// - /// WebB.xaml 的交互逻辑 - /// - public partial class WebB_GoodsSource : Page - { - private WebView2Manager w2m; - private bool isNavigated; - - private GlobalContext globalContext; - - public WebB_GoodsSource() - { - InitializeComponent(); - this.Loaded += WebB_Loaded; - this.Unloaded += WebB_Unloaded; - - //WeakReferenceMessenger.Default.Register(this, (o, x) => - //{ - // this.Dispatcher.Invoke(() => - // { - // _ = w2m.wb2.ExecuteScriptAsync("window.location.reload();"); - // }); - //}); - - //WeakReferenceMessenger.Default.Register(this, (o, x) => - //{ - // this.Dispatcher.Invoke(() => - // { - // _ = w2m.wb2.ExecuteScriptAsync("window.BBWY_B_WebContex('PACK_CONFIG_SUCCESS');"); - // }); - //}); - } - - private void WebB_Unloaded(object sender, RoutedEventArgs e) - { - grid.Children.Remove(w2m.wb2); - //w2m.wb2.Dispose(); - w2m.Close(); - WeakReferenceMessenger.Default.UnregisterAll(this); - } - - private void WebB_Loaded(object sender, System.Windows.RoutedEventArgs e) - { - var sp = (App.Current as App).ServiceProvider; - using (var s = sp.CreateScope()) - { - w2m = s.ServiceProvider.GetRequiredService(); - globalContext = s.ServiceProvider.GetRequiredService(); - } - -#if DEBUG - var url = "http://192.168.1.2:8080/#/goods-source"; - var registerName = "webTestContext"; - //var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html"); -#else - var url = "http://qtbbwy.qiyue666.com/#/goods-source"; - var registerName = "webContext"; -#endif - w2m.CoreWebView2InitializationCompleted = (e) => - { - w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext); - isNavigated = true; - w2m.wb2.CoreWebView2.Navigate(url); - }; - - - w2m.Init("bbwyb_web"); - w2m.wb2.SetValue(Grid.RowProperty, 1); - w2m.wb2.Margin = new Thickness(1, 0, 1, 0); - //grid.Children.Clear(); - grid.Children.Add(w2m.wb2); - - if (w2m.IsInitializationCompleted && !isNavigated) - { - w2m.wb2.CoreWebView2.Navigate(url); - //w2m.wb2.CoreWebView2.NavigateToString(content); - isNavigated = true; - } - } - } - - - //public class Message_WebB_GoodsSource_Refresh : ValueChangedMessage - //{ - // public Message_WebB_GoodsSource_Refresh(object value) : base(value) - // { - // } - //} - - //public class Message_WebB_GoodsSource_RefreshPack : ValueChangedMessage - //{ - // public Message_WebB_GoodsSource_RefreshPack(object value) : base(value) - // { - // } - //} -} diff --git a/BBWYB.Client/Views/WebB/WebB_KPI.xaml b/BBWYB.Client/Views/WebB/WebB_KPI.xaml deleted file mode 100644 index 261dbfd..0000000 --- a/BBWYB.Client/Views/WebB/WebB_KPI.xaml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - diff --git a/BBWYB.Client/Views/WebB/WebB_KPI.xaml.cs b/BBWYB.Client/Views/WebB/WebB_KPI.xaml.cs deleted file mode 100644 index da0813d..0000000 --- a/BBWYB.Client/Views/WebB/WebB_KPI.xaml.cs +++ /dev/null @@ -1,87 +0,0 @@ -using CommunityToolkit.Mvvm.Messaging; -using CommunityToolkit.Mvvm.Messaging.Messages; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Windows; -using System.Windows.Controls; - -namespace BBWYB.Client.Views.WebB -{ - /// - /// WebB_KPI.xaml 的交互逻辑 - /// - public partial class WebB_KPI : Page - { - private WebView2Manager w2m; - private bool isNavigated; - - private GlobalContext globalContext; - public WebB_KPI() - { - InitializeComponent(); - - this.Loaded += WebB_KPI_Loaded; ; - this.Unloaded += WebB_KPI_Unloaded; - - WeakReferenceMessenger.Default.Register(this, (o, x) => - { - this.Dispatcher.Invoke(() => - { - _ = w2m.wb2.ExecuteScriptAsync("window.location.reload();"); - }); - }); - } - - private void WebB_KPI_Unloaded(object sender, RoutedEventArgs e) - { - grid.Children.Remove(w2m.wb2); - w2m.Close(); - WeakReferenceMessenger.Default.UnregisterAll(this); - } - - private void WebB_KPI_Loaded(object sender, RoutedEventArgs e) - { - var sp = (App.Current as App).ServiceProvider; - using (var s = sp.CreateScope()) - { - w2m = s.ServiceProvider.GetRequiredService(); - globalContext = s.ServiceProvider.GetRequiredService(); - } - -#if DEBUG - var url = "http://localhost:8080/#/performance"; - var registerName = "webTestContext"; -#else - var url = "http://qtbbwy.qiyue666.com/#/performance"; - var registerName = "webContext"; -#endif - w2m.CoreWebView2InitializationCompleted = (e) => - { - w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext); - isNavigated = true; - w2m.wb2.CoreWebView2.Navigate(url); - }; - - - w2m.Init("bbwyb_web"); - w2m.wb2.SetValue(Grid.RowProperty, 1); - w2m.wb2.Margin = new Thickness(1, 0, 1, 0); - //grid.Children.Clear(); - grid.Children.Add(w2m.wb2); - - if (w2m.IsInitializationCompleted && !isNavigated) - { - w2m.wb2.CoreWebView2.Navigate(url); - //w2m.wb2.CoreWebView2.NavigateToString(content); - isNavigated = true; - } - } - } - - public class Message_WebBKPI_Refresh : ValueChangedMessage - { - public Message_WebBKPI_Refresh(object value) : base(value) - { - } - } -} diff --git a/BBWYB.Common/Extensions/ConverterExtensions.cs b/BBWYB.Common/Extensions/ConverterExtensions.cs new file mode 100644 index 0000000..9f27cc3 --- /dev/null +++ b/BBWYB.Common/Extensions/ConverterExtensions.cs @@ -0,0 +1,29 @@ +namespace BBWYB.Common.Extensions +{ + public static class ConverterExtensions + { + public static long? ToInt64(this object? o) + { + try + { + return Convert.ToInt64(o); + } + catch + { + return null; + } + } + + public static int? ToInt32(this object? o) + { + try + { + return Convert.ToInt32(o); + } + catch + { + return null; + } + } + } +} diff --git a/BBWYB.PurchaserCapture/App.xaml b/BBWYB.PurchaserCapture/App.xaml new file mode 100644 index 0000000..796be7b --- /dev/null +++ b/BBWYB.PurchaserCapture/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/BBWYB.PurchaserCapture/App.xaml.cs b/BBWYB.PurchaserCapture/App.xaml.cs new file mode 100644 index 0000000..03ed6cd --- /dev/null +++ b/BBWYB.PurchaserCapture/App.xaml.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Configuration; +using System.Configuration; +using System.Data; +using System.Windows; + +namespace BBWYB.PurchaserCapture +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + public IServiceProvider ServiceProvider { get; private set; } + public IConfiguration Configuration { get; private set; } + + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + } + } + +} diff --git a/BBWYB.PurchaserCapture/AssemblyInfo.cs b/BBWYB.PurchaserCapture/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/BBWYB.PurchaserCapture/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/BBWYB.PurchaserCapture/BBWYB.PurchaserCapture.csproj b/BBWYB.PurchaserCapture/BBWYB.PurchaserCapture.csproj new file mode 100644 index 0000000..fc64378 --- /dev/null +++ b/BBWYB.PurchaserCapture/BBWYB.PurchaserCapture.csproj @@ -0,0 +1,21 @@ + + + + Exe + net6.0-windows + enable + enable + true + + + + + + + + + + + + + diff --git a/BBWYB.PurchaserCapture/EncryptionExtension.cs b/BBWYB.PurchaserCapture/EncryptionExtension.cs new file mode 100644 index 0000000..517892e --- /dev/null +++ b/BBWYB.PurchaserCapture/EncryptionExtension.cs @@ -0,0 +1,83 @@ +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace BBWYB.Common.Extensions +{ + public static class EncryptionExtension + { + + public static string Md5Encrypt(this string originStr) + { + using (var md5 = MD5.Create()) + { + return string.Join(string.Empty, md5.ComputeHash(Encoding.UTF8.GetBytes(originStr)).Select(x => x.ToString("x2"))); + } + } + + //AES加密 传入,要加密的串和, 解密key + public static string AESEncrypt(this string input) + { + var key = "dataplatform2019"; + var ivStr = "1012132405963708"; + + var encryptKey = Encoding.UTF8.GetBytes(key); + var iv = Encoding.UTF8.GetBytes(ivStr); //偏移量,最小为16 + using (var aesAlg = Aes.Create()) + { + using (var encryptor = aesAlg.CreateEncryptor(encryptKey, iv)) + { + using (var msEncrypt = new MemoryStream()) + { + using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, + CryptoStreamMode.Write)) + + using (var swEncrypt = new StreamWriter(csEncrypt)) + { + swEncrypt.Write(input); + } + var decryptedContent = msEncrypt.ToArray(); + + return Convert.ToBase64String(decryptedContent); + } + } + } + } + + public static string AESDecrypt(this string cipherText) + { + var fullCipher = Convert.FromBase64String(cipherText); + + var ivStr = "1012132405963708"; + var key = "dataplatform2019"; + + var iv = Encoding.UTF8.GetBytes(ivStr); + var decryptKey = Encoding.UTF8.GetBytes(key); + + using (var aesAlg = Aes.Create()) + { + using (var decryptor = aesAlg.CreateDecryptor(decryptKey, iv)) + { + string result; + using (var msDecrypt = new MemoryStream(fullCipher)) + { + using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)) + { + using (var srDecrypt = new StreamReader(csDecrypt)) + { + result = srDecrypt.ReadToEnd(); + } + } + } + + return result; + } + } + } + + public static string Base64Encrypt(this string originStr) + { + return Convert.ToBase64String(Encoding.UTF8.GetBytes(originStr)); + } + } +} diff --git a/BBWYB.PurchaserCapture/MainWindow.xaml b/BBWYB.PurchaserCapture/MainWindow.xaml new file mode 100644 index 0000000..9ea773e --- /dev/null +++ b/BBWYB.PurchaserCapture/MainWindow.xaml @@ -0,0 +1,19 @@ + + + + + + + + + +