Exemplo n.º 1
0
        public static void HandleException(string context, Exception ex)
        {
            var entry = new StatusEntry()
            {
                TypeOfEntry = StatusEntry.EntryType.Error,
                Summary     = context
            };

            for (var currentException = ex;
                 currentException != null;
                 currentException = currentException.InnerException)
            {
                entry.AddLine(currentException.Message);
                entry.AddLine(currentException.StackTrace);
            }

            NotifyListeners(entry);
        }
Exemplo n.º 2
0
        public static void LogQBError(string context, string statusMessage, int statusCode)
        {
            var entry = new StatusEntry()
            {
                TypeOfEntry = StatusEntry.EntryType.Error,
                Summary     = "QuickBooks Error:" + context,
                Details     = statusMessage
            };

            entry.AddLine("Status Code:" + statusCode);

            NotifyListeners(entry);
        }
Exemplo n.º 3
0
        private void HostQueryFail(string statusMsg, int statusCode)
        {
            var entry = new StatusEntry()
            {
                TypeOfEntry = StatusEntry.EntryType.Error,
                Summary     = "Host Query Failed",
                Details     = statusMsg
            };

            entry.AddLine("Status Code:" + statusCode);

            StatusMgr.LogEntry(entry);
        }
Exemplo n.º 4
0
        private void StatusMessage(int idx, string Heading, string StatusMessage, int statusCode, bool IsError)
        {
            StatusEntry.EntryType t = StatusEntry.EntryType.Status;
            if (IsError)
            {
                t = StatusEntry.EntryType.Error;
            }

            var entry = new StatusEntry()
            {
                TypeOfEntry = t,
                Summary     = Heading + "detected for index " + idx,
                Details     = StatusMessage
            };

            entry.AddLine("Status Code:" + statusCode);

            StatusMgr.LogEntry(entry);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        private void HostQueryFail(string statusMsg, int statusCode)
        {
            var entry = new StatusEntry()
            {
                TypeOfEntry = StatusEntry.EntryType.Error,
                Summary = "Host Query Failed",
                Details = statusMsg
            };

            entry.AddLine("Status Code:" + statusCode);

            StatusMgr.LogEntry(entry);
        }
Exemplo n.º 7
0
        public bool Run()
        {
            switch (_msg.RequestList.Count)
            {
            case 0:
                StatusMgr.LogError("No items in batch to process");
                return(false);

            case 1:
                break;

            default:
                if (_iterator != null)
                {
                    StatusMgr.LogError("Iterators are only allowed in single request batches");
                    return(false);
                }
                _msg.Attributes.OnError = SDK.ENRqOnError.roeContinue;
                break;
            }

            try
            {
                bool retVal = false;

                IteratorCall iterCall = null;

                do
                {
                    retVal = RunOneBatch(out iterCall);

                    if (iterCall != null)
                    {
                        if (!iterCall.iterator(iterCall.iteratorId, iterCall.remaining))
                        {
                            return(false); //user cancelled
                        }
                    }
                }while (retVal == true && iterCall != null);

                return(retVal);
            }
            catch (System.Runtime.InteropServices.COMException cex)
            {
                var entry = new StatusEntry()
                {
                    Summary     = "Request Error",
                    TypeOfEntry = StatusEntry.EntryType.Error
                };
                entry.AddLine(cex.Message);

                try
                {
                    //This may not be the source of the error
                    //entry.AddLine(_msg.ToXMLString());

                    //this causes further COM errors
                    //entry.AddLine(_msg.Attributes.ResponseData.ToString());
                    entry.AddLine("Enable SDK logging for further diagnostics");
                }
                catch (Exception)
                {
                }

                StatusMgr.LogEntry(entry);

                return(false);
            }
        }
Exemplo n.º 8
0
        public bool Run()
        {
            switch(_msg.RequestList.Count)
            {
                case 0:
                StatusMgr.LogError("No items in batch to process");
                return false;

                case 1:
                break;

                default:
                if (_iterator != null)
                {
                    StatusMgr.LogError("Iterators are only allowed in single request batches");
                    return false;
                }
                _msg.Attributes.OnError = SDK.ENRqOnError.roeContinue;
                break;
            }

            try
            {
                bool retVal = false;

                IteratorCall iterCall = null;

                do
                {
                    retVal = RunOneBatch(out iterCall);

                    if (iterCall != null)
                    {
                        if (!iterCall.iterator(iterCall.iteratorId, iterCall.remaining))
                        {
                            return false; //user cancelled
                        }
                    }
                }
                while (retVal == true && iterCall != null);

                return retVal;
            }
            catch (System.Runtime.InteropServices.COMException cex)
            {
                var entry = new StatusEntry()
                {
                    Summary = "Request Error",
                    TypeOfEntry = StatusEntry.EntryType.Error
                };
                entry.AddLine(cex.Message);

                try
                {
                    //This may not be the source of the error
                    //entry.AddLine(_msg.ToXMLString());

                    //this causes further COM errors
                    //entry.AddLine(_msg.Attributes.ResponseData.ToString());
                    entry.AddLine("Enable SDK logging for further diagnostics");
                }
                catch (Exception)
                {
                }

                StatusMgr.LogEntry(entry);

                return false;
            }
        }
Exemplo n.º 9
0
        private void StatusMessage(int idx, string Heading, string StatusMessage, int statusCode, bool IsError)
        {
            StatusEntry.EntryType t = StatusEntry.EntryType.Status;
            if(IsError) t = StatusEntry.EntryType.Error;

            var entry = new StatusEntry()
            {
                TypeOfEntry = t,
                Summary = Heading + "detected for index " + idx,
                Details = StatusMessage
            };

            entry.AddLine("Status Code:" + statusCode);

            StatusMgr.LogEntry(entry);
        }
Exemplo n.º 10
0
        public static void LogQBError(string context, string statusMessage, int statusCode)
        {
            var entry = new StatusEntry()
            {
                TypeOfEntry = StatusEntry.EntryType.Error,
                Summary = "QuickBooks Error:" + context,
                Details = statusMessage
            };

            entry.AddLine("Status Code:" + statusCode);

            NotifyListeners(entry);
        }
Exemplo n.º 11
0
        public static void HandleException(string context, Exception ex)
        {
            var entry = new StatusEntry()
            {
                TypeOfEntry = StatusEntry.EntryType.Error,
                Summary = context
            };

            for (var currentException = ex;
                    currentException != null;
                    currentException = currentException.InnerException)
            {
                entry.AddLine(currentException.Message);
                entry.AddLine(currentException.StackTrace);
            }

            NotifyListeners(entry);
        }
Exemplo n.º 12
0
        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);
        }