public void GetIssues()
        {
            var request = CreateRequestMock(issuesXml);

            var issues = redmine.GetIssues();

            Assert.AreEqual(1, issues.Length);
            Assert.AreEqual("Parse Redmine API XML", issues[0].Subject);
        }
        public void GetIssues_BaseUriIsNotSet_ThrowsInvalidOperationException()
        {
            redmine = new RedmineService();

            Assert.IsNull(redmine.BaseUri);
            Assert.That(() => redmine.GetIssues(), Throws.InstanceOf <InvalidOperationException>());
        }
Esempio n. 3
0
        public async void init()
        {
            var sv = new RedmineService();

            sv.ApiKey  = "7ee40c509bc59555251e2fd757f2e4a6e816989f";
            sv.BaseUrl = "http://openccpm.com/redmine/";
            int pid = 10;

            this.items = await sv.GetIssues(pid);
        }
Esempio n. 4
0
        private async void Load()
        {
            var redmineService = new RedmineService(null);
            var response       = await redmineService.GetIssues();

            foreach (var issue in response.issues)
            {
                if (!double.IsNaN(issue.lat))
                {
                    var pushpin = new Pushpin();
                    MapLayer.SetPosition(pushpin, new Location(issue.lat, issue.lng));
                    Map.Children.Add(pushpin);

                    var toolTip = new ToolTip();
                    toolTip.Content = issue.subject;
                    pushpin.ToolTip = toolTip;
                }
            }
        }
Esempio n. 5
0
        private async void LoadIssues()
        {
            var sharedPreferences = GetSharedPreferences("IssueApp", FileCreationMode.Private);
            var key = sharedPreferences.GetString("Key", null);

            if (key == null)
            {
                var editText    = new EditText(this);
                var alertDialog = new AlertDialog.Builder(this);
                alertDialog.SetIcon(Android.Resource.Drawable.IcDialogInfo);
                alertDialog.SetTitle("Redmine認証キー").SetView(editText).SetPositiveButton("OK", async(sender, args) =>
                {
                    var service = new RedmineService(editText.Text);
                    var check   = await service.CheckAsync();
                    if (check)
                    {
                        var preferencesEditor = sharedPreferences.Edit();
                        preferencesEditor.PutString("Key", editText.Text);
                        preferencesEditor.Apply();
                        LoadIssues();
                    }
                    else
                    {
                        LoadIssues();
                    }
                }).SetNegativeButton(Properties.Resources.Host + "を開く", (sender, args) =>
                {
                    var uri    = Uri.Parse(Properties.Resources.Url);
                    var intent = new Intent(Intent.ActionView, uri);
                    StartActivity(intent);
                    LoadIssues();
                }).Show();
                return;
            }

            var progressDialog = new ProgressDialog(this);

            progressDialog.SetMessage("Redmineから読み込み中");
            progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
            progressDialog.SetButton("この表示を消す", (sender, args) => progressDialog.Hide());
            progressDialog.Show();

            var redmineService = new RedmineService(key);
            var response       = await redmineService.GetIssues();

            _issues = response.issues;

            foreach (var issue in _issues)
            {
                if (double.IsNaN(issue.lat))
                {
                    continue;
                }

                var markerOptions = new MarkerOptions();
                markerOptions.SetPosition(new LatLng(issue.lat, issue.lng));
                markerOptions.SetTitle(issue.subject);
                _googleMap.AddMarker(markerOptions);
            }

            UpdateList();

            progressDialog.Hide();

            if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) == Permission.Granted)
            {
                _googleMap.MyLocationEnabled = true;
            }
            else
            {
                RequestPermissions(new[] { Manifest.Permission.AccessFineLocation, Manifest.Permission.AccessCoarseLocation }, 0x01);
            }

            _googleApiClient = new GoogleApiClient.Builder(this)
                               .AddApi(LocationServices.API)
                               .AddConnectionCallbacks(this)
                               .Build();
            await Task.Run(() =>
            {
                _googleApiClient.BlockingConnect();
            });
        }