我想使用Metatrader Manager API取消归档用户。我有管理员权限来执行此过程,我可以从管理应用程序中取消归档用户。以下是我的解压缩过程的代码,
public ClrWrapper Metatrader(string host, int login, string password, string apiPath)
{
var param = new ConnectionParameters()
{
Server = host,
Login = login,
Password = password
};
return metatrader = new ClrWrapper(param, apiPath);
}
public void UnarchiveAccounts(int[] logins)
{
StringBuilder builder = new StringBuilder();
foreach(int login in logins)
{
if (login!=0)
{ builder.Append(login).Append(","); }
}
string request = builder.ToString();
IList<BackupInfo> userInfo = metatrader.BackupInfoUsers(2);
IList<BackupInfo> orderInfo = metatrader.BackupInfoOrders(2);
IList<UserRecord> userRecords = new List<UserRecord>();
List<TradeRecord> tradeRecords = new List<TradeRecord>();
foreach (BackupInfo userInfoItem in userInfo)
{
if (userInfoItem.File.ToUpper().Contains("ARCHIVE"))
{
userRecords = userRecords.Concat(metatrader.BackupRequestUsers(userInfoItem.File, request)).ToList();
if (userRecords.Count >= logins.Length)
{
break;
}
}
}
int userUnarchiveFlag = metatrader.BackupRestoreUsers(userRecords);
string error = metatrader.ErrorDescription(userUnarchiveFlag);
// restore trades
foreach(BackupInfo orderInfoItem in orderInfo)
{
if(orderInfoItem.File.ToUpper().Contains("ARCHIVE"))
{
tradeRecords.AddRange(metatrader.BackupRequestOrders(orderInfoItem.File, request));
}
}
IList<TradeRestoreResult> tradeRestore = metatrader.BackupRestoreOrders(tradeRecords);
}
我没有使用抽水模式,BackupRestoreUser的错误代码是3,这意味着无效的参数; BackupRestoreTrades的错误代码是2,这意味着常见错误。我试图解决这个问题几个小时,但无法取得任何进展。我非常感谢你们的任何帮助。
谢谢!