Ejemplo n.º 1
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(10, 70, 50, 30), "Save"))
     {
         SaveToFile.DumpRenderTexture(m_rt, Application.dataPath + "/../" + Time.frameCount + ".png");
     }
 }
        private void InsertSMSClick()
        {
            if (string.IsNullOrWhiteSpace(TBoxMID) || string.IsNullOrWhiteSpace(TBoxSender) || string.IsNullOrWhiteSpace(TBoxBody))
            {
                MessageBox.Show("Please fill out all boxes please");
                return;
            }

            EmailAdd AddEmail = new EmailAdd();

            {
                AddEmail.MessageID = "E" + TBoxMID;
                AddEmail.Sender    = TBoxSender;
                AddEmail.Subject   = TBoxSubject;
                AddEmail.Body      = TBoxBody;
            }

            ListEmail.Add(AddEmail);

            SaveToFile save = new SaveToFile();

            if (!save.EmailToCSV(ListEmail, MessageType))
            {
                MessageBox.Show("Error while saving\n" + save.ErrorCode);
            }
            else
            {
                save = null;
            }
            MessageBox.Show("Order saved");
        }
        private void InsertSMSClick()
        {
            if (string.IsNullOrWhiteSpace(TBoxMID) || string.IsNullOrWhiteSpace(TBoxSender) || string.IsNullOrWhiteSpace(TBoxBody))
            {
                MessageBox.Show("Please fill out all boxes please");
                return;
            }

            MessageAdd AddMessage = new MessageAdd();

            {
                AddMessage.MessageID = "S" + TBoxMID;
                AddMessage.Sender    = TBoxSender;
                AddMessage.Body      = TBoxBody;
            }

            ListMessage.Add(AddMessage);

            SaveToFile save = new SaveToFile();

            if (!save.WriteToCSV(ListMessage, MessageType))
            {
                MessageBox.Show("Error while saving\n" + save.ErrorCode);
            }
            else
            {
                save = null;
            }
            MessageBox.Show("Order saved");
        }
Ejemplo n.º 4
0
        private void AddButtonClick()
        {
            if (string.IsNullOrWhiteSpace(ItemNameTextBox) || string.IsNullOrWhiteSpace(ItemPriceTextBox))
            {
                MessageBox.Show("Please enter all values");
                return;
            }

            Order order = new Order()
            {
                Name   = ItemNameTextBox,
                Price  = Convert.ToDecimal(ItemPriceTextBox),
                IsPaid = IsPaid
            };

            SaveToFile save = new SaveToFile();

            if (!save.ToCsv(order))
            {
                MessageBox.Show("Error while saving\n" + save.ErrorCode);
            }
            else
            {
                MessageBox.Show("Order Saved");
                save = null;
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var exampleToRun = ExamplesEnumeration.GetFromFile;

            switch (exampleToRun)
            {
            case ExamplesEnumeration.ShowJsonSerialization:
                SimpleJsonSerizalization.ShowJsonSerialization();
                break;

            case ExamplesEnumeration.SerializerOptions:
                SimpleJsonSerizalization.ShowSerializerOptions();
                break;

            case ExamplesEnumeration.CustomAttributes:
                SimpleJsonSerizalization.ShowSerializedAttributes();
                break;

            case ExamplesEnumeration.Deserialize:
                JsonDesirealization.ShowDeserialization();
                break;

            case ExamplesEnumeration.SaveToFile:
                SaveToFile.SaveJsonToFile();
                break;

            case ExamplesEnumeration.GetFromFile:
                SaveToFile.GetFromFile();
                break;
            }

            Console.Read();
        }
Ejemplo n.º 6
0
        public static UserDifficulty SuggestingDifficulty(string userName)
        {
            ToFile         objnew         = SaveToFile.DeserializeLastTest(userName);
            UserDifficulty userDifficulty = UserDifficulty.Easy;

            Console.WriteLine($"Last time you did the test on {objnew.UserDifficulty} level and got {objnew.TotalScore}/{objnew.NumberOfQuestions}");
            double decimalScore = (double)objnew.TotalScore / (double)objnew.NumberOfQuestions;

            if (objnew.UserDifficulty == UserDifficulty.Easy)
            {
                if (decimalScore <= 0.7)
                {
                    Console.WriteLine($"You should stay on Easy difficulty");
                    userDifficulty = UserDifficulty.Easy;
                }
                else
                {
                    Console.WriteLine($"Easy difficulty seems to easy for you💪! You should go up to Normal difficulty");
                    userDifficulty = UserDifficulty.Normal;
                }
            }
            else if (objnew.UserDifficulty == UserDifficulty.Normal)
            {
                if (decimalScore <= 0.3)
                {
                    Console.WriteLine($"Normal difficulty seems to be to hard for you☹️. You should go down to Easy difficulty");
                    userDifficulty = UserDifficulty.Easy;
                }
                else if ((decimalScore > 0.3) && (decimalScore <= 0.7))
                {
                    Console.WriteLine($"You should stay on Normal difficulty");
                    userDifficulty = UserDifficulty.Normal;
                }
                else
                {
                    Console.WriteLine($"Normal difficulty seems to easy for you💪! You should go up to Hard difficulty");
                    userDifficulty = UserDifficulty.Hard;
                }
            }
            else if (objnew.UserDifficulty == UserDifficulty.Hard)
            {
                if (decimalScore <= 0.3)
                {
                    Console.WriteLine($"Hard difficulty seems to hard for you☹️. You should go down to Normal difficulty");
                    userDifficulty = UserDifficulty.Normal;
                }
                else if ((decimalScore > 0.3) && (decimalScore <= 0.8))
                {
                    Console.WriteLine($"You should stay on Hard difficulty");
                    userDifficulty = UserDifficulty.Hard;
                }
                else
                {
                    Console.WriteLine($"You are a maths Genius🥳! Sadly this is the hardest level");
                    userDifficulty = UserDifficulty.Hard;
                }
            }
            return(userDifficulty);
        }
Ejemplo n.º 7
0
 void savePrefs()
 {
     if (SaveToFile.readyToSave)
     {
         SaveToFile.savePrefs();
     }
     KongregateAPIBehaviour.sumbitScore("moneyReached", (int)(getRpMoney(1) / 1000000));
 }
        private void Save(object obj)
        {
            SaveSettings();
            var edi = new ElectronicDataInterchange();

            var save = new SaveToFile();

            save.SaveFile(edi.BuildEdi(patientList.ToList(), insurance, billingProvider));
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            IRepository        repo   = new ContactsRepository();
            ISearchEngine      search = new SearchContacts(repo);
            SaveToFile         saver  = new SaveToFile();
            LoadFromFile       loader = new LoadFromFile();
            ContactsController con    = new ContactsController(repo, loader, saver, search);

            con.ShowMainMenu();
        }
Ejemplo n.º 10
0
 private void OlympicProcess_Load(object sender, EventArgs e)
 {
     ClassLbl.Text = string.Join(" ", Res.ClassNameLbl, AppConstants.CurrentUser.Class);
     UserLbl.Text  = AppConstants.CurrentUser.SimpleName;
     CloseBtn.SmallBtnSetStyle(Res.CloseBtn);
     SaveBtn.SmallBtnSetStyle(Res.SaveBtn);
     FullNameLbl.Text = Res.FullNameLbl;
     SubjectLbl.Text  = string.Empty;
     SaveToFile.SmallBtnSetStyle(Res.SaveToFileLbl);
     SaveToFile.Visible = teach.IsAdmin;
 }
Ejemplo n.º 11
0
        public static void Main(String[] args)
        {
            //TODO switch dodaj,przeczytaj wszystko, pofiltruj po imieniu,zapisz w pliku, przeczytajplik
            AddNewUser          addNewUser   = new AddNewUser();
            ReadAllBook         readAllBook  = new ReadAllBook();
            SaveToFile          saveToFile   = new SaveToFile();
            ReadFromFile        readFromFile = new ReadFromFile();
            PhoneBookOperations operations   = new PhoneBookOperations();
            var    items  = new List <ContactItem>();
            Filter filter = new Filter();

            bool continueLoop = true;

            while (continueLoop)
            {
                Console.WriteLine("enter command Add, readAll, filter, saveToFile, readFromFile, readDatabase End");
                string command = Console.ReadLine().ToUpper();
                switch (command)
                {
                case "ADD":
                    items.Add(operations.Add());
                    break;

                case "READALL":
                    operations.readAll();
                    break;

                case "FILTER":
                    operations.filter(items);
                    break;

                case "SAVETOFILE":
                    operations.saveToFile(items);
                    break;

                case "READFROMFILE":
                    operations.readFromFile();
                    break;

                case "READDATABASE":
                    operations.sqlDataRead();
                    break;

                case "END":
                    Console.WriteLine("end of the program");
                    continueLoop = false;
                    break;

                default:
                    Console.WriteLine("\nentered command doesn't exist!\n");
                    break;
                }
            }
        }
Ejemplo n.º 12
0
        //add all desirialized SMS messages from json file to the list which will be shown on the data grid
        private void ShowSmsButtonClick()
        {
            MessageList.Clear();
            SaveToFile load = new SaveToFile();

            List <Sms> result = load.LoadJsonSms();

            foreach (var item in result)
            {
                MessageList.Add(item);
            }
        }
Ejemplo n.º 13
0
        //add all desirialized Tweet messages from json file to the list which will be shown on the data grid
        private void ShowTwitterButtonClick()
        {
            MessageList.Clear();
            SaveToFile file = new SaveToFile();

            var result = file.LoadJsonTweet();

            foreach (var item in result)
            {
                MessageList.Add(item);
            }
        }
 public void Awake()
 {
     if (!instance)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 15
0
        private void btSave_Click(object sender, EventArgs e)  //кнопка сохранения
        {
            DialogResult result = MessageBox.Show("Вы уверены, что хотите сохранить объекты в файл?", "Сохранение", MessageBoxButtons.YesNo);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                if (SaveToFile.ShowDialog() == DialogResult.OK)
                {
                    writeFile = SaveToFile.FileName;
                    storage.saveToFile(writeFile);
                }
            }
        }
    public void SaveGame()
    {
        SaveToFile save = CreateSaveGameObject();

        BinaryFormatter bf = new BinaryFormatter();

        Directory.CreateDirectory(Application.persistentDataPath + "/saves");
        FileStream file = File.Create(Application.persistentDataPath + "/saves/RankingTable.save");

        bf.Serialize(file, save);
        file.Close();

        Debug.Log("Game Saved");
    }
Ejemplo n.º 17
0
        public static void ScoreDisplay(int numberOfQuestions, Calculation.OperationQuestionScore score, UserDifficulty userDifficulty, string userName)
        {
            if (File.Exists(FileUtils.GetUserFileName(userName)))
            {
                ToFile objnew = SaveToFile.DeserializeLastTest(userName);
                score.TotalEasyQuestion       = objnew.TotalEasyQuestion;
                score.TotalEasyScore          = objnew.TotalEasyScore;
                score.TotalNormalQuestion     = objnew.TotalNormalQuestion;
                score.TotalNormalScore        = objnew.TotalNormalScore;
                score.TotalHardQuestion       = objnew.TotalHardQuestion;
                score.TotalHardScore          = objnew.TotalHardScore;
                score.EasyTests               = objnew.EasyTests;
                score.NormalTests             = objnew.NormalTests;
                score.HardTests               = objnew.HardTests;
                score.TwoPlayerChallengeScore = objnew.TwoPlayerChallengeScore;
                score.AllTimeCorrectAnswers   = objnew.AllTimeCorrectAnswers;
            }

            if (userDifficulty == UserDifficulty.Easy)
            {
                Console.WriteLine($"Addition score: {score.AdditionScore} of {score.AdditionQuestion}");
                Console.WriteLine($"Subtraction score: {score.SubtractionScore} of {score.SubtractionQuestion}");
                Console.WriteLine($"Multiplication score: {score.MultiplicationScore} of {score.MultiplicationQuestion}");
                score.EasyTests++;
                score.TotalEasyQuestion += numberOfQuestions;
                score.TotalEasyScore     = Math.Round((score.TotalEasyScore + (double)(score.TotalScore / (double)numberOfQuestions) * 100) / score.EasyTests, 2);
            }
            else if (userDifficulty == UserDifficulty.Normal)
            {
                Console.WriteLine($"Addition score: {score.AdditionScore} of {score.AdditionQuestion}");
                Console.WriteLine($"Subtraction score: {score.SubtractionScore} of {score.SubtractionQuestion}");
                Console.WriteLine($"Multiplication score: {score.MultiplicationScore} of {score.MultiplicationQuestion}");
                Console.WriteLine($"Division score: {score.DivisionScore} of {score.DivisionQuestion}");
                score.NormalTests++;
                score.TotalNormalQuestion += numberOfQuestions;
                score.TotalNormalScore     = Math.Round((score.TotalNormalScore + (double)(score.TotalScore / (double)numberOfQuestions) * 100) / score.NormalTests, 2);
            }
            else if (userDifficulty == UserDifficulty.Hard)
            {
                Console.WriteLine($"Multipication score: {score.MultiplicationScore} of {score.MultiplicationQuestion}");
                Console.WriteLine($"Division score: {score.DivisionScore} of {score.DivisionQuestion}");
                Console.WriteLine($"Power score: {score.PowerScore} of {score.PowerQuestion}");
                Console.WriteLine($"Squareroot score: {score.SquareRootScore} of {score.SquareRootQuestion}");
                score.HardTests++;
                score.TotalHardQuestion += numberOfQuestions;
                score.TotalHardScore     = Math.Round((score.TotalHardScore + (double)(score.TotalScore / (double)numberOfQuestions) * 100) / score.HardTests, 2);
            }
            score.AllTimeCorrectAnswers += score.TotalScore;
            Console.WriteLine("\n");
        }
    private SaveToFile CreateSaveGameObject()
    {
        SaveToFile save = new SaveToFile();

        foreach (int score in savedScores)
        {
            save.allScores.Add(score);
        }
        foreach (string name in savedNames)
        {
            save.allInitials.Add(name);
        }

        return(save);
    }
Ejemplo n.º 19
0
 private void readBtn_Click(object sender, EventArgs e)
 {
     
     if (opnFileDialog.ShowDialog() == DialogResult.Cancel)
     {
         return;
     }
     else
     {
         nameLstBox.Items.Clear();
         foreach (string s in SaveToFile.Read(opnFileDialog.FileName))
         {
             nameLstBox.Items.Add(s);
         }
     }
 }
        public ActionResult Create([Bind(Include = "Id,Description,CatagoryImage,Name")] Catagory catagory)
        {
            if (ModelState.IsValid)
            {
                SaveToFile s = new SaveToFile()
                {
                    ServerPath = Server.MapPath("~/Images"),
                    Image      = catagory.CatagoryImage
                };
                string fileName = s.SaveToServer();
                catagory.ImageUrl = fileName;
                db.Catagories.Add(catagory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(catagory));
        }
Ejemplo n.º 21
0
 private void saveBtn_Click(object sender, EventArgs e)
 {
     if (opnFileDialog.ShowDialog() == DialogResult.Cancel)
     {
         return;
     }
     else
     {
         if (!String.IsNullOrEmpty(input.Text))
         {
             p.Name = input.Text;
             SaveToFile.Save(opnFileDialog.FileName, p.Name);
         }
         else
         {
             MessageBox.Show("Add your name", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
Ejemplo n.º 22
0
    // Use this for initialization
    void Start()
    {
        rp           = rp / 3;
        area         = area << 3;
        money        = money / 3;
        profitsMulti = profitsMulti / 3;

        InvokeRepeating("savePrefs", 3, 1);
        AudioListener.volume        = 0.5f;
        audioSource                 = GetComponent <AudioSource> ();
        Application.targetFrameRate = 30;
        InvokeRepeating("checkSpeedHack", 0, 3f);
        startMoneyTimer = (System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond);
        StartCoroutine(startGame());
        timer         = Time.realtimeSinceStartup;
        dateTimer     = (System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond);
        rpTxt         = transform.GetChild(2).GetComponentsInChildren <Text> ()[0];
        moneyTxt      = transform.GetChild(2).GetComponentsInChildren <Text> ()[1];
        unlockAreaObj = GameObject.FindGameObjectWithTag("unlockArea");
        unlockAreaObj.SetActive(false);
        areaBgs [0]       = GameObject.FindGameObjectWithTag("areaBg1").GetComponent <Image> ();
        areaBgs [1]       = GameObject.FindGameObjectWithTag("areaBg2").GetComponent <Image> ();
        obstacleImg       = GameObject.FindGameObjectWithTag("obstacle").GetComponent <Image> ();
        areaDropdown      = GetComponentInChildren <Dropdown> ();
        areasUnlocked [0] = true;
        addRp(0);
        addMoney(0);
        StartCoroutine(SaveToFile.fileCheck());
        GameDetails gd = SaveToFile.load();

        if (gd != null)
        {
            gd.load();
        }
        //InvokeRepeating ("save",1,1);
        StartCoroutine(checkMusic());
    }
Ejemplo n.º 23
0
        public void CreateEmployee(string firstName, string lastName, EmployeeType employeeType)
        {
            BaseEmployee employee = null;

            SaveToFile saveToFile = new SaveToFile();

            switch (employeeType)
            {
            case EmployeeType.Employee:
                employee = new Employee(firstName, lastName);
                break;

            case EmployeeType.Head:
                employee = new Head(firstName, lastName);
                break;

            case EmployeeType.Freelanser:
                employee = new Freelancer(firstName, lastName);
                break;

            default: throw new Exception("Ошибка!");
            }
            saveToFile.Save(Settings1.Default.PathToAllEmployees, employee);
        }
    public void LoadGame()
    {
        if (File.Exists(Application.persistentDataPath + "/saves/RankingTable.save")) //If we have a saved file
        {
            savedScores.Clear();
            savedNames.Clear();

            BinaryFormatter bf = new BinaryFormatter();

            FileStream file = File.Open(Application.persistentDataPath + "/saves/RankingTable.save", FileMode.Open);
            SaveToFile save = (SaveToFile)bf.Deserialize(file);
            file.Close();

            for (int i = 0; i < save.allScores.Count; i++)
            {
                savedScores.Add(save.allScores[i]);
                savedNames.Add(save.allInitials[i]);
            }
        }
        else
        {
            Debug.Log("No Save to Load");
        }
    }
Ejemplo n.º 25
0
        private void InsertSMSClick()
        {
            var email   = new EmailAddressAttribute();
            var website = new UrlAttribute();

            if (email.IsValid(TBoxSender))
            {
                string[] Body = TBoxBody.Split(' ');
                foreach (string word in Body)
                {
                    WebCheck = word;
                    if (website.IsValid(word) || word.Contains("www"))
                    {
                        ListAdd Quarantine = new ListAdd();
                        {
                            Quarantine.ListType = word;
                            Quarantine.Count    = "1";
                        }
                        ListType = "Q";
                        ListQuarantine.Add(Quarantine);

                        SaveToList Q = new SaveToList();

                        if (!Q.WriteToCSV(ListQuarantine, ListType))
                        {
                            MessageBox.Show("Error while saving\n" + Q.ErrorCode);
                        }
                        else
                        {
                            Q = null;
                        }

                        WebCheck = WebCheck.Replace(WebCheck, "<URL Quarantined>");
                        MessageBox.Show(WebCheck);
                        for (int x = 0; x < Body.Length; x++)
                        {
                            if (Body[x] == word)
                            {
                                Body[x] = Body[x].Replace(word, WebCheck);
                            }
                        }
                    }
                }
                TBoxBody = string.Join(" ", Body);
                MessageBox.Show(TBoxBody);

                EmailAdd AddEmail = new EmailAdd();
                {
                    AddEmail.MessageID = "E" + TBoxMID;
                    AddEmail.Sender    = TBoxSender;
                    try
                    {
                        AddEmail.Subject = "SIR " + DPickerContent.ToString();
                        check            = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Please Select a date");
                        check = false;
                    }
                    AddEmail.Body = CentreCode + "" + Incident + "" + TBoxBody;
                }

                if (check == true)
                {
                    ListEmail.Add(AddEmail);

                    SaveToFile save = new SaveToFile();

                    if (!save.EmailToCSV(ListEmail, MessageType))
                    {
                        MessageBox.Show("Error while saving\n" + save.ErrorCode);
                    }
                    else
                    {
                        save = null;
                    }

                    ListAdd SIRList = new ListAdd();
                    {
                        SIRList.ListType = AddEmail.Subject;
                        SIRList.Count    = "66-666-99";
                    }

                    ListType = "S";
                    ListSIR.Add(SIRList);

                    SaveToList SIR = new SaveToList();
                    if (!SIR.WriteToCSV(ListSIR, ListType))
                    {
                        MessageBox.Show("Error while saving\n" + SIR.ErrorCode);
                    }
                    else
                    {
                        SIR = null;
                    }
                    MessageBox.Show("Order saved");
                }
            }
            else
            {
                MessageBox.Show("Wrong");
            }
        }
Ejemplo n.º 26
0
            public void StartMethod()
            {
                SaveToFile saveFile   = new SaveToFile();
                string     pathToFile = @"D:\test.txt";
                bool       isqutting  = false;
                string     command;
                string     commandDo;
                string     txt;

                while (isqutting == false)
                {
                    txt = Console.ReadLine();
                    string[] splitInput = txt.Trim().Split(new char[] { ' ' }, 2);
                    command = CleanText(splitInput[0]).ToLower();

                    if (splitInput.Length == 1)
                    {
                        if (command == "showall")
                        {
                            PrintList(OpenFileList(pathToFile));
                        }
                        else if (command == "quit")
                        {
                            isqutting = true;
                        }
                        else if (command == "")
                        {
                            Console.WriteLine("You entered nothing");
                        }
                        else
                        {
                            Console.WriteLine("Need more for this command");
                        }
                    }
                    else
                    {
                        commandDo = CleanText(splitInput[1]);

                        switch (command)
                        {
                        case "addperson":
                            Console.WriteLine("Name was has been added");
                            saveFile.SaveContent(pathToFile, commandDo, command);
                            break;

                        case "deleteperson":
                            bool isDeleted = false;
                            for (int i = 0; i < OpenFileList(pathToFile).Count; i += 1)
                            {
                                if (OpenFileList(pathToFile)[i] == commandDo)
                                {
                                    saveFile.SaveContent(pathToFile, commandDo, command);
                                    Console.WriteLine("Name was has been deleted");
                                    isDeleted = true;
                                    break;
                                }
                            }
                            if (isDeleted == false)
                            {
                                Console.WriteLine("Name is not on the list");
                            }
                            break;

                        case "changeperson":
                            bool matcthes = false;
                            splitInput = commandDo.Trim().Split(new char[] { ' ' }, 2);
                            for (int i = 0; i < OpenFileList(pathToFile).Count; i += 1)
                            {
                                if (OpenFileList(pathToFile)[i] == splitInput[0])
                                {
                                    saveFile.SaveContent(pathToFile, splitInput[0] + " " + splitInput[1], command);
                                    Console.WriteLine("Name has been changed");
                                    matcthes = true;
                                    break;
                                }
                            }
                            if (matcthes == false)
                            {
                                Console.WriteLine("Name is not on the list");
                            }
                            break;

                        case "changeage":
                            saveFile.SaveContent(pathToFile, commandDo, command);
                            break;

                        default:
                            Console.WriteLine("Not a command");
                            break;
                        }
                    }
                }
            }
        // This method contains the functionality to be executed when button is pressed.
        // It ensures all fileds are filled before sending, creates and saves an sms object,
        // and provides meaning of any abbreviations
        private void SendButtonClick()
        {
            // If statement prompts user to fill in all fields before message can be sent, by checking if the
            // component is empty
            if (string.IsNullOrWhiteSpace(HeaderTextBox) || string.IsNullOrWhiteSpace(SenderTextBox) || string.IsNullOrWhiteSpace(BodyTextBox))
            {
                MessageBox.Show("Please Enter All Values");
                return;
            }

            Textspeak(); // Call Textspeak method

            // If statement checks if body contains textspeak abbreviation, if true creates new object and adds
            // textspeak, then saves to json file
            if (saveRegular == true)
            {
                // Create object
                Sms smsMessage = new Sms()
                {
                    Header = HeaderTextBox, // Set header
                    Sender = SenderTextBox, // Set sender
                    Body   = newMessage     // Set body to  textspeak
                };

                SaveToFile save = new SaveToFile(); // Create new instance of SaveToFIle class

                // If cannot be saved display error message, otherwise save file
                if (!save.ToJsonSms(smsMessage))
                {
                    MessageBox.Show("Error While Saving\n" + save.ErrorCode); // Display error code
                }
                else
                {
                    MessageBox.Show("Order Saved"); // Let user know file has been saved
                    save = null;
                }
            }

            // If statement checks if body contains textspeak abbreviation, if false creates new object and saves standard body,
            // then saves to json file
            if (saveRegular == false)
            {
                Sms smsMessage = new Sms()
                {
                    Header = HeaderTextBox, // Set header
                    Sender = SenderTextBox, // Set sender
                    Body   = BodyTextBox    // Set body to standard body text
                };

                SaveToFile save = new SaveToFile(); // Create new instance of SaveToFIle class

                // If cannot be saved display error message, otherwise save file
                if (!save.ToJsonSms(smsMessage))
                {
                    MessageBox.Show("Error While Saving\n" + save.ErrorCode); // Display error code
                }
                else
                {
                    MessageBox.Show("Order Saved"); // Let user know file has been saved
                    save = null;
                }
            }
        }
        // This method contains the functionality to be executed when button is pressed.
        // It ensures all fields are filled before sending, creates and saves an EMail object,
        // Removes and quarantines URL's, and serialises information from certain textboxes
        private void SendButtonClick()
        {
            List <string> CsvLines  = new List <String>(); // Create a list to hold SORT CODE
            List <string> CsvLines2 = new List <String>(); // Create a list to hold combo box values

            // If statement prompts user to fill in all fields before message can be sent, by checking if the
            // component is empty
            if (string.IsNullOrWhiteSpace(HeaderTextBox) || string.IsNullOrWhiteSpace(SenderTextBox) || string.IsNullOrWhiteSpace(SubjectTextBox) ||
                string.IsNullOrWhiteSpace(SortTextBox) || string.IsNullOrWhiteSpace(BodyTextBox))
            {
                MessageBox.Show("Please Enter All Values");
                return;
            }

            // Split up the values held in the sortcode box
            var links = SortTextBox.Split("\t\n ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Where(s => s.StartsWith("0") || s.StartsWith("1") || s.StartsWith("2") || s.StartsWith("3") ||
                                                                                                              s.StartsWith("4") || s.StartsWith("5") || s.StartsWith("6") || s.StartsWith("7") || s.StartsWith("8") || s.StartsWith("9"));

            // Feed sort code values into trends file
            foreach (string s in links)
            {
                CsvLines.Add(s);
                File.AppendAllLines("Data/trends.csv", CsvLines);
            }

            // Feed value fromincident box into trends list
            CsvLines2.Add(IncidentCombo);
            File.AppendAllLines("Data/trends.csv", CsvLines2);

            QuarantineURL(); // Call method which quarantines URL's

            // If statement checks if body contains textspeak abbreviation, if true creates new object and adds
            // textspeak, then saves to json file
            if (saveRegular == true)
            {
                Email emailMessage = new Email()
                {
                    Header   = HeaderTextBox,
                    Sender   = SenderTextBox,
                    Subject  = SubjectTextBox,
                    Incident = IncidentCombo,
                    SortCode = SortTextBox,
                    Body     = QuarantineURL()
                };

                SaveToFile save = new SaveToFile();

                // If cannot be saved display error message, otherwise save file
                if (!save.ToJsonEMail(emailMessage))
                {
                    MessageBox.Show("Error While Saving\n" + save.ErrorCode);
                }
                else
                {
                    MessageBox.Show("Order Saved");
                    save = null;
                }
            }

            // If statement checks if body contains textspeak abbreviation, if false creates new object and saves standard body,
            // then saves to json file
            if (saveRegular == false)
            {
                Email emailMessage = new Email()
                {
                    Header   = HeaderTextBox,
                    Sender   = SenderTextBox,
                    Subject  = SubjectTextBox,
                    Incident = IncidentCombo,
                    Body     = BodyTextBox
                };

                SaveToFile save = new SaveToFile();

                // If cannot be saved display error message, otherwise save file
                if (!save.ToJsonEMail(emailMessage))
                {
                    MessageBox.Show("Error While Saving\n" + save.ErrorCode);
                }
                else
                {
                    MessageBox.Show("Order Saved");
                    save = null;
                }
            }
        }
Ejemplo n.º 29
0
        public static void Main(string[] args)
        {
            var filePath = Path.Combine(AppContext.BaseDirectory, "AccountDetail.gitignore");

            (string userName, int LogInOrSignUp) = UserManager.LogInProcess(filePath);

            OperationQuestionScore score;
            OperationQuestionScore playerTwoScore;

            UserDifficulty userSuggestingDifficulty = UserDifficulty.Easy;

            if (File.Exists(FileUtils.GetUserFileName(userName)))
            {
                userSuggestingDifficulty = SuggestingDifficulty(userName);
            }
            var(userDifficulty, numberOfQuestions, autoDifficultyInput, numberOfSeconds, testOrTwoPlayer) = UserInputs(userName);
            string playerTwoUserName;
            int    playerTwoLogInOrSignUp;

            if (LogInOrSignUp == 1)
            {
                if (autoDifficultyInput == "Y")
                {
                    userDifficulty = userSuggestingDifficulty;
                }
            }

            Console.WriteLine("Get a piece of paper and a pen out, and Lets Start!");
            Console.WriteLine("\n");
            if (testOrTwoPlayer == "T")
            {
                score = RunTest(numberOfQuestions, userDifficulty, numberOfSeconds);

                Console.WriteLine($"Total score: {score.TotalScore} of {numberOfQuestions}");
                ScoreDisplay(numberOfQuestions, score, userDifficulty, userName);
                if (LogInOrSignUp != 3)
                {
                    StatsDisplay(score);
                    SaveToFile.SerializeLastTest(numberOfQuestions, score.TotalScore, userDifficulty, userName, score.TotalEasyQuestion, score.TotalEasyScore, score.TotalNormalQuestion, score.TotalNormalScore, score.TotalHardQuestion, score.TotalHardScore, score.EasyTests, score.NormalTests, score.HardTests, score.TwoPlayerChallengeScore, score.AllTimeCorrectAnswers);
                }
            }
            else if (testOrTwoPlayer == "2")
            {
                Console.WriteLine($"Player 1: {userName}");
                Console.WriteLine($"What is Player 2's name?");
                (playerTwoUserName, playerTwoLogInOrSignUp) = UserManager.LogInProcess(filePath);
                if (File.Exists(FileUtils.GetUserFileName(playerTwoUserName)))
                {
                    SaveToFile.DeserializeLastTest(playerTwoUserName);
                }
                Console.WriteLine($"{userName} will go first!");
                score = RunTest(numberOfQuestions, userDifficulty, numberOfSeconds);
                Console.WriteLine($"{userName} got a score of {score.PlayerOneScore} out of {numberOfQuestions}", false);
                ScoreDisplay(numberOfQuestions, score, userDifficulty, userName);
                Console.WriteLine($"Now it is {playerTwoUserName}'s turn");
                string playerTwoReady;
                do
                {
                    Console.WriteLine($"Are you ready {playerTwoUserName}?");
                    playerTwoReady = Console.ReadLine().ToUpper();
                } while (playerTwoReady != "Y");
                playerTwoScore = RunTest(numberOfQuestions, userDifficulty, numberOfSeconds);
                Console.WriteLine($"{playerTwoUserName} got a score of {playerTwoScore.PlayerTwoScore} out of {numberOfQuestions}", false);
                ScoreDisplay(numberOfQuestions, playerTwoScore, userDifficulty, playerTwoUserName);
                if (score.TotalScore > playerTwoScore.TotalScore)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"{userName} won the challenge!🥳");
                    Console.ResetColor();
                    score.TwoPlayerChallengeScore++;
                }
                else if (score.TotalScore < playerTwoScore.TotalScore)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"{playerTwoUserName} won the challenge!🥳");
                    Console.ResetColor();
                    playerTwoScore.TwoPlayerChallengeScore++;
                }
                else
                {
                    Console.WriteLine("This challenge ended in stalemate");
                }
                if (LogInOrSignUp != 3)
                {
                    SaveToFile.SerializeLastTest(numberOfQuestions, score.TotalScore, userDifficulty, userName, score.TotalEasyQuestion, score.TotalEasyScore, score.TotalNormalQuestion, score.TotalNormalScore, score.TotalHardQuestion, score.TotalHardScore, score.EasyTests, score.NormalTests, score.HardTests, score.TwoPlayerChallengeScore, score.AllTimeCorrectAnswers);
                    StatsDisplay(score);
                }
                if (playerTwoLogInOrSignUp != 3)
                {
                    SaveToFile.SerializeLastTest(numberOfQuestions, playerTwoScore.TotalScore, userDifficulty, playerTwoUserName, playerTwoScore.TotalEasyQuestion, playerTwoScore.TotalEasyScore, playerTwoScore.TotalNormalQuestion, playerTwoScore.TotalNormalScore, playerTwoScore.TotalHardQuestion, playerTwoScore.TotalHardScore, playerTwoScore.EasyTests, playerTwoScore.NormalTests, playerTwoScore.HardTests, playerTwoScore.TwoPlayerChallengeScore, playerTwoScore.AllTimeCorrectAnswers);
                }
            }
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            var parametersValidator = new ParametersValidator();
            var parametersAreValid  = parametersValidator.Validate(args);

            if (parametersAreValid)
            {
                string nameOfFile;
                string numberOfLines;
                string numberOfUniqueIp;
                var    parametersDictionary = CommandLineParser.Parse(args);
                if (parametersDictionary.TryGetValue("nameoffile", out nameOfFile) && parametersDictionary.TryGetValue("numberoflines", out numberOfLines) && parametersDictionary.TryGetValue("numberofuniqueip", out numberOfUniqueIp))
                {
                    var      uniqueIpCount    = Convert.ToInt32(numberOfUniqueIp);
                    var      linesLength      = Convert.ToInt32(numberOfLines);
                    var      configFileReader = new Settings.ConfigFileReader(@"D:\Univercity\Univercity\3курс-лабы\config.yaml");
                    string[] methods          =
                    {
                        "POST",   "LINK", "DELETE", "PUT", "PATCH", "GET", "OPTIONS", "HEAD", "TRACE",
                        "UNLINK", "CONNECT"
                    };
                    string[]  extensions                = { "txt", "pdf", "doc", "exe", "jmp", "cpp", "obj", "iso" };
                    string[]  protocols                 = { "http", "https" };
                    string[]  serverResponseCodes       = { "200", "401", "204", "404", "501" };
                    const int minIntervalInMilliseconds = 100;
                    const int maxIntervalInMilliseconds = 100000;
                    const int minNumberOfFolders        = 3;
                    const int maxNumberOfFolders        = 7;
                    const int minNumberOfCharacters     = 3;
                    const int maxNumberOfCharacters     = 7;
                    const int minSizeOfResponse         = 100;
                    const int maxSizeOfResponse         = 10000;

                    var recordFormat = new RecordFormat
                    {
                        IpIsPresent                 = true,
                        QueryTimeIsPresent          = true,
                        QueryMethodIsPresent        = true,
                        FileNameIsPresent           = true,
                        ExtensionIsPresent          = true,
                        ProtocolIsPresent           = true,
                        ServerResponseCodeIsPresent = true,
                        SizeOfTheResponseIsPresent  = true
                    };
                    var generator = new Generator
                    {
                        Extensions                = extensions,
                        Protocols                 = protocols,
                        Methods                   = methods,
                        Settings                  = configFileReader.Settings,
                        ServerResponseCodes       = serverResponseCodes,
                        MinIntervalInMilliseconds = minIntervalInMilliseconds,
                        MaxIntervalInMilliseconds = maxIntervalInMilliseconds,
                        MinNumberOfCharacters     = minNumberOfCharacters,
                        MaxNumberOfCharacters     = maxNumberOfCharacters,
                        MinNumberOfFolders        = minNumberOfFolders,
                        MaxNumberOfFolders        = maxNumberOfFolders,
                        MinSizeOfResponse         = minSizeOfResponse,
                        MaxSizeOfResponse         = maxSizeOfResponse,
                        NumberOfUniqueIp          = uniqueIpCount
                    };
                    var allRecords = generator.GenerateRecords(linesLength);
                    var rows       = ApacheLogFormat.RecordsToString(allRecords, recordFormat);
                    SaveToFile.SaveRowsToFile(nameOfFile, rows);
                    Console.WriteLine("Save succesed!");
                }
                else
                {
                    Console.WriteLine("Входные параметры не соответствуют шаблону.");
                }
            }
            else
            {
                Console.WriteLine(parametersValidator.ValidationInformation);
            }
            Console.ReadKey();
        }