コード例 #1
0
ファイル: MainForm.cs プロジェクト: x-plora/miakro911
        private void lbClients_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            sClient c = lvClients.SelectedItems[0].Tag as sClient;

            if (c.Dongles == null)
            {
                return;
            }
            lvDongles.Items.Clear();
            foreach (sDongle d in c.Dongles)
            {
                ListViewItem lvi = lvDongles.Items.Add(d.Id);
                lvi.SubItems.Add(string.Format("0x{0:8:X}", d.Id));
                lvi.SubItems.Add(c.Organization);
                lvi.SubItems.Add(d.Farms);
                lvi.SubItems.Add(d.StartDate);
                lvi.SubItems.Add(d.EndDate);
                lvi.SubItems.Add(d.Flags);
                lvi.SubItems.Add(d.TimeFlags);
                lvi.SubItems.Add(d.TimeFlagsEnd);
                lvi.Tag = d;
            }
            if (lvDongles.Items.Count == 1)
            {
                lvDongles.Items[0].Selected = true;
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: x-plora/miakro911
        private void btEditKey_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            try
            {
                if (lvDongles.SelectedItems.Count == 0)
                {
                    throw new Exception("Не выбран ключ");
                }
                if (lvClients.SelectedItems.Count == 0)
                {
                    throw new Exception("Не выбран пользователь");
                }

                sClient client = lvClients.SelectedItems[0].Tag as sClient;
                sDongle dongle = lvDongles.SelectedItems[0].Tag as sDongle;
                //GRDVendorKey key = new GRDVendorKey();
                //if (key.ID == 0)
                //throw new Exception("Произошла ошибка подключения к ключу.\nПодробности в логах");

                AddDongleForm dlg = new AddDongleForm(client, dongle, true);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    /*string q;
                     * int retCode = key.GetTRUQuestion(out q);
                     * if (retCode != 0) throw new Exception("Ощибка при генерировании числа-вопроса: " + retCode.ToString());
                     * ResponceItem s = _reqSend.ExecuteMethod(MethodName.VendorUpdateDongle, //MName.VendorSheduleDongle,
                     *  MPN.base64_question, q,
                     *  MPN.orgId, client.Id,
                     *  MPN.farms, dlg.Farms.ToString(),
                     *  MPN.flags, dlg.Flags.ToString(),
                     *  MPN.startDate, (lvDongles.SelectedItems[0].Tag as sDongle).StartDate,
                     *  MPN.endDate, dlg.EndDate.ToString("yyyy-MM-dd"),
                     *  MPN.dongleId, key.ID.ToString());
                     *
                     * retCode = key.SetTRUAnswer(s.Value.ToString());
                     * if (retCode != 0) throw new Exception("Ощибка установки числа ответа: " + retCode.ToString());
                     * MessageBox.Show("Прошивка Завершена");*/
                    ResponceItem s = _reqSend.ExecuteMethod(MethodName.VendorSheduleDongle,
                                                            MPN.orgId, client.Id,
                                                            MPN.farms, dlg.Farms.ToString(),
                                                            MPN.flags, dlg.Flags.ToString(),
                                                            MPN.startDate, (lvDongles.SelectedItems[0].Tag as sDongle).StartDate,
                                                            MPN.endDate, dlg.EndDate.ToString("yyyy-MM-dd"),
                                                            MPN.dongleId, dongle.Id);
                    MessageBox.Show("Отправлено");
                }
                //key.Dispose();
            }
            catch (Exception exc)
            {
                MessageBox.Show(
                    (exc.InnerException != null) ? exc.InnerException.Message : exc.Message,
                    "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            fillUsers();
            this.Enabled = true;
        }
コード例 #3
0
        public AddDongleForm(sClient client, uint dongleId, bool flags)
        {
            InitializeComponent();
            this.Text      += client.Organization;
            _client         = client;
            tbDongleId.Text = dongleId.ToString();
            int i = 0;

            foreach (GRD_Base.FlagType s in Enum.GetValues(typeof(GRD_Base.FlagType)))
            {
                chbFlags.Items.Add(s.ToString());
                chbTimeFlags.Items.Add(s.ToString());
                if (_client.SAAS && s == GRD_Base.FlagType.SAASVersion)
                {
                    _flags += 1 << i;
                    chbFlags.SetItemChecked(i, true);
                }
                i++;
            }

            if (!_client.SAAS)
            {
                const int YEARS = 20;
                nudMonths.Enabled          =
                    dtpStartDate.Enabled   =
                        dtpEndDate.Enabled = false;
                dtpEndDate.Value           = dtpStartDate.Value.AddYears(YEARS);
                nudMonths.Value            = YEARS * 12;
            }

            if (!flags)
            {
                label6.Visible                   =
                    label7.Visible               =
                        chbTimeFlags.Visible     =
                            dtpTimeFlags.Visible = false;
                this.Height -= 170;

                label4.Anchor                         =
                    label3.Anchor                     =
                        label9.Anchor                 =
                            nudMonths.Anchor          =
                                dtpStartDate.Anchor   =
                                    dtpEndDate.Anchor = AnchorStyles.Bottom;

                label2.Visible       =
                    chbFlags.Visible = false;
                this.Height         -= 140;
            }

            _manual = true;
            calcMoney();
        }
コード例 #4
0
        public AddDongleForm(sClient client, sDongle dongle, bool flags)
            : this(client, uint.Parse(dongle.Id), flags)
        {
            _manual = false;
            if (_client.SAAS)
            {
                _from = DateTime.Parse(dongle.EndDate);
            }
            dtpStartDate.Value     = DateTime.Parse(dongle.StartDate);
            dtpEndDate.Value       = DateTime.Parse(dongle.EndDate);
            dtpStartDate.Enabled   = false;
            nudMonths.Enabled      =
                dtpEndDate.Enabled = true;
            nudFarms.Value         = int.Parse(dongle.Farms);

            _manual = true;
        }
コード例 #5
0
 public AddClientForm(sClient client) : this()
 {
     tbAddress.Text = client.Address;
     tbContact.Text = client.ContactMan;
     tbOrgName.Text = client.Organization;
 }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: x-plora/miakro911
        private void btAddKey_Click(object sender, System.EventArgs e)
        {
            GRDVendorKey key = null;

            try
            {
                int retCode = 0;
                if (lvClients.SelectedItems.Count == 0)
                {
                    throw new Exception("Не выбран клиент");
                }

                sClient client = lvClients.SelectedItems[0].Tag as sClient;
                key = new GRDVendorKey();
                if (key.ID == 0)
                {
                    throw new Exception("Произошла ошибка подключения к ключу.\nПодробности в логах");
                }
#if !DEBUG
                foreach (sDongle d in client.Dongles)
                {
                    if (d.Id == key.ID.ToString())
                    {
                        throw new Exception("Данный клиент уже имеет этот ключ");
                    }
                }
#endif
                this.Enabled = false;
                AddDongleForm dlg = new AddDongleForm(client, key.ID, true);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    _reqSend.ExecuteMethod(MethodName.VendorAddDongle,
                                           MPN.dongleId, key.ID.ToString(),
                                           MPN.orgId, client.Id,
                                           MPN.model, key.Model.ToString());

                    retCode = key.SetTRUKey();
                    if (retCode != 0)
                    {
                        throw new Exception("Ощибка при инициализации ключа: " + retCode.ToString());
                    }
                    string q = "";
                    retCode = key.GetTRUQuestion(out q);
                    if (retCode != 0)
                    {
                        throw new Exception("Ощибка при генерировании числа-вопроса: " + retCode.ToString());
                    }

                    ResponceItem s = _reqSend.ExecuteMethod(MethodName.VendorUpdateDongle,
                                                            MPN.base64_question, q,
                                                            MPN.orgId, client.Id,
                                                            MPN.farms, dlg.Farms.ToString(),
                                                            MPN.flags, dlg.Flags.ToString(),
                                                            MPN.startDate, dlg.StartDate.ToString("yyyy-MM-dd"),
                                                            MPN.endDate, dlg.EndDate.ToString("yyyy-MM-dd"),
                                                            MPN.dongleId, key.ID.ToString());
                    string ans = s.Value.ToString();
                    if (ans == "")
                    {
                        throw new Exception("Пустое число-ответ");
                    }
                    key.SetTRUAnswer(ans);
                    MessageBox.Show("Прошивка Завершена");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(
                    (exc.InnerException != null) ? exc.InnerException.Message : exc.Message,
                    "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (key != null)
            {
                key.Dispose();
            }
            this.Enabled = true;
            fillUsers();
        }