示例#1
0
 public WhoAmIResponse Get(WhoAmI dto)
 {
     var session = GetSession();
     var username = session.UserAuthName;
     var user = db.FindUserByUsername(username);
     return (new WhoAmIResponse(user.Id, user.Username, user.Name));
 }
示例#2
0
    private void GoToTargetInterface(Command command, Drone drone)
    {
        InteractiveObject interfaceObject = ObjectsManager.Instance.GetObject(0, CommandReceivers.Interface);

        if (interfaceObject == null)
        {
            // _response?.Invoke(InterfaceNotExistResponse(command));
            return;
        }

        drone.SetDestination(interfaceObject.gameObject.transform.position);
        ResponseManager.Instance.DroneMoveTo(WhoAmI.ToString() + drone.Id.ToString() + '>', "Interface");
    }
示例#3
0
    private void GoToTargetRoom(Command command, Drone drone)
    {
        int  targetRoomId = command.Args[0];
        Room room         = RoomManager.Instance.GetRoomById(targetRoomId);

        if (room == null)
        {
            ResponseManager.Instance.RoomNotExist(WhoAmI.ToString() + drone.Id.ToString() + '>', command.Args[0].ToString());
            return;
        }

        Vector3 targetRoomCenterPosition = room.GetCenter();

        drone.SetDestination(targetRoomCenterPosition);
        ResponseManager.Instance.DroneMoveTo(WhoAmI.ToString() + drone.Id.ToString() + '>', "room " + command.Args[0].ToString());
    }
示例#4
0
        public static bool WhoAmI()
        {
            try
            {

                WhoAmIResponse response;
                WhoAmI request;

                // Build Request
                request = new WhoAmI();

                // Send Request
                Presentation.UpdateStatus("Connecting to Preparation Server", "Determining connection authentication, please wait...", true, -1);
                response = request.Post(true);

                // Process Response
                response.Process();

                // Complete
                return true;
            }
            catch (WebException webEx)
            {
                // Check for 'Unauthenticated' Connection
                if ((webEx.Status == WebExceptionStatus.ProtocolError) && ((HttpWebResponse)webEx.Response).StatusCode == HttpStatusCode.Unauthorized)
                {
                    WhoAmIExtensions.UnauthenticatedResponse();
                    return true;
                }
                else
                {
                    // Some other Web Error
                    ErrorReporting.ReportError(webEx, false);
                }
            }
            catch (Exception ex)
            {
                ErrorReporting.ReportError(ex, true);
            }
            return false;
        }
示例#5
0
        public virtual ActionResult Authenticated(string feature)
        {
            if (string.IsNullOrEmpty(feature))
            {
                WhoAmIResponse whoAmIResponse = new WhoAmI().BuildResponse();
                return Json(whoAmIResponse, JsonRequestBehavior.AllowGet);
            }
            switch (feature.ToLower())
            {
                case "whoami":
                    {
                        WhoAmIResponse whoAmIResponse = new WhoAmI().BuildResponse();
                        return Json(whoAmIResponse, JsonRequestBehavior.AllowGet);
                    }
                case "enrol":
                    {
                        // Ensure supported version
                        if (Request.UserAgent.StartsWith(@"Disco-Client/", StringComparison.OrdinalIgnoreCase))
                        {
                            Version clientVersion;
                            if (Version.TryParse(Request.UserAgent.Substring(13), out clientVersion))
                            {
                                if (clientVersion < new Version(2, 2))
                                {
                                    return new HttpStatusCodeResult(400, "Disco Client not compatible");
                                }
                            }
                        }

                        var serializer = new JsonSerializer();
                        Enrol enrolRequest;

                        Request.InputStream.Position = 0;
                        using (var streamReader = new StreamReader(Request.InputStream))
                        {
                            using (var jsonReader = new JsonTextReader(streamReader))
                            {
                                enrolRequest = serializer.Deserialize<Enrol>(jsonReader);
                            }
                        }

                        EnrolResponse enrolResponse = enrolRequest.BuildResponse();
                        return Json(enrolResponse);
                    }
            }
            throw new MissingMethodException(string.Format("Unknown Feature: {0}", feature));
        }
        public string CreateAutomatedFolderName(string folderpath,WhoAmI ident)
        {
            //create automated foldername

            string versionNumber = "BACKUPSETTINGS_NOTFOUND";
            getallversionnumbers("", false);

            if (ident==WhoAmI.Tv_Server)
            {
                versionNumber = ActualTvServerVersion;
            }
            else if (ident == WhoAmI.MP1_Client)
            {
                versionNumber = ActualMediaPortalVersion;
            }
            else if (ident == WhoAmI.MP2_Server)
            {
                versionNumber = ActualMP2ServerVersion;
            }
            else if (ident == WhoAmI.MP2_Client)
            {
                versionNumber = ActualMP2ClientVersion;
            }

            string timestamp = "Version_" + versionNumber + "_Date_" + DateTime.Now.ToString("yyyy_MM_dd", CultureInfo.InvariantCulture) + "_Time_" + DateTime.Now.ToString("HH_mm_ss", CultureInfo.InvariantCulture);
            string[] tokenarray = folderpath.Split('\\');
            if ((tokenarray.Length > 0) && (folderpath.Length > 2))
            {
                string lastFolder = tokenarray[tokenarray.Length - 1];
                if ((lastFolder.StartsWith("Version_") == true) && (lastFolder.Contains("_Date_") == true) && (lastFolder.Contains("_Time_") == true))
                {
                    folderpath = "";
                    for (int i = 0; i <= tokenarray.Length - 2; i++)
                    {
                        folderpath += tokenarray[i] + "\\";
                    }
                    folderpath += timestamp;
                }
                else
                {
                    folderpath = folderpath + "\\" + timestamp;
                }
            }
            else
            {
                folderpath = @"C:\MediaPortal Backups\" + timestamp;
            }
            return folderpath;
        }
示例#7
0
        public Form1(string id)
        {
            InitializeComponent();

            instpaths.DEBUG = DEBUG; //not loaded yet from settings

            instpaths.GetInstallPaths(); //do not log before status file has been opened

            textBoxMP1P.Text = instpaths.MP_PROGRAM_FOLDER;
            textBoxMP1U.Text = instpaths.MP_USER_FOLDER;
            textBoxTV1P.Text = instpaths.TV_PROGRAM_FOLDER;
            textBoxTV1U.Text = instpaths.TV_USER_FOLDER;

            instpaths.GetInstallPathsMP2(); //do not log before status file has been opened

            textBoxMP2P.Text = instpaths.MP2_PROGRAM_FOLDER;
            textBoxMP2U.Text = instpaths.MP2_USER_FOLDER;
            textBoxSV2P.Text = instpaths.SV2_PROGRAM_FOLDER;
            textBoxSV2U.Text = instpaths.SV2_USER_FOLDER;

            instpaths.GetMediaPortalDirs(); //do not log before status file has been opened

            instpaths.GetMediaPortalDirsMP2(); //do not log before status file has been opened

            //use loadsettings or installpaths from starting tvservice before loadsettings
            MP_PROGRAM_FOLDER = textBoxMP1P.Text;
            MP_USER_FOLDER = textBoxMP1U.Text;
            TV_PROGRAM_FOLDER = textBoxTV1P.Text;
            TV_USER_FOLDER = textBoxTV1U.Text;

            MP2_PROGRAM_FOLDER = textBoxMP2P.Text;
            MP2_USER_FOLDER = textBoxMP2U.Text; ;
            SV2_PROGRAM_FOLDER = textBoxSV2P.Text;
            SV2_USER_FOLDER = textBoxSV2U.Text;

            //determine ID

            if (id.ToLower() == WhoAmI.MP1_Client.ToString().ToLower())
            {
                IDENT = WhoAmI.MP1_Client;
            }
            else if (id.ToLower() == WhoAmI.MP2_Client.ToString().ToLower())
            {
                IDENT = WhoAmI.MP2_Client;
            }
            else //default MP2-Server
            {
                IDENT = WhoAmI.MP2_Server;
            }

            //if not found by autodetection user must be asked!!!

            // if not available ask for installation folders

            switch (IDENT)
            {
                case WhoAmI.MP1_Client:
                    {
                        #region MP1 Client

                        if (File.Exists(MP_PROGRAM_FOLDER + @"\MediaPortal.exe") == false)
                        {
                            MP_PROGRAM_FOLDER = instpaths.ask_MP_PROGRAM();
                        }

                        if (File.Exists(MP_PROGRAM_FOLDER + @"\MediaPortal.exe") == false)
                        {
                            MessageBox.Show(MP_PROGRAM_FOLDER + @"\MediaPortal.exe does not exist ", "Error");
                            return;
                        }

                        if (Directory.Exists(MP_USER_FOLDER) == false)
                        {
                            MP_USER_FOLDER = instpaths.ask_MP_USER();
                        }

                        if (Directory.Exists(MP_USER_FOLDER) == false)
                        {
                            MessageBox.Show("MediaPortal user folder "+MP_USER_FOLDER+" does not exist ", "Error");
                            return;
                        }

                        BackupSettings_DIR = MP_USER_FOLDER + @"\BackupSettings";
                        CONFIG_FILE = MP_USER_FOLDER + @"\BackupSettingsMP.xml";
                        RESTART_APPLICATION = MP_PROGRAM_FOLDER + @"\Configuration.exe";

                        #endregion MP1 Client
                        break;
                    }
                case WhoAmI.MP2_Client:
                    {
                        #region MP2 Client

                        if (File.Exists(MP2_PROGRAM_FOLDER + @"\MP2-Client.exe") == false)
                        {
                            MP2_PROGRAM_FOLDER = instpaths.ask_MP2_PROGRAM();
                        }

                        if (File.Exists(MP2_PROGRAM_FOLDER + @"\MP2-Client.exe") == false)
                        {
                            MessageBox.Show(MP2_PROGRAM_FOLDER + @"\MP2-Client.exe does not exist ", "Error");
                            return;
                        }

                        if (Directory.Exists(MP2_USER_FOLDER) == false)
                        {
                            MP2_USER_FOLDER = instpaths.ask_MP2_USER();
                        }

                        if (Directory.Exists(MP2_USER_FOLDER) == false)
                        {
                            MessageBox.Show("MediaPortal2 client user folder "+MP2_USER_FOLDER+" does not exist ", "Error");
                            return;
                        }

                        BackupSettings_DIR = instpaths.DIR_MP2_Config + @"\" + System.Environment.UserName + @"\BackupSettings";
                        CONFIG_FILE = instpaths.DIR_MP2_Config + @"\" + System.Environment.UserName + @"\BackupSettings\BackupSettingsMP.xml";
                        RESTART_APPLICATION = MP2_PROGRAM_FOLDER + @"\MP2-Client.exe";

                        #endregion MP2 Client
                        break;
                    }
                case WhoAmI.MP2_Server:
                    {
                        #region MP2 Server

                        if (File.Exists(SV2_PROGRAM_FOLDER + @"\MP2-Server.exe") == false)
                        {
                            SV2_PROGRAM_FOLDER = instpaths.ask_SV2_PROGRAM();
                        }

                        if (File.Exists(SV2_PROGRAM_FOLDER + @"\MP2-Server.exe") == false)
                        {
                            MessageBox.Show(SV2_PROGRAM_FOLDER + @"\MP2-Server.exe does not exist ", "Error");
                            return;
                        }

                        if (Directory.Exists(SV2_USER_FOLDER) == false)
                        {
                            SV2_USER_FOLDER = instpaths.ask_SV2_USER();
                        }

                        if (Directory.Exists(SV2_USER_FOLDER) == false)
                        {
                            MessageBox.Show("MediaPortal2 server user folder "+SV2_USER_FOLDER+" does not exist ", "Error");
                            return;
                        }

                        BackupSettings_DIR = instpaths.DIR_SV2_Config + @"\" + System.Environment.UserName + @"\BackupSettings";
                        CONFIG_FILE = BackupSettings_DIR + @"\BackupSettingsMP.xml";
                        //RESTART_APPLICATION = SV2_PROGRAM_FOLDER + @"\MP2-Server.exe";
                        RESTART_APPLICATION = ""; //no restart

                        #endregion SV2 Server
                        break;
                    }

            }

            if (Directory.Exists(BackupSettings_DIR) == false)
            {
                Directory.CreateDirectory(BackupSettings_DIR);
            }

            // read old status from file
            if (File.Exists(BackupSettings_DIR + @"\" + STATUS_FILE) == true)
            {
                try
                {
                    //read old status
                    StreamReader sfile = File.OpenText(BackupSettings_DIR + @"\" + STATUS_FILE);
                    ReadOldStatusFile(sfile);
                }
                catch (Exception exc)
                {
                    textoutput("BackupSettings: Fatal Error: Could not open file in append mode for " + BackupSettings_DIR + @"\" + STATUS_FILE + " - Exception:" + exc.Message);
                    return;
                }
            }

            //open file in append mode for new status
            try
            {
                Status = File.AppendText(BackupSettings_DIR + @"\" + STATUS_FILE);
                if (DEBUG)
                    textoutput("BackupSettingsSetup: Status File opened in append mode");
            }
            catch (Exception exc)
            {
                textoutput("BackupSettingsSetup: Fatal Error: Could not open file in append mode for " + BackupSettings_DIR + @"\" + STATUS_FILE + " - Exception:" + exc.Message);
            }

            defaults();
            LoadSettings();  //update GUI based on settings
            SaveSettings();  //ensures that paths are written to setting file and setting file does exist for importexport

            //enable text events
            if (instpaths != null)
            {
                instpaths.newmessage += new textmessage(textoutput);
                instpaths.DEBUG = DEBUG;
            }

            if (newexportimport != null)
            {
                newexportimport.newmessage += new textexportmessage(textoutput);
                newexportimport.ExportImport(ref progressBar, CONFIG_FILE);
                newexportimport.MyLoadSettings();
                newexportimport.getallversionnumbers("", false); //get only program version numbers after loadsettings
            }

            textoutput("Plugin: " + IDENT.ToString() + "\n");

            //enable autodate if checked
            if (checkBoxUseAutoDate.Checked == true)
            {
                //create automated foldername
                SaveSettings();
                newexportimport.MyLoadSettings();
                filenametextBox.Text = newexportimport.CreateAutomatedFolderName(filenametextBox.Text, IDENT);
            }

            UpdateGUI();

            //set current working directory

            switch (IDENT)
            {
                case WhoAmI.MP1_Client:
                    {
                        System.Environment.CurrentDirectory = MP_PROGRAM_FOLDER;
                        break;
                    }
                case WhoAmI.MP2_Client:
                    {
                        System.Environment.CurrentDirectory = MP2_PROGRAM_FOLDER;
                        break;
                    }
                case WhoAmI.MP2_Server:
                    {
                        System.Environment.CurrentDirectory = SV2_PROGRAM_FOLDER;
                        break;
                    }
            }
        }
示例#8
0
 public static string EncryptToken(this WhoAmI user)
 {
     return(Convert.ToBase64String(Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(user)), Base64FormattingOptions.None));
 }
示例#9
0
 protected override void Execute(InteractiveObject obj, Command command)
 {
     obj.Use();
     ResponseManager.Instance.UsedAirlock(WhoAmI.ToString() + '>', command.ReceiverID.ToString());
 }