Exemplo n.º 1
0
        public static Tuple <ManagerConnection, string> TryLogin(LoginCredentials creds, bool saveToFile = true)
        {
            ManagerConnection _ami         = null;
            string            resultString = pabxLogin(creds.host, creds.login.ToString(), creds.password);

            Console.WriteLine(resultString);
            bool result = !resultString.ToLower().Contains("incorrect");

            if (result) // Save credentials if valid
            {
                dynamic resultJson = JObject.Parse(resultString);
                creds.ami_login    = resultJson.username;
                creds.ami_password = resultJson.password;
                Console.WriteLine("Retrieved AMI login Successfully");
                SaveCreds(creds);
                //MessageBox.Show("Host: " + creds.host + " AMI Login : "******" AMI PW: " + creds.ami_password);
                _ami = new ManagerConnection(creds.host, 5038, creds.ami_login, creds.ami_password);
                _ami.Login();
                _ami.UseASyncEvents = true;
            }
            return(new Tuple <ManagerConnection, string>(_ami, (result != false).ToString()));
        }
Exemplo n.º 2
0
        public async static void SaveCreds(LoginCredentials creds)
        {
            string credString = JsonConvert.SerializeObject(creds);

            if (creds.remember == true)
            {
                if (File.Exists("login_details.bbs"))              //If the file exists
                {
                    var auth = await PABXFile <List <LoginCredentials> > .LoadObjectAsync("login_details.bbs");

                    bool exists = false;

                    foreach (LoginCredentials a in auth)
                    {
                        if (a.login == creds.login)
                        {
                            exists = true;
                        }
                    }
                    if (exists == false)        //Only add the login if it doesn't already exist
                    {
                        auth.Add(creds);
                    }

                    List <LoginCredentials> l = new List <LoginCredentials>();
                    foreach (var value in auth.OrderBy(i => i.login)) //Order the list of users numerically
                    {
                        l.Add(value);
                    }

                    PABXFile <List <LoginCredentials> > .SaveObject("login_details.bbs", l);
                }
                else                                                //If the file doesn't exist create it and write everything to it
                {
                    File.WriteAllText("login_details.bbs", BBSEncrypt("[" + credString + "]"));
                }
            }
        }
Exemplo n.º 3
0
        public static string CallStatus(LoginCredentials creds)
        {
            string status = "Unknown";

            return(status);
        }