public ActionResult Post(dataJson data)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var contextForEmp = new ContextAR();

                    var newEmpEntry = new Employee
                    {
                        Id      = data.Id,
                        Code    = data.Code,
                        Name    = data.Name,
                        Surname = data.Surname,
                        Title   = data.Title,
                        Sector  = data.Sector,
                        Key     = data.Key
                    };

                    contextForEmp.Add(newEmpEntry);
                    contextForEmp.SaveChanges();

                    return(Content("succes", "text/plain"));
                }
                else
                {
                    return(Content("Bad request", "text/plain"));
                }
            }
            catch (Exception ex)
            {
                return(Content(ex.Message, "text/plain"));
            }
        }
Example #2
0
        private void Settings_Load(object sender, EventArgs e)
        {
            //Setup data for use outside of if statement
            var data = new dataJson();

            //Create Defaults
            data.key = "";

            //Load current data
            if (File.Exists(appDataPath + @"\data.json"))
            {
                var creds = File.ReadAllText(appDataPath + @"\data.json").Split(Convert.ToChar(","));
                try
                {
                    data = JsonConvert.DeserializeObject <dataJson>(EncryptProvider.AESDecrypt(creds[2], creds[0], creds[1]));
                }
                catch
                {
                    File.Delete(appDataPath + @"\data.json");
                }
            }

            //Apply saved data
            textBox1.Text = data.key;
        }
Example #3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            //Setup data varible
            var data = new dataJson();

            //Setup json
            data.key = textBox1.Text;
            var JSON = JsonConvert.SerializeObject(data);

            //Setup keys for encryption
            var creds = EncryptProvider.CreateAesKey();
            var key   = creds.Key;
            var IV    = creds.IV;

            //Encrypt data
            var encrypted = EncryptProvider.AESEncrypt(JSON, key, IV);

            //FInishing touches for encryption
            encrypted = key + "," + IV + "," + encrypted;

            //Write data to file
            File.WriteAllText(appDataPath + @"\data.json", encrypted);

            //Exit
            BypassQuit = true;
            this.Close();
        }
        public ActionResult Put(dataJson data)
        {
            if (ModelState.IsValid)
            {
                var      ContextAR   = new ContextAR();
                Employee empToUpdate = ContextAR.employee.Single(emp => emp.Key == data.Key);

                empToUpdate.Id      = data.Id;
                empToUpdate.Code    = data.Code;
                empToUpdate.Name    = data.Name;
                empToUpdate.Surname = data.Surname;
                empToUpdate.Title   = data.Title;
                empToUpdate.Sector  = data.Sector;

                ContextAR.SaveChanges();

                return(Content("Succes", "text/plain"));
            }
            else
            {
                return(Content("Something went wrong", "text/plain"));
            }
        }
Example #5
0
        public void AddChild(TreeNode pNode, int data, int father, dataJson containt)
        {
            TreeNode nNode = new TreeNode(data, containt);

            if (pNode.Data == father)
            {
                pNode.incrementChild(nNode);
            }
            else
            {
                for (int i = 0; i < pNode.NoChildren; i++)
                {
                    if (pNode.Child[i].Data == father)
                    {
                        pNode.Child[i].incrementChild(nNode);
                    }
                    else
                    {
                        AddChild(pNode.Child[i], data, father, containt);
                    }
                }
            }
        }
Example #6
0
        void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            var id = AccountIndex;

            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.AccountLogonDenied)
                {
                    // if we recieve AccountLogonDenied or one of it's flavors (AccountLogonDeniedNoMailSent, etc)
                    // then the account we're logging into is SteamGuard protected
                    // see sample 5 for how SteamGuard can be handled

                    Console.WriteLine("[Steam] Unable to logon to Steam: This account is SteamGuard protected." + "\n");

                    isRunning = false;
                    return;
                }

                Console.WriteLine("[Steam] Unable to logon to Steam: {0} / {1}" + "\n", callback.Result, callback.ExtendedResult);

                isRunning = false;
                return;
            }

            Console.WriteLine("[Steam] Successfully logged on!" + "\n");

            var data = new dataJson();
            var ID   = steamUser.SteamID;

            // at this point, we'd be able to perform actions on Steam
            if (File.Exists(appDataPath + @"\data.json"))
            {
                string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\SteamAccountGenerator";
                var    creds       = File.ReadAllText(appDataPath + @"\data.json").Split(Convert.ToChar(","));
                data = JsonConvert.DeserializeObject <dataJson>(EncryptProvider.AESDecrypt(creds[2], creds[0], creds[1]));
            }
            else
            {
                MessageBox.Show("Please set your settings\nthis menu will now close", "Error");
                steamUser.LogOff();
                steamClient.Disconnect();
                this.Close();
            }
            Console.WriteLine("[Steam] SteamID: " + ID.ToString() + "\n");
            Console.WriteLine("[Converted] SteamID Converted: " + ID.ConvertToUInt64() + "\n");
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=" + data.key + "&steamids=" + ID.ConvertToUInt64());

            request.AutomaticDecompression = DecompressionMethods.GZip;
            try
            {
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    using (Stream stream = response.GetResponseStream())
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            var html      = reader.ReadToEnd();
                            var responses = JObject.Parse(html);
                            Console.WriteLine("[Steam API] Results:\n   HTML: " + html + "\n   Response: " + responses.ToString() + "\n");
                            try
                            {
                                if ((string)responses["players"][0]["CommunityBanned"].ToString() != "False")
                                {
                                    Console.WriteLine("[BAN] Community banned\n   Returned: " + (string)responses["players"][0]["CommunityBanned"].ToString() + "\n");
                                    account_status.Text      = "BANNED";
                                    account_status.ForeColor = Color.Red;
                                }
                                else
                                {
                                    if (!importing)
                                    {
                                        if ((string)responses["players"][0]["VACBanned"].ToString() != "False")
                                        {
                                            Console.WriteLine("[BAN] VAC Banned\n   Returned: " + (string)responses["players"][0]["VACBanned"].ToString() + "\n");
                                            account_status.Text      = "BANNED";
                                            account_status.ForeColor = Color.Red;
                                        }
                                        else
                                        {
                                            if ((string)responses["players"][0]["NumberOfGameBans"].ToString() != "0")
                                            {
                                                Console.WriteLine("[BAN] Game Banned\n   Returned: " + (string)responses["players"][0]["NumberOfGameBans"].ToString() + "\n");
                                                account_status.Text      = "BANNED";
                                                account_status.ForeColor = Color.Red;
                                            }
                                            else
                                            {
                                                account_status.Text      = "Unbanned";
                                                account_status.ForeColor = Color.Green;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        var banned = false;
                                        if ((string)responses["players"][0]["VACBanned"].ToString() != "False")
                                        {
                                            Console.WriteLine("[BAN] VAC Banned\n   Returned: " + (string)responses["players"][0]["VACBanned"].ToString() + "\n");
                                            account_status.Text      = "BANNED";
                                            account_status.ForeColor = Color.Red;
                                            banned = true;
                                        }
                                        else
                                        {
                                            if ((string)responses["players"][0]["NumberOfGameBans"].ToString() != "0")
                                            {
                                                Console.WriteLine("[BAN] Game Banned\n   Returned: " + (string)responses["players"][0]["NumberOfGameBans"].ToString() + "\n");
                                                account_status.Text      = "BANNED";
                                                account_status.ForeColor = Color.Red;
                                                banned = true;
                                            }
                                            else
                                            {
                                                account_status.Text      = "Unbanned";
                                                account_status.ForeColor = Color.Green;
                                            }
                                        }
                                        if (banned)
                                        {
                                            Console.WriteLine("Listed banned account:\n   " + usernames[id] + ":" + passwords[id] + "\n");
                                            bannedAccs += "\n   " + usernames[id] + ":" + passwords[id];
                                        }
                                        else
                                        {
                                            Console.WriteLine("Listed unbanned account:\n   " + usernames[id] + ":" + passwords[id] + "\n");
                                            unbannedAccs += "\n   " + usernames[id] + ":" + passwords[id];
                                        }
                                    }
                                }
                            }
                            catch (Exception a)
                            {
                                var result = MessageBox.Show("Unexpected error caught\nDid you input the right API key?", "Incorrect API key");
                                if (result == DialogResult.OK)
                                {
                                    parent.ShowSettings();
                                    this.Close();
                                }
                            }
                            Console.WriteLine("[Form] Reenabling next and back buttons, Logging off steam..." + "\n");
                            account_back.BeginInvoke(new MethodInvoker(() =>
                            {
                                account_back.Enabled = true;
                            }));
                            account_next.BeginInvoke(new MethodInvoker(() =>
                            {
                                account_next.Enabled = true;
                            }));
                            steamUser.LogOff();
                        }
            }catch (Exception a)
            {
                if (a.Message == "The remote server returned an error: (403) Forbidden.")
                {
                    Console.WriteLine(a.Message);
                    var result = MessageBox.Show("Unexpected error caught\nDid you input the right API key?", "Incorrect API key");
                    if (result == DialogResult.OK)
                    {
                        parent.ShowSettings();
                        this.Close();
                    }
                }
                else
                {
                    Console.WriteLine("Error Caught, Please open a issue on github!\n" + a.Message);
                    MessageBox.Show(a.Message, "Error Caught");
                }
            }
        }
Example #7
0
 public TreeNode insertRoot(int data, dataJson containt)
 {
     root = new TreeNode(data, containt);
     return(root);
 }