/// <summary>
 /// Returns a list of projections.
 /// </summary>
 /// <returns></returns>
 public List <string> ReadFromDownloadUsagePurposes()
 {
     try
     {
         using (var r = new StreamReader(ApplicationService.GetPurposesFilePath()))
         {
             var json      = r.ReadToEnd();
             var upurposes = JsonConvert.DeserializeObject <List <string> >(json);
             Log.Debug("Read from download usage purpose file");
             r.Close();
             return(upurposes);
         }
     }
     catch (Exception e)
     {
         Log.Error(e, "Read from download usage purpose file");
         return(new List <string>());
     }
 }
        /// <summary>
        /// /// Write list of download usage to file in case registry api won't respond
        /// </summary>
        /// <param name="userPurposes">list of purposes</param>
        public void WriteToUsagePurposeFile(List <string> userPurposes)
        {
            var serializer = new JsonSerializer();

            serializer.Converters.Add(new JavaScriptDateTimeConverter());
            serializer.NullValueHandling = NullValueHandling.Ignore;

            try
            {
                using (var outputFile = new StreamWriter(ApplicationService.GetPurposesFilePath(), false))
                    using (JsonWriter writer = new JsonTextWriter(outputFile))
                    {
                        serializer.Serialize(writer, userPurposes);
                        Log.Debug("Write to download usage purpose file");
                        writer.Close();
                    }
            }
            catch (Exception e)
            {
                Log.Error(e, "Write to download usage purpose file");
            }
        }