コード例 #1
0
        private void prepareForm()
        {
            try
            {
                var timeStamp = Globals.GetUnixTimeStamp();
                var hash      = Globals.Hash(Globals.Password + timeStamp);
                var service   = Globals.GetService("Internet", "GetCandidates") as InternetService.IInternetService;

                var electionInstruments = service.GetCandidates(Globals.CurrentElection.ElectionId, Globals.CurrentVoter.IdentityNo, timeStamp, hash);
                if (electionInstruments != null)
                {
                    var parties           = electionInstruments.Parties.ToList();
                    var displayingParties = new List <PartyModel>();
                    foreach (var party in parties)
                    {
                        var partyModel = new PartyModel();
                        partyModel.Party = party;
                        if (electionInstruments.Candidates.Any(x => x.PartyId == party.PartyId))
                        {
                            var candidates = electionInstruments.Candidates.Where(x => x.PartyId == party.PartyId).ToList();
                            partyModel.Candidates = new List <InternetService.VVoterMachineCandidate>();
                            foreach (var candidate in candidates)
                            {
                                partyModel.Candidates.Add(candidate);
                            }
                            displayingParties.Add(partyModel);
                        }
                    }
                    prepareParties(displayingParties);
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #2
0
        private void prepareParty(PartyModel partyModel)
        {
            try
            {
                if (partyModel != null && partyModel.Candidates != null && partyModel.Party != null)
                {
                    byte[] data = partyModel.Party.Image.Bytes.ToArray();

                    MemoryStream strm = new MemoryStream();

                    strm.Write(data, 0, data.Length);

                    strm.Position = 0;

                    var img = System.Drawing.Image.FromStream(strm);

                    BitmapImage bi = new BitmapImage();

                    bi.BeginInit();

                    MemoryStream ms = new MemoryStream();

                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                    ms.Seek(0, SeekOrigin.Begin);

                    bi.StreamSource = ms;

                    bi.EndInit();

                    //imagebox.Source = bi;
                    PartyImage.Source = bi;
                    PartyAcr.Text     = partyModel.Party.PartyAcr;
                    PartyManager.Text = partyModel.Party.Name + " " + partyModel.Party.Surname;
                    PartyName.Text    = partyModel.Party.PartyName;

                    foreach (var candidate in partyModel.Candidates.OrderBy(x => x.OrderNo))
                    {
                        var textblock = new TextBlock();
                        textblock.Padding      = new Thickness(10, 0, 0, 0);
                        textblock.Text         = candidate.OrderNo + ") " + candidate.Name + " " + candidate.Surname;
                        textblock.TextWrapping = TextWrapping.Wrap;
                        partyStackPanel.Children.Add(textblock);
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
コード例 #3
0
        private void prepareForm()
        {
            try
            {
                var timeStamp = Globals.GetUnixTimeStamp();
                var hash = Globals.Hash(Globals.Password + timeStamp);
                var service = Globals.GetService("Internet", "GetCandidates") as InternetService.IInternetService;

                var electionInstruments = service.GetCandidates(Globals.CurrentElection.ElectionId, Globals.CurrentVoter.IdentityNo, timeStamp, hash);
                if (electionInstruments != null)
                {
                    var parties = electionInstruments.Parties.ToList();
                    var displayingParties = new List<PartyModel>();
                    foreach (var party in parties)
                    {
                        var partyModel = new PartyModel();
                        partyModel.Party = party;
                        if (electionInstruments.Candidates.Any(x => x.PartyId == party.PartyId))
                        {
                            var candidates = electionInstruments.Candidates.Where(x => x.PartyId == party.PartyId).ToList();
                            partyModel.Candidates = new List<InternetService.VVoterMachineCandidate>();
                            foreach (var candidate in candidates)
                            {
                                partyModel.Candidates.Add(candidate);
                            }
                            displayingParties.Add(partyModel);
                        }
                    }
                    prepareParties(displayingParties);
                }
            }
            catch (Exception ex)
            {

            }
        }
コード例 #4
0
 public PartyUserControl(PartyModel partyModel)
 {
     InitializeComponent();
     prepareParty(partyModel);
     m_ParyModel = partyModel;
 }