Example #1
0
        public static string GetCRMLinkError(RestCommand command, int cRMLinkErrorID)
        {
            CRMLinkError cRMLinkError = CRMLinkErrors.GetCRMLinkError(command.LoginUser, cRMLinkErrorID);

            if (cRMLinkError.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(cRMLinkError.GetXml("CRMLinkError", true));
        }
        public void ClearCrmLinkError(string objectId, string objectFieldName, CRMLinkErrors crmErrors)
        {
            CRMLinkError error = crmErrors.FindUnclearedByObjectIDAndFieldName(objectId, objectFieldName);

            if (error != null)
            {
                error.IsCleared    = true;
                error.DateModified = DateTime.UtcNow;
                error.Collection.Save();
            }
        }
        public void WriteToCrmErrorReport(LoginUser loginUser,
                                          string errorMessage,
                                          int organizationId,
                                          string objectId,
                                          string objectType,
                                          string objectFieldName,
                                          string objectData,
                                          string operation,
                                          IntegrationType integration,
                                          string orientation,
                                          CRMLinkErrors crmErrors,
                                          bool logText = false)
        {
            CRMLinkError error = crmErrors.FindUnclearedByObjectIDAndFieldName(objectId, objectFieldName);

            if (error == null)
            {
                CRMLinkErrors newCrmLinkError = new CRMLinkErrors(loginUser);
                error = newCrmLinkError.AddNewCRMLinkError();
                error.OrganizationID  = organizationId;
                error.CRMType         = Enums.GetDescription(integration);
                error.Orientation     = orientation;
                error.ObjectType      = objectType;
                error.ObjectID        = objectId.ToString();
                error.ObjectFieldName = objectFieldName;
                error.ObjectData      = objectData;
                error.Exception       = errorMessage;
                error.OperationType   = operation;
                error.ErrorCount      = 1;
                error.IsCleared       = false;
                error.ErrorMessage    = errorMessage;
                newCrmLinkError.Save();
            }
            else
            {
                error.ErrorCount = error.ErrorCount + 1;
                error.IsCleared  = false;
                error.ObjectData = objectData;
                error.Exception  = errorMessage;
                error.Collection.Save();
            }

            if (logText)
            {
                Write(errorMessage);
            }
        }