Пример #1
0
        /// <summary>
        /// To Create Parts Order Record
        /// </summary>
        /// <param name="partsID">Parent Parts ID</param>
        /// <returns></returns>
        public int CreatePartsOrder(int partsID)
        {
            try
            {
                GenericObject partsOrderObject = new GenericObject();
                partsOrderObject.ObjectType = new RNObjectType
                {
                    Namespace = "CO",
                    TypeName  = "PartsOrder"
                };
                List <GenericField> genericFields = new List <GenericField>();
                genericFields.Add(createGenericField("Parts", createNamedIDDataValue(partsID), DataTypeEnum.NAMED_ID));
                partsOrderObject.GenericFields = genericFields.ToArray();

                ClientInfoHeader hdr = new ClientInfoHeader()
                {
                    AppID = "Create Parts Order"
                };

                RNObject[] resultObj = _rightNowClient.Create(hdr, new RNObject[] { partsOrderObject }, new CreateProcessingOptions {
                    SuppressExternalEvents = false, SuppressRules = false
                });
                if (resultObj != null)
                {
                    return(Convert.ToInt32(resultObj[0].ID.id));
                }
            }
            catch (Exception ex)
            {
                ReportCommandAddIn.form.Hide();
                MessageBox.Show("Exception in creating Parts Order Record: " + ex.Message);
            }
            return(0);
        }
        internal CreateObjectsResponse CreateObjects(RNObject[] objects)
        {
            var result = new List <RNObject>();

            bool mustRetry  = false;    // used to determine if we should retry a failed job
            int  retryTimes = 0;        // we don't want to endlessly retry, so we only will retry 3 times

            do
            {
                try
                {
                    var soapResult = _client.Create(_clientInfoHeader, objects, new CreateProcessingOptions {
                        SuppressExternalEvents = false, SuppressRules = false
                    });
                    if (soapResult.Any())
                    {
                        result = soapResult.ToList();
                    }

                    return(new CreateObjectsResponse
                    {
                        CreatedObjects = result,
                        Successful = true,
                        SuccessfulSet = true
                    });
                }
                catch (Exception ex)
                {
                    GlobalContext.Log(string.Format("Failed Create: Retry {0}: {1}", retryTimes, ex.Message), true);
                    GlobalContext.Log(string.Format("Failed Create: Retry {0}: {1}{2}{3}", retryTimes, ex.Message, Environment.NewLine, ex.StackTrace), false);

                    string innerExMsg = GetInnerExceptionMessage(ex);
                    if (!string.IsNullOrEmpty(innerExMsg))
                    {
                        GlobalContext.Log(string.Format("Failed Create: Retry {0}: InnerException Messages: {1}", retryTimes, innerExMsg), true);
                    }

                    if (retryTimes < 3)
                    {
                        // if we haven't retried 3 times then we retry the load again
                        mustRetry = true;
                        retryTimes++;
                    }
                    else
                    {
                        // don't retry for 3rd retry
                        return(new CreateObjectsResponse
                        {
                            CreatedObjects = null,
                            Successful = false,
                            SuccessfulSet = true,
                            Details = ex.Message
                        });
                    }
                }
                GlobalContext.Log(string.Format("Create Must Retry {0}", mustRetry), false);
            } while (mustRetry);
            GlobalContext.Log("Create End: This code should never be hit.", false);
            return(null);        // this code should never be hit
        }
Пример #3
0
        public RNObject[] createObject(RNObject[] objects)
        {
            //Create the update processiong options
            CreateProcessingOptions options = new CreateProcessingOptions();

            options.SuppressExternalEvents = false;
            options.SuppressRules          = false;


            //Invoke the Update operation
            RNObject[] results = _rnowClient.Create(this._rnowClientInfoHeader, objects, options);
            return(results);
        }
Пример #4
0
    public long CreateContact()
    {
        Contact newContact = Contactinfo();
        //Set the application ID in the client info header
        ClientInfoHeader clientInfoHeader = new ClientInfoHeader();

        clientInfoHeader.AppID = ".NET Getting Started";
        //Set the create processing options, allow external events and rules to execute
        CreateProcessingOptions createProcessingOptions = new CreateProcessingOptions();

        createProcessingOptions.SuppressExternalEvents = false;
        createProcessingOptions.SuppressRules          = false;
        RNObject[] createObjects = new RNObject[] { newContact };
        //Invoke the create operation on the RightNow server
        RNObject[] createResults = _Service.Create(clientInfoHeader, createObjects, createProcessingOptions);
        //We only created a single contact, this will be at index 0 of the results
        newContact = createResults[0] as Contact;
        return(newContact.ID.id);
    }
Пример #5
0
        private RNObject createExtension()
        {
            GenericObject go = new GenericObject();

            //Set the object type
            RNObjectType objType = new RNObjectType();

            objType.Namespace = "SvcVentures";
            objType.TypeName  = "scProductExtension";
            go.ObjectType     = objType;

            List <GenericField> gfs = new List <GenericField>();

            gfs.Add(createGenericField("ExtensionName", ItemsChoiceType.StringValue, this.extName));
            gfs.Add(createGenericField("Signature", ItemsChoiceType.StringValue, this.extSignature));
            gfs.Add(createGenericField("Description", ItemsChoiceType.StringValue, "Not Specified"));
            gfs.Add(createGenericField("Authors", ItemsChoiceType.StringValue, "Not Specified"));
            gfs.Add(createGenericField("ExtConfiguration", ItemsChoiceType.StringValue, DEFAULT_CONFIG));
            go.GenericFields = gfs.ToArray();

            CreateProcessingOptions cpo = new CreateProcessingOptions();

            cpo.SuppressExternalEvents = false;
            cpo.SuppressRules          = false;

            ClientInfoHeader clientInfoHeader = new ClientInfoHeader();

            clientInfoHeader.AppID = "Create Extension";
            RNObject[] results = client.Create(clientInfoHeader, new RNObject[] { go }, cpo);

            // check result and save incident id
            if (results != null && results.Length > 0)
            {
                return(go);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Create Reporting Incident
        /// </summary>
        /// <param name="contactID"></param>
        /// <param name="fsarID"></param>
        /// <param name="orgID"></param>
        /// <returns></returns>
        public int CreateReportingIncident(int contactID, int fsarID, int orgID)
        {
            try
            {
                string response = checkIfReportingIncidentExistforFSAR(fsarID, contactID);
                if (response != null)
                {
                    return(Convert.ToInt32(response));
                }
                /*Set OOTB fields*/
                Incident        reportedIncident = new Incident();
                IncidentContact primarycontact   = new IncidentContact {
                    Contact = new NamedID {
                        ID = new ID {
                            id = contactID, idSpecified = true
                        }
                    }
                };
                reportedIncident.PrimaryContact = primarycontact;
                reportedIncident.Organization   = new NamedID {
                    ID = new ID {
                        id = orgID, idSpecified = true
                    }
                };
                reportedIncident.StatusWithType = new StatusWithType
                {
                    Status = new NamedID
                    {
                        Name = "Solution Development"
                    }
                };

                /*Set Custom Attributes*/
                List <GenericField> customAttributes = new List <GenericField>();
                customAttributes.Add(createGenericField("FSAR", createNamedIDDataValue(fsarID), DataTypeEnum.NAMED_ID));
                customAttributes.Add(createGenericField("FSAR_required", createBooleanDataValue(true), DataTypeEnum.BOOLEAN));
                GenericObject customAttributeobj = genericObject(customAttributes.ToArray(), "IncidentCustomFieldsc");
                GenericField  caPackage          = createGenericField("CO", createObjDataValue(customAttributeobj), DataTypeEnum.OBJECT);

                /*Set Custom fields*/
                List <GenericField> customFields = new List <GenericField>();
                customFields.Add(createGenericField("incident_type", createNamedIDDataValueForName("Reported Incident"), DataTypeEnum.NAMED_ID));//55 is id of "Internal incident"
                GenericObject customfieldobj = genericObject(customFields.ToArray(), "IncidentCustomFieldsc");
                GenericField  cfpackage      = createGenericField("c", createObjDataValue(customfieldobj), DataTypeEnum.OBJECT);

                reportedIncident.CustomFields = genericObject(new[] { caPackage, cfpackage }, "IncidentCustomFields");

                ClientInfoHeader hdr = new ClientInfoHeader()
                {
                    AppID = "Create Reported Incident"
                };
                RNObject[] resultobj = _rightNowClient.Create(hdr, new RNObject[] { reportedIncident }, new CreateProcessingOptions {
                    SuppressExternalEvents = false, SuppressRules = false
                });
                if (resultobj != null)
                {
                    return(Convert.ToInt32(resultobj[0].ID.id));
                }
            }
            catch (Exception ex)
            {
                WorkspaceAddIn.InfoLog("Excpetion in creating reported incident: " + ex.Message);
            }
            return(0);
        }
Пример #7
0
            /// <summary>
            /// Create a log entry in the custom object PSLog$Log
            ///
            /// If this table does not exists, please retrieve the package from: https://tools.src.rightnow.com/spaces/logging/documents
            /// </summary>
            /// <param name="client">Extend the RightNow soap client</param>
            /// <param name="type">Required: application type causing the log message</param>
            /// <param name="message">Required: human readable friendly message</param>
            /// <param name="subtype">Required: friendly name of the application</param>
            /// <param name="note">Optional (default=blank): additional details about the message</param>
            /// <param name="source">Optional (default=current assembly name): the name of the script that is executing</param>
            /// <param name="interfaceID">Optional (default=blank): the interface this error occurred on. (GlobalContext.InterfaceId)</param>
            /// <param name="severity">Optional (default=blank): mark the importance of the message</param>
            /// <param name="exception">Optional (default=blank): if populated the stack trace from the exception will be stored in the log</param>
            /// <param name="account">Optional (default=blank): reference to an Account</param>
            /// <param name="answer">Optional (default=blank): reference to an Answer</param>
            /// <param name="contact">Optional (default=blank): reference to a Contact</param>
            /// <param name="incident">Optional (default=blank): reference to an Incident</param>
            /// <param name="opportunity">Optional (default=blank): reference to an Opportunity</param>
            /// <param name="org">Optional (default=blank): reference to an Organization</param>
            /// <param name="task">Optional (default=blank): reference to a Task</param>
            /// <param name="customObjects">Optional (default=blank): an array of custom object references. the name of the object must match the name of the database column</param>
            /// <returns>ID of the newly created log object</returns>
            public static int CreateLog(this RightNowSyncPortClient client,
                                        Type type,
                                        string message,
                                        string subtype          = null,
                                        string note             = null,
                                        string source           = null,
                                        int?interfaceID         = null,
                                        Severity severity       = Severity.None,
                                        Exception exception     = null,
                                        Account account         = null,
                                        Answer answer           = null,
                                        Contact contact         = null,
                                        Incident incident       = null,
                                        Opportunity opportunity = null,
                                        Organization org        = null,
                                        Task task = null,
                                        GenericObject[] customObjects = null)
            {
                #region sanity checks
                if (type == Type.None)
                {
                    throw new Exception("Type can not be None when creating a new Log entry");
                }

                if (string.IsNullOrWhiteSpace(message))
                {
                    throw new Exception("Message can not be empty");
                }
                #endregion

                try
                {
                    if (source == null)
                    {
                        source = Assembly.GetExecutingAssembly().ManifestModule.Name + " (" + Assembly.GetExecutingAssembly().GetName().Version + ")";
                    }

                    GenericObject go = CreateLogGenericObject(type, subtype, message, note, source, interfaceID, severity, exception, account, answer, contact, incident, opportunity, org, task, customObjects);

                    RNObject[] results = client.Create(
                        new ClientInfoHeader {
                        AppID = "PSLog"
                    },
                        new RNObject[] { go },
                        new CreateProcessingOptions {
                        SuppressExternalEvents = true, SuppressRules = false
                    });

                    if (results == null || results.Length == 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return((int)results[0].ID.id);
                    }
                }
                catch (Exception ex)
                {
                    if (LogFailedEvent != null)
                    {
                        LogFailedEvent(ex);
                    }

                    return(0);
                }
            }