Ejemplo n.º 1
0
        public async static Task <IEnumerable <SegmentModel> > LoadSegments(APIConnection api, FileIdentifier identifier)
        {
            var parser = new VTTFormat();

            using (var ms = new MemoryStream())
            {
                IEnumerable <SegmentModel> segments = null;

                await api.File.DownloadAsync(identifier, async (stream, cancel) =>
                {
                    var items = await parser.ParseStreamAsync(stream);

                    segments = items.Select(i => {
                        var text = i.Lines != null ? string.Join('\n', i.Lines) : string.Empty;
                        return(new SegmentModel
                        {
                            StartTime = (int)i.StartTime.TotalMilliseconds,
                            EndTime = (int)i.EndTime.TotalMilliseconds,
                            Text = text,
                            TextOriginal = text
                        });
                    });
                });

                return(segments);
            }
        }
Ejemplo n.º 2
0
        public async static Task <String> GetCoachID()
        {
            String result = String.Empty;
            String userID = await GetUserId();

            result = await SecureStorage.GetAsync("CoachID");

            if (result == null)
            {
                var findCoach = await APIConnection.findCoaches();

                if (findCoach.Errors == null)
                {
                    var coachs      = new ObservableCollection <Coach>(findCoach.Data.FindCoaches);
                    var targetCoach = coachs.Where(x => x.User.Id.Equals(userID)).FirstOrDefault();
                    if (targetCoach != null)
                    {
                        result = targetCoach.Id;
                        await SecureStorage.SetAsync("CoachID", result);
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        public void APITestChangeSetOpenCloseGet()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                                                "osmsharp", "osmsharp");

            // opens the changeset.
            long changesetId = apiInstance.ChangeSetOpen("A test changeset!");

            // get the changeset.
            ChangeSetInfo simpleChangesetInfo =
                apiInstance.ChangeSetGet(changesetId);

            Assert.IsTrue(simpleChangesetInfo.Open);
            Assert.IsFalse(simpleChangesetInfo.ClosedAt.HasValue);

            // closes the current changeset.
            apiInstance.ChangeSetClose();

            // get the same changeset again!
            simpleChangesetInfo =
                apiInstance.ChangeSetGet(changesetId);
            Assert.IsFalse(simpleChangesetInfo.Open);
            Assert.IsTrue(simpleChangesetInfo.ClosedAt.HasValue);
        }
Ejemplo n.º 4
0
        private async void postButton_Clicked(object sender, EventArgs e)
        {
            var result = await DisplayAlert(ResxFile.msg_confirm, ResxFile.msg_confirmComment, ResxFile.btn_yes, ResxFile.btn_cancel);

            if (result)
            {
                if (!String.IsNullOrEmpty(contentEditor.Text))
                {
                    String commentContent = contentEditor.Text;
                    String userID         = await Constants.GetUserId();

                    String planID = plan.Id;

                    DateTime now = DateTime.Now;
                    now = DateTime.SpecifyKind(now, DateTimeKind.Utc);
                    DateTimeOffset nowOffset = now;

                    var postComment = await APIConnection.commentPlan(userID, planID, nowOffset.ToString(), commentContent);

                    if (postComment.Errors != null)
                    {
                        await DisplayAlert(ResxFile.str_error, postComment.Errors[0].Message, ResxFile.err_confirm);

                        return;
                    }
                    else
                    {
                        await DisplayAlert(ResxFile.msg_Success, ResxFile.msg_postCommentSucc, ResxFile.btn_ok);

                        await Navigation.PopAsync();
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void APITestWayCreateGet()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                                                "osmsharp", "osmsharp");

            // open a changeset.
            long changesetId = apiInstance.ChangeSetOpen("Simple Way Creation Test");

            // initialize the way.
            var way = new Way();

            way.Tags = new SimpleTagsCollection();
            way.Tags.Add("type", "testway");
            way.Nodes   = new List <long>();
            way.Visible = true;

            // initialize the nodes.
            var node = new Node();

            node.Latitude  = -0.494497;
            node.Longitude = -24.119325;
            node.Tags      = new SimpleTagsCollection();
            node.Tags.Add("type", "testnode1");
            node.Visible = true;
            node         = apiInstance.NodeCreate(node);
            way.Nodes.Add(node.Id.Value);
            node           = new Node();
            node.Latitude  = -0.494497 + 0.0001f;
            node.Longitude = -24.119325 + 0.0001f;
            node.Tags      = new SimpleTagsCollection();
            node.Tags.Add("type", "testnode2");
            node.Visible = true;
            node         = apiInstance.NodeCreate(node);
            way.Nodes.Add(node.Id.Value);

            // save the way.
            way = apiInstance.WayCreate(way);

            // close the changeset.
            apiInstance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(way.Id.HasValue);

            // get the new way id.
            long wayId = way.Id.Value;

            // get the way from the api.
            Way wayAPI = apiInstance.WayGet(way.Id.Value);

            Assert.AreEqual(wayId, wayAPI.Id.Value);
            Assert.AreEqual(way.Tags.Count, wayAPI.Tags.Count);
            Assert.AreEqual(way.Visible, wayAPI.Visible);
            Assert.IsTrue(wayAPI.ChangeSetId.HasValue);
            Assert.AreEqual(changesetId, wayAPI.ChangeSetId.Value);
            Assert.AreEqual(way.Nodes[0], wayAPI.Nodes[0]);
            Assert.AreEqual(way.Nodes[1], wayAPI.Nodes[1]);
        }
Ejemplo n.º 6
0
 public ModuleConfigurator(EDiscovery eDiscovery, EArraignment eArraignment, LEOUploadModule leoUpload, APIConnection connection, LogReaderModule logReader)
 {
     this.connection   = connection;
     this.eArraignment = eArraignment;
     this.eDiscovery   = eDiscovery;
     this.leoUpload    = leoUpload;
     this.logReader    = logReader;
 }
Ejemplo n.º 7
0
 public LEOUploadModule(APIConnection connection, APIConnection priveligedConnection, ManagerConfiguration managerConfiguration, MetadataAuditLogStore auditLogStore)
 {
     this.connection           = connection;
     this.managerConfiguration = managerConfiguration;
     // This privieged connection allows us to do things like add a user.
     this.privilegedConnection = priveligedConnection;
     this.auditLogStore        = auditLogStore;
 }
Ejemplo n.º 8
0
 public PublishPage()
 {
     this.user = App.user;
     this.conn = App.conn;
     InitializeComponent();
     entryBody.Text      = "";
     this.BindingContext = GPSFetcher.pvm;
 }
 public void Handle(APIConnection apiConnection, BinaryReader currentPacket)
 {
     this.UserID            = currentPacket.ReadUInt32();
     this.Won               = currentPacket.ReadBoolean();
     this.BigParachutesUsed = currentPacket.ReadInt32();
     this.MissilesUsed      = currentPacket.ReadInt32();
     this.ShildsUsed        = currentPacket.ReadInt32();
 }
Ejemplo n.º 10
0
        public ActionResult Index(int page = 1)
        {
            CharacterList retour = APIConnection.getCharacterList(page);

            retour.page = page;

            return(View(retour));
        }
Ejemplo n.º 11
0
 public LEOUserItemQueryHandler(
     PathService pathService,
     APIConnection connection,
     IAuditLogStore auditLogStore, LEOUploadModule leoUploadModule, ManagerConfiguration managerConfiguration, FileService fileService) : base(pathService, connection, managerConfiguration, fileService)
 {
     this.auditLogStore        = auditLogStore;
     this.LEOUploadModule      = leoUploadModule;
     this.ManagerConfiguration = managerConfiguration;
 }
Ejemplo n.º 12
0
        public async Task LoadDataAsyncTestAsync()
        {
            string apiUrl   = "https://catfact.ninja/fact?max_length=140";
            string response = await APIConnection.LoadDataAsync(apiUrl);

            if (!response.Any())
            {
                Assert.Fail();
            }
        }
        private void GetComments()
        {
            this.comments.Clear();
            List <Comment> data = APIConnection.GetComments(this.post.id);

            foreach (Comment c in data)
            {
                this.comments.Add(c);
            }
        }
Ejemplo n.º 14
0
 public SearchController(
     ILogger <SearchController> logger,
     APIConnection connection,
     SearchService search
     )
 {
     Logger     = logger;
     Connection = connection;
     Search     = search;
 }
Ejemplo n.º 15
0
 public UploadController(
     ILogger <UploadController> logger,
     ModuleConfigurator moduleConfigurator,
     APIConnection connection
     )
 {
     Logger             = logger;
     ModuleConfigurator = moduleConfigurator;
     Connection         = connection;
 }
Ejemplo n.º 16
0
        public EDiscovery(APIConnection connection, APIConnection priveligedConnection, ManagerConfiguration managerConfiguration, MetadataAuditLogStore auditLogStore)
        {
            this.connection           = connection;
            this.managerConfiguration = managerConfiguration;
            // This priveleged connection is used specifically when we're upgrading to the edisc credentials.  We really don't want anything else
            // in the pipeline to be able to use this.  So to be safe we're creating a seperate connection in this case.
            this.privilegedConnection = priveligedConnection;

            this.auditLogStore = auditLogStore;
        }
Ejemplo n.º 17
0
 public LogReaderQueryHandler(
     PathService pathService,
     APIConnection connection,
     ManagerConfiguration managerConfiguration,
     FileService fileService,
     LogReaderService logReaderService
     ) : base(pathService, connection, managerConfiguration, fileService)
 {
     this.ManagerConfiguration = managerConfiguration;
     this.LogReaderService     = logReaderService;
 }
Ejemplo n.º 18
0
        private void TestData()
        {
            list = new List <AddPlantModel>();
            APIConnection connector = new APIConnection();

            list = connector.GetData <List <AddPlantModel> >(APIConnection.Plants);

            adapter                    = new PlantAdapter(this.Activity, list);
            listView.Adapter           = adapter;
            listView.TextFilterEnabled = true;
        }
Ejemplo n.º 19
0
 public JWTAuthController(
     ManagerConfiguration managerConfiguration,
     APIConnection connection,
     SSOJWTAuthentication ssoJWTAuthentication,
     ILogger <JWTAuthController> logger
     )
 {
     ManagerConfiguration = managerConfiguration;
     Connection           = connection;
     SSOJWTAuthentication = ssoJWTAuthentication;
     Logger = logger;
 }
        private void GetPosts()
        {
            ControlActivityIndicator(true);
            posts.Clear();
            List <Post> data = APIConnection.GetPosts();

            foreach (Post p in data)
            {
                this.posts.Add(p);
            }
            ControlActivityIndicator(false);
        }
Ejemplo n.º 21
0
 public LogReaderModule(
     APIConnection connection,
     APIConnection priveligedConnection,
     ManagerConfiguration managerConfiguration,
     LogReaderService logReaderService
     )
 {
     this.connection           = connection;
     this.managerConfiguration = managerConfiguration;
     // This privieged connection allows us to do things like add a user.
     this.privilegedConnection = priveligedConnection;
     this.logReaderService     = logReaderService;
 }
Ejemplo n.º 22
0
        public async Task ParseJSONForPlotTestAsync()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            string apiUrl   = "http://api.coinranking.com/v1/public/coins?base=PLN&timePeriod=7d";
            string response = await APIConnection.LoadDataAsync(apiUrl);

            List <DataPoint> values = JSONParser.ParseJSONForPlot(response);

            if (!values.Any())
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 23
0
        public void APITestNodeCreateGetUpdate()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                                                "osmsharp", "osmsharp");

            // open a changeset.
            apiInstance.ChangeSetOpen("Simple Node Creation Test");

            // initialize the node.
            var node = new Node();

            node.Latitude  = -0.494497;
            node.Longitude = -24.119325;
            node.Tags      = new SimpleTagsCollection();
            node.Tags.Add("type", "testnode");
            node.Visible = true;

            // save the node.
            node = apiInstance.NodeCreate(node);

            // close the changeset.
            apiInstance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(node.Id.HasValue);

            // get the new node id.
            long nodeId = node.Id.Value;

            // open new changeset.
            apiInstance.ChangeSetOpen("Simple Node Update Test");

            // get the node.
            Node apiNode = apiInstance.NodeGet(node.Id.Value);

            apiNode.Tags.Add("another_tag", "test adding a tag!");
            apiInstance.NodeUpdate(apiNode);

            // close the current changeset.
            apiInstance.ChangeSetClose();

            // get the api node.
            apiNode = apiInstance.NodeGet(node.Id.Value);

            Assert.AreEqual(2, apiNode.Tags.Count);
            Assert.IsTrue(apiNode.Tags.ContainsKey("another_tag"));
            Assert.AreEqual("test adding a tag!", apiNode.Tags["another_tag"]);
        }
Ejemplo n.º 24
0
 public PathService(
     APIConnection connection,
     MetadataAuditLogStore auditLogStore,
     ViewSetService viewSetService,
     ModuleConfigurator moduleConfigurator,
     ManagerConfiguration managerConfiguration,
     FileService fileService
     ) : base(connection)
 {
     this.auditLogStore        = auditLogStore;
     this.viewSetService       = viewSetService;
     this.moduleConfigurator   = moduleConfigurator;
     this.ManagerConfiguration = managerConfiguration;
     this.fileService          = fileService;
 }
Ejemplo n.º 25
0
        public void Handle(BaseConnection connection, BinaryReader packet)
        {
            APIConnection api = connection as APIConnection;

            if (api?.PrivateAPIUsable ?? false)
            {
                uint            userId      = packet.ReadUInt32();
                GamePowerupType powerupType = (GamePowerupType)packet.ReadByte();
                int             amount      = packet.ReadInt32();

                FastFoodUser user = api.Hotel.GetUser(userId);
                if (user != null)
                {
                    switch (powerupType)
                    {
                    case GamePowerupType.Missile:
                        user.Missiles = amount;
                        break;

                    case GamePowerupType.Parachute:
                        user.Parachutes = amount;
                        break;

                    case GamePowerupType.Shield:
                        user.Shields = amount;
                        break;
                    }

                    Dictionary <int, int> powerups = new Dictionary <int, int>();
                    if (user.Missiles > 0)
                    {
                        powerups.Add(UserPowerupsOutgoingPacket.Missile, user.Missiles);
                    }

                    if (user.Parachutes > 0)
                    {
                        powerups.Add(UserPowerupsOutgoingPacket.Parachute, user.Parachutes);
                    }

                    if (user.Shields > 0)
                    {
                        powerups.Add(UserPowerupsOutgoingPacket.Shield, user.Shields);
                    }

                    user.GameConnection?.SendPacket(new UserPowerupsOutgoingPacket(powerups));
                }
            }
        }
Ejemplo n.º 26
0
        public async Task ParseJSONTestAsync()
        {
            JSONParser parser   = new JSONParser();
            string     apiUrl   = "https://catfact.ninja/fact?max_length=140";
            string     response = await APIConnection.LoadDataAsync(apiUrl);

            try
            {
                Person result = JSONParser.ParseJSON(response, apiUrl);
            }

            catch (Exception ex)
            {
                Assert.Fail();
            }
        }
        public void Handle(APIConnection apiConnection, BinaryReader currentPacket)
        {
            bool matches = true;

            foreach (byte byte_ in ServerVersionIncomingPacket.MAGIC)
            {
                if (byte_ != currentPacket.ReadByte())
                {
                    matches = false;
                }
            }

            this.MagicMatches = matches;
            this.FullVersion  = currentPacket.ReadString();
            this.Build        = currentPacket.ReadInt16();
        }
Ejemplo n.º 28
0
        public void APITestNodeCreateGetDelete()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                                                "osmsharp", "osmsharp");

            // open a changeset.
            apiInstance.ChangeSetOpen("Simple Node Creation Test");

            // initialize the node.
            var node = new Node();

            node.Latitude  = -0.494497;
            node.Longitude = -24.119325;
            node.Tags      = new SimpleTagsCollection();
            node.Tags.Add("type", "testnode");
            node.Visible = true;

            // save the node.
            node = apiInstance.NodeCreate(node);

            // close the changeset.
            apiInstance.ChangeSetClose();

            // check if the id now has a value.
            Assert.IsTrue(node.Id.HasValue);

            // get the new node id.
            long nodeId = node.Id.Value;

            // get the node again: a node can only be deleted using the correct changesetid and version.
            node = apiInstance.NodeGet(node.Id.Value);

            // open new changeset.
            apiInstance.ChangeSetOpen("Simple Node Delete Test");

            // get the node.
            apiInstance.NodeDelete(node);

            // close the current changeset.
            apiInstance.ChangeSetClose();

            // get the node.
            Node apiNode = apiInstance.NodeGet(node.Id.Value);

            Assert.IsNull(apiNode);
        }
Ejemplo n.º 29
0
        public void APITestDeleteBoundingBox()
        {
            // intialize the connection.
            var apiInstance = new APIConnection("http://api06.dev.openstreetmap.org/",
                                                "osmsharp", "osmsharp");

            // get all objects in the box.
            var box = new GeoCoordinateBox(new GeoCoordinate(-0.494497, -24.119325),
                                           new GeoCoordinate(-0.494497, -24.119325));

            box = box.Resize(0.001f); // create a box around the usual test coordinates.
            List <OsmGeo> boxObjects = apiInstance.BoundingBoxGet(box);

            // delete all objects.
            long changesetId = apiInstance.ChangeSetOpen("delete test objects again");

            foreach (OsmGeo geoObject in boxObjects)
            {
                switch (geoObject.Type)
                {
                case OsmGeoType.Relation:
                    apiInstance.RelationDelete(geoObject as Relation);
                    break;
                }
            }

            foreach (OsmGeo geoObject in boxObjects)
            {
                switch (geoObject.Type)
                {
                case OsmGeoType.Way:
                    apiInstance.WayDelete(geoObject as Way);
                    break;
                }
            }

            foreach (OsmGeo geoObject in boxObjects)
            {
                switch (geoObject.Type)
                {
                case OsmGeoType.Node:
                    apiInstance.NodeDelete(geoObject as Node);
                    break;
                }
            }
        }
Ejemplo n.º 30
0
        public void Handle(BaseConnection connection, BinaryReader packet)
        {
            APIConnection api = connection as APIConnection;

            if (api != null)
            {
                if (!api.PrivateAPIUsable)
                {
                    string key  = packet.ReadString();
                    string sign = packet.ReadString();

                    (api.Hotel = Server.GetGame().GetHotelManager().PrivateAPIAuthenication(key, sign)).APIConnection = api;
                }

                connection.SendPacket(new PrivateAPIAuthenicationResponseOutgoingPacket(api.PrivateAPIUsable));
            }
        }
 public ChampionManager(APIConnection apiConnection, string rawChampionDataDirectory)
 {
     _apiConnection = apiConnection;
     _rawChampionDataDirectory = rawChampionDataDirectory;
 }
 public ItemManager(APIConnection apiConnection, string rawItemDataDirectory)
 {
     _apiConnection = apiConnection;
     _rawItemDataDirectory = rawItemDataDirectory;
 }
 public VersionManager(APIConnection apiConnection)
 {
     _apiConnection = apiConnection;
 }
 public MatchManager(APIConnection apiConnection, string rawMatchDataDirectory)
 {
     _apiConnection = apiConnection;
     _rawMatchDataDirectory = rawMatchDataDirectory;
 }