Browse Source

pjzs 10002

qianyi
shanji 2 years ago
parent
commit
f8a6249414
  1. 2
      BBWY.Client/Views/MainWindow.xaml
  2. 35
      PJZS/App.xaml.cs
  3. 2
      PJZS/MainWindow.xaml
  4. 53
      PJZS/MemoryHelper.cs

2
BBWY.Client/Views/MainWindow.xaml

@ -26,7 +26,7 @@
<!--<TextBlock Text="{Binding GlobalContext.User.TeamName}" Margin="5,0,0,0"/> <!--<TextBlock Text="{Binding GlobalContext.User.TeamName}" Margin="5,0,0,0"/>
<TextBlock Text="{Binding GlobalContext.User.Shop.Platform}" Margin="5,0,0,0"/>--> <TextBlock Text="{Binding GlobalContext.User.Shop.Platform}" Margin="5,0,0,0"/>-->
<TextBlock Text="{Binding GlobalContext.User.Shop.ShopName}" Margin="5,0,0,0"/> <TextBlock Text="{Binding GlobalContext.User.Shop.ShopName}" Margin="5,0,0,0"/>
<TextBlock Text="v10076" Margin="5,0,0,0"/> <TextBlock Text="v10077" Margin="5,0,0,0"/>
</StackPanel> </StackPanel>
</Border> </Border>
<Grid Grid.Row="1"> <Grid Grid.Row="1">

35
PJZS/App.xaml.cs

@ -12,6 +12,7 @@ using PJZS.Models;
using System.Linq; using System.Linq;
using System.IO.MemoryMappedFiles; using System.IO.MemoryMappedFiles;
using System.Diagnostics; using System.Diagnostics;
using Utils;
namespace PJZS namespace PJZS
{ {
@ -38,13 +39,8 @@ namespace PJZS
//齐越山鸡 //齐越山鸡
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNjk0NjY5NjkxfQ.cSwro-7bGwOu92YejH9JhMenTai7Mvf99i2paQCmxIw"; userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNjk0NjY5NjkxfQ.cSwro-7bGwOu92YejH9JhMenTai7Mvf99i2paQCmxIw";
#else #else
var uid = e.Args.Count() > 0 ? e.Args.LastOrDefault(args => args.StartsWith("uid:")) : string.Empty;
if (string.IsNullOrEmpty(uid)) var tokenResult = ReadMMF();
{
MessageBox.Show("缺少启动参数", "提示");
Environment.Exit(0);
}
var tokenResult = ReadMMF(uid);
if (tokenResult.isOk) if (tokenResult.isOk)
userToken = tokenResult.content; userToken = tokenResult.content;
else else
@ -94,19 +90,24 @@ namespace PJZS
throw new NotImplementedException(); throw new NotImplementedException();
} }
public (bool isOk, string content) ReadMMF(string mapname) public (bool isOk, string content) ReadMMF()
{ {
try try
{ {
using (MemoryMappedFile mmf = MemoryMappedFile.OpenExisting(mapname)) var token = MemoryHelper.GetMemoryToken();
{ if (string.IsNullOrEmpty(token))
using (var mmfStream = mmf.CreateViewStream(0, 1000, MemoryMappedFileAccess.ReadWrite)) return (false, "token为空");
{ else
StreamReader reader = new StreamReader(mmfStream); return (true, token);
string jwt = reader.ReadToEnd().Replace("\0", "").TrimEnd(); //using (MemoryMappedFile mmf = MemoryMappedFile.OpenExisting(mapname))
return (true, jwt); //{
} // using (var mmfStream = mmf.CreateViewStream(0, 1000, MemoryMappedFileAccess.ReadWrite))
} // {
// StreamReader reader = new StreamReader(mmfStream);
// string jwt = reader.ReadToEnd().Replace("\0", "").TrimEnd();
// return (true, jwt);
// }
//}
} }
catch (Exception ex) catch (Exception ex)
{ {

2
PJZS/MainWindow.xaml

@ -27,7 +27,7 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"
TextBlock.Foreground="White"> TextBlock.Foreground="White">
<TextBlock Text="评价助手"/> <TextBlock Text="评价助手"/>
<TextBlock Text="v10001" Margin="5,0,0,0"/> <TextBlock Text="v10002" Margin="5,0,0,0"/>
<TextBlock x:Name="txtUserName" Margin="5,0,0,0"/> <TextBlock x:Name="txtUserName" Margin="5,0,0,0"/>
</StackPanel> </StackPanel>
</Border> </Border>

53
PJZS/MemoryHelper.cs

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.IO.Pipes;
using System.Text;
using System.Windows;
namespace Utils
{
public class MemoryHelper
{
/// <summary>
/// 获取token
/// </summary>
/// <returns></returns>
public static string GetMemoryToken()
{
try
{
string pipeId = Environment.GetCommandLineArgs()[1];
//创建输入类型匿名管道
using (PipeStream pipeClient = new AnonymousPipeClientStream(PipeDirection.In, pipeId))
{
using (StreamReader sr = new StreamReader(pipeClient))
{
string temp;
do
{
temp = sr.ReadLine();
}
while (!temp.StartsWith("SYNC"));
while ((temp = sr.ReadLine()) != null)
{
return temp;
}
}
}
return string.Empty;
}
catch (Exception ex)
{
return string.Empty;
}
}
}
}
Loading…
Cancel
Save