Skip to content

Commit

Permalink
整理代码,删除不用的项目
Browse files Browse the repository at this point in the history
  • Loading branch information
renyh1013 committed Jun 5, 2016
1 parent c22f20a commit 0c22d09
Show file tree
Hide file tree
Showing 45 changed files with 4,731 additions and 121 deletions.
18 changes: 1 addition & 17 deletions dp2-v3.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalPlatform.IO", "Digit
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalPlatform.LibraryRestClient", "DigitalPlatform.LibraryRestClient\DigitalPlatform.LibraryRestClient.csproj", "{1B74D69A-530F-4275-845B-8CA6D1463BDD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dp2Command.Service", "dp2Command.Server\dp2Command.Service.csproj", "{A77B8A4A-3AE8-4BD7-B09A-BF8D92FE802D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dp2weixin", "dp2weixin\dp2weixin.csproj", "{2BD6F79E-A776-4A08-B972-C61F70F78BD5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ilovelibrary", "ilovelibrary\ilovelibrary.csproj", "{7C31EA17-404D-4CE6-8401-71808BEB5883}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ilovelibrary.Server", "ilovelibrary.Server\ilovelibrary.Server.csproj", "{159E08AE-5C0F-4DA7-9F73-AF07791247CE}"
Expand All @@ -47,7 +43,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalPlatform.LibraryClie
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DigitalPlatform.ServiceProcess", "DigitalPlatform.ServiceProcess\DigitalPlatform.ServiceProcess.csproj", "{696B2B7F-D5F6-47AE-8113-C0CD27FAD21E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dp2weixinP2P", "dp2weixinP2P\dp2weixinP2P.csproj", "{95CB7353-995B-4B82-8DFF-41C0133FFF78}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dp2weixinWeb", "dp2weixinP2P\dp2weixinWeb.csproj", "{95CB7353-995B-4B82-8DFF-41C0133FFF78}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dp2weixin.service", "dp2weixin.service\dp2weixin.service.csproj", "{50E36C13-A3DE-4638-BE87-E5E254EEC386}"
EndProject
Expand Down Expand Up @@ -135,18 +131,6 @@ Global
{1B74D69A-530F-4275-845B-8CA6D1463BDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B74D69A-530F-4275-845B-8CA6D1463BDD}.Release|Any CPU.Build.0 = Release|Any CPU
{1B74D69A-530F-4275-845B-8CA6D1463BDD}.Release|x86.ActiveCfg = Release|Any CPU
{A77B8A4A-3AE8-4BD7-B09A-BF8D92FE802D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A77B8A4A-3AE8-4BD7-B09A-BF8D92FE802D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A77B8A4A-3AE8-4BD7-B09A-BF8D92FE802D}.Debug|x86.ActiveCfg = Debug|Any CPU
{A77B8A4A-3AE8-4BD7-B09A-BF8D92FE802D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A77B8A4A-3AE8-4BD7-B09A-BF8D92FE802D}.Release|Any CPU.Build.0 = Release|Any CPU
{A77B8A4A-3AE8-4BD7-B09A-BF8D92FE802D}.Release|x86.ActiveCfg = Release|Any CPU
{2BD6F79E-A776-4A08-B972-C61F70F78BD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BD6F79E-A776-4A08-B972-C61F70F78BD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BD6F79E-A776-4A08-B972-C61F70F78BD5}.Debug|x86.ActiveCfg = Debug|Any CPU
{2BD6F79E-A776-4A08-B972-C61F70F78BD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BD6F79E-A776-4A08-B972-C61F70F78BD5}.Release|Any CPU.Build.0 = Release|Any CPU
{2BD6F79E-A776-4A08-B972-C61F70F78BD5}.Release|x86.ActiveCfg = Release|Any CPU
{7C31EA17-404D-4CE6-8401-71808BEB5883}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C31EA17-404D-4CE6-8401-71808BEB5883}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C31EA17-404D-4CE6-8401-71808BEB5883}.Debug|x86.ActiveCfg = Debug|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion dp2Command.Server/dp2BaseCommandService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public virtual int GetMyInfo(string remoteUserName,
/// </summary>
/// <param name="dom"></param>
/// <returns></returns>
public string GetContactString(XmlDocument dom)
public static string GetContactString(XmlDocument dom)
{
string strTel = DomUtil.GetElementText(dom.DocumentElement, "tel");
string strEmail = DomUtil.GetElementText(dom.DocumentElement, "email");
Expand Down
25 changes: 25 additions & 0 deletions dp2weixin.service/ApiResult.cs
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; }
}
}
13 changes: 13 additions & 0 deletions dp2weixin.service/Command/BaseCommand.cs
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;}
}
}
14 changes: 14 additions & 0 deletions dp2weixin.service/Command/BindingCommand.cs
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 = "";
}
}
45 changes: 45 additions & 0 deletions dp2weixin.service/Command/CommandContainer.cs
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;
}

}
}
102 changes: 102 additions & 0 deletions dp2weixin.service/Command/SearchCommand.cs
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;
}
}
}
58 changes: 58 additions & 0 deletions dp2weixin.service/Command/dp2CommandUtility.cs
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;
}
}
}
17 changes: 17 additions & 0 deletions dp2weixin.service/Interface/MessageInterface.cs
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;
}
}
60 changes: 60 additions & 0 deletions dp2weixin.service/Interface/ScriptManager.cs
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;
}

}
}
}
Loading

0 comments on commit 0c22d09

Please sign in to comment.