Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Oxml">Не забуь его заполнить</param>
        public OrganizerXML[] SerializeFileRead()
        {
            bool      PainOfRain = true;
            StartMenu Menu       = new StartMenu();

            if (!Menu.ExistAuthorizationBinaryFile(WinFormsLab.Constants.FileTask_xml))
            {
                Menu.CreateAuthorizationBinaryFile(WinFormsLab.Constants.FileTask_xml);
                PainOfRain = false;
            }
            FileInfo fl = new FileInfo(Constants.FileTask_xml);

            if (fl == null)
            {
                return(null);
            }
            if (!PainOfRain || fl.Length == 0)
            {
                return(null);
            }

            XmlSerializer formatter = new XmlSerializer(typeof(OrganizerXML[]));

            using (FileStream fs1 = new FileStream(Constants.FileTask_xml, FileMode.Open))
            {
                OrganizerXML[] newXML = (OrganizerXML[])formatter.Deserialize(fs1);
                Console.WriteLine("Объект десериализован");
                return(newXML);
            }
        }
Esempio n. 2
0
        public static void Build()
        {
            StartMenu Menu = new StartMenu();

            if (!Menu.ExistAuthorizationBinaryFile(WinFormsLab.Constants.FileAutorizarion_dat))
            {
                Menu.CreateAuthorizationBinaryFile(WinFormsLab.Constants.FileAutorizarion_dat);
            }
        }
Esempio n. 3
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            StructAutorization StructAutorize = new StructAutorization();
            StartMenu          menu           = new StartMenu();

            if (textBoxLogin.Text.Trim(' ').Length == 0 || textBoxPassword.Text.Trim(' ').Length == 0 || menu.CheckNullInString(textBoxLogin.Text) || menu.CheckNullInString(textBoxPassword.Text))
            {
                MessageBox.Show("Wrong login or password!");
            }
            else
            {
                bool tus = false;
                StructAutorize.Login    = textBoxLogin.Text;
                StructAutorize.Password = textBoxPassword.Text;
                StructAutorization[] StructAutorize1 = menu.ReadLoginPasswordAuthorizationBinaryFile(Constants.FileAutorizarion_dat);
                foreach (StructAutorization StrucAuto in StructAutorize1)
                {
                    if (menu.CheckLogin(StrucAuto.Login, StructAutorize.Login) && menu.CheckPassword(StrucAuto.Password, StructAutorize.Password))
                    {
                        //место входа
                        Constants.Name = StructAutorize.Login;
                        Organizer MenuOrganizer = new Organizer(StructAutorize.Login);
                        MenuOrganizer.Show();
                        MessageBox.Show("Добро пожаловать " + StructAutorize.Login, "Вход", MessageBoxButtons.OK);
                        tus = true;
                        textBoxLogin.Text    = "";
                        textBoxPassword.Text = "";
                        break;
                    }
                }

                if (!tus)
                {
                    DialogResult res = MessageBox.Show("Wrong login or password!\r\nСоздать запись?", "Создать запись?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (res == DialogResult.Yes)
                    {
                        for (int i = StructAutorize.Login.Length; i < 32; i++)
                        {
                            StructAutorize.Login += "0";
                        }
                        for (int i = StructAutorize.Password.Length; i < 32; i++)
                        {
                            StructAutorize.Password += "0";
                        }
                        menu.WriteLoginPasswordAuthorizationBinaryFile(WinFormsLab.Constants.FileAutorizarion_dat, StructAutorize);
                        textBoxLogin.Text    = "";
                        textBoxPassword.Text = "";
                    }
                }
            }
        }