Пример #1
0
        public void Unigraph_FourSquareTest()
        {
            char[] ab = Utility.EnglishAlphabet();
            Array.Resize(ref ab, ab.Length - 1);
            FourSquare foursquare = new FourSquare(ab);// KeyedEnglishAlphabet("KRYPTOS"));

            cipher    = "";
            clear     = "";
            generated = "";
            for (int i = 0; i < 25; i++)
            {
                foursquare.KeySquare1 = new string(foursquare.ScrambledAlphabet());
                foursquare.KeySquare2 = new string(foursquare.ScrambledAlphabet());

                generated = foursquare.GenerateRandomString();

                cipher = foursquare.Encrypt(generated);
                clear  = foursquare.Decrypt(cipher);

                if (cipher.Length - 1 == generated.Length)
                {
                    clear = clear.Substring(0, clear.Length - 1);
                }

                Assert.AreEqual(generated, clear);
            }
        }
Пример #2
0
        public void DecryptBasicTest()
        {
            FourSquare fs = new FourSquare(
                new Alphabet("ZGPTFOGHMUWDRCNYKEQAXVSBL"),
                new Alphabet("MFNBDCRHSAXYOGVITUEWLQZKP"));
            var encrypted = fs.Decrypt("TIYBFHTIZBSY");

            Assert.AreEqual("ATTACKATDAWN", encrypted);
        }
 private void OnDuplicatesChallenge(FourSquare.DuplicateVenueChallenge dvc)
 {
     OnVenueCreateFailure(null);
 }
        private void FlagThisVenue(FourSquare.VenueProblem problem)
        {
            var venue = DataContext as Model.Venue;
            if (venue == null)
            {
                return;
            }

            string caption;
            switch (problem)
            {
                case FourSquare.VenueProblem.Closed:
                    caption = "Closed place";
                    break;

                case FourSquare.VenueProblem.Duplicate:
                    caption = "Duplicate place";
                    break;

                case FourSquare.VenueProblem.Mislocated:
                    caption = "Mislocated place";
                    break;

                default:
                    caption = "Flag an issue";
                    break;
            }

            // trying to address random flag this venue crashes...
            /*
Invalid cross-thread access.
System.UnauthorizedAccessException
   at MS.Internal.XcpImports.CheckThread()
   at System.Windows.DependencyObject..ctor(UInt32 nativeTypeIndex, IntPtr constructDO)
   at System.Windows.Controls.ContentControl..ctor()
   at System.Windows.Controls.HeaderedContentControl..ctor()
   at JeffWilcox.Controls.WindowBase..ctor()
   at JeffWilcox.Controls.MessageBoxWindow..ctor()
   at JeffWilcox.Controls.MessageBoxWindow.Show(String text, String caption, String leftButton, String rightButton, String checkBoxContent)
   at JeffWilcox.Controls.MessageBoxWindow.Show(String text, String caption, String leftButton, String rightButton)
   at JeffWilcox.Controls.MessageBoxWindow.Show(String text, String caption, MessageBoxButton buttons)
   at JeffWilcox.FourthAndMayor.Views.VenueMore.<>c__DisplayClass8.<FlagThisVenue>b__6(Exception ex)
   at JeffWilcox.FourthAndMayor.FourSquare.<>c__DisplayClass22.<FlagVenue>b__21(String str, Exception ex)
   at JeffWilcox.FourthAndMayor.Model.FourSquareServiceRequest.DownloadStringCompleted(Object sender, MyDownloadStringCompletedEventArgs args)
   at JeffWilcox.FourthAndMayor.WebRequestClient.BeginResponse(IAsyncResult ar)
   at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.<InvokeGetResponseCallback>b__8(Object state2)
   at System.Threading.ThreadPool.WorkItem.doWork(Object o)
   at System.Threading.Timer.ring()
             * */
            Dispatcher.BeginInvoke(() =>
            {
                MessageBoxWindow mbw = MessageBoxWindow.Show(
                    "Are you sure you want to report this problem?",
                    caption,
                    "yes, report",
                    "cancel");

                // TODO: 500ms of global loading for this type of action!

                mbw.LeftButtonClick += (x, xe) =>
                {
                    FourSquare.Instance.FlagVenue(venue.VenueId, problem,
                        () =>
                        {
                            Dispatcher.BeginInvoke(() => NavigationService.GoBackWhenReady());

                            Dispatcher.BeginInvoke(() =>
                            {
                                MessageBoxWindow.Show(
                                    "Thanks for reporting this issue. The foursquare moderators and super users will handle it from here.",
                                    null,
                                    MessageBoxButton.OK);
                            });
                        },
                        (ex) =>
                        {
                            Dispatcher.BeginInvoke(() => NavigationService.GoBackWhenReady());

                            Dispatcher.BeginInvoke(() =>
                            {
                                MessageBoxWindow.Show(
                                    "There was trouble reporting the issue. There could be a foursquare server issue. Can you try again later please?",
                                    null,
                                    MessageBoxButton.OK);
                            }); // fixed a crash.
                        });
                };
            });
        }
Пример #5
0
        public void OnDuplicatesChallenge(FourSquare.DuplicateVenueChallenge challenge)
        {
            // This set of pages will definitely be a little buggy because for
            // now it doesn't support tombstoning.

            CurrentChallenge = challenge;
            PriorityQueue.AddUiWorkItem(() =>
                {
                    NavigationService.RemoveBackEntry(); // the add page. NOT this page which will next be removed..
                    NavigationService.Navigate(new Uri("/JeffWilcox.FourthAndMayor.Place;component/AddVenueDuplicates.xaml", UriKind.Relative));
                });
        }