27-11-2013 08:42 AM
Is there any c# documentation to connection mega.exe , I sending some code to connect mega like an external api but this code block just workin while mega.exe open in my local. We want to run mega from code
newLib = "Yapi Kredi";
env = new MegaCurrentEnvClass();
root = env.get_GetRoot("");
oFolderLib2 = root.get_GetCollection("Folder of Business Processes");
foreach (MegaObject item3 in oFolderLib2)
{
hex = item3.get_GetProp("absolute identifier").ToString();
processname = item3.get_GetProp("shortname").ToString();
CreationDate = Convert.ToDateTime(item3.get_GetProp("creation date").ToString());
ModificationDate = Convert.ToDateTime(item3.get_GetProp("modification date").ToString());
coreList.Add(new FolderOfBusiness((int)Enumeration.ObjectType.FolderofBusinessProcesses, processname,
hex, "", "", 1, ReferencedId, ReferencedTypeId, CreationDate, ModificationDate));
RoofId = item3.get_GetProp("absolute identifier").ToString();
RoofTypeId = (int)Enumeration.ObjectType.FolderofBusinessProcesses;
}
Solved! Go to Solution.
28-11-2013 12:43 PM
Hi ,
First of all , thanks for your support .Our Mega.exe in shared folder and our developed api project in my local pc .
When I connect to mega my steps is like that
directory for mega.exe: \\lvdmega\Mega\MEGA 2009 SP5
and login screen at the below.
Then I try your connection code block like at the below .It doesnt connect and error happened.
Error note:MyEnv object is null .
How could we fixed this error and login mega .
Thanks.
28-11-2013 10:02 AM
Hi,
Here is a short example:
using System;
using System.Collections;
using System.Linq;
using System.Text;
using MegaMapp;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
MegaApplication mapp = new MegaApplication();
MegaEnvironment myenv = mapp.Environments()["c:\\clients\\XXXXX\\YYYYY"]; //Environment path
myenv.CurrentAdministrator = "mega"; //User name
myenv.CurrentPassword = ""; // User password
foreach(MegaDatabase mydb in myenv.Databases()) {
if (mydb.Name == "ZZZZZ") { //Repository name
MegaRoot myroot = mydb.Open();
Console.WriteLine("There are {0} organizational processes.", myroot.get_GetCollection("Organizational process").Count);
myroot = null;
}
}
string s = Console.ReadLine();
myenv = null;
mapp = null;
}
}
}
28-11-2013 08:21 AM - edited 28-11-2013 08:22 AM
Hi ,
Thanks for advice , can you show me some code MegaDatabese obeject have wrote with c# .
Which connect mega and then close mega connection.
28-11-2013 07:57 AM
There are 2 entry points to the MEGA API:
- MegaCurrentEnv (the one you are using at the moment) connects to a running instance of MEGA
- Using the MegaDatabase object, you can specify which environment/repository/user to use. In that case Mega must not be running.