cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Asp.net Api working like a windows service ?

tunc
Super Contributor

 

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;

 

}

4 Replies

tunc
Super Contributor

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.

ask9.png

 

 

 

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.

 

 

 

 

ask8.png

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;
        }
    }
}

tunc
Super Contributor

Hi ,

 

Thanks for advice , can you show me some code MegaDatabese obeject have wrote with c# .

Which connect  mega and then close mega connection.

 

 

gquiniou
Retired

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.