public void DeleteObjects <T>(List <T> lstObj) where T : class, new() { List <GenericObject> lstgenericObject = new List <GenericObject>(); foreach (T sam in lstObj) { ID autoID = new ID(); 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) { RightNowCustomObjectFieldAttribute attribute = property.GetCustomAttributes(typeof(RightNowCustomObjectFieldAttribute), true).FirstOrDefault() as RightNowCustomObjectFieldAttribute; if (attribute != null && attribute.CanUpdate) { var propValue = property.GetValue(sam, null); //if (!string.IsNullOrWhiteSpace(propValue.ToString())) && !string.IsNullOrWhiteSpace(propValue.ToString()) if (propValue != null && !string.IsNullOrWhiteSpace(propValue.ToString())) { genericFields.Add(createGenericField(attribute, propValue)); } } else { if (attribute.Name == "ID") { var propValue = property.GetValue(sam, null); autoID.id = Convert.ToInt64(propValue); } } } genericObject.GenericFields = genericFields.ToArray(); autoID.idSpecified = true; genericObject.ID = autoID; lstgenericObject.Add(genericObject); } DestroyProcessingOptions options = new DestroyProcessingOptions(); options.SuppressExternalEvents = false; options.SuppressRules = false; RNObject[] rnobj = lstgenericObject.ToArray <RNObject>(); DestroyRequest destroyRequest = new DestroyRequest(getClientInfoHeader(), rnobj, options); DestroyResponse destroyResponse = getChannel().Destroy(destroyRequest); }
public void DeleteObject <T>(long uniqueId) 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>(); genericObject.GenericFields = genericFields.ToArray(); ID autoID = new ID(); autoID.id = uniqueId; autoID.idSpecified = true; genericObject.ID = autoID; DestroyProcessingOptions options = new DestroyProcessingOptions(); options.SuppressExternalEvents = false; options.SuppressRules = false; DestroyRequest destroyRequest = new DestroyRequest(getClientInfoHeader(), new RNObject[] { genericObject }, options); DestroyResponse destroyResponse = getChannel().Destroy(destroyRequest); }
/********************/ public UpdateResponse UpdateObject <T>(T obj, long uniqueId) where T : class, new() { UpdateResponse updateResponse = null; Logger.Logger.Log.Debug(string.Format("Update : {0}", uniqueId)); try { 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) { RightNowCustomObjectFieldAttribute attribute = property.GetCustomAttributes(typeof(RightNowCustomObjectFieldAttribute), true).FirstOrDefault() as RightNowCustomObjectFieldAttribute; if (attribute != null && attribute.CanUpdate) { var propValue = property.GetValue(obj, null); //if (!string.IsNullOrWhiteSpace(propValue.ToString())) && !string.IsNullOrWhiteSpace(propValue.ToString()) if (propValue != null && !string.IsNullOrWhiteSpace(propValue.ToString())) { genericFields.Add(createGenericField(attribute, propValue)); } } } genericObject.GenericFields = genericFields.ToArray(); ID autoID = new ID(); autoID.id = uniqueId; autoID.idSpecified = true; genericObject.ID = autoID; UpdateProcessingOptions options = new UpdateProcessingOptions(); options.SuppressExternalEvents = false; options.SuppressRules = false; UpdateRequest updateRequest = new UpdateRequest(getClientInfoHeader(), new RNObject[] { genericObject }, options); updateResponse = this.getChannel().Update(updateRequest); } catch (Exception ex) { Logger.Logger.Log.Error("RightNowObject:", ex); } return(updateResponse); }
public CreateResponse CreateObjects <T>(List <T> lstobj) { List <GenericObject> lstgenericObject = new List <GenericObject>(); foreach (T sam in lstobj) { 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(sam, null); if (propValue != null && !string.IsNullOrWhiteSpace(propValue.ToString())) { genericFields.Add(createGenericField(rightNowAttribute, propValue)); } } } } genericObject.GenericFields = genericFields.ToArray(); lstgenericObject.Add(genericObject); } CreateProcessingOptions options = new CreateProcessingOptions(); options.SuppressExternalEvents = false; options.SuppressRules = false; RNObject[] rnobj = lstgenericObject.ToArray <RNObject>(); CreateRequest createRequest = new CreateRequest(getClientInfoHeader(), rnobj, options); CreateResponse createResponcse = this.getChannel().Create(createRequest); return(createResponcse); }
/// <summary> /// Create Generic Object type data value /// </summary> /// <param name="gF">Array of Generic Field</param> /// <param name="typeName">RNObjectType Type name</param> /// <returns> GenericObject</returns> private GenericObject genericObject(GenericField[] gF, string typeName) { RNObjectType rnObjType = new RNObjectType(); rnObjType.TypeName = typeName; GenericObject gObj = new GenericObject(); gObj.GenericFields = gF; gObj.ObjectType = rnObjType; return(gObj); }
internal void UpdateStaffAccountInformation(StaffAccountInfo staffActInfo) { try { Logger.Logger.Log.Debug("RightNowObjectProvider: Get User Account Details"); Account acobj = new Account(); acobj.ID = new ID() { id = Global.Context.AccountId, idSpecified = true }; GenericObject genericObject = new GenericObject(); GenericObject genericObjectFinal = new GenericObject(); RNObjectType rnobj = new RNObjectType(); List <GenericField> genericFields = new List <GenericField>(); List <GenericField> genericField = new List <GenericField>(); //Convert.ToInt64(AgentID)) staffActInfo.Password = string.IsNullOrEmpty(staffActInfo.Password) ? " " : staffActInfo.Password; genericFields.Add(createGenericField("AgentID", ItemsChoiceType.StringValue, staffActInfo.AgentID.ToString())); genericFields.Add(createGenericField("password", ItemsChoiceType.StringValue, staffActInfo.Password)); genericFields.Add(createGenericField("Extension", ItemsChoiceType.StringValue, staffActInfo.Extension.ToString())); genericFields.Add(createGenericField("Queue", ItemsChoiceType.IntegerValue, staffActInfo.Queue)); genericObject.GenericFields = genericFields.ToArray(); rnobj.TypeName = "AccountCustomFields"; genericObject.ObjectType = rnobj; genericField.Add(createGenericField("c", ItemsChoiceType.ObjectValue, genericObject)); genericObjectFinal.GenericFields = genericField.ToArray(); genericObjectFinal.ObjectType = new RNObjectType() { TypeName = "AccountCustomFieldsc" }; acobj.CustomFields = genericObjectFinal; UpdateProcessingOptions cpo = new UpdateProcessingOptions(); cpo.SuppressExternalEvents = false; cpo.SuppressRules = false; UpdateRequest cre = new UpdateRequest(getClientInfoHeader(), new RNObject[] { acobj }, cpo); UpdateResponse res = getChannel().Update(cre); } catch (Exception ex) { Logger.Logger.Log.Error("RightNowObjectProvider:", ex); } }
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); } }
private RNObject lookupExtension() { GenericObject generic = new GenericObject(); RNObjectType rnObj = new RNObjectType(); rnObj.Namespace = "SvcVentures"; rnObj.TypeName = "scProductExtension"; generic.ObjectType = rnObj; string query = "SELECT SvcVentures.scProductExtension FROM SvcVentures.scProductExtension where Signature like '" + this.extSignature + "';"; RNObject[] objectTemplate = new RNObject[] { generic }; RNObject[] result = null; try { QueryResultData[] queryObjects = client.QueryObjects( new ClientInfoHeader { AppID = "SCLog" }, query, objectTemplate, 10000); result = queryObjects[0].RNObjectsResult; } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } if (result != null && result.Length > 0) { return(result[0]); } else { return(null); } }
/// <summary> /// Update "Supplier Credit" child record of sClaim /// </summary> /// <param name="cmReturnItems">response of BOM query web-service</param> /// <param name="scID">supplier Credit record ID</param> public void upadteSupplierCredit(object[] cmReturnItems, List <int> scIDs) { try { //cmReturnItems. List <RNObject> rnObjs = new List <RNObject>(); int ii = 0; foreach (int scID in scIDs)//loop over each supplier credit IDs { Dictionary <string, object> cmReturnItem = (Dictionary <string, object>)cmReturnItems[ii++]; List <GenericField> gfs = new List <GenericField>(); GenericObject gnObject = new GenericObject(); RNObjectType objType = new RNObjectType(); objType.Namespace = "CO"; objType.TypeName = "SupplierCredits"; gnObject.ObjectType = objType; ID goID = new ID(); goID.id = scID; goID.idSpecified = true; gnObject.ID = goID; if (cmReturnItem["RETURN_STATUS"].ToString().Trim().Length > 0) { gfs.Add(createGenericField("ebs_status", createStringDataValue(cmReturnItem["RETURN_STATUS"].ToString()), DataTypeEnum.STRING)); if (cmReturnItem["RETURN_STATUS"].ToString() == "S") { gfs.Add(createGenericField("date_processed", createDateDataValue(DateTime.Now.ToShortDateString()), DataTypeEnum.DATE)); } } if (cmReturnItem["CONVERTED_CURRENCY"].ToString().Trim().Length > 0) { gfs.Add(createGenericField("converted_currency", createNamedIDDataValueForName(cmReturnItem["CONVERTED_CURRENCY"].ToString()), DataTypeEnum.NAMED_ID)); } if (cmReturnItem["CONVERTED_AMOUNT"].ToString().Trim().Length > 0) { gfs.Add(createGenericField("converted_amount", createStringDataValue(cmReturnItem["CONVERTED_AMOUNT"].ToString()), DataTypeEnum.STRING)); } if (cmReturnItem["CONVERTED_TAX_CURRENCY"].ToString().Trim().Length > 0) { gfs.Add(createGenericField("converted_tax_currency", createNamedIDDataValueForName(cmReturnItem["CONVERTED_TAX_CURRENCY"].ToString()), DataTypeEnum.NAMED_ID)); } if (cmReturnItem["CONVERTED_TAX_AMOUNT"].ToString().Trim().Length > 0) { gfs.Add(createGenericField("converted_tax_amount", createStringDataValue(cmReturnItem["CONVERTED_TAX_AMOUNT"].ToString()), DataTypeEnum.STRING)); } if (cmReturnItem["RETURN_MESSAGE"].ToString().Trim().Length > 0) { gfs.Add(createGenericField("ebs_message", createStringDataValue(cmReturnItem["RETURN_MESSAGE"].ToString()), DataTypeEnum.STRING)); } gnObject.GenericFields = gfs.ToArray(); rnObjs.Add(gnObject); } callBatchJob(getUpdateMsg(rnObjs));//update supplier credit } catch (Exception ex) { MessageBox.Show(ex.Message); } return; }
/// <summary> /// Method called to update the social channel /// </summary> /// <param name="incident"></param> private void updateSocialChannelAccount(IIncident incident) { // get it again _socialChannelAccountId = ConfigurationSetting.getSrmStringCustomAttrInt(incident, "srm_social_channel_account_id"); if (_socialChannelAccountId == 0) { ConfigurationSetting.logWrap.DebugLog(logMessage: String.Format(Properties.Resources.SocialChannelEmptyError, incident.ID)); return; } /* Custom Object: SocialChannelAccount * */ int incidentContactId = 0; foreach (IInc2Contact c in incident.Contact) { if (c.Prmry == true) { incidentContactId = (int)c.Cid; } } Boolean toUpdate = false; // if incident's contact is changed if (_incidentContactIdWhenLoaded != incidentContactId) { // check if updated incidentContactId same as SocialChannelAccount.ContactId if (_socialChannelAccountId != 0 && incidentContactId != _socialChannelAccountId) { DialogResult result = MessageBox.Show(String.Format(Properties.Resources.ChangeContactReassignMessage, _socialChannelUserName), Properties.Resources.Info, MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { toUpdate = true; } } // update in Accelerator.SocialChannelAccount if (toUpdate) { // create a row in SocialChannelAccount ClientInfoHeader clientInfoHeader = new ClientInfoHeader(); clientInfoHeader.AppID = "Update a SocialChannelAccount"; GenericObject go = new GenericObject(); //Set the object type RNObjectType objType = new RNObjectType(); objType.Namespace = "Accelerator"; objType.TypeName = "SocialChannelAccount"; go.ObjectType = objType; List <GenericField> gfs = new List <GenericField>(); ID socialAccountId = new ID(); socialAccountId.id = _socialChannelAccountId; socialAccountId.idSpecified = true; go.ID = socialAccountId; NamedID contactIdNamedID = new NamedID { ID = new ID { id = incidentContactId, idSpecified = true } }; gfs.Add(createGenericField("ContactId", ItemsChoiceType.NamedIDValue, contactIdNamedID)); go.GenericFields = gfs.ToArray(); RNObject[] objects = new RNObject[] { go }; UpdateProcessingOptions cpo = new UpdateProcessingOptions(); cpo.SuppressExternalEvents = false; cpo.SuppressRules = false; ConfigurationSetting.logWrap.DebugLog(logMessage: String.Format(Properties.Resources.UpdateSocialChannelMessage, _socialChannelAccountId, incidentContactId)); ConfigurationSetting.client.Update(clientInfoHeader, objects, cpo); DialogResult result = MessageBox.Show(String.Format(Properties.Resources.ReassignAllIncidentsMessage, _socialChannelUserName), Properties.Resources.Info, MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) { updateIncidents(incidentContactId); } } } }