I am tring to use the Metatrader Manager API to unarchive the user. I have the admin permission to do this process and I can unarchive users from the admin application. And the following is my code for the unarchive process,
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);
}
I didn't use the pumping mode, the error code for BackupRestoreUser is 3, which means invalid paramater; the error code for BackupRestoreTrades is 2, which means common error. I've tried to solve this for hours but couldn't make any progress. I do appreciate any help from you guys.
Thank you!