Beispiel #1
0
 public bool Equals(HardWareInfo obj)
 {
     return(this.BaseGoardSerialNumber.Equals(obj.BaseGoardSerialNumber) &&
            (this.EndData >= obj.EndData) &&
            this.HDDserialNumber.Equals(HDDserialNumber) &&
            this.ProcessorID.Equals(obj.ProcessorID) &&
            this.ProcessorName.Equals(obj.ProcessorName) &&
            this.VideoControllerId.Equals(obj.VideoControllerId));
 }
Beispiel #2
0
        public Form1()
        {
            InitializeComponent();


            GenerateLicenceFile.Click += (object sender, EventArgs e) =>
            {
                try
                {
                    if (Convert.ToDateTime(EndDate.Text) <= DateTime.Today)
                    {
                        throw new ArgumentException("Дата не может быть меньше текующей!");
                    }
                    ;
                    GetHDDInfo HDDInf = new GetHDDInfo();
                    HDDInf.GetDeviceInfo();
                    GetProcessorInfo ProcessorInf = new GetProcessorInfo();
                    ProcessorInf.GetDeviceInfo();
                    GetVideoControllerInfo VideoControllerInf = new GetVideoControllerInfo();
                    VideoControllerInf.GetDeviceInfo();
                    GetBaseBoardInfo BaseBoardInf = new GetBaseBoardInfo();
                    BaseBoardInf.GetDeviceInfo();
                    HardWareInfo HardWare = new HardWareInfo(HDDInf.hddInfo[0].GetSerialNumber(),
                                                             ProcessorInf.processorInfo[0].GetProcessorName(),
                                                             ProcessorInf.processorInfo[0].GetProcessorID(),
                                                             VideoControllerInf.videoControllers[0].GetDeviceID(),
                                                             BaseBoardInf.baseBoard[0].GetSerialNumber(),
                                                             Convert.ToDateTime(EndDate.Text));

                    BinaryFormatter     formatter = new BinaryFormatter();
                    FolderBrowserDialog Folder    = new FolderBrowserDialog();
                    if (Folder.ShowDialog() == DialogResult.OK)
                    {
                        using (FileStream fs = new FileStream(Path.Combine(Folder.SelectedPath, "hardware.dat"), FileMode.OpenOrCreate))
                        {
                            formatter.Serialize(fs, HardWare);
                        }

                        MessageBox.Show("Файл-лицензия успешно сгенирирован!", "Успешно!", MessageBoxButtons.OK);
                    }
                }catch (ArgumentException ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK);
                }
            };
        }