private static bool CheckRelatedListExists(string relatedModuleName, JArray modulerelatedListJA, CommonAPIHandler commonAPIHandler) { foreach (JObject relatedListJO in modulerelatedListJA) { if (relatedListJO.ContainsKey(Constants.API_NAME) && relatedListJO.GetValue(Constants.API_NAME) != null && relatedListJO.GetValue(Constants.API_NAME).ToString().Equals(relatedModuleName, StringComparison.OrdinalIgnoreCase)) { if (relatedListJO[Constants.HREF].Equals(Constants.NULL_VALUE)) { throw new SDKException(Constants.UNSUPPORTED_IN_API, commonAPIHandler.HttpMethod + " " + commonAPIHandler.APIPath + Constants.UNSUPPORTED_IN_API_MESSAGE); } if (relatedListJO.ContainsKey(Constants.MODULE) && !string.IsNullOrEmpty(relatedListJO[Constants.MODULE].ToString())) { commonAPIHandler.ModuleAPIName = (string)relatedListJO[Constants.MODULE]; GetFieldsInfo((string)relatedListJO[Constants.MODULE]); } return(true); } } return(false); }
public XMLConverter(CommonAPIHandler commonAPIHandler) : base(commonAPIHandler) { }
public static void GetRelatedLists(string relatedModuleName, string moduleAPIName, CommonAPIHandler commonAPIHandler) { lock (LOCK) { try { bool isNewData = false; string key = (moduleAPIName + Constants.UNDERSCORE + Constants.RELATED_LISTS).ToLower(); string resourcesPath = Initializer.GetInitializer().ResourcePath + Path.DirectorySeparatorChar + Constants.FIELD_DETAILS_DIRECTORY; if (!Directory.Exists(resourcesPath)) { Directory.CreateDirectory(resourcesPath); } string recordFieldDetailsPath = resourcesPath + Path.DirectorySeparatorChar + GetFileName(); if (!System.IO.File.Exists(recordFieldDetailsPath) || (System.IO.File.Exists(recordFieldDetailsPath) && (!Initializer.GetJSON(recordFieldDetailsPath).ContainsKey(key) || (Initializer.GetJSON(recordFieldDetailsPath).GetValue(key) == null || ((JArray)Initializer.GetJSON(recordFieldDetailsPath).GetValue(key)).Count <= 0)))) { isNewData = true; JArray relatedListValues = GetRelatedListDetails(moduleAPIName); JObject recordFieldDetailsJSON1 = System.IO.File.Exists(recordFieldDetailsPath) ? Initializer.GetJSON(recordFieldDetailsPath) : new JObject(); recordFieldDetailsJSON1[key] = relatedListValues; using (StreamWriter sw = System.IO.File.CreateText(recordFieldDetailsPath)) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(sw, recordFieldDetailsJSON1); sw.Flush(); sw.Close(); } } JObject recordFieldDetailsJSON = Initializer.GetJSON(recordFieldDetailsPath); JArray modulerelatedList = (JArray)recordFieldDetailsJSON.GetValue(key); if (!CheckRelatedListExists(relatedModuleName, modulerelatedList, commonAPIHandler) && !isNewData) { recordFieldDetailsJSON.Remove(key); using (StreamWriter sw = System.IO.File.CreateText(recordFieldDetailsPath)) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(sw, recordFieldDetailsJSON); sw.Flush(); sw.Close(); } GetRelatedLists(relatedModuleName, moduleAPIName, commonAPIHandler); } } catch (SDKException e) { throw e; } catch (Exception e) { throw new SDKException(Constants.EXCEPTION, e); } } }
/// <summary> /// Creates a Converter class instance with the CommonAPIHandler class instance. /// </summary> /// <param name="commonAPIHandler">A CommonAPIHandler class instance.</param> public Converter(CommonAPIHandler commonAPIHandler) { this.commonAPIHandler = commonAPIHandler; }
public Downloader(CommonAPIHandler commonAPIHandler) : base(commonAPIHandler) { }
public FormDataConverter(CommonAPIHandler commonAPIHandler) : base(commonAPIHandler) { }
public JSONConverter(CommonAPIHandler commonAPIHandler) : base(commonAPIHandler) { }