Esempio n. 1
0
        /**m* SpringCardApplication/RtdSmartPoster.GetContentEx
         *
         * SYNOPSIS
         *   public RtdSmartPoster GetContentEx()
         *
         * DESCRIPTION
         *   Constructs a RtdSmartPoster object, using the values of the different fields in the form
         *   and returns this object
         *
         **/
        public RtdSmartPoster GetContentEx()
        {
            RtdSmartPoster smartPoster = new RtdSmartPoster();

            smartPoster.Uri = nfcRtdUriControl1.GetContentEx();

            RtdText t = nfcRtdTextControl1.GetContentEx();

            if (t != null)
            {
                smartPoster.Title.Add(t);
            }

            switch (ACT_Combo.SelectedIndex)
            {
            case 1:                                     /*	do	*/
                smartPoster.Action = new RtdSmartPosterAction(0x00);
                break;

            case 2:                                     /*	save	*/
                smartPoster.Action = new RtdSmartPosterAction(0x01);
                break;

            case 3:                                     /*	open	*/
                smartPoster.Action = new RtdSmartPosterAction(0x02);
                break;

            default:
                break;
            }

            if (!SIZE_txt.Text.Equals(""))
            {
                try
                {
                    smartPoster.TargetSize = new RtdSmartPosterTargetSize(Int32.Parse(SIZE_txt.Text));
                }
                catch
                {
                }
            }

            if (!cbMime.Text.Equals(""))
            {
                smartPoster.TargetType = new RtdSmartPosterTargetType(cbMime.Text);
            }

            return(smartPoster);
        }
Esempio n. 2
0
        /**m* SpringCardApplication/RtdSmartPoster.SetContent
         *
         * SYNOPSIS
         *   public void SetContent(RtdSmartPoster smartPoster)
         *
         * DESCRIPTION
         *   Only called by the "public override void SetContent(Ndef ndef)" method, if the ndef is an RtdSmartPoster object.
         *   It prints on the form the content of the RtdSmartPoster object passed as a parameter.
         *
         **/
        public void SetContent(RtdSmartPoster smartPoster)
        {
            ClearContent();

            if (smartPoster.Uri != null)
            {
                nfcRtdUriControl1.SetContent(smartPoster.Uri);
            }
            if ((smartPoster.Title != null) && (smartPoster.Title.Count > 0))
            {
                nfcRtdTextControl1.SetContent(smartPoster.Title[0]);
            }

            if (smartPoster.Action != null)
            {
                switch (smartPoster.Action.Value)
                {
                case 0:
                    ACT_Combo.Text = "Do the action";
                    break;

                case 1:
                    ACT_Combo.Text = "Save for later";
                    break;

                case 2:
                    ACT_Combo.Text = "Open for editing";
                    break;

                default:
                    ACT_Combo.Text = "";
                    break;
                }
            }

            if (smartPoster.TargetType != null)
            {
                cbMime.Text = smartPoster.TargetType.Value;
            }

            if (smartPoster.TargetSize != null)
            {
                SIZE_txt.Text = smartPoster.TargetSize.Value.ToString();
            }
        }
        private void btnAttach_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtStudentMatric.Text.Trim() != _studentData.StudentProfileData.MatricNumber)
                {
                    MessageBox.Show(
                        @"Please request for the Student you wish to Tag. Some modifications have been made to the information retrieved.");
                    return;
                }

                if (_tag == null)
                {
                    MessageBox.Show(
                        @"Lets start over. Close this message and Place a blank Tag");
                    return;
                }

                if (!CheckTagValidity())
                {
                    var dialogResult =
                        MessageBox.Show(
                            @"The Current Tag has some data on it? This operation will totally overwrite it. Should I proceed?",
                            @"Waiting for Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dialogResult != DialogResult.Yes)
                    {
                        return;
                    }
                }

                if (!RemoteTagClean())
                {
                    return;
                }

                var settings =
                    RemoteRequest.Get(
                        $"{DatabaseManager.UpdateSpec.RemoteUrl}ApiStudentManagement/TagStudent?matricNumber={txtStudentMatric.Text.Trim()}&tagId={_tagUID}");

                if (!settings.Result.Status)
                {
                    MessageBox.Show(
                        @"Cannot Write Tag at the moment. Why? " + settings.Result.Message);
                    return;
                }

                var smartPoster = new RtdSmartPoster();
                smartPoster.Title.Add(new RtdText(_studentData.StudentProfileData.MatricNumber, "US"));
                Ndef ndefData = smartPoster;

                using (var localEntities = new LocalEntities())
                {
                    var recordInDb =
                        localEntities.Student_ProfileData.FirstOrDefault(x =>
                                                                         x.MatricNumber == txtStudentMatric.Text.Trim());

                    if (recordInDb != null)
                    {
                        recordInDb.TagId = _tagUID;
                        localEntities.Entry(recordInDb).State = EntityState.Modified;
                        localEntities.SaveChanges();
                    }
                }

                _tag.Content.Clear();
                _tag.Content.Add(ndefData);
                _cardthread = new Thread(() => { card_write_proc(_tag); });
                _cardthread.Start();
            }
            catch (Exception exception)
            {
                ErrorHandler.TreatError(exception);
            }
        }