Beispiel #1
0
 public void SetTransitionButton(GameObject tb)
 {
     //print("gc: " + tb.name);
     transitionButton    = tb;
     transitionSelection = tb.GetComponentInChildren <SelectionText>();
     tb.SetActive(false);
 }
Beispiel #2
0
        private void GenerateReportedSelectedTextTables(string pageUrl, string pageUrlHash, string selectionText, string selectionTextHash, ReportItEntities rie, SelectionText st, ReportedSelectedText rst)
        {
            if (!string.IsNullOrEmpty(selectionText))
            {
                // Does the pageUrl exist?
                // Does the srcUrl exist?
                // Do they both exist in the ReportedSrcUrls table? They should be it is nice to have a sanity check
                EUReported puRecord = GetPageUrlRecord(rie, pageUrlHash);
                if (puRecord == null)
                {
                    // The page record has never been created
                    // Create Page Record
                    puRecord             = new EUReported();
                    puRecord.Count       = 1;
                    puRecord.PageUrl     = pageUrl;
                    puRecord.PageUrlHash = pageUrlHash;
                    puRecord.Processed   = false;
                    puRecord.CreatedOn   = DateTime.UtcNow;
                    puRecord.UpdatedOn   = DateTime.UtcNow;
                    rie.EUReporteds.Add(puRecord);
                }
                else
                {
                    // The page record has been created - update count
                    puRecord.Count     = puRecord.Count + 1;
                    puRecord.UpdatedOn = DateTime.UtcNow;
                }

                // Ok now check to see if the SrcUrl exists
                st = GetSelectionTextRecord(rie, selectionTextHash);
                if (st == null)
                {
                    // The SrcUrl record has never been created
                    // Create SrcUrl record
                    st                   = new SelectionText();
                    st.Count             = 1;
                    st.Processed         = false;
                    st.SelectionText1    = selectionText;
                    st.SelectionTextHash = selectionTextHash;
                    st.CreatedOn         = DateTime.UtcNow;
                    st.UpdatedOn         = DateTime.UtcNow;
                    rie.SelectionTexts.Add(st);
                }
                else
                {
                    // The srcUrl record has been created - update count
                    st.Count     = st.Count + 1;
                    st.UpdatedOn = DateTime.UtcNow;
                }


                // Ok Now the Sanity Check to make sure that the Many to Many table is correctly populated
                if (!ReportedSelectedTextExists(rie, pageUrlHash, selectionTextHash))
                {
                    rst.PageUrlHash      = pageUrlHash;
                    rst.SelectedTextHash = selectionTextHash;
                    rie.ReportedSelectedTexts.Add(rst);
                }
                rie.SaveChanges();
            }
        }
Beispiel #3
0
        // POST api/Reports
        public void Post([FromBody] string value)
        {
            // Parts received separated by ,
            // PageUrl          -- The Url of the page being reported [0]
            // SrcUrl           -- The SrcUrl of any Image being reported [1]
            // LinkUrl          -- The Url of any link that is being reported [2]
            // SelectionText    -- Any Text that is being reported [3..n]

            try
            {
                if (value != null)
                {
                    // Get the Reported values and Hashes of them
                    string pu          = GetPageUrl(value);
                    string pageUrlHash = GetSHA512(pu);
                    string pageUrl     = Security.Encrypt(pu, pageUrlHash);
                    string srcUrl      = Security.Encrypt(GetSrcUrl(value), pageUrlHash);
                    //string pageUrl = pu;
                    //string srcUrl = GetSrcUrl(value);

                    string srcUrlHash = null;
                    if (!string.IsNullOrEmpty(srcUrl))
                    {
                        srcUrlHash = GetSHA512(srcUrl);
                    }

                    string lulu        = GetLinkUrl(value);
                    string linkUrlHash = null;
                    if (!string.IsNullOrEmpty(lulu))
                    {
                        linkUrlHash = GetSHA512(lulu);
                    }
                    string linkUrl = Security.Encrypt(lulu, linkUrlHash);
                    //string linkUrl = lulu;

                    string stst = GetSelectionText(value);
                    string selectionTextHash = null;
                    if (!string.IsNullOrEmpty(stst))
                    {
                        selectionTextHash = GetSHA512(stst);
                    }
                    string selectionText = Security.Encrypt(stst, selectionTextHash);
                    //string selectionText = stst;

                    ReportItEntities rie = new ReportItEntities();
                    rie.Database.Connection.Open(); // Connect to the Database

                    // Generate our tables
                    EUReported           eur = new EUReported();
                    SrcUrl               su  = new SrcUrl();
                    ReportedSrcUrl       rsu = new ReportedSrcUrl();
                    LinkUrl              lu  = new LinkUrl();
                    ReportedLinkUrl      rlu = new ReportedLinkUrl();
                    SelectionText        st  = new SelectionText();
                    ReportedSelectedText rst = new ReportedSelectedText();


                    if (!string.IsNullOrEmpty(pageUrl))
                    {
                        GenerateReportedSrcsTables(pageUrl, pageUrlHash, srcUrl, srcUrlHash, rie, su, rsu);
                        GenerateReportedLinksTables(pageUrl, pageUrlHash, linkUrl, linkUrlHash, rie, lu, rlu);
                        GenerateReportedSelectedTextTables(pageUrl, pageUrlHash, selectionText, selectionTextHash, rie, st, rst);
                    }
                    else
                    {
                        //Just drop out the bottom -no PageUrl == nothing to process
                    }

                    rie.Database.Connection.Close();
                }
                // return "Nothing received";
            }
            catch (Exception)
            {
                // return ex.InnerException.ToString();
            }
        }
Beispiel #4
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a button to the inputGrid on the dynElement
            _selectButton = new DynamoNodeButton
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center
            };
            _selectButton.Click += selectButton_Click;

            _tb = new TextBlock
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                Background          = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0)),
                TextWrapping        = TextWrapping.Wrap,
                TextTrimming        = TextTrimming.WordEllipsis,
                MaxWidth            = 200,
                MaxHeight           = 100
            };

            if (SelectedElements == null || !SelectedElements.Any() || !SelectionText.Any() || !SelectButtonContent.Any())
            {
                SelectionText       = "Nothing Selected";
                SelectButtonContent = "Select Instances";
            }


            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());
            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());

            nodeUI.inputGrid.Children.Add(_tb);
            nodeUI.inputGrid.Children.Add(_selectButton);

            System.Windows.Controls.Grid.SetRow(_selectButton, 0);
            System.Windows.Controls.Grid.SetRow(_tb, 1);

            _tb.DataContext           = this;
            _selectButton.DataContext = this;

            var selectTextBinding = new System.Windows.Data.Binding("SelectionText")
            {
                Mode = BindingMode.TwoWay,
            };

            _tb.SetBinding(TextBlock.TextProperty, selectTextBinding);

            var buttonTextBinding = new System.Windows.Data.Binding("SelectButtonContent")
            {
                Mode = BindingMode.TwoWay,
            };

            _selectButton.SetBinding(ContentControl.ContentProperty, buttonTextBinding);

            var buttonEnabledBinding = new System.Windows.Data.Binding("CanSelect")
            {
                Mode = BindingMode.TwoWay,
            };

            _selectButton.SetBinding(Button.IsEnabledProperty, buttonEnabledBinding);
        }