Skip to content

Commit

Permalink
为获取参数接口增加重试
Browse files Browse the repository at this point in the history
  • Loading branch information
renyh committed Dec 6, 2022
1 parent e524472 commit 74e08cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dp2weixin.service/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ public void CheckIsHangup(Library library)
return;
}

// 设置版本
// 给内存中的lib设置上版本
library.Version = capoVersion;

// 比较capo版本是否满足需求
nRet = StringUtil.CompareVersion(library.Version,
LibraryManager.C_RequestCapoVersion);
Expand Down
35 changes: 32 additions & 3 deletions dp2weixin.service/dp2WeiXinService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3659,6 +3659,13 @@ public MessageInterface GetMessageInterface(string strType)
public const string C_State_Expire = "到期";


/// <summary>
/// 检查图书馆是否在线
/// </summary>
/// <param name="libEntity"></param>
/// <param name="clock"></param>
/// <param name="strError"></param>
/// <returns></returns>
public bool CheckIsOnline(LibEntity libEntity,
out string clock,
out string strError)
Expand Down Expand Up @@ -3929,6 +3936,7 @@ public void WarnOfflineLib()

// 查找绑定了这个图书馆的工作人员 weixinid
List<WxUserItem> libWorkers = this.getWarningWorkerWeixinIds(lib.Entity);

this.WriteDebug("找到 " + libWorkers.Count.ToString() + " 位图书馆 " + lib.Entity.libName + " 工作人员");

// 当这个图书馆和数字平台都没有可收警告的工作人员,则不再发送通知
Expand Down Expand Up @@ -8529,7 +8537,10 @@ public int GetInfo(LibEntity lib,
strError = "";
dataList = new List<string>();


int redocount = 0;

REDO1:

CancellationToken cancel_token = new CancellationToken();
string id = Guid.NewGuid().ToString();
SearchRequest request = new SearchRequest(id,
Expand All @@ -8556,9 +8567,16 @@ public int GetInfo(LibEntity lib,
cancel_token).Result;
if (result.ResultCount == -1)
{
bool bOffline = false;
//bool bOffline = false;
strError = "图书馆[" + lib.libName + "]返回错误:" + result.ErrorInfo;

// 通道断了,重来一次
if (result.ErrorCode == "ChannelReleased" && redocount == 0)
{
redocount++;
goto REDO1;
}

//strError = this.GetFriendlyErrorInfo(result, lib.libName, out bOffline);// result.ErrorInfo;
return -1;
}
Expand All @@ -8574,17 +8592,28 @@ public int GetInfo(LibEntity lib,
dataList.Add(result.Records[i].Data);
}
}

return 1;
}
catch (AggregateException ex)
{
strError = MessageConnection.GetExceptionText(ex);
if (redocount == 0)
{
redocount++;
goto REDO1;
}

goto ERROR1;
}
catch (Exception ex)
{
strError = ex.Message;
if (redocount == 0)
{
redocount++;
goto REDO1;
}

goto ERROR1;
}
ERROR1:
Expand Down

0 comments on commit 74e08cf

Please sign in to comment.