Skip to content

Commit

Permalink
Merge pull request #5 from DigitalPlatform/master
Browse files Browse the repository at this point in the history
更新 dp2library 版本号
  • Loading branch information
任延华 authored Aug 16, 2018
2 parents 5a3b630 + 4dcdbcb commit 5688a3d
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 4 deletions.
3 changes: 2 additions & 1 deletion DigitalPlatform.LibraryServer/LibraryApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ public partial class LibraryApplication : IDisposable
// 3.1 (2018/7/1) GetSearchResult() API 在返回 -1 的时候,ErrorCode 的错误码不再是 CommonError,而是具体的错误码值。比如 NotFound 表示结果集不存在
// 3.2 (2018/7/17) GetSystemParameter() API 增加了 system/expire 获取 dp2library 失效日期的功能
// 3.3 (2018/7/28) SetBiblioInfo() API 增加了格式 marc(或 marcquery),机内格式 MARC 字符串
public static string Version = "3.3";
// 3.4 (2018/8/7) SetOrders() API 所保存的订购记录里面增加了 fixedPrice 和 discount 元素。早先版本如果保存时候提交这两个元素,会被 dp2library 过滤掉
public static string Version = "3.4";

internal static DateTime _expire = new DateTime(2018, 9, 15); // 上一个版本是 2018/7/15 2018/5/15 2018/3/15 2017/1/15 2017/12/1 2017/9/1 2017/6/1 2017/3/1 2016/11/1

Expand Down
74 changes: 72 additions & 2 deletions dp2Circulation/Order/OrderControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -816,10 +816,80 @@ void dlg_GetDefaultRecord(object sender, DigitalPlatform.CommonControl.GetDefaul
throw new Exception(strError);
}

public override int DoSaveItems(LibraryChannel channel)
{
if (StringUtil.CompareVersion(Program.MainForm.ServerVersion, "3.4") < 0)
{
// 检查订购记录里面是否含有 fixedPrice 和 discount 元素,dp2library 是否在 3.4 版以上
if (ExistingFixedPrice(out string strError) != 0)
{
MessageBox.Show(this, "保存操作无法进行。订购记录中含有码洋或折扣字段信息,必须在 dp2library 服务器 3.4 版以上才能无损保存。请系统管理员尽快升级 dp2library 到最新版本");
return -1;
}
}
return base.DoSaveItems(channel);
}

// 检查即将保存的订购记录里面是否有 fixedPrice 和 discount 元素
// return:
// -1 检查过程出错
// 0 不存在
// 1 存在
int ExistingFixedPrice(
out string strError)
{
strError = "";
int nRet = 0;

Debug.Assert(this.Items != null, "");

List<EntityInfo> entityArray = new List<EntityInfo>();

foreach (OrderItem bookitem in this.Items)
{
if (bookitem.ItemDisplayState == ItemDisplayState.Normal)
continue;

if (bookitem.ItemDisplayState == ItemDisplayState.Deleted)
continue;

nRet = bookitem.BuildRecord(
true, // 要检查 Parent 成员
out string strXml,
out strError);
if (nRet == -1)
return -1;

XmlDocument dom = new XmlDocument();
try
{
dom.LoadXml(strXml);
}
catch(Exception ex)
{
strError = "订购记录装入 XMLDOM 失败: " + ex.Message;
return -1;
}

string strFixedPrice = DomUtil.GetElementText(dom.DocumentElement, "fixedPrice");
string strDiscount = DomUtil.GetElementText(dom.DocumentElement, "discount");

if (string.IsNullOrEmpty(strFixedPrice) == false
|| string.IsNullOrEmpty(strDiscount) == false)
{
strError = "订购记录中存在 fixedPrice(码洋) 或者 discount(折扣) 元素";
return 1;
}
}

return 0;
}


// 根据XML记录恢复一些不重要的其他字段值
int RestoreOtherFields(string strXml,
OrderItem item,
out string strError)
OrderItem item,
out string strError)
{
strError = "";

Expand Down
2 changes: 1 addition & 1 deletion dp2Circulation/dp2Circulation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<IsWebBootstrapper>true</IsWebBootstrapper>
<ManifestCertificateThumbprint>458DBD8488B5B2A4FD0653A590D3F6E2BC38DA9F</ManifestCertificateThumbprint>
<ManifestKeyFile>dp2003.pfx</ManifestKeyFile>
<GenerateManifests>true</GenerateManifests>
<GenerateManifests>false</GenerateManifests>
<SignManifests>true</SignManifests>
<ApplicationIcon>nei.ico</ApplicationIcon>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
Expand Down

0 comments on commit 5688a3d

Please sign in to comment.