Пример #1
0
        private void AddItem(Certificate certificate)
        {
            ListViewItem item = new ListViewItem(certificate.Id.ToString());
              item.SubItems.Add(certificate.TypeText);

              if (certificate is VoterCertificate)
              {
            item.SubItems.Add(controller.Status.GetGroupName(((VoterCertificate)certificate).GroupId));
              }
              else if (certificate is AuthorityCertificate)
              {
            item.SubItems.Add(((AuthorityCertificate)certificate).FullName);
              }
              else if (certificate is AdminCertificate)
              {
            item.SubItems.Add(((AdminCertificate)certificate).FullName);
              }
              else if (certificate is NotaryCertificate)
              {
            item.SubItems.Add(((NotaryCertificate)certificate).FullName);
              }
              else
              {
            item.SubItems.Add(string.Empty);
              }

              item.SubItems.Add(certificate.Validate(controller.Status.CertificateStorage).Text());

              DateTime validFrom = certificate.ExpectedValidFrom(controller.Status.CertificateStorage);

              if (validFrom == DateTime.MinValue)
              {
            item.SubItems.Add(Resources.CertificateManagerValidIndefinite);
              }
              else if (validFrom == DateTime.MaxValue)
              {
            item.SubItems.Add(string.Empty);
              }
              else
              {
            item.SubItems.Add(validFrom.ToShortDateString());
              }

              DateTime validUntil = certificate.ExpectedValidUntil(controller.Status.CertificateStorage, DateTime.Now);

              if (validUntil == DateTime.MinValue)
              {
            item.SubItems.Add(string.Empty);
              }
              else if (validUntil == DateTime.MaxValue)
              {
            item.SubItems.Add(Resources.CertificateManagerValidIndefinite);
              }
              else
              {
            item.SubItems.Add(validUntil.ToShortDateString());
              }

              item.Tag = certificate;
              this.certificateList.Items.Add(item);

              this.certificates.Add(certificate, item);
        }
Пример #2
0
        private void UpdateItem(Certificate certificate)
        {
            ListViewItem item = this.certificates[certificate];

              item.SubItems[3].Text = certificate.Validate(controller.Status.CertificateStorage).Text();

              DateTime validFrom = certificate.ExpectedValidFrom(controller.Status.CertificateStorage);

              if (validFrom == DateTime.MinValue)
              {
            item.SubItems[4].Text = Resources.CertificateManagerValidIndefinite;
              }
              else if (validFrom == DateTime.MaxValue)
              {
            item.SubItems[4].Text = string.Empty;
              }
              else
              {
            item.SubItems[4].Text = validFrom.ToShortDateString();
              }

              DateTime validUntil = certificate.ExpectedValidUntil(controller.Status.CertificateStorage, DateTime.Now);

              if (validUntil == DateTime.MinValue)
              {
            item.SubItems[5].Text = string.Empty;
              }
              else if (validUntil == DateTime.MaxValue)
              {
            item.SubItems[5].Text = Resources.CertificateManagerValidIndefinite;
              }
              else
              {
            item.SubItems[5].Text = validUntil.ToShortDateString();
              }
        }