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); }
/// <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); }
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); }
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; }
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); }
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); } }
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; }
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); } }