/// <summary> /// This indexer pulls custom fields by name. /// </summary> /// <param name="fieldName">The case insensitive name of the custom field</param> /// <returns>The field value if found or string.Empty if the field is not found /// and an exact match is not required</returns> public string this[string fieldName] { get { string targetName = fieldName.ToLower(); foreach (var field in _fields) { if (Safe.Value(field.DataExtName).ToLower() == targetName) { return(Safe.Value(field.DataExtValue)); } } if (_requireFieldMatch) { throw new Exception( string.Format("A QuickBooks custom field with the name {0} was not found", fieldName)); } return(string.Empty); } }
private void HostQuerySuccess(SDK.IQBBase baseObj) { var respHost = baseObj as SDK.IHostRet; if (respHost == null) { string typeName = "null type"; if (baseObj != null) { typeName = baseObj.Type.GetAsString(); } throw new Exception("1.0 host query failure: unexpected detail type:" + typeName); } var lstVersion = respHost.SupportedQBXMLVersionList; double candidateVersion = 0.0; string versionList = string.Empty; for (int idx = 0; idx < lstVersion.Count; idx++) { string svers = lstVersion.GetAt(idx); if (versionList != string.Empty) { versionList += ", "; } versionList += svers; double dver = 0.0; if (!double.TryParse(svers, NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out dver)) { StatusMgr.LogStatus("Unexpected SDK version:" + svers); continue; } if (dver > candidateVersion && dver <= MAX_DESKTOP_QBXML_VERSION) { candidateVersion = dver; } } if (candidateVersion == 0.0) { StatusMgr.FormatError("No compatible SDK version found, using {0}", MAX_DESKTOP_QBXML_VERSION); candidateVersion = MAX_DESKTOP_QBXML_VERSION; } _SDKMajorVersion = (short)candidateVersion; string minor = (candidateVersion - _SDKMajorVersion).ToString(); if (minor.Length > 1) { minor = minor.Substring(2, minor.Length - 1); _SDKMinorVersion = short.Parse(minor); } else { _SDKMinorVersion = 0; } var successEntry = new StatusEntry() { Summary = "QuickBooks Connection Established", TypeOfEntry = StatusEntry.EntryType.Status }; successEntry.AddLine(string.Format("{0} version {1}.{2}", Safe.Value(respHost.ProductName), Safe.Value(respHost.MajorVersion), Safe.Value(respHost.MinorVersion))); successEntry.AddLine(string.Format("Supported qbXML versions:{0}", versionList)); successEntry.AddLine(string.Format("Using version {0}.{1}", _SDKMajorVersion, _SDKMinorVersion)); StatusMgr.LogEntry(successEntry); }