Example #1
0
    public IEnumerator SearchArticle(string query)
    {
        if (resultsAPI.Length > 0)
        {
            resultsAPI = new ArticleSerializable[0];
        }

        url = GameObject.Find("GlobalManager").GetComponent <GlobalManager> ().url;
        string endPoint = "/forest/v1/articles/?search=";

        UnityWebRequest webRequest = UnityWebRequest.Get(url + endPoint + query);

        yield return(webRequest.Send());

        if (!webRequest.isError)
        {
            ArticleListSerializable articleList = JsonUtility.FromJson <ArticleListSerializable> (
                JSONHelpers.WrapToClass("articles", webRequest.downloadHandler.text)
                );

            resultsAPI = articleList.articles;
        }
        else
        {
            Debug.Log(webRequest.error);
        }
    }
        public object Read(
            object data,
            string masterPassphrase,
            params KeyValuePair <string, string>[] parameters)
        {
            FormatVersionAttribute formatVersion = FormatVersionAttribute.GetAttributeFromType(this.GetType());

            DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information, "Writing Credential from JSON using serialiser '{0}'.", formatVersion);

            JObject       dataJSON               = (JObject)data;
            String        id                     = JSONHelpers.ReadString(dataJSON, "ID");
            String        glyphKey               = JSONHelpers.ReadString(dataJSON, "GlyphKey");
            String        glyphColour            = JSONHelpers.ReadString(dataJSON, "GlyphColour");
            String        name                   = JSONHelpers.ReadString(dataJSON, "Name");
            String        description            = JSONHelpers.ReadString(dataJSON, "Description");
            String        website                = JSONHelpers.ReadString(dataJSON, "Website");
            DateTime      createdAt              = JSONHelpers.ReadDateTime(dataJSON, "CreatedAt");
            DateTime      lastUpdatedAt          = JSONHelpers.ReadDateTime(dataJSON, "LastUpdatedAt");
            DateTime      passwordLastModifiedAt = JSONHelpers.ReadDateTime(dataJSON, "PasswordLastModifiedAt", createdAt);
            String        username               = JSONHelpers.ReadString(dataJSON, "Username");
            String        password               = JSONHelpers.ReadString(dataJSON, "Password");
            JArray        tagsArray              = JSONHelpers.ReadJArray(dataJSON, "Tags", true);;
            List <String> tags                   = new List <String>();

            foreach (JValue curValue in tagsArray)
            {
                tags.Add(curValue.Value <String>());
            }
            String notes = JSONHelpers.ReadString(dataJSON, "Notes");
            List <AuditLogEntry> auditLogEntriesList = new List <AuditLogEntry>();

            if (dataJSON.ContainsKey("AuditLogEntries"))
            {
                ISerialiser auditLogEntrySerialiser = FormatVersions.Instance.GetSerialiser(formatVersion.Version, typeof(AuditLogEntry));
                JArray      auditLogEntries         = JSONHelpers.ReadJArray(dataJSON, "AuditLogEntries", true);
                foreach (JObject curEntry in auditLogEntries)
                {
                    AuditLogEntry entry = (AuditLogEntry)auditLogEntrySerialiser.Read(curEntry, String.Empty);
                    auditLogEntriesList.Add(entry);
                }
                if (auditLogEntriesList.Count > 0)
                {
                    auditLogEntriesList = auditLogEntriesList.OrderByDescending(ale => ale.DateTime).ToList();
                }
            }
            return(new Credential(id,
                                  glyphKey,
                                  glyphColour,
                                  name,
                                  description,
                                  website,
                                  createdAt,
                                  lastUpdatedAt,
                                  passwordLastModifiedAt,
                                  username,
                                  password,
                                  tags.ToArray(),
                                  notes,
                                  auditLogEntriesList.ToArray()));
        }
Example #3
0
        public object Read(
            object data,
            string masterPassphrase,
            params KeyValuePair <string, string>[] parameters)
        {
            FormatVersionAttribute formatVersion = FormatVersionAttribute.GetAttributeFromType(this.GetType());

            DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information, "Reading AuditLogEntry from JSON using serialiser '{0}'.", formatVersion);

            JObject   dataJSON  = (JObject)data;
            EntryType entryType = (EntryType)Enum.Parse(typeof(EntryType), JSONHelpers.ReadString(dataJSON, "TypeOfEntry"), true);
            DateTime  dateTime  = JSONHelpers.ReadDateTime(dataJSON, "DateTime", "HH:mm:ss dd-MM-yyyy");
            Dictionary <String, String> paramsDictionary = new Dictionary <String, String>();
            JObject entyryParams = dataJSON["Parameters"].Value <JObject>();

            foreach (JToken curToken in entyryParams.Children())
            {
                JProperty curProperty = (JProperty)curToken;
                paramsDictionary.Add(curProperty.Name,
                                     curProperty.Value.ToString());
            }
            AuditLogEntry entry = new AuditLogEntry(dateTime,
                                                    entryType,
                                                    paramsDictionary.ToArray());

            return(entry);
        }
Example #4
0
 internal static void LoadCommands()
 {
     if (File.Exists(commandPath))
     {
         myTarget.commandList = JSONHelpers.Deserialize <Command[]>(File.ReadAllText(commandPath));
     }
     else
     {
         Debug.LogError("Command file couldn't be found!");
     }
 }
        public object Read(
            object data,
            string masterPassphrase,
            params KeyValuePair <string, string>[] parameters)
        {
            FormatVersionAttribute formatVersion = FormatVersionAttribute.GetAttributeFromType(this.GetType());

            DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information, "Reading Vault from JSON using serialiser '{0}'.", formatVersion);

            JObject dataJSON = (JObject)data;

            String            id             = JSONHelpers.ReadString(dataJSON, "ID");
            String            name           = JSONHelpers.ReadString(dataJSON, "Name");
            String            description    = JSONHelpers.ReadString(dataJSON, "Description");
            DateTime          createdAt      = JSONHelpers.ReadDateTime(dataJSON, "CreatedAt");
            DateTime          lastUpdatedAt  = JSONHelpers.ReadDateTime(dataJSON, "LastUpdatedAt");
            List <Credential> credentialList = new List <Credential>();

            ISerialiser credentialSerialiser = FormatVersions.Instance.GetSerialiser(formatVersion.Version, typeof(Credential));
            JArray      credentials          = JSONHelpers.ReadJArray(dataJSON, "Credentials", true);

            foreach (JObject curCredential in credentials)
            {
                Credential credential = (Credential)credentialSerialiser.Read(curCredential, String.Empty);
                credentialList.Add(credential);
            }
            List <AuditLogEntry> auditLogEntriesList = new List <AuditLogEntry>();

            if (dataJSON.ContainsKey("AuditLogEntries"))
            {
                ISerialiser auditLogEntrySerialiser = FormatVersions.Instance.GetSerialiser(formatVersion.Version, typeof(AuditLogEntry));
                JArray      auditLogEntries         = JSONHelpers.ReadJArray(dataJSON, "AuditLogEntries", true);
                foreach (JObject curEntry in auditLogEntries)
                {
                    AuditLogEntry entry = (AuditLogEntry)auditLogEntrySerialiser.Read(curEntry, String.Empty);
                    auditLogEntriesList.Add(entry);
                }
                if (auditLogEntriesList.Count > 0)
                {
                    auditLogEntriesList = auditLogEntriesList.OrderByDescending(ale => ale.DateTime).ToList();
                }
            }
            return(new Vault(id,
                             name,
                             description,
                             createdAt,
                             lastUpdatedAt,
                             credentialList.ToArray(),
                             auditLogEntriesList.ToArray()));
        }
Example #6
0
    public IEnumerator GetThematics(string url)
    {
        UnityWebRequest webRequest = UnityWebRequest.Get(url);

        yield return(webRequest.Send());

        if (!webRequest.isError)
        {
            ThematicListSerializable thematicList = JsonUtility.FromJson <ThematicListSerializable> (
                JSONHelpers.WrapToClass("thematics", webRequest.downloadHandler.text)
                );

            thematics = thematicList.thematics;
        }
        else
        {
            Debug.Log(webRequest.error);
        }
    }
Example #7
0
    public IEnumerator GetCategories(string url)
    {
        UnityWebRequest webRequest = UnityWebRequest.Get(url);

        yield return(webRequest.Send());

        if (!webRequest.isError)
        {
            CategoryListSerializable categoryList = JsonUtility.FromJson <CategoryListSerializable> (
                JSONHelpers.WrapToClass("categories", webRequest.downloadHandler.text)
                );

            categories = categoryList.categories;
        }
        else
        {
            Debug.Log(webRequest.error);
        }
    }
Example #8
0
 internal static void UpdateCheck(bool successEnabled = false)
 {
     if (!File.Exists(localVersionFilepath))
     {
         JSONHelpers.SerializeToFile(localVersionFilepath, new LerpedUpdater(), true);
     }
     if (!noConnection)
     {
         try
         {
             WWW www = new WWW("https://raw.githubusercontent.com/Lerp2Dev/Lerp2API/master/Lerp2API.version");
             wh = new WWWHandler();
             wh.Add(www);
             wh.Start <WWW>(false, (x) =>
             {
                 var updater = x.text.Deserialize <LerpedUpdater>();
                 if (updater.versionStr != curVersion)
                 {
                     WarnOutdated(updater.versionStr);
                 }
                 else
                 {
                     if (successEnabled)
                     {
                         Debug.Log("Lerp2API is up-to-date!");
                     }
                 }
             });
         }
         catch (Exception e)
         {
             Debug.LogError("Internet connection couldn't be detected, Updates are disabled!\nMaybe it can be another problem, check the log by clicking this message.\n" + e.Message + "\n" + e.StackTrace);
             noConnection = true;
         }
     }
     else
     {
         CheckForConnection();
     }
 }
Example #9
0
 internal static void SaveCommands()
 {
     JSONHelpers.SerializeToFile(commandPath, myTarget.commandList);
     Debug.Log("Command file saved!");     //Better a dialog, not?
 }
 public ApplicationDbContext(DbContextOptions options) : base(GetOptions(JSONHelpers.ReadJsonStringFromPathFile(appSettingsPath, "DefaultConnection")))
 {
 }