protected void Page_Load(object sender, EventArgs e)
    {
        //ClientCredentials cc = new ClientCredentials();
        //Engine obj = new Engine();

        EngineClient objEngineClient = new EngineClient();
        MobileMeetingProject.EsEngine.MyLoginResult lr = objEngineClient.Login("*****@*****.**", "Jhansibk5");

        GridView1.DataSource = objEngineClient.GetYears();
        GridView1.DataBind();

        //userid
        GridView2.DataSource = objEngineClient.GetEvents("bc705759-0855-e411-a06d-6c3be5a82838","2014");
        GridView2.DataBind();

        //eventid
        GridView3.DataSource = objEngineClient.GetAttendees("2ea2e9ea-06a6-4362-97c8-8635c0cbb9ae");
        GridView3.DataBind();

        //for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        //{
        //    if (GridView2.Rows.Count == 0)
        //    {
        //        GridView2.DataSource = objEngineClient.GetEvents("bc705759-0855-e411-a06d-6c3be5a82838", GridView1.Rows[i].Cells[0].Text);
        //        GridView2.DataBind();
        //    }
        //    else
        //    {
        //        break;
        //    }
        //}

        //GridView2.DataSource = objEngineClient.GetEvents(lr.UserId.ToString() , "2013");
        //GridView2.DataBind();
    }
        public void Run(string accessKey)
        {
            Console.WriteLine("EngineExample Running");
            var engineClient = new EngineClient(accessKey);
            if (!engineClient.IsAlive())
            {
                Console.WriteLine("Engine is not running");
                return;
            }

            try
            {
                var result = engineClient.Get("1", 10, new[] { "1" });
                foreach (var res in result.ItemScores)
                {
                    Console.WriteLine("Sync:" + res.Item + " " + res.Score);
                }
                var asyncResult = engineClient.GetAsync("1", 10, new[] { "1" }).Result;
                foreach (var res in asyncResult.ItemScores)
                {
                    Console.WriteLine("Async:" + res.Item + " " + res.Score);
                }
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

        }
    public static EngineClient GetEngineClient()
    {
        if (HttpContext.Current.Session["EngClient"] == null)
        {
            EngineClient EngClient = new EngineClient();

            EngClient.ClientCredentials.UserName.UserName = "******";
            EngClient.ClientCredentials.UserName.Password = "******";

            //EngClient.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            //EngClient.ClientCredentials.Windows.ClientCredential = new NetworkCredential(GetWindowsUsername(), GetWindowsPassword(), "naseba");
            //EngClient.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Identification;
            //EngClient.ClientCredentials.Windows.AllowNtlm = true;

            /*EngClient.ClientCredentials.UserName.UserName = GetWindowsUsername();
            EngClient.ClientCredentials.UserName.Password = GetWindowsPassword();
            EngClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;*/

            MobileMeetingProject.EsEngine.MyLoginResult LR =  EngClient.WebLogin();

            if (LR != null && LR.OpResult != null && LR.OpResult.Success)
            {
                HttpContext.Current.Session["EngClient"] = EngClient;
                return EngClient;
            }
            else
            {
                return null;
            }
        }
        else
        {
            return (EngineClient)HttpContext.Current.Session["EngClient"];
        }
    }
Ejemplo n.º 4
0
        public static void Main(String[] args)
        {
            var accessKey = args.Length > 0 ? args[0] : "AEEASHv5XNkTHL4AzyoE1Hu9gTrDP2AFa7qXEQfWA5y33KdO5Hk5sNExJkW5udWX";
            Console.WriteLine("Running");
            using (var client = new EventClient(accessKey))
            {
                var rand = new Random();
                //var emptyProperty = new Dictionary<string, object>();

                // generate 10 users, with user ids 1 to 10
                for (int user = 1; user <= 10; user++)
                {
                    Console.WriteLine("Add user " + user);
                    client.SetUser("i" + user, new Dictionary<string, object>
                    {
                        {"name","ibrahim"+user}, 
                        {"surname","özgön"+user}, 
                    });
                }

                // generate 50 items, with item ids 1 to 50
                for (int item = 1; item <= 50; item++)
                {
                    Console.WriteLine("Add item " + item);
                    client.SetItem("" + item, new Dictionary<string, object>
                    {
                        {"item","pencil"+item},
                        {"item2","pencil"+item},

                    });
                }

                // each user randomly views 10 items
                for (int user = 1; user <= 10; user++)
                {
                    for (int i = 1; i <= 10; i++)
                    {
                        int item = rand.Next(50) + 1;
                        Console.WriteLine("User " + user + " views item " + item);
                        client.UserActionItem("view", "" + user, "" + item, new Dictionary<string, object>
                        {
                            {"actionview","viewed"+user}
                        });
                    }
                }
                Console.ReadLine();
            }
            using (var engineClient = new EngineClient())
            {
                var dic = new Dictionary<string, object>();
                dic.Add("num", 20);
                dic.Add("user", 1);
                try
                {
                    var result = engineClient.SendQuery<ItemScoresRootObject>(dic);
                    foreach (var res in result.ItemScores)
                    {
                        Console.WriteLine(res.Item + " " + res.Score);
                    }
                    Console.ReadLine();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
        }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (this.IsValid)
        {
            SFUsername = string.Empty;
            SFPassword = string.Empty;
            Domain = string.Empty;
            try
            {
                EngineClient EngClient = Authentication.GetEngineClient();
                SFUsername = username.Text.Trim();
                SFPassword = pass.Text.Trim();
                //Domain = SFUsername.Split(new char[] { '@' })[1].ToString();
                //SFUsername = SFUsername.Split(new char[] { '@' })[0].ToString();
                //Domain = Domain.Split(new char[] { '.' })[0].ToString();
                EngClient = new EngineClient();
                MobileMeetingProject.EsEngine.MyLoginResult CurrentUser = EngClient.Login(username.Text.Trim(), pass.Text.Trim());
                // CurrentUser = EngClient.Login(SFUsername, SFPassword);

                if (CurrentUser.OpResult.Success)
                {
                    HttpCookie ContactCookie = new HttpCookie("ContactInfo");
                    ContactCookie["ContactTitle"] = CurrentUser.UserId.ToString();
                    ContactCookie["ContactName"] = CurrentUser.UserName.ToString();
                    ContactCookie.Expires = DateTime.Now.AddMonths(1);

                    Response.Cookies.Add(ContactCookie);

                    //FormsAuthentication.RedirectFromLoginPage(CurrentUser.UserId.ToString(), false);
                    //FormsAuthentication.RedirectFromLoginPage("bc705759-0855-e411-a06d-6c3be5a82838", false);
                    Response.Redirect("Selection.aspx");
                    /* if (chkbox_remeberme.Checked)
                     {
                         HttpCookie SchedulerLoginCookie = new HttpCookie("SchedulerLoginCookie");
                         SchedulerLoginCookie["Username"] = txt_username.Text.Trim();
                         SchedulerLoginCookie["Password"] = Params.Encrypt(txt_password.Text.Trim());
                         SchedulerLoginCookie.Expires = DateTime.Now.AddDays(7);

                         Response.Cookies.Add(SchedulerLoginCookie);
                     }
                     else
                     {
                         HttpCookie SchedulerLoginCookie = Request.Cookies.Get("SchedulerLoginCookie");
                         if (SchedulerLoginCookie != null)
                         {
                             SchedulerLoginCookie.Expires = DateTime.Now.AddYears(-1);
                             Response.Cookies.Add(SchedulerLoginCookie);
                         }
                     }

                     /*if (Request.QueryString["returnurl"] != null && Request.QueryString["returnurl"].Trim() != string.Empty)
                     {
                         Response.Redirect(Request.QueryString["returnurl"]);
                     }
                     else
                     {
                         Response.Redirect("~/Pages/Welcome.aspx");
                     }*/
                }
                else
                {
                    //lbl_msg.Text = "Authentication failed: invalid username or password";

                }
            }
            catch (Exception ex)
            {
                //lbl_msg.Text = "Authentication failed: " + ex.Message;
            }
        }
    }
Ejemplo n.º 6
0
        public override Return OnExecute()
        {
            string           indexes;
            HashSet <string> hsMD5       = new HashSet <string>();
            int     emptyLinesCount      = 0;
            int     duplicatesLinesCount = 0;
            int     writtenLinesCount    = 0;
            int     rowProcessed         = 0;
            ListStr lHeaders             = new ListStr();

            EngineClient _client = null;

            Sinequa.Engine.Client.Cursor _cursor = null;

            //do not use StreamWriter in a using statement. In simulate mode the file is not created so this will trigger an exception.
            StreamWriter sw = null;

            try
            {
                _client = EngineClientsPool.FromPoolByIndexList(conf.listIndexes, out indexes, conf.engine, false);
            }
            catch (Exception ex)
            {
                Sys.LogError("Cannot get Engine Client from pool for indexes [" + conf.listIndexes + "]");
                Sys.LogError(ex);
                return(Return.Error);
            }
            Sys.Log("Using Engine client  [" + _client.Name + "]");

            try
            {
                Sys.Log("Execute query [" + conf.GetSQL() + "]");

                _cursor = _client.ExecCursor(conf.GetSQL());

                if (_cursor == null)
                {
                    Sys.LogError("Cannot get cursor for query [" + conf.GetSQL() + "]");
                    return(Return.Error);
                }

                DocExportIndexToCsv doc = new DocExportIndexToCsv(this, _cursor, conf.dColumnColumnAlias);
                var context             = new IDocContext {
                    Doc = doc
                };

                Sys.Log("Query processingtime [" + _cursor.GetAttribute("processingtime") + "]");
                Sys.Log("Query row count [" + _cursor.TotalRowCount + "]");
                int globalTimer = Sys.TimerStart();

                if (!conf.simulate)
                {
                    sw = new StreamWriter(conf.destinationFilePath, false, Encoding.UTF8);
                }

                int localTimer = Sys.TimerStart();
                while (!_cursor.End())
                {
                    rowProcessed++;
                    if (rowProcessed % logStatsEveryNRows == 0)
                    {
                        Sys.Log("----------------------------------------------------");
                        Sys.Log("Number of rows processed [" + rowProcessed + "] ");
                        Sys.Log("Number of lines exported [" + writtenLinesCount + "] ");
                        Sys.Log("Number of empty lines removed [" + emptyLinesCount + "] ");
                        Sys.Log("Number of duplicated lines removed [" + duplicatesLinesCount + "] ");
                        Sys.Log("Processing [" + logStatsEveryNRows + "] rows in [", Sys.TimerGetText(Sys.TickDuration(localTimer)), "]");
                        localTimer = Sys.TimerStart();
                    }

                    ListStr l       = new ListStr();
                    bool    isEmpty = true;

                    for (int i = 0; i < _cursor.ColumnCount; i++)
                    {
                        if (conf.addHeaders && rowProcessed == 1)   //headers
                        {
                            string header = _cursor.GetColumnName(i);
                            if (conf.useDblQuote)
                            {
                                header = "\"" + header + "\"";
                            }
                            lHeaders.Add(header);
                        }

                        string colValue = Str.Empty;
                        //cursor column match column mapping column name ?
                        if (conf.lColumnMapping.Exists(x => Str.EQNC(x.columnName, _cursor.GetColumnName(i))))
                        {
                            //get all matching column mapping for current column
                            List <ColumnMapping> lColumnMapping = conf.lColumnMapping.FindAll(x => Str.EQNC(x.columnName, _cursor.GetColumnName(i)));
                            foreach (ColumnMapping columnMapping in lColumnMapping)
                            {
                                if (columnMapping.slectionQuery.IsSelected(context, doc))  //match selection query ? if so, apply value pattern
                                {
                                    Sys.Log2(40, "Column [" + columnMapping.columnName + "] match selection query [" + columnMapping.slectionQuery.Sql + "]");

                                    colValue = IDocHelper.GetValue(context, doc, columnMapping.valueExpression);
                                    Sys.Log2(40, "Column [" + columnMapping.columnName + "] use value pattern [" + columnMapping.valueExpression + "] = [" + colValue + "]");
                                    break;  //stop mapping when selection query match
                                }
                                else
                                {
                                    Sys.Log2(40, "Column [" + columnMapping.columnName + "] don't match selection query [" + columnMapping.slectionQuery.Sql + "]");
                                    continue;   //go to next expression
                                }
                            }
                        }
                        //no column mapping, get value from cursor
                        else
                        {
                            colValue = _cursor.GetColumn(i);
                        }
                        if (!Str.IsEmpty(colValue))
                        {
                            isEmpty = false;
                        }
                        if (conf.useReplaceSeparator)
                        {
                            colValue = colValue.Replace(conf.separator, conf.replaceSeparator);                            //replace separator in values
                        }
                        if (conf.useDblQuote)
                        {
                            colValue = "\"" + colValue + "\"";                      //use double quote
                        }
                        l.Add(colValue);
                    }

                    string line = l.ToStr(conf.separator);

                    if (conf.removeDuplicates)  //remove duplicates
                    {
                        string MD5 = Str.Md5(line);
                        if (!hsMD5.Add(MD5))
                        {
                            duplicatesLinesCount++;
                            _cursor.MoveNext();
                            continue;
                        }
                    }

                    if (conf.removeEmptyLines && isEmpty)   //remove empty lines
                    {
                        emptyLinesCount++;
                        _cursor.MoveNext();
                        continue;
                    }

                    writtenLinesCount++;
                    if (conf.simulate)  //simulate, add headers and line into logs
                    {
                        if (conf.addHeaders && rowProcessed == 1)
                        {
                            Sys.Log(GetHeaders(lHeaders)); // write headers
                        }
                        Sys.Log(line);                     //write line
                        if (writtenLinesCount >= conf.simulateCount)
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (conf.addHeaders && rowProcessed == 1)
                        {
                            sw.WriteLine(GetHeaders(lHeaders)); // write headers
                        }
                        sw.WriteLine(line);                     //write line
                    }

                    _cursor.MoveNext();
                }

                if (sw != null)
                {
                    sw.Close();             //dispose stream writer
                }
                Sys.Log("----------------------------------------------------");
                if (conf.removeEmptyLines)
                {
                    Sys.Log("Number of empty lines removed [" + emptyLinesCount + "]");
                }
                if (conf.removeDuplicates)
                {
                    Sys.Log("Number of duplicated lines removed [" + duplicatesLinesCount + "]");
                }
                Sys.Log("[" + writtenLinesCount + "] lines exported into file [" + conf.destinationFilePath + "]");
                Sys.Log("Processing [" + rowProcessed + "] rows in [", Sys.TimerGetText(Sys.TickDuration(globalTimer)), "]");
            }
            catch (Exception ex)
            {
                Sys.LogError("Select index Cursor error : ", ex);
                try
                {
                    if (_client != null)
                    {
                        EngineClientsPool.ToPool(_client);
                    }
                }
                catch (Exception exe)
                {
                    Sys.LogError("EngineClientsPool ToPool : ", exe);
                    Sys.Log(exe.StackTrace);
                }
            }
            finally
            {
                try
                {
                    if (_cursor != null)
                    {
                        _cursor.Close();
                    }
                }
                catch (Exception ex)
                {
                    Sys.LogError("Close cursor error : ", ex);
                    Sys.Log(ex.StackTrace);
                }
                EngineClientsPool.ToPool(_client);
            }

            return(base.OnExecute());
        }
Ejemplo n.º 7
0
 private string GetSRPC(EngineClient client)
 {
     return("srpc://" + client.Host + ":" + client.Port);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Update the content of a comment
        /// </summary>
        /// <param name="client"></param>
        /// <param name="docid"></param>
        private void Update(EngineClient client, string docid)
        {
            // Get required inputs
            string commentid = ensureStrInput("commentid");

            if (commentid == null)
            {
                return;
            }

            string message = ensureStrInput("message");

            if (message == null)
            {
                return;
            }

            // Read the comment from the engine
            var comment = ReadComment(client, commentid, docid);

            if (comment == null)
            {
                return;
            }

            // Prevent updating a deleted comment
            if (comment.deleted)
            {
                SetError(400, $"Cannot like/unlike a deleted comment");
                return;
            }

            // Update the message content
            comment.message  = message;
            comment.modified = Dat.ToUtc(DateTime.Now);

            string sql = comment.ToUpdateSQL(indexname);

            // Admin can update any comment
            if (!Method.Session.User.IsAdministrator)
            {
                string userid = Method.Session.UserId;
                sql = $"{sql} AND userid={Str.SqlValue(userid)}";
            }

            // Update the index;
            int res = client.Exec(sql);

            if (client.HasError())
            {
                SetError(500, client.GetError());
                Sys.LogError($"Error engine: {client.GetError()} for SQL: {sql}");
                return;
            }

            // Check that the comment was correctly updated
            if (res != 1)
            {
                SetError(404, $"This comment could not be found");
                return;
            }

            // Return the updated comment
            JsonResponse.Set("comment", comment.ToJson());
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Main entry point of the web service. This method simply retrieves the "action"
        /// input from the request, and calls the corresponding method accordingly (among which
        /// Create(), Read(), Update(), Delete(), Like()).
        /// </summary>
        public override void OnPluginMethod()
        {
            //Sys.Log("Comments Web Service Plugin Start");

            string action = ensureStrInput("action");
            string docid  = ensureStrInput("docid");

            if (docid == null || action == null)
            {
                return;
            }

            if (!Method.Session.HasAccessToDocId(docid))
            {
                SetError(403, "You do not have access to this document");
                return;
            }

            CCIndex      index  = CC.Current.Indexes[indexname];
            EngineClient client = null;

            try
            {
                client = EngineClientsPool.FromPool(index);

                switch (action.ToLower())
                {
                case "create":
                    Create(client, docid);
                    break;

                case "read":
                    Read(client, docid);
                    break;

                case "update":
                    Update(client, docid);
                    break;

                case "delete":
                    Delete(client, docid);
                    break;

                case "like":
                    Like(client, docid);
                    break;

                default:
                    SetError(400, "Invalid 'action' input. Possible actions: 'create','read','update','delete','like'");
                    break;
                }
            }
            catch (Exception ex)
            {
                JsonResponse.SetValue("error", ex.StackTrace);
                SetError(400, ex.Message);
            }
            finally
            {
                EngineClientsPool.ToPool(client);
            }

            //Sys.Log("Comments Web Service Plugin End");
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Toolbox.RegisterLogCallback(ErrorCallback, LogMask.ERROR);
            Toolbox.SetDefinitionLoadCallback(File.ReadAllText);
            Toolbox.SetResourceLoadCallback(File.ReadAllBytes);
            Comet.InitModule();
            Nebula.InitModule();
            Engine.InitModule("SBG/MouseDeamon");

            while (!Engine.IsLocalRunning())
            {
                Console.WriteLine("Waiting for local engine...");
                System.Threading.Thread.Sleep(1000);
            }

            try {
                Satellite.GetSelf();
            } catch (StarburstException) {
                Satellite.Deploy();
            }
            Component mouseComp = new Component("SBG/MouseClient");

            Topic.CometReceiver mousePositionTopic = new Topic.CometReceiver("mousePosition", Topic.CometReceiver.StorageType.STREAM);
            Topic.CometReceiver mouseEventTopic    = new Topic.CometReceiver("mouseEvent", Topic.CometReceiver.StorageType.QUEUE);

            Satellite self    = Satellite.GetSelf();
            string    address = EngineClient.Get(self.EngineClientID).Address;

            Session se = null;

            while (!Session.TryFind(out se))
            {
                System.Threading.Thread.Sleep(1000);
            }
            Engine.JoinSession(se);
            while (mouseComp.Action != ComponentAction.START)
            {
                System.Threading.Thread.Sleep(100);
            }
            mouseComp.ReportState(ComponentState.STARTED);

            CMouseInput mi = new CMouseInput {
                dwFlags = CMouseInput.FLAG_ABSOLUTE
            };

            var  inputPtr     = Marshal.AllocHGlobal(Marshal.SizeOf <CInput>());
            bool inputChanged = false;

            while (mouseComp.Action != ComponentAction.STOP)
            {
                Comet c = mousePositionTopic.GetComet();                    // Range: -1 to 1
                if (c != null)
                {
                    if ((mi.dx != WinRange(c["X"].AsFloat()) || mi.dy != WinRange(c["Y"].AsFloat())) && c["Client"].AsString() == address)
                    {
                        mi.dx        = WinRange(c["X"].AsFloat());                    // Range: 0 to 65536
                        mi.dy        = WinRange(c["Y"].AsFloat());
                        mi.dwFlags  |= CMouseInput.FLAG_MOUSEMOVED;
                        inputChanged = true;
                    }

                    c.Dispose();
                }

                c = mouseEventTopic.GetComet();
                if (c != null)
                {
                    if (c["Client"].AsString() == address)
                    {
                        mi.dwFlags  |= c["LeftDown"].AsBool() ? CMouseInput.FLAG_LEFTDOWN : 0;
                        mi.dwFlags  |= c["LeftUp"].AsBool() ? CMouseInput.FLAG_LEFTUP : 0;
                        mi.dwFlags  |= c["RightDown"].AsBool() ? CMouseInput.FLAG_RIGHTDOWN : 0;
                        mi.dwFlags  |= c["RightUp"].AsBool() ? CMouseInput.FLAG_RIGHTUP : 0;
                        inputChanged = true;
                    }

                    c.Dispose();
                }

                if (inputChanged)
                {
                    Marshal.StructureToPtr(mi.AsCInput(), inputPtr, true);
                    if (SendInput(1, inputPtr, Marshal.SizeOf <CInput>()) < 1)
                    {
                        throw new Exception("Couldn't send input : error " + GetLastError());
                    }
                    mi.dwFlags   = CMouseInput.FLAG_ABSOLUTE;                    // reseting flags
                    inputChanged = false;
                }

                System.Threading.Thread.Sleep(20);
            }
            mouseComp.ReportState(ComponentState.STOPPED);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates new instance of engine interaction service
 /// </summary>
 /// <param name="engineClient">The engine client</param>
 public EngineService(EngineClient engineClient)
 {
     this.engineClient = engineClient;
 }
Ejemplo n.º 12
0
        public Engine(HostType hostType, ICommandLine commandLine, string gameDirectory, EngineConfiguration engineConfiguration, ILogger logger, ForwardingTextWriter forwardingTextWriter)
        {
            _hostType = hostType;

            CommandLine         = commandLine ?? throw new ArgumentNullException(nameof(commandLine));
            GameDirectory       = gameDirectory ?? throw new ArgumentNullException(nameof(gameDirectory));
            EngineConfiguration = engineConfiguration ?? throw new ArgumentNullException(nameof(engineConfiguration));
            Log.Logger          = Logger = logger ?? throw new ArgumentNullException(nameof(logger));
            LogTextWriter       = forwardingTextWriter ?? throw new ArgumentNullException(nameof(forwardingTextWriter));

            FileSystem = new DiskFileSystem();

            SetupFileSystem(GameDirectory);

            CommandSystem = new SharpLife.CommandSystem.CommandSystem(Logger, CultureInfo.InvariantCulture);

            EngineContext = CommandSystem.CreateContext("EngineContext");

            var startupState = new EngineStartupState(Logger, GameDirectory,
                                                      new IModelFormatProvider[]
            {
                new SpriteModelFormatProvider(),
                new StudioModelFormatProvider(),
                //BSP loader comes last due to not having a way to positively recognize the format
                new BSPModelFormatProvider(Framework.BSPModelNamePrefix)
            });

            //Add the engine assembly so builtin data gets added
            startupState.EntitySystemMetaData.AddAssembly(typeof(Engine).Assembly);

            //create the game window if this is a client
            if (_hostType == HostType.Client)
            {
                Client = new EngineClient(this, startupState);
            }

            Server = new EngineServer(this, Logger, startupState);

            PluginManager = startupState.PluginManager.Build();

            //Automatically add in all plugin assemblies to the entity system
            foreach (var pluginAssembly in PluginManager.Assemblies)
            {
                startupState.EntitySystemMetaData.AddAssembly(pluginAssembly);
            }

            var renderer = (IRenderer)Client?.UserInterface.Renderer ?? new ServerRenderer();

            World = new WorldState(
                Logger,
                EventSystem,
                FileSystem,
                startupState.EntitySystemMetaData.Build(),
                renderer,
                startupState.ModelFormats);

            _engineTimeStopwatch.Start();

            EngineContext.AddStuffCmds(Logger, CommandLine);
            EngineContext.AddExec(Logger, FileSystem, ExecPathIDs);
            EngineContext.AddEcho(Logger);
            EngineContext.AddAlias(Logger);
            EngineContext.AddFind(Logger);
            EngineContext.AddHelp(Logger);

            _fpsMax = EngineContext.RegisterVariable(
                new VirtualVariableInfo <uint>("fps_max", DefaultFPS)
                .WithHelpInfo("Sets the maximum frames per second")
                .WithChangeHandler((ref VariableChangeEvent <uint> @event) =>
            {
                @event.Value = Math.Min(@event.Value, MaximumFPS);

                var desiredFPS = @event.Value;

                if (desiredFPS == 0)
                {
                    desiredFPS = MaximumFPS;
                }

                _desiredFrameLengthSeconds = 1.0 / desiredFPS;
            }));

            EngineContext.RegisterVariable("engine_builddate", () => BuildDate, "The engine's build date");

            EngineContext.RegisterCommand(new CommandInfo("map", StartNewMap).WithHelpInfo("Loads the specified map"));

            //Get the build date from the generated resource file
            var assembly = typeof(Engine).Assembly;

            using (var reader = new StreamReader(assembly.GetManifestResourceStream($"{assembly.GetName().Name}.Resources.BuildDate.txt")))
            {
                string buildTimestamp = reader.ReadToEnd();

                BuildDate = DateTimeOffset.Parse(buildTimestamp);

                Logger.Information($"Exe: {BuildDate.ToString("HH:mm:ss MMM dd yyyy")}");
            }

            //TODO: initialize subsystems
        }