Просмотр исходного кода

1.增加查询角色信息功能
2.增加禁止帐号登录允许帐号登录功能

tanghai 13 лет назад
Родитель
Сommit
f315a3adf8

+ 2 - 0
.gitignore

@@ -14,6 +14,8 @@ Opt/
 */Temp/
 */TestResults/
 
+*/.svn/
+.svn/
 bin/
 Bin/
 obj/

+ 3 - 0
CSharp/App/BossBase/Messages.cs

@@ -251,5 +251,8 @@ namespace BossBase
 	{
 		[DataMember(Order = 1, IsRequired = true)]
 		public uint ErrorCode { get; set; }
+
+		[DataMember(Order = 2, IsRequired = false)]
+		public string Content { get; set; }
 	}
 }

+ 1 - 1
CSharp/App/BossCommand/BCCommand.cs

@@ -16,7 +16,7 @@ namespace BossCommand
 			this.SendMessage(new CMSG_Boss_Gm { Message = this.Command });
 
 			var smsgBossCommandResponse = await this.RecvMessage<SMSG_Boss_Command_Response>();
-			return smsgBossCommandResponse.ErrorCode;
+			return smsgBossCommandResponse;
 		}
 	}
 }

+ 0 - 21
CSharp/App/BossCommand/BCFindPlayer.cs

@@ -1,21 +0,0 @@
-using System.Threading.Tasks;
-using BossBase;
-
-namespace BossCommand
-{
-	public class BCFindPlayer: ABossCommand
-	{
-		public BCFindPlayer(IMessageChannel iMessageChannel): base(iMessageChannel)
-		{
-		}
-
-		public int FindTypeIndex { get; set; }
-
-		public string FindType { get; set; }
-
-		public override Task<object> DoAsync()
-		{
-			return null;
-		}
-	}
-}

+ 24 - 0
CSharp/App/BossCommand/BCForbiddenAccountLogin.cs

@@ -0,0 +1,24 @@
+using System.Threading.Tasks;
+using BossBase;
+
+namespace BossCommand
+{
+	public class BCForbiddenAccountLogin: ABossCommand
+	{
+		public string Account { get; set; }
+		public string ForbiddenLoginTime { get; set; }
+		public BCForbiddenAccountLogin(IMessageChannel iMessageChannel): base(iMessageChannel)
+		{
+		}
+
+		public override async Task<object> DoAsync()
+		{
+			this.SendMessage(new CMSG_Boss_Gm
+			{
+				Message = string.Format("forbid_account {0} {1}", this.Account, this.ForbiddenLoginTime)
+			});
+			var smsgBossCommandResponse = await RecvMessage<SMSG_Boss_Command_Response>();
+			return smsgBossCommandResponse.ErrorCode;
+		}
+	}
+}

+ 51 - 0
CSharp/App/BossCommand/BCGetCharacterInfo.cs

@@ -0,0 +1,51 @@
+using System;
+using System.Runtime.Serialization;
+using System.Threading.Tasks;
+using BossBase;
+using Helper;
+using Log;
+
+namespace BossCommand
+{
+	public class BCGetCharacterInfo: ABossCommand
+	{
+		public BCGetCharacterInfo(IMessageChannel iMessageChannel): base(iMessageChannel)
+		{
+		}
+
+		public int FindTypeIndex { get; set; }
+
+		public string FindType { get; set; }
+
+		public override async Task<object> DoAsync()
+		{
+			this.SendMessage(new CMSG_Boss_Gm
+			{
+				Message = string.Format(
+					"get_character_info {0} {1} ", this.FindTypeIndex, this.FindType)
+			});
+			var smsgBossCommandResponse = await this.RecvMessage<SMSG_Boss_Command_Response>();
+			if (smsgBossCommandResponse.ErrorCode != ErrorCode.RESPONSE_SUCCESS)
+			{
+				Logger.Trace("get character info fail, error code: {0}", smsgBossCommandResponse.ErrorCode);
+				return null;
+			}
+
+			var characterInfo = JsonHelper.FromString<CharacterInfo>(smsgBossCommandResponse.Content);
+			return characterInfo;
+		}
+	}
+
+	[DataContract]
+	public class CharacterInfo
+	{
+		[DataMember(Order = 0, IsRequired = false)]
+		public string Account { get; set; }
+
+		[DataMember(Order = 1, IsRequired = false)]
+		public string Name { get; set; }
+
+		[DataMember(Order = 2, IsRequired = false)]
+		public UInt64 Guid { get; set; }
+	}
+}

+ 4 - 2
CSharp/App/BossCommand/BossCommand.csproj

@@ -18,7 +18,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
+    <OutputPath>..\..\Bin\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
@@ -34,12 +34,14 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Runtime.Serialization" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ABossCommand.cs" />
+    <Compile Include="BCForbiddenAccountLogin.cs" />
     <Compile Include="BCAllowBuy.cs" />
     <Compile Include="BCCommand.cs" />
-    <Compile Include="BCFindPlayer.cs" />
+    <Compile Include="BCGetCharacterInfo.cs" />
     <Compile Include="BCServerInfo.cs" />
     <Compile Include="BCReloadWorld.cs" />
     <Compile Include="BCForbiddenBuy.cs" />

+ 2 - 2
CSharp/App/Editor/app.config

@@ -18,7 +18,7 @@
   <appSettings>
     <add key="IP" value="192.168.11.95" />
     <add key="Port" value="8888" />
-	<add key="Account" value="test01@163.com" />
-	<add key="Password" value="111111" />
+	<add key="Account" value="egametang@163.com" />
+	<add key="Password" value="163bio1" />
   </appSettings>
 </configuration>

+ 4 - 0
CSharp/App/Modules/Robot/Robot.csproj

@@ -74,6 +74,10 @@
     </Page>
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\..\Platform\Helper\Helper.csproj">
+      <Project>{24233cd5-a5df-484b-a482-b79cb7a0d9cb}</Project>
+      <Name>Helper</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\Platform\Log\Log.csproj">
       <Project>{72e16572-fc1f-4a9e-bc96-035417239298}</Project>
       <Name>Log</Name>

+ 70 - 49
CSharp/App/Modules/Robot/RobotView.xaml

@@ -10,64 +10,85 @@
 	<Grid>
 		<DockPanel x:Name="dock" Visibility="{Binding DockPanelVisiable}">
 			<Menu DockPanel.Dock="Top" Margin="0,2" >
-				<MenuItem Header="登录" x:Name="menuLogin" Click="menuLogin_Click" />
+				<MenuItem x:Name="menuLogin" Header="登录" Click="menuLogin_Click"/>
 				<MenuItem Header="服务器"  >
 					<MenuItem x:Name="menuServers" Header="显示服务器" Click="menuServers_Click"/>
 					<MenuItem x:Name="menuReload" Header="Reload World" Click="menuReload_Click"/>
 				</MenuItem>
 			</Menu>
-			<ListBox Height="723" Width="119" SelectionMode="Multiple" ItemsSource="{Binding ServerInfos}" 
-				d:DataContext="{d:DesignInstance {x:Type Robot:RobotViewModel}}" 
-				BorderThickness="3" BorderBrush="BurlyWood" >
-				<ListBox.ItemTemplate>
-					<DataTemplate>
-						<Label Content="{Binding Name}" />
-					</DataTemplate>
-				</ListBox.ItemTemplate>
-			</ListBox>
 			<Grid>
 				<Canvas>
-					<GroupBox Header="角色信息" Canvas.Left="10" Height="723" Width="734" BorderBrush="BurlyWood">
-						<Canvas>
-							<ComboBox x:Name="cbFindType" SelectedIndex="{Binding FindTypeIndex}" Canvas.Left="32" Canvas.Top="23" Height="25">
-								<ComboBoxItem Content="帐 号"/>
-								<ComboBoxItem Content="名 字"/>
-								<ComboBoxItem Content="GUID"/>
-							</ComboBox>
-							<TextBox Width="166" Text="{Binding FindType}" Canvas.Left="88" Canvas.Top="23" Height="25"/>
-							<Button x:Name="btnFindPlayer" Content="查询" Click="btnFindPlayer_Click" RenderTransformOrigin="9.161,1.435" Canvas.Left="261" Canvas.Top="23" Height="25"/>
-							<Label Content="帐 号:" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="52" />
-							<TextBox Text="{Binding Account}"  Grid.Row="1" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="53" Width="204"/>
-							<Label Content="名 字:" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="83" />
-							<TextBox Text="{Binding Name}" Grid.Row="2" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="84" Width="204"/>
-							<Label Content="GUID:" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="114" />
-							<TextBox Text="{Binding Guid}" Grid.Row="3" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="114" Width="204"/>
-							<TabControl Height="541" Canvas.Top="160" Width="722" IsEnabled="{Binding IsGMEnable}">
-								<TabItem Header="信息">
-									<Grid Margin="0,0,8,36"/>
-								</TabItem>
-								<TabItem Header="包裹">
-									<Grid/>
-								</TabItem>
-								<TabItem Header="BUFF">
-									<Grid/>
-								</TabItem>
-								<TabItem Header="装备">
-									<Canvas/>
-								</TabItem>
-								<TabItem Header="GM">
+					<TabControl Name="tcAll" Height="713" Width="867">
+						<TabItem Header="服务器">
+							<Canvas>
+								<ListBox Height="667" Width="119" SelectionMode="Multiple" ItemsSource="{Binding ServerInfos}" 
+										d:DataContext="{d:DesignInstance {x:Type Robot:RobotViewModel}}" 
+										BorderThickness="3" BorderBrush="BurlyWood" >
+									<ListBox.ItemTemplate>
+										<DataTemplate>
+											<Label Content="{Binding Name}" />
+										</DataTemplate>
+									</ListBox.ItemTemplate>
+								</ListBox>
+							</Canvas>
+						</TabItem>
+						<TabItem Header="帐号">
+							<Canvas>
+								<TextBox Text="{Binding Account}" Height="23" Canvas.Left="69" Canvas.Top="19" Width="120"/>
+								<Button Content="禁止帐号登录" Canvas.Left="194" Canvas.Top="47" Width="83" Click="btnForbiddenAccountLoginButton_Click"/>
+								<Button Content="允许帐号登录" Canvas.Left="194" Canvas.Top="19" Width="83" Click="btnAllowAccountLogin_Click"/>
+								<Label Content="帐号:" Canvas.Left="10" Canvas.Top="19" Width="38"/>
+								<TextBox Text="{Binding ForbiddenLoginTime}" Height="23" Canvas.Left="69" Canvas.Top="47" Width="120"/>
+								<Label Content="禁止时间:" Canvas.Left="10" Canvas.Top="47"/>
+							</Canvas>
+						</TabItem>
+						<TabItem Header="角色">
+							<Canvas>
+								<GroupBox Header="角色信息" Canvas.Left="10" Height="723" Width="734" BorderBrush="BurlyWood">
 									<Canvas>
-										<Button x:Name="btnForbiddenBuy" Content="禁止交易" Canvas.Left="11" Canvas.Top="10" Width="75" Click="btnForbiddenBuy_Click"/>
-										<Button x:Name="btnAllowBuy" Content="允许交易" Canvas.Left="11" Canvas.Top="38" Width="75" Click="btnAllowBuy_Click" />
+										<ComboBox x:Name="cbFindType" SelectedIndex="{Binding FindTypeIndex}" Canvas.Left="32" Canvas.Top="23" Height="25">
+											<ComboBoxItem Content="帐 号"/>
+											<ComboBoxItem Content="名 字"/>
+											<ComboBoxItem Content="GUID"/>
+										</ComboBox>
+										<TextBox Width="166" Text="{Binding FindType}" Canvas.Left="88" Canvas.Top="23" Height="25"/>
+										<Button x:Name="btnFindPlayer" Content="查询" Click="btnFindPlayer_Click" Canvas.Left="261" Canvas.Top="23" Height="25"/>
+										<Label Content="帐 号:" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="52" />
+										<TextBox Text="{Binding Account}"  Grid.Row="1" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="53" Width="204"/>
+										<Label Content="名 字:" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="83" />
+										<TextBox Text="{Binding Name}" Grid.Row="2" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="84" Width="204"/>
+										<Label Content="GUID:" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="114" />
+										<TextBox Text="{Binding Guid}" Grid.Row="3" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="114" Width="204"/>
+										<TabControl Height="541" Canvas.Top="160" Width="722" IsEnabled="{Binding IsGMEnable}">
+											<TabItem Header="信息">
+												<Grid Margin="0,0,8,36"/>
+											</TabItem>
+											<TabItem Header="包裹">
+												<Grid/>
+											</TabItem>
+											<TabItem Header="BUFF">
+												<Grid/>
+											</TabItem>
+											<TabItem Header="装备">
+												<Canvas/>
+											</TabItem>
+											<TabItem Header="GM">
+												<Canvas>
+													<Button x:Name="btnForbiddenBuy" Content="禁止交易" Canvas.Left="11" Canvas.Top="10" Width="75" Click="btnForbiddenBuy_Click"/>
+													<Button x:Name="btnAllowBuy" Content="允许交易" Canvas.Left="11" Canvas.Top="38" Width="75" Click="btnAllowBuy_Click" />
+												</Canvas>
+											</TabItem>
+										</TabControl>
 									</Canvas>
-								</TabItem>
-							</TabControl>
-						</Canvas>
-					</GroupBox>
-					<TextBox Name="tbLog" Height="675" Canvas.Left="749" TextWrapping="Wrap" Text="" 
-							Canvas.Top="38" Width="402" IsReadOnly="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"/>
-					<TextBox Text="{Binding Command}" Height="23" Canvas.Left="749" TextWrapping="Wrap" Canvas.Top="10" Width="315" />
-					<Button Name="btnSendCommand" Content="发送" Canvas.Left="1072" Canvas.Top="9" Width="75" Click="btnSendCommand_Click"/>
+								</GroupBox>
+							</Canvas>
+						</TabItem>
+					</TabControl>
+					<TextBox Name="tbLog" Height="675" Canvas.Left="872" TextWrapping="Wrap" Text="" 
+						Canvas.Top="38" Width="398" IsReadOnly="True" HorizontalScrollBarVisibility="Visible" 
+						VerticalScrollBarVisibility="Visible"/>
+					<TextBox Text="{Binding Command}" Height="23" Canvas.Left="872" TextWrapping="Wrap" Canvas.Top="10" Width="315" />
+					<Button Name="btnSendCommand" Content="发送" Canvas.Left="1195" Canvas.Top="10" Width="75" Click="btnSendCommand_Click"/>
 				</Canvas>
 			</Grid>
 		</DockPanel>

+ 16 - 1
CSharp/App/Modules/Robot/RobotView.xaml.cs

@@ -36,7 +36,7 @@ namespace Modules.Robot
 
 		private void btnFindPlayer_Click(object sender, RoutedEventArgs e)
 		{
-			this.ViewModel.FindPlayer();
+			this.ViewModel.GetCharacterInfo();
 			this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
 			this.tbLog.ScrollToEnd();
 		}
@@ -49,6 +49,7 @@ namespace Modules.Robot
 		private async void menuServers_Click(object sender, RoutedEventArgs e)
 		{
 			await this.ViewModel.Servers();
+			this.tcAll.SelectedIndex = 0;
 			this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
 			this.tbLog.ScrollToEnd();
 		}
@@ -73,5 +74,19 @@ namespace Modules.Robot
 			this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
 			this.tbLog.ScrollToEnd();
 		}
+
+		private async void btnForbiddenAccountLoginButton_Click(object sender, RoutedEventArgs e)
+		{
+			await this.ViewModel.ForbiddenAccountLogin();
+			this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
+			this.tbLog.ScrollToEnd();
+		}
+
+		private async void btnAllowAccountLogin_Click(object sender, RoutedEventArgs e)
+		{
+			await this.ViewModel.AllowAccountLogin();
+			this.tbLog.AppendText(Environment.NewLine + this.ViewModel.ErrorInfo);
+			this.tbLog.ScrollToEnd();
+		}
 	}
 }

+ 91 - 16
CSharp/App/Modules/Robot/RobotViewModel.cs

@@ -5,7 +5,8 @@ using System.Globalization;
 using System.Threading.Tasks;
 using System.Windows;
 using BossCommand;
-using BossBase;
+using BossBase;
+using Helper;
 using Log;
 using Microsoft.Practices.Prism.Events;
 using Microsoft.Practices.Prism.ViewModel;
@@ -20,11 +21,12 @@ namespace Modules.Robot
 
 		private string errorInfo = "";
 		private int findTypeIndex;
-		private string account = "";
-		private string findType = "";
+		private string account = "";
+		private string findType = "egametang@126.com";
 		private string name = "";
 		private string guid = "";
-		private string command = "";
+		private string command = "";
+		private string forbiddenLoginTime = "";
 		private bool isGMEnable;
 		private Visibility dockPanelVisiable = Visibility.Hidden;
 		private readonly BossClient.BossClient bossClient = new BossClient.BossClient();
@@ -175,6 +177,23 @@ namespace Modules.Robot
 				this.isGMEnable = value;
 				this.RaisePropertyChanged("IsGMEnable");
 			}
+		}
+
+		public string ForbiddenLoginTime
+		{
+			get
+			{
+				return this.forbiddenLoginTime;
+			}
+			set
+			{
+				if (this.forbiddenLoginTime == value)
+				{
+					return;
+				}
+				this.forbiddenLoginTime = value;
+				this.RaisePropertyChanged("ForbiddenLoginTime");
+			}
 		}
 
 		public string Command
@@ -255,14 +274,24 @@ namespace Modules.Robot
 			bossCommand.DoAsync();
 		}
 
-		public void FindPlayer()
+		public async void GetCharacterInfo()
 		{
-			ABossCommand bossCommand = new BCFindPlayer(this.IMessageChannel)
+			ABossCommand bossCommand = new BCGetCharacterInfo(this.IMessageChannel)
 			{
 				FindTypeIndex = this.FindTypeIndex, 
 				FindType = this.FindType
-			};
-			bossCommand.DoAsync();
+			};
+			var result = await bossCommand.DoAsync();
+			if (result == null)
+			{
+				this.ErrorInfo = string.Format("获取玩家信息失败");
+				return;
+			}
+			this.ErrorInfo = "获取玩家信息成功";
+			var characterInfo = (CharacterInfo)result;
+			this.Account = characterInfo.Account;
+			this.Name = characterInfo.Name;
+			this.Guid = characterInfo.Guid.ToString();
 		}
 
 		public async Task ForbiddenBuy()
@@ -301,7 +330,7 @@ namespace Modules.Robot
 				Guid = this.Guid
 			};
 			var result = await bossCommand.DoAsync();
-			var errorCode = (int) result;
+			var errorCode = (uint) result;
 			if (errorCode == ErrorCode.RESPONSE_SUCCESS)
 			{
 				this.ErrorInfo = "允许交易成功";
@@ -311,11 +340,57 @@ namespace Modules.Robot
 			this.ErrorInfo = errorCode.ToString();
 		}
 
+		public async Task ForbiddenAccountLogin()
+		{
+			int time = 0;
+			if (!int.TryParse(this.ForbiddenLoginTime, out time))
+			{
+				this.ErrorInfo = "禁止时间请输入数字";
+				return;
+			}
+			if (time < 0)
+			{
+				this.ErrorInfo = "禁止时间必须>=0";
+				return;
+			}
+
+			ABossCommand bossCommand = new BCForbiddenAccountLogin(this.IMessageChannel) 
+			{ Account = this.Account, ForbiddenLoginTime = this.ForbiddenLoginTime };
+			var result = await bossCommand.DoAsync();
+
+			var errorCode = (uint)result;
+
+			if (errorCode == ErrorCode.RESPONSE_SUCCESS)
+			{
+				this.ErrorInfo = "禁止帐号登录成功";
+				return;
+			}
+			this.ErrorInfo = string.Format("禁止帐号登录失败, error code: {0}", errorCode);
+		}
+
+		public async Task AllowAccountLogin()
+		{
+			ABossCommand bossCommand = new BCForbiddenAccountLogin(this.IMessageChannel)
+			{
+				Account = this.Account, ForbiddenLoginTime = "-1"
+			};
+			var result = await bossCommand.DoAsync();
+
+			var errorCode = (uint)result;
+
+			if (errorCode == ErrorCode.RESPONSE_SUCCESS)
+			{
+				this.ErrorInfo = "允许帐号登录成功";
+				return;
+			}
+			this.ErrorInfo = string.Format("允许帐号登录失败, error code: {0}", errorCode);
+		}
+
 		public async Task SendCommand()
-		{
-			if (this.Command.StartsWith("gm ", true, CultureInfo.CurrentCulture))
-			{
-				this.Command = this.Command.Substring(3);
+		{
+			if (this.Command.StartsWith("gm ", true, CultureInfo.CurrentCulture))
+			{
+				this.Command = this.Command.Substring(3);
 			}
 			ABossCommand bossCommand = new BCCommand(this.IMessageChannel)
 			{ Command = this.Command };
@@ -329,10 +404,10 @@ namespace Modules.Robot
 			{
 				Logger.Trace(e.ToString());
 				return;
-			}
-			var errorCode = (uint)result;
+			}
+			var smsgBossCommandResponse = (SMSG_Boss_Command_Response)result;
 			this.ErrorInfo = string.Format(" send command: {0}, error code: {1}", 
-				commandString, errorCode);
+				commandString, JsonHelper.ToString(smsgBossCommandResponse));
 		}
 	}
 }