Exemple #1
0
        public int[] EnableDisableAssignments(
            string technologyPollingID,
            bool enable,
            int[] netObjectIDs = null)
        {
            if (string.IsNullOrEmpty(technologyPollingID))
            {
                throw new ArgumentNullException(nameof(technologyPollingID));
            }
            ITechnologyPolling technologyPolling = this.GetTechnologyPolling(technologyPollingID);

            int[] netObjectsInstanceIDs = (netObjectIDs == null ? technologyPolling.EnableDisableAssignment(enable) : technologyPolling.EnableDisableAssignment(enable, netObjectIDs)) ?? new int[0];
            TechnologyPollingFactory.log.DebugFormat("{0} TechnologyPolling:'{1}' of Technology:'{2}' on NetObjects:'{3}'", new object[4]
            {
                enable ? (object)"Enabled" : (object)"Disabled",
                (object)technologyPollingID,
                (object)technologyPolling.get_TechnologyID(),
                netObjectsInstanceIDs == null ? (object)"" : (object)string.Join <int>(",", (IEnumerable <int>)netObjectsInstanceIDs)
            });
            if (enable)
            {
                using (IEnumerator <ITechnologyPolling> enumerator = this.ItemsByTechnology(technologyPolling.get_TechnologyID()).GetEnumerator())
                {
                    while (((IEnumerator)enumerator).MoveNext())
                    {
                        ITechnologyPolling current = enumerator.Current;
                        if (!technologyPollingID.Equals(current.get_TechnologyPollingID(), StringComparison.Ordinal))
                        {
                            int[] numArray = current.EnableDisableAssignment(false, netObjectsInstanceIDs) ?? new int[0];
                            TechnologyPollingFactory.log.DebugFormat("{0} TechnologyPolling:'{1}' of Technology:'{2}' on NetObjects:'{3}'", new object[4]
                            {
                                (object)"Disabled",
                                (object)current.get_TechnologyPollingID(),
                                (object)current.get_TechnologyID(),
                                numArray == null ? (object)"" : (object)string.Join <int>(",", (IEnumerable <int>)numArray)
                            });
                        }
                    }
                }
            }
            if (BusinessLayerSettings.Instance.EnableTechnologyPollingAssignmentsChangesAuditing)
            {
                this.changesIndicator.ReportTechnologyPollingAssignmentIndication(technologyPolling, netObjectsInstanceIDs, enable);
            }
            return(netObjectsInstanceIDs);
        }
        public void ReportTechnologyPollingAssignmentIndication(
            ITechnologyPolling technologyPolling,
            int[] netObjectsInstanceIDs,
            bool enabledStateChangedTo)
        {
            if (technologyPolling == null)
            {
                throw new ArgumentNullException(nameof(technologyPolling));
            }
            if (netObjectsInstanceIDs == null)
            {
                throw new ArgumentNullException(nameof(netObjectsInstanceIDs));
            }
            if (netObjectsInstanceIDs.Length == 0)
            {
                return;
            }
            ITechnology technology      = TechnologyManager.Instance.TechnologyFactory.GetTechnology(technologyPolling.get_TechnologyID());
            string      netObjectPrefix = NetObjectTypesDAL.GetNetObjectPrefix(this.swisFactory, technology.get_TargetEntity());
            string      entityName      = NetObjectTypesDAL.GetEntityName(this.swisFactory, technology.get_TargetEntity());
            Dictionary <int, string> netObjectsCaptions = NetObjectTypesDAL.GetNetObjectsCaptions(this.swisFactory, technology.get_TargetEntity(), netObjectsInstanceIDs);

            foreach (int objectsInstanceId in netObjectsInstanceIDs)
            {
                PropertyBag propertyBag1 = new PropertyBag();
                ((Dictionary <string, object>)propertyBag1).Add("InstanceType", (object)"Orion.TechnologyPollingAssignments");
                ((Dictionary <string, object>)propertyBag1).Add("InstanceID", (object)objectsInstanceId.ToString());
                ((Dictionary <string, object>)propertyBag1).Add("TechnologyPollingID", (object)technologyPolling.get_TechnologyPollingID());
                ((Dictionary <string, object>)propertyBag1).Add("Enabled", (object)enabledStateChangedTo);
                ((Dictionary <string, object>)propertyBag1).Add("TargetEntity", (object)technology.get_TargetEntity());
                ((Dictionary <string, object>)propertyBag1).Add("TechPollingDispName", (object)technologyPolling.get_DisplayName());
                ((Dictionary <string, object>)propertyBag1).Add("TechnologyDispName", (object)technology.get_DisplayName());
                PropertyBag propertyBag2 = propertyBag1;
                string      str;
                if (netObjectsCaptions.TryGetValue(objectsInstanceId, out str))
                {
                    ((Dictionary <string, object>)propertyBag2).Add("NetObjectCaption", (object)str);
                }
                if (netObjectPrefix != null)
                {
                    ((Dictionary <string, object>)propertyBag2).Add("NetObjectPrefix", (object)netObjectPrefix);
                    ((Dictionary <string, object>)propertyBag2).Add((string)KnownKeys.NetObject, (object)string.Format("{0}:{1}", (object)netObjectPrefix, (object)objectsInstanceId));
                }
                if (entityName != null)
                {
                    ((Dictionary <string, object>)propertyBag2).Add("NetObjectName", (object)entityName);
                }
                this.publishManager.Publish(PublishHelper.ConvertIndication((IIndication) new TechnologyPollingAssignmentIndication((IndicationType)2, propertyBag2)));
            }
        }