コード例 #1
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);
        }
コード例 #2
0
        /// <summary>
        /// To create Create Message for Batch
        /// </summary>
        /// <param name="coList"></param>
        /// <returns></returns>
        private CreateMsg getCreateMsg(List <RNObject> coList)
        {
            CreateMsg createMsg = new CreateMsg();
            CreateProcessingOptions createProcessingOptions = new CreateProcessingOptions();

            createProcessingOptions.SuppressExternalEvents = true;
            createProcessingOptions.SuppressRules          = true;
            createMsg.ProcessingOptions = createProcessingOptions;

            createMsg.RNObjects = coList.ToArray();

            return(createMsg);
        }
コード例 #3
0
        public CreateResponse CreateObject <T>(T obj) where T : class, new()
        {
            Type objType      = typeof(T);
            var  objAttribute = objType.GetCustomAttributes(typeof(RightNowCustomObjectAttribute), true).FirstOrDefault() as RightNowCustomObjectAttribute;

            if (objAttribute == null)
            {
                throw new InvalidOperationException("The type provided is not a RightNow custom object type. Please use the RightNowObjectAttribute to associate the proper metadata with the type");
            }

            GenericObject genericObject = new GenericObject();
            RNObjectType  rnObjType     = new RNObjectType()
            {
                Namespace = objAttribute.PackageName, TypeName = objAttribute.ObjectName
            };

            genericObject.ObjectType = rnObjType;

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

            PropertyInfo[] properties = objType.GetProperties();
            foreach (PropertyInfo property in properties)
            {
                object attribute = property.GetCustomAttributes(typeof(RightNowCustomObjectFieldAttribute), true).FirstOrDefault();
                if (attribute != null)
                {
                    RightNowCustomObjectFieldAttribute rightNowAttribute = attribute as RightNowCustomObjectFieldAttribute;
                    if (rightNowAttribute.CanUpdate)
                    {
                        var propValue = property.GetValue(obj, null);
                        if (propValue != null && !string.IsNullOrWhiteSpace(propValue.ToString()))
                        {
                            genericFields.Add(createGenericField(rightNowAttribute, propValue));
                        }
                    }
                }
            }

            genericObject.GenericFields = genericFields.ToArray();
            CreateProcessingOptions options = new CreateProcessingOptions();

            options.SuppressExternalEvents = false;
            options.SuppressRules          = false;
            CreateRequest  createRequest   = new CreateRequest(getClientInfoHeader(), new RNObject[] { genericObject }, options);
            CreateResponse createResponcse = this.getChannel().Create(createRequest);

            return(createResponcse);
        }
コード例 #4
0
 public RNObject[] CreateContact(string FirstName, string LastName,string EmailAddress)
 {
     Contact newContact = populateContactInfo(FirstName, LastName,EmailAddress);
         //Set the application ID in the client info header
         ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
         clientInfoHeader.AppID = ".NET Getting Started test in log API";
         //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 };
         GetProcessingOptions options = new GetProcessingOptions();
         options.FetchAllNames = false;
         //Invoke the create operation on the server. This will create a contact
         RNObject[] createResults = _service.Create(clientInfoHeader, createObjects, createProcessingOptions);
         newContact = createResults[0] as Contact;
         RNObject[] rnObjects = _service.Get(clientInfoHeader, createResults, options);
         return rnObjects;
 }
コード例 #5
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);
    }
コード例 #6
0
ファイル: SCLog.cs プロジェクト: victor-zucchi/accelerators
        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);
            }
        }
コード例 #7
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;
        }
コード例 #8
0
ファイル: SCLog.cs プロジェクト: victor-zucchi/accelerators
        public Boolean log(string message, string detail = null, Incident incident = null, Contact contact = null, string source = null, string function = null, int timeElapsed = 0, logLevel messageType = logLevel.Debug, string host = null, int processID = 0)
        {
            if (this.extConfigs == null)
            {
                throw new Exception("SCLog has not been initialized");
            }
            if ((int)messageType > this.extConfigs.logThreshhold)
            {
                return(false);
            }
            GenericObject go = new GenericObject
            {
                ObjectType = new RNObjectType
                {
                    Namespace = "SvcVentures", // Custom Object
                    TypeName  = "scLog"        // Custom Object
                }
            };
            List <GenericField> fields = new List <GenericField>();

            if (message.Length > 255)
            {
                message = message.Substring(0, 255);
            }

            fields.Add(createGenericField("Message", ItemsChoiceType.StringValue, message));
            fields.Add(createGenericField("MsgType", ItemsChoiceType.IntegerValue, (int)messageType));
            long memory = GC.GetTotalMemory(true) / (1024 * 1024);

            fields.Add(createGenericField("PeakMemory", ItemsChoiceType.IntegerValue, (int)memory));

            if (string.IsNullOrWhiteSpace(source) == false)
            {
                fields.Add(createGenericField("File", ItemsChoiceType.StringValue, trimMaxLengthString(source)));
            }

            if (string.IsNullOrWhiteSpace(function) == false)
            {
                fields.Add(createGenericField("Function", ItemsChoiceType.StringValue, trimMaxLengthString(function)));
            }

            if (string.IsNullOrWhiteSpace(detail) == false)
            {
                fields.Add(createGenericField("Detail", ItemsChoiceType.StringValue, trimMaxLengthString(detail)));
            }

            if (string.IsNullOrWhiteSpace(host) == false)
            {
                fields.Add(createGenericField("Host", ItemsChoiceType.StringValue, trimMaxLengthString(host)));
            }

            fields.Add(createGenericField("ProcessID", ItemsChoiceType.IntegerValue, processID));
            fields.Add(createGenericField("TimeElapsed", ItemsChoiceType.IntegerValue, timeElapsed));
            fields.Add(createGenericField("scProductExtension", ItemsChoiceType.NamedIDValue,
                                          new NamedID
            {
                ID = new ID
                {
                    id          = (int)this.extObject.ID.id,
                    idSpecified = true
                }
            }
                                          ));

            if (!string.IsNullOrWhiteSpace(detail))
            {
                fields.Add(createGenericField("Detail", ItemsChoiceType.StringValue, trimMaxLengthString(detail)));
            }

            go.GenericFields = fields.ToArray();

            CreateProcessingOptions cpo = new CreateProcessingOptions();

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

            ClientInfoHeader clientInfoHeader = new ClientInfoHeader();

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

            // check result and save incident id
            if (results != null && results.Length > 0)
            {
                bool          xRefsPresent = false;
                GenericObject xRefObj      = new GenericObject
                {
                    ObjectType = new RNObjectType
                    {
                        Namespace = "SvcVentures", // Custom Object
                        TypeName  = "scLogXref"    // Custom Object
                    }
                };
                List <GenericField> xRefFields = new List <GenericField>();
                if (incident != null)
                {
                    xRefsPresent = true;
                    xRefFields.Add(createGenericField("Incident", ItemsChoiceType.NamedIDValue,
                                                      new NamedID
                    {
                        ID = new ID
                        {
                            id          = (int)incident.ID.id,
                            idSpecified = true
                        }
                    }));
                }
                if (contact != null)
                {
                    xRefsPresent = true;
                    xRefFields.Add(createGenericField("Contact", ItemsChoiceType.NamedIDValue,
                                                      new NamedID
                    {
                        ID = new ID
                        {
                            id          = (int)contact.ID.id,
                            idSpecified = true
                        }
                    }));
                }
                if (xRefsPresent == false)
                {
                    return(true);
                }
                xRefFields.Add(createGenericField("scLog", ItemsChoiceType.NamedIDValue,
                                                  new NamedID
                {
                    ID = new ID
                    {
                        id          = (int)results[0].ID.id,
                        idSpecified = true
                    }
                }
                                                  ));
                xRefObj.GenericFields = xRefFields.ToArray();
                RNObject[] xRefResults = this.client.Create(clientInfoHeader, new RNObject[] { xRefObj }, cpo);
                return(true);
            }
            else
            {
                return(false);
            }
        }