MT4 Manager API how to get opening positions - c#

I would like to get the list of opening positions from MT4 via MT4 Manager API, I am using the ClrWrapper library.
Below is my source code, I tried few methods, but all returned me empty list.
Code 1:
var mt = new ClrWrapper("\mtmanapi.dll");
var connect = mt.Connect("0.0.0.0:443");
mt.Login(0, "abcac");
mt.PumpingSwitchEx(PumpingMode.Default);
var na = mt.TradesGet();
var open = mt.TradesGetByLogin(0, "abc");
Code 2:
var mt = new ClrWrapper("\mtmanapi.dll");
var connect = mt.Connect("0.0.0.0:443");
mt.Login(0, "abcac");
mt.PumpingSwitch((i)=> { });
var na = mt.TradesGet();
var open = mt.TradesGetByLogin(0, "abc");
Code 3:
var mt = new ClrWrapper("\mtmanapi.dll");
var connect = mt.Connect("0.0.0.0:443");
mt.Login(0, "abcac");
var na = mt.TradesGet();
var open = mt.TradesGetByLogin(0, "abc");

Related

Selenium C# How to get image and fill in web form

I want to write capcha from this (https://file-online.taxservice.am/pages/loginPage.jsf) site and fill in textbox above.
var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
var driver = new ChromeDriver(driverService, new ChromeOptions());
driver.Navigate().GoToUrl("https://file-online.taxservice.am/pages/loginPage.jsf");
var ocr = new IronTesseract();
IWebElement captchaImage = driver.FindElement(By.Id("mainForm:captchaImage"));
using (var input = new OcrInput(capchaImage))
{
var result = ocr.Read(input);
string result1 = Regex.Replace(result.Text, #"\s", "");
string result2 = Regex.Replace(result1, #"\B\p{Lu}", m => m.ToString().ToLower());
driver.FindElement(By.Id("userName")).SendKeys("1");
driver.FindElement(By.Id("tin")).SendKeys("2");
driver.FindElement(By.Id("password")).SendKeys("3");
driver.FindElement(By.Id("captchaEntry")).SendKeys(result2);
}

How to get Perforce (P4Api.net) Workspace Path

var P4USER = p4Config.P4USER;
var P4PORT = p4Config.P4PORT;
var P4CLIENT = p4Config.P4CLIENT;
var P4PASSWD = p4Config.P4PASSWD;
Perforce.P4.Server srv = new Perforce.P4.Server(new ServerAddress(P4PORT));
Perforce.P4.Repository p4 = new Perforce.P4.Repository(srv);
p4.Connection.UserName = P4USER;
p4.Connection.SetClient(P4CLIENT);
p4.Connection.Connect(new Perforce.P4.Options());
p4.Connection.Login(P4PASSWD);
I using P4Api.net and login done. but how can I get my worksapce path ?
I found solution , so I answer by my self.
string P4CLIENT = "YourWorkSpaceName";
Client c = p4.GetClient(P4CLIENT);
//here
Console.WriteLine(c.Root);

Enable sharding from C# MongoDb

I'm using Mongo 4 with the latest C# driver. My application creates DBs and Collections on the fly and I want to enable sharding. I'm using the following code:
if (!ShardingEnabled) return;
var database = collection.Database;
var databaseName = database.DatabaseNamespace.DatabaseName;
var collectionName = collection.CollectionNamespace.CollectionName;
var shardDbScript = $"{{ enableSharding: \"{databaseName}\" }}";
var shardDbResult = database.RunCommand<MongoDB.Bson.BsonDocument>(new MongoDB.Bson.BsonDocument() {
{ "eval",shardDbScript }
});
var adminDb = Client.GetDatabase("admin");
var shardScript = $"{{shardCollection: \"{databaseName}.{collectionName}\"}}";
var commandDoc = new BsonDocumentCommand<MongoDB.Bson.BsonDocument>(new MongoDB.Bson.BsonDocument() {
{ "eval",shardScript }
});
var response = adminDb.RunCommand(commandDoc);
I get an 'ok' response back from mongo, but my dbs arent sharded.
Output from sh.status()
{
"_id" : "uat_Test_0",
"primary" : "SynoviaShard2",
"partitioned" : false,
"version" : {
"uuid" : UUID("69576c3b-817c-4853-bb02-ea0a8e9813a4"),
"lastMod" : 1
}
}
How can I enable sharding from within C#?
I figured it out. This is how you shard a database and its collections from c#, note, that the sharding key index must already exist:
if (!ShardingEnabled) return;
var database = collection.Database;
var adminDb = Client.GetDatabase("admin");
var configDb = Client.GetDatabase("config");
//var dbs = Client.ListDatabaseNames().ToList();
var databaseName = database.DatabaseNamespace.DatabaseName;
var collectionName = collection.CollectionNamespace.CollectionName;
var shardDbResult = adminDb.RunCommand<MongoDB.Bson.BsonDocument>(new MongoDB.Bson.BsonDocument() {
{ "enableSharding",$"{databaseName}" }
});
var shardScript = $"{{shardCollection: \"{databaseName}.{collectionName}\"}}";
var commandDict = new Dictionary<string,object>();
commandDict.Add("shardCollection", $"{databaseName}.{collectionName}");
commandDict.Add("key",new Dictionary<string,object>(){{"_id","hashed"}});
var bsonDocument = new MongoDB.Bson.BsonDocument(commandDict);
var commandDoc = new BsonDocumentCommand<MongoDB.Bson.BsonDocument>(bsonDocument);
var response = adminDb.RunCommand(commandDoc);

How to fetch data from mongodb and display the data in datagridform in windows forms c#?

can anyone please help how to fetch data from Mongodb and display that data in Datagridview. here i tried this one.can anyone give better answer
var ConnectionString = "mongodb://localhost";
var client = new MongoClient(connectionString);
// var server = client.GetServer();
var database = client.GetDatabase("testdb1");
var collection = database.GetCollection<Entity>("tablo1");
//var entity = collection.FindAll();
BindingList<Entity> doclist = new BindingList<Entity>();
foreach (var deger in collection.Find(doclist))
doclist.Add(deger);
//string[] row1 = new string[] { deger.deger1.ToString() };
//dataGridView1.Rows.Add(row1);
Application.DoEvents();
}
try out this one:
var connectionString = "mongodb://localhost";
var client = new MongoClient(connectionString);
var server = client.GetServer();
var database = server.GetDatabase("DB Name");
var collection = database.GetCollection<Class Name>("Table Name");
List<Class Name> list = await collection .Find(x => true).ToListAsync();
dataGridView1.DataSource = list

How to get internal & external url data using Mozscape API?

I am using C# wrapper for SEOmoz API. The internal/external data which is displayed in open site explorer. How to get this data using this API?
var moz = new Mozscape() { MozAccessId = "xxxxxx-xxxxxxxx", MozSecretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", MozApiType = MozAPI.URL_METRICS };
var url = moz.CreateMozAPIUrl("webmetro.com", MozAPI.URL_METRICS, 1);
var results = moz.GetUrlMetrics(url);
Mozscape Link Metrics is used for internal and external data.
To get Internal Data.
var moz = new Mozscape() { MozAccessId = MozAccessID, MozSecretKey = MozSecretKEY, MozApiType = MozAPI.LINK_SCAPE };
var url = moz.CreateMozAPIUrl_LinkMetrics(DomainName, MozAPI.LINK_SCAPE, 1, Scope.page_to_domain);
var FullIntUrl = url + "&Filter=internal&Sort=page_authority&SourceCols=103079217573&TargetCols=4&Limit=1000";
var Intr = moz.GetLinkMetrics(FullIntUrl);
To get External data.
var FullExtUrl = url + "&Filter=external&Sort=page_authority&SourceCols=103079217573&TargetCols=4&Limit=1000";
var Extr = moz.GetLinkMetrics(FullExtUrl);

Categories

Resources