public BaseResult ExportCubeGrid(long entityID)
        {
            try
            {
                BaseObject baseObj = SectorObjectManager.Instance.GetEntry(entityID);

                if (!(baseObj is CubeGridEntity))
                {
                    return(new BaseResult(string.Format("Entity {0} is not a cubeGrid", entityID), true));
                }

                CubeGridEntity cubeGrid = (CubeGridEntity)baseObj;
                string         date     = DateTime.Now.ToString("yyyyMMddHHmmss");
                //new FileInfo(Config.Settings.ExportShipPath + @"\" + cubeGrid.EntityId + ".sbc");
                FileInfo file = new FileInfo(string.Format(@"{0}\{1}_{2}.sbc", Config.Settings.ExportShipPath, cubeGrid.EntityId, date));

                cubeGrid.Export(file);
                SavedCubeGridManager.AddSavedCubeGrid(entityID, ulong.Parse(date), file);

                return(new BaseResult(string.Format("{0} exported successfully", entityID), false));
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(new BaseResult(string.Format("Internal error: {0}. See log for details", e.Message), true));
            }
        }
        public BaseResult ImportCubeGrid(long entityID)
        {
            try
            {
                if (!SavedCubeGridManager.Contains(entityID))
                {
                    SavedCubeGridManager.ScanDirectory();
                    if (!SavedCubeGridManager.Contains(entityID))
                    {
                        return(new BaseResult(string.Format("{0} is not saved", entityID), true));
                    }
                }
                if (SectorObjectManager.Instance.GetEntry(entityID) != null)
                {
                    return(new BaseResult(string.Format("{0} is already in the world", entityID), true));
                }

                var            savedCubeGrid = SavedCubeGridManager.GetSavedCubeGrid(entityID);
                CubeGridEntity cubeGrid      = new CubeGridEntity(savedCubeGrid.m_versionList.Values[0]);

                SectorObjectManager.Instance.AddEntity(cubeGrid);

                return(new BaseResult(string.Format("{0} lastest save imported successfully", entityID), false));
            }
            catch (Exception e)
            {
                Log.Error(e);
                return(new BaseResult(string.Format("Internal error: {0}. See log for details", e.Message), true));
            }
        }
Ejemplo n.º 3
0
        public void InitWithPath(string path)
        {
            try
            {
                Log.ConsoleAndFile("Loading configuration...");
                Config.FolderPath = new FileInfo(path).DirectoryName;
                Log.ConsoleAndFile("Scanning for previously exported ships...");
                SavedCubeGridManager.ScanDirectory();

                StartWebAPI();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }