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 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);
        }
示例#3
0
        public void destroyObjects(RNObject[] objects)
        {
            DestroyProcessingOptions dpo = new DestroyProcessingOptions()
            {
                SuppressExternalEvents = false,
                SuppressRules          = false
            };

            _rnowClient.Destroy(_rnowClientInfoHeader, objects, dpo);
        }
        /// <summary>
        /// Create DestroyMsg object
        /// </summary>
        /// <param name="coList">RNObject List</param>
        /// <returns> DestroyMsg</returns>
        private DestroyMsg getDestroyMsg(List <RNObject> coList)
        {
            DestroyMsg deleteMsg = new DestroyMsg();
            DestroyProcessingOptions deleteProcessingOptions = new DestroyProcessingOptions();

            deleteProcessingOptions.SuppressExternalEvents = true;
            deleteProcessingOptions.SuppressRules          = true;
            deleteMsg.ProcessingOptions = deleteProcessingOptions;
            deleteMsg.RNObjects         = coList.ToArray();
            return(deleteMsg);
        }
        public void DestroyReasoncodes(long config)
        {
            List <RNObject> destroyfields = new List <RNObject>();

            List <ScreenPopOptions> profiledata = new List <ScreenPopOptions>(GetObjects <ScreenPopOptions>(string.Format(" where ScreenPopConfigID={0}", config)));

            foreach (ScreenPopOptions rn in profiledata)
            {
                _icGenericObject            = new GenericObject();
                _rnObjType.Namespace        = OracleCtiObjectStrings.ScreenPopPackageName;
                _rnObjType.TypeName         = OracleCtiObjectStrings.ScreenPopOptions;
                _icGenericObject.ObjectType = _rnObjType;
                NamedID relationid = new NamedID();
                ID      incID      = new ID();
                incID.id          = config;
                incID.idSpecified = true;
                relationid.ID     = incID;

                ID rowid = new ID();
                rowid.id            = rn.ID;
                rowid.idSpecified   = true;
                _icGenericObject.ID = rowid;

                List <GenericField> gfs = new List <GenericField>();
                //gfs.Add(createGenericField("AgentEntityID", ItemsChoiceType.NamedIDValue, relationid));
                _icGenericObject.GenericFields = gfs.ToArray();
                destroyfields.Add(_icGenericObject);
            }

            if (destroyfields.Count() > 0)
            {
                DestroyProcessingOptions drop = new DestroyProcessingOptions();
                drop.SuppressExternalEvents = false;
                drop.SuppressRules          = false;
                DestroyRequest  destroyReq = new DestroyRequest(getClientInfoHeader(), destroyfields.ToArray(), drop);
                DestroyResponse destroyRes = getChannel().Destroy(destroyReq);
            }
        }