-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
renyh1013
committed
Jun 5, 2016
1 parent
c22f20a
commit 0c22d09
Showing
45 changed files
with
4,731 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace dp2weixin.service | ||
{ | ||
// API返回结果 | ||
public class ApiResult | ||
{ | ||
public string errorInfo = ""; | ||
|
||
/// <summary> | ||
/// -1:表示出错 | ||
/// </summary> | ||
public int errorCode = 0; | ||
} | ||
|
||
public class WxUserResult | ||
{ | ||
public WxUserItem userItem { get; set; } | ||
public ApiResult apiResult { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace dp2Command.Service | ||
{ | ||
public class BaseCommand | ||
{ | ||
public string CommandName { get;set;} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace dp2Command.Service | ||
{ | ||
public class BindingCommand:BaseCommand | ||
{ | ||
public string ReaderBarcode = ""; | ||
public string Password = ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace dp2Command.Service | ||
{ | ||
public class CommandContainer | ||
{ | ||
public Dictionary<string, BaseCommand> CmdDict = null; | ||
|
||
public CommandContainer() | ||
{ | ||
CmdDict = new Dictionary<string, BaseCommand>(); | ||
} | ||
|
||
public BaseCommand GetCommand(string cmdName) | ||
{ | ||
if (CmdDict.ContainsKey(cmdName)) | ||
{ | ||
return CmdDict[cmdName]; | ||
} | ||
|
||
// 不存在自动创建 | ||
BaseCommand command = null; | ||
if (cmdName == dp2CommandUtility.C_Command_Search) | ||
{ | ||
command = new SearchCommand(); | ||
} | ||
else if (cmdName == dp2CommandUtility.C_Command_Binding) | ||
{ | ||
command = new BindingCommand(); | ||
} | ||
else | ||
{ | ||
command = new BaseCommand(); | ||
} | ||
command.CommandName = cmdName; | ||
CmdDict[cmdName] = command; | ||
return command; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace dp2Command.Service | ||
{ | ||
public class SearchCommand:BaseCommand | ||
{ | ||
|
||
/// <summary> | ||
/// 书目检索结果集,存路径 | ||
/// </summary> | ||
public List<string> BiblioResultPathList { get; set; } | ||
|
||
/// <summary> | ||
/// 是否继续输入n翻页 | ||
/// </summary> | ||
public bool IsCanNextPage = false; | ||
|
||
/// <summary> | ||
/// 下一步开始序号 | ||
/// </summary> | ||
public long ResultNextStart = -1; | ||
|
||
/// <summary> | ||
/// 获取下一页检索结果 | ||
/// </summary> | ||
/// <param name="strText"></param> | ||
/// <param name="strError"></param> | ||
/// <returns></returns> | ||
public bool GetNextPage(out string strText, | ||
out string strError) | ||
{ | ||
strText = ""; | ||
strError = ""; | ||
|
||
if (this.IsCanNextPage == false) | ||
{ | ||
strError = "已到末页。"; | ||
return false; | ||
} | ||
|
||
long lTotalCount = this.BiblioResultPathList.Count; | ||
if (this.ResultNextStart >= lTotalCount) | ||
{ | ||
strError = "内部错误,下页起始序号>=总记录数了"; | ||
return false; | ||
} | ||
|
||
// 本页显示的最大序号 | ||
long nMaxIndex = this.ResultNextStart + dp2CommandUtility.C_ViewCount_OnePage; | ||
if (nMaxIndex > lTotalCount) | ||
{ | ||
nMaxIndex = lTotalCount; | ||
} | ||
|
||
string strPreMessage = ""; | ||
if (nMaxIndex < dp2CommandUtility.C_ViewCount_OnePage | ||
|| (this.ResultNextStart == 0 && nMaxIndex == lTotalCount)) | ||
{ | ||
// 没有下页了 | ||
this.IsCanNextPage = false; | ||
strPreMessage = "命中'" + lTotalCount + "'条书目记录。您可以回复序列查看详细信息。\r\n"; | ||
} | ||
else if (nMaxIndex < lTotalCount) | ||
{ | ||
// 有下页 | ||
this.IsCanNextPage = true; | ||
strPreMessage = "命中'" + lTotalCount + "'条书目记录。本次显示第" + (this.ResultNextStart + 1).ToString() + "-" + nMaxIndex + "条,您可以回复N继续显示下一页,或者回复序列查看详细信息。\r\n"; | ||
} | ||
else if (nMaxIndex == lTotalCount) | ||
{ | ||
//无下页 | ||
this.IsCanNextPage = false; | ||
strPreMessage = "命中'" + lTotalCount + "'条书目记录。本次显示第" + (this.ResultNextStart + 1).ToString() + "-" + nMaxIndex + "条,已到末页。您可以回复序列查看详细信息。\r\n"; | ||
} | ||
|
||
string strBrowse = ""; | ||
for (long i = this.ResultNextStart; i < nMaxIndex; i++) | ||
{ | ||
if (strBrowse != "") | ||
strBrowse += "\n"; | ||
|
||
string text = this.BiblioResultPathList[(int)i]; | ||
int index = text.IndexOf("*"); | ||
if (index >= 0) | ||
text = text.Substring(index + 1); | ||
strBrowse += (i + 1).ToString().PadRight(5, ' ') + text; | ||
} | ||
|
||
// 设置下页索引 | ||
this.ResultNextStart = nMaxIndex; | ||
|
||
//返回结果 | ||
strText = strPreMessage + strBrowse; | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
|
||
namespace dp2Command.Service | ||
{ | ||
public class dp2CommandUtility | ||
{ | ||
// 2016/2/20 选择图书馆 | ||
public const string C_Command_SelectLib = "selectlib"; | ||
// 切换读者,用于微信用户绑定多个读者的情况 | ||
public const string C_Command_ChangePatron = "changepatron"; | ||
|
||
|
||
public const string C_Command_Binding = "binding"; | ||
public const string C_Command_Unbinding = "unbinding"; | ||
public const string C_Command_MyInfo = "myinfo"; | ||
public const string C_Command_BorrowInfo = "borrowinfo"; | ||
public const string C_Command_Renew = "renew"; | ||
public const string C_Command_Search = "search"; | ||
public const string C_Command_SearchDetail = "search-detail"; | ||
// 公共信息 | ||
public const string C_Command_BookRecommend = "bookrecommend"; | ||
public const string C_Command_Notice = "notice";//Notice | ||
// 检索每页显示记录数 | ||
public const int C_ViewCount_OnePage = 20; | ||
|
||
|
||
public const String C_WeiXinIdPrefix = "weixinid:"; | ||
|
||
/// <summary> | ||
/// 校验字符串是否是命令 | ||
/// </summary> | ||
/// <param name="strText"></param> | ||
/// <returns></returns> | ||
public static bool CheckIsCommand(string strText) | ||
{ | ||
strText = strText.ToLower(); | ||
if (strText == C_Command_Search | ||
|| strText == C_Command_Binding | ||
|| strText == C_Command_Unbinding | ||
|| strText == C_Command_MyInfo | ||
|| strText == C_Command_BorrowInfo | ||
|| strText == C_Command_Renew | ||
|| strText == C_Command_BookRecommend | ||
|| strText == C_Command_Notice | ||
|| strText == C_Command_SelectLib | ||
|| strText == C_Command_ChangePatron | ||
) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DigitalPlatform.Interfaces | ||
{ | ||
// 一个扩展消息接口 | ||
public class MessageInterface | ||
{ | ||
public string Type = ""; | ||
public Assembly Assembly = null; | ||
public ExternalMessageHost HostObj = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DigitalPlatform.Interfaces | ||
{ | ||
public class ScriptManager | ||
{ | ||
// 获得从指定类或者接口派生的类 | ||
public static Type GetDerivedClassType(Assembly assembly, | ||
string strBaseTypeFullName) | ||
{ | ||
if (assembly == null) | ||
return null; | ||
|
||
Type[] types = assembly.GetTypes(); | ||
foreach (Type type in types) | ||
{ | ||
if (type.IsClass == false) | ||
continue; | ||
|
||
// 2015/5/28 | ||
Type[] interfaces = type.GetInterfaces(); | ||
foreach (Type inter in interfaces) | ||
{ | ||
if (inter.FullName == strBaseTypeFullName) | ||
return type; | ||
} | ||
|
||
if (IsDerivedFrom(type, | ||
strBaseTypeFullName) == true) | ||
return type; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
// 观察type的基类中是否有类名为strBaseTypeFullName的类。 | ||
public static bool IsDerivedFrom(Type type, | ||
string strBaseTypeFullName) | ||
{ | ||
Type curType = type; | ||
for (; ; ) | ||
{ | ||
if (curType == null | ||
|| curType.FullName == "System.Object") | ||
return false; | ||
|
||
if (curType.FullName == strBaseTypeFullName) | ||
return true; | ||
|
||
curType = curType.BaseType; | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.