Beispiel #1
0
        /// <summary>
        /// Called when an account status has been updated.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        internal static void OnAccountStatusUpdated(APIKey apiKey)
        {
            if (Closed)
            {
                return;
            }

            Trace(apiKey.ToString());
            AccountStatusUpdated?.ThreadSafeInvoke(null, EventArgs.Empty);
        }
Beispiel #2
0
        /// <summary>
        /// Called when all characters, exposed throu the API key, 'skill in training' check has been updated.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        internal static void OnCharactersSkillInTrainingUpdated(APIKey apiKey)
        {
            if (Closed)
            {
                return;
            }

            Trace(apiKey.ToString());
            CharactersSkillInTrainingUpdated?.ThreadSafeInvoke(null, EventArgs.Empty);
        }
Beispiel #3
0
        /// <summary>
        /// Called when the character list updated.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        internal static void OnCharacterListUpdated(APIKey apiKey)
        {
            if (Closed)
            {
                return;
            }

            Trace(apiKey.ToString());
            Settings.Save();
            CharacterListUpdated?.ThreadSafeInvoke(null, new APIKeyInfoChangedEventArgs(apiKey));
        }
Beispiel #4
0
        /// <summary>
        /// Called when the API key info updated.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        internal static void OnAPIKeyInfoUpdated(APIKey apiKey)
        {
            if (Closed)
            {
                return;
            }

            Trace(apiKey.ToString());
            Settings.Save();
            APIKeyInfoUpdated?.ThreadSafeInvoke(null, EventArgs.Empty);
        }
Beispiel #5
0
        /// <summary>
        /// Called when an account status has been updated.
        /// </summary>
        /// <param name="apiKey">The API key.</param>
        internal static void OnAccountStatusUpdated(APIKey apiKey)
        {
            if (Closed)
            {
                return;
            }

            Trace(apiKey.ToString());
            EveMonClient.Characters.UpdateAccountStatuses();
            Settings.Save();
            AccountStatusUpdated?.ThreadSafeInvoke(null, EventArgs.Empty);
        }
        public new void ToString()
        {
            // retrieve API key
            File.WriteAllText("test.key", "0");
            APIKey key = new APIKey("test.key");

            key.Load();
            Console.WriteLine("Key: {0}", key.ToString());
            // create Riot URL
            RiotURL url = new RiotURL(key, 1.2, true, "champion?");

            Console.WriteLine("URL: {0}", (string)url);
            Assert.AreEqual(url, "https://na.api.pvp.net/api/lol/static-data/na/" + string.Format("v{0}", APISettings.DEFAULT_API_VER) + "/champion?&api_key=" + key);
            return;
        }
        public void Retrieval()
        {
            // retrieve API key
            string full_path = Path.GetFullPath("key.txt");

            Console.WriteLine("Key Path: {0}", full_path);
            APIKey key = new APIKey("key.txt");

            key.Load();
            Console.WriteLine("Key: {0}", key.ToString());
            // create Riot URL
            RiotURL url = new RiotURL(key, APISettings.DEFAULT_API_VER, true, "champion?");

            Console.WriteLine("URL: {0}", (string)url);
            // create web request
            HttpWebRequest request       = HttpWebRequest.Create((string)url) as HttpWebRequest;
            StreamReader   stream_reader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.UTF8);
            // validate response
            string text = stream_reader.ReadToEnd();

            Console.WriteLine("Response: {0}", text);
            Assert.IsTrue(text.Contains("Tristana"), "Invalid response");
            return;
        }
Beispiel #8
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="key">Valid API key</param>
 /// <param name="api_version">Desired API version</param></para>
 /// <param name="static_data">True if accessing static data, false otherwise</param>
 /// <param name="sub_url">Sub-URL to be appended onto the root URL</param>
 public RiotURL(APIKey key, double api_version, bool static_data, string sub_url)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key", "Invalid API key");
     }
     this.Region  = "na";
     this.BaseURL = RiotURL.URL_ROOT + (static_data ? RiotURL.URL_STATIC : RiotURL.URL_LIVE) +
                    this.Region + "/" + string.Format("v{0}", api_version) + "/" + sub_url + key.ToString(true);
     return;
 }
Beispiel #9
0
        public async Task <IActionResult> UploadFile()
        {
            if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
            {
                return(BadRequest($"Expected a multipart request, but got {Request.ContentType}"));
            }

            var stationFile = await HandleMultipartRequest();

            var          formData = stationFile.formAccumulator.GetResults();
            StringValues filename;
            bool         ok = false;
            //Cuando se envian los audios se envia el APIKey con ese obtener el id y guardar en la base
            //APIKey para autenticar
            StringValues APIKey;
            StringValues Id;

            ok = formData.TryGetValue("APIKey", out APIKey);
            if (!ok)
            {
                return(BadRequest("Expected APIKey key"));
            }

            ok = formData.TryGetValue("Id", out Id);
            if (!ok)
            {
                return(BadRequest("Expected ID key"));
            }

            {
                string strStationId = "";
                int    id;
                var    StationResult = _StationRepository.Get(APIKey.ToString());
                var    stationCount  = _StationRepository.GetStationCount(APIKey);

                if (stationCount != 0)
                {
                    id           = StationResult.Result.Id;
                    strStationId = id.ToString(); //id 1 2 3
                    //string name=StationResult.Result.Name; //name folder with station name

                    //Authentication
                    if (strStationId != Id)
                    {
                        return(BadRequest("Authentication Failed"));
                    }

                    //other parameters
                    ok = formData.TryGetValue("filename", out filename);
                    if (!ok)
                    {
                        return(BadRequest("Expected filename key"));
                    }

                    StringValues recordingDate;
                    ok = formData.TryGetValue("RecordingDate", out recordingDate);
                    if (!ok)
                    {
                        return(BadRequest("Expected RecordingDate key"));
                    }

                    StringValues duration;
                    ok = formData.TryGetValue("Duration", out duration);
                    if (!ok)
                    {
                        return(BadRequest("Expected Duration key"));
                    }

                    StringValues format;
                    ok = formData.TryGetValue("Format", out format);
                    if (!ok)
                    {
                        return(BadRequest("Expected Format key"));
                    }

                    var audio = new Audio();
                    try {
                        audio.RecordingDate = DateTime.ParseExact(recordingDate, "d/M/yyyy HH:mm", CultureInfo.InvariantCulture);
                    }
                    catch (Exception ex)
                    {
                        return(BadRequest("Expected date to be in format 'dd/mm/yyyy hh:mm'"));
                    }
                    audio.ArriveDate = DateTime.Now;
                    audio.StationId  = id;
                    audio.Duration   = duration;
                    audio.Format     = format;
                    audio.LabelList  = new List <String>();
                    await _AudioRepository.Add(audio);

                    var new_audio = await _AudioRepository.GetLastAudio();

                    string strfilename = "" + new_audio.Id + "." + new_audio.Format;

                    var filePath = "";
                    if (strStationId != null)
                    {
                        Core.MakeStationFolder(strStationId);
                        filePath = Path.Combine(Core.StationAudiosFolderPath(strStationId),
                                                strfilename);
                        Console.Write(filePath);
                    }

                    using (var stream = new FileStream(filePath, FileMode.Create)) {
                        await stationFile.memoryStream.CopyToAsync(stream);

                        stationFile.memoryStream.Close();
                    }

                    { // Convert Decompressed File to ogg and add to playlist
                        var process = new Process();
                        process.StartInfo.FileName = "ffmpeg";
                        var fileInfo            = new FileInfo(filePath);
                        var filenameNoExtension = fileInfo.Name.Remove((int)(fileInfo.Name.Length - fileInfo.Extension.Length));
                        // var milliseconds = long.Parse(filenameNoExtension);
                        // var date = DateTimeExtensions.DateTimeFromMilliseconds(milliseconds);
                        // var localDate = date.ToLocalTime();
                        var oggFilename = filenameNoExtension + ".ogg";
                        var oggFilePath = Path.Combine(Core.StationOggFolderPath(strStationId), oggFilename);
                        process.StartInfo.Arguments = "-i " + filePath + " " + oggFilePath;
                        process.Start();
                    }
                }
                else
                {
                    return(Content("Invalid APIKEY"));
                }
            }
            return(Content("File received"));
        }