Exemplo n.º 1
0
        private void PrepareGrid()
        {
            ActivationManager.Modules.ToList().ForEach(module =>
            {
                var row = serialTable.NewRow();
                row.SetValue <bool>(EF_Serial.Enable, module.Value.Enabled);
                row.SetValue <string>(EF_Serial.Code, module.Value.Code);
                row.SetValue <string>(EF_Serial.ModuleName, module.Value.Name);
                row.SetValue <SerialType>(EF_Serial.SerialType, module.Value.SerialType);
                row.SetValue <DateTime>(EF_Serial.Expiration, module.Value.Expiration);
#if DEBUG
                module.Value.SerialNo = ActivationManager.CreateSerial(txtLicense.Text, txtMac.Text, module.Value.Code, module.Value.SerialType, module.Value.Expiration, txtPenDrive.Text);
#endif
                row.SetValue <string>(EF_Serial.Serial, module.Value.SerialNo);

                serialTable.Rows.Add(row);
            });
        }
Exemplo n.º 2
0
        private bool CheckData()
        {
            var isOK = true;

            serialTable.Rows.Cast <DataRow>().ToList().ForEach(row =>
            {
                if (!isOK)
                {
                    return;
                }

                if (row.GetValue <bool>(EF_Serial.Enable) && row.GetValue <string>(EF_Serial.Serial).IsEmpty())
                {
                    isOK = false;
                    row.SetValue <ActivationState>(EF_Serial.Active, ActivationState.NotActivate);
                    MessageBox.Show(Properties.Resources.Msg_MissingSerialNumber, Properties.Resources.Msg_Attention,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                var code           = row.GetValue <string>(EF_Serial.Code);
                var serialType     = row.GetValue <SerialType>(EF_Serial.SerialType);
                var expirationDate = row.GetValue <DateTime>(EF_Serial.Expiration);

                var serial = ActivationManager.CreateSerial(txtLicense.Text, txtMac.Text, code, serialType, expirationDate, txtPenDrive.Text);
                if (serial != row.GetValue <string>(EF_Serial.Serial))
                {
                    isOK = false;
                    row.SetValue <ActivationState>(EF_Serial.Active, ActivationState.NotActivate);
                    var mess = string.Format(Properties.Resources.Msg_IncorrectSerialNumber, row.GetValue <string>(EF_Serial.ModuleName));
                    MessageBox.Show(mess, Properties.Resources.Msg_Attention,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                var activationState = (row.GetValue <SerialType>(EF_Serial.SerialType) & SerialType.TRIAL) == SerialType.TRIAL
                                        ? ActivationState.Activate | ActivationState.Trial
                                        : ActivationState.Activate;

                row.SetValue <ActivationState>(EF_Serial.Active, activationState);
            });

            return(isOK);
        }