示例#1
0
 /// <summary>
 /// A shorthand method for executing <see cref="ModifyModelRequest"/> for this model..
 /// </summary>
 /// <param name="action">the modification action</param>
 /// <param name="name">the new model name</param>
 /// <param name="concepts">the concepts update the model with</param>
 /// <param name="areConceptsMutuallyExclusive">are concepts mutually exclusive</param>
 /// <param name="isEnvironmentClosed">is environment closed</param>
 /// <param name="language">the language</param>
 public ModifyModelRequest Modify(ModifyAction action            = null, string name = null,
                                  IEnumerable <Concept> concepts = null, bool?areConceptsMutuallyExclusive = null,
                                  bool?isEnvironmentClosed       = null, string language = null)
 {
     return(new ModifyModelRequest(HttpClient, ModelID, action, name, concepts,
                                   areConceptsMutuallyExclusive, isEnvironmentClosed, language));
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TriggerParameters"/> class.
        /// </summary>
        /// <param name="type">The type of notification trigger this object will manipulate.</param>
        /// <param name="objectId">The object ID the trigger will apply to.</param>
        /// <param name="subId">If this trigger is being edited, the trigger's sub ID. If the trigger is being added, this value is null.</param>
        /// <param name="action">Whether to add a new trigger or modify an existing one.</param>
        protected TriggerParameters(TriggerType type, int objectId, int?subId, ModifyAction action)
        {
            if (action == ModifyAction.Add && subId != null)
            {
                throw new ArgumentException("SubId must be null when ModifyAction is Add", nameof(subId));
            }

            if (action == ModifyAction.Edit && subId == null)
            {
                throw new ArgumentException("SubId cannot be null when ModifyAction is Edit", nameof(subId));
            }

            if (action == ModifyAction.Add)
            {
                OnNotificationAction = null;
            }

            ObjectId = objectId;

            this.subId = action == ModifyAction.Add ? "new" : subId.Value.ToString();
            Action     = action;
            Type       = type;

            this[Parameter.Id]    = objectId;
            this[Parameter.SubId] = this.subId;

            if (action == ModifyAction.Add)
            {
                Parameters.Add(new CustomParameter("class", type));
                this[Parameter.ObjectType] = "nodetrigger";
            }
        }
示例#3
0
 /// <inheritdoc />
 public ModifyInputRequest ModifyInput(string inputID, ModifyAction action,
                                       IEnumerable <Concept> positiveConcepts = null,
                                       IEnumerable <Concept> negativeConcepts = null)
 {
     return(new ModifyInputRequest(HttpClient, inputID, action, positiveConcepts,
                                   negativeConcepts));
 }
示例#4
0
        public static void Enqueue(AppCommands commandType, IEntityBase entity, ExecutionTrigger trigger, object value, ModifyAction modifyAction)
        {
            var command = new QueuedCommand
            {
                CommandType = commandType,
                Target = entity.UniqueId,
                Status = ExecutionStatus.Pending,
                TriggerType = trigger,
                Value = value.ToString(),
                ModifyAction = modifyAction,
                DateCreated = DateTime.Now,
                DateScheduled = DateTime.Now
            };

            ThreadPool.QueueUserWorkItem(delegate
            {
                ClientState.Current.DataService.Save(command);

                switch (trigger)
                {
                    case ExecutionTrigger.Connection:
                        EventBroker.Publish(AppEvents.RequestCommands);
                        break;

                    case ExecutionTrigger.Send:
                        EventBroker.Publish(AppEvents.RequestSend);
                        break;

                    case ExecutionTrigger.Receive:
                        EventBroker.Publish(AppEvents.RequestReceive);
                        break;
                }
            });
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TriggerParameters"/> class.
        /// </summary>
        /// <param name="type">The type of notification trigger this object will manipulate.</param>
        /// <param name="objectId">The object ID the trigger will apply to.</param>
        /// <param name="subId">If this trigger is being edited, the trigger's sub ID. If the trigger is being added, this value is null.</param>
        /// <param name="action">Whether to add a new trigger or modify an existing one.</param>
        protected TriggerParameters(TriggerType type, int objectId, int?subId, ModifyAction action)
        {
            if (action == ModifyAction.Add && subId != null)
            {
                throw new ArgumentException("SubId must be null when ModifyAction is Add", nameof(subId));
            }
            else if (action == ModifyAction.Edit && subId == null)
            {
                throw new ArgumentException("SubId cannot be null when ModifyAction is Edit", nameof(subId));
            }

            if (action == ModifyAction.Add)
            {
                OnNotificationAction = null;
            }

            ObjectId = objectId;

            this.subId = action == ModifyAction.Add ? "new" : subId.Value.ToString();
            Action     = action;
            Type       = type;

            this[Parameter.Id]    = objectId;
            this[Parameter.SubId] = this.subId;

            if (action == ModifyAction.Add)
            {
                Parameters.Add(new CustomParameter("class", type.ToString().ToLower())); //todo: does this tolower itself during prtgurl construction? check debug output!
                this[Parameter.ObjectType] = "nodetrigger";
            }
        }
 /// <inheritdoc />
 public ModifyInputRequest ModifyInput(string inputID, ModifyAction action,
                                       IEnumerable <Concept> positiveConcepts       = null,
                                       IEnumerable <Concept> negativeConcepts       = null,
                                       IEnumerable <RegionFeedback> regionFeedbacks = null)
 {
     return(new ModifyInputRequest(this, inputID, action, positiveConcepts,
                                   negativeConcepts, regionFeedbacks));
 }
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="httpClient">the HTTP client</param>
 /// <param name="inputID">the input ID</param>
 /// <param name="action">the action</param>
 /// <param name="positiveConcepts">positive concepts</param>
 /// <param name="negativeConcepts">negative concepts</param>
 public ModifyInputRequest(IClarifaiHttpClient httpClient, string inputID,
                           ModifyAction action, IEnumerable <Concept> positiveConcepts,
                           IEnumerable <Concept> negativeConcepts)
     : base(httpClient)
 {
     _inputID          = inputID;
     _action           = action;
     _positiveConcepts = positiveConcepts;
     _negativeConcepts = negativeConcepts;
 }
 /// <inheritdoc />
 public ModifyInputRequest(IClarifaiClient client, string inputID, ModifyAction action,
                           IEnumerable <Concept> positiveConcepts, IEnumerable <Concept> negativeConcepts,
                           IEnumerable <RegionFeedback> regionFeedbacks = null)
     : base(client)
 {
     _inputID          = inputID;
     _action           = action;
     _positiveConcepts = positiveConcepts;
     _negativeConcepts = negativeConcepts;
     _regionFeedbacks  = regionFeedbacks;
 }
示例#9
0
 public virtual ActionResult AddUpdateSpotCheckSetting(ModifyAction action, string style, string color, string sewingPlantId,
                                                       int?spotCheckPercent, bool enabled = false)
 {
     if (action == ModifyAction.Delete)
     {
         var rows = _service.Value.DeleteSpotCheckSetting(style, color, sewingPlantId);
         AddStatusMessage(string.Format("{0} Spot check setting has been deleted for Sewing Plant: {0}, Style: {1}, Color: {2} ", rows, string.IsNullOrEmpty(sewingPlantId) ? "All" : sewingPlantId, string.IsNullOrEmpty(style) ? "All" : style, string.IsNullOrEmpty(color) ? "All" : color));
     }
     else
     {
         var inserted = _service.Value.AddUpdateSpotCheckSetting(style, color, sewingPlantId, spotCheckPercent, enabled);
         if (inserted)
         {
             AddStatusMessage(string.Format("Spot check setting has been added for Sewing Plant: {0}, Style: {1}, Color: {2} ", string.IsNullOrEmpty(sewingPlantId) ? "All" : sewingPlantId, string.IsNullOrEmpty(style) ? "All" : style, string.IsNullOrEmpty(color) ? "All" : color));
         }
         else
         {
             AddStatusMessage(string.Format("Spot check setting has been modified for Sewing Plant: {0}, Style: {1}, Color: {2} ", string.IsNullOrEmpty(sewingPlantId) ? "All" : sewingPlantId, string.IsNullOrEmpty(style) ? "All" : style, string.IsNullOrEmpty(color) ? "All" : color));
         }
     }
     return(RedirectToAction(MVC_Receiving.Receiving.Rad.Index()));
 }
        private T CreateParameters <T>(ModifyAction action)
        {
            if (Source != null)
            {
                if (Id != null)
                {
                    return((T)Activator.CreateInstance(typeof(T), Id, Source, action));  //Add from an existing notification trigger
                }
                else
                {
                    return((T)Activator.CreateInstance(typeof(T), Source.ObjectId, Source.SubId));  //Edit from an existing notification trigger
                }
            }

            if (TriggerId != null)
            {
                return((T)Activator.CreateInstance(typeof(T), Id, TriggerId));  //Edit a notification trigger
            }
            else
            {
                return((T)Activator.CreateInstance(typeof(T), Id));  //Create a new notification trigger
            }
        }
示例#11
0
 void EnqueueCloudNotification(ModifyAction action, object value)
 {
     //if (IsManaged())
     //    CommandQueue.Enqueue(AppCommands.SyncStatusUpdate, this, ExecutionTrigger.Connection, value, action);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ThresholdTriggerParameters"/> class for creating a new trigger from an existing <see cref="TriggerType.Threshold"/> <see cref="NotificationTrigger"/>.
 /// </summary>
 /// <param name="objectId">The object ID the trigger will apply to.</param>
 /// <param name="sourceTrigger">The notification trigger whose properties should be used.</param>
 /// <param name="action">Whether these parameters will create a new trigger or edit an existing one.</param>
 public ThresholdTriggerParameters(int objectId, NotificationTrigger sourceTrigger, ModifyAction action) : base(TriggerType.Threshold, objectId, sourceTrigger, action)
 {
     if (action == ModifyAction.Add)
     {
         OffNotificationAction = sourceTrigger.OffNotificationAction;
         Latency   = sourceTrigger.Latency;
         Threshold = sourceTrigger.ThresholdInternal;
         Condition = sourceTrigger.Condition;
         Channel   = sourceTrigger.Channel;
     }
 }
示例#13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TriggerParameters"/> class for creating a new <see cref="NotificationTrigger"/> from an existing one.
        /// </summary>
        /// <param name="type">The type of notification trigger these parameters will manipulate.</param>
        /// <param name="objectId">The ID of the object the notification trigger will apply to.</param>
        /// <param name="sourceTrigger">The notification trigger whose properties should be used as the basis of this trigger.</param>
        /// <param name="action">Whether these parameters will create a new trigger or edit an existing one.</param>
        protected TriggerParameters(TriggerType type, int objectId, NotificationTrigger sourceTrigger, ModifyAction action) : this(type, objectId, action == ModifyAction.Edit ? sourceTrigger.SubId : (int?)null, action)
        {
            if (sourceTrigger == null)
            {
                throw new ArgumentNullException(nameof(sourceTrigger));
            }

            if (sourceTrigger.Type != type)
            {
                throw new ArgumentException($"A NotificationTrigger of type '{sourceTrigger.Type}' cannot be used to initialize trigger parameters of type '{type}'");
            }

            if (action == ModifyAction.Add)
            {
                OnNotificationAction = sourceTrigger.OnNotificationAction;
            }
            else
            {
                if (sourceTrigger.Inherited)
                {
                    throw new InvalidOperationException($"Cannot modify NotificationTrigger '{sourceTrigger.OnNotificationAction}' applied to object ID {sourceTrigger.ObjectId} as this trigger is inherited from object ID {sourceTrigger.ParentId}. To modify this trigger, retrieve it from its parent object");
                }
            }
        }
示例#14
0
        public static void Enqueue(AppCommands commandType, IEntityBase entity, ExecutionTrigger trigger, object value, ModifyAction modifyAction)
        {
            var command = new QueuedCommand
            {
                CommandType   = commandType,
                Target        = entity.UniqueId,
                Status        = ExecutionStatus.Pending,
                TriggerType   = trigger,
                Value         = value.ToString(),
                ModifyAction  = modifyAction,
                DateCreated   = DateTime.Now,
                DateScheduled = DateTime.Now
            };

            ThreadPool.QueueUserWorkItem(delegate
            {
                ClientState.Current.DataService.Save(command);

                switch (trigger)
                {
                case ExecutionTrigger.Connection:
                    EventBroker.Publish(AppEvents.RequestCommands);
                    break;

                case ExecutionTrigger.Send:
                    EventBroker.Publish(AppEvents.RequestSend);
                    break;

                case ExecutionTrigger.Receive:
                    EventBroker.Publish(AppEvents.RequestReceive);
                    break;
                }
            });
        }
示例#15
0
        /// <summary>
        /// Iterates over the vertices in the height map and modifies them according to the provided modifier.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="radius"></param>
        /// <param name="magnitude"></param>
        /// <param name="modifyVertex"></param>
        private void ModifyVertices(Vector2 position, float radius, float magnitude, int numPasses, VertexModifier modifyVertex)
        {
            if (NewAction)
            {
                NewAction = false;

                BackupVertices();
                mUndoStack.Push(mCurrentAction);
                mCurrentAction = null;
                mCurrentAction = new ModifyAction();
                mRedoStack.Clear();
            }

            float radiusSquared = radius * radius;

            // Normalize origin of modification to [0,mHeight), [0, mWidth).
            position.X = position.X / Utils.WorldScale.X + mWidth / 2;
            position.Y = position.Y / Utils.WorldScale.Z + mHeight / 2;

            int minZ = (int)Math.Max(0, position.Y - radius), maxZ = (int)Math.Min(mHeight - 1, position.Y + radius);
            int minX = (int)Math.Max(0, position.X - radius), maxX = (int)Math.Min(mWidth - 1, position.X + radius);

            for (int pass = 0; pass < numPasses; ++pass)
            {
                for (int zIndex = minZ; zIndex <= maxZ; ++zIndex)
                {
                    for (int xIndex = minX; xIndex <= maxX; ++xIndex)
                    {
                        Vector2 displacement = new Vector2(xIndex, zIndex) - position;

                        if (mIsBlock || displacement.LengthSquared() < radiusSquared)
                        {
                            float featherScale = mIsFeathered ? mIsBlock ? Math.Max(0.0f, (float)Math.Log(radius * 2.0f - displacement.Length())) / radius : Math.Max(0.0f, (float)Math.Log(radius - displacement.Length())) / radius : 1.0f;
                            modifyVertex(xIndex, zIndex, magnitude * featherScale, pass);

                            WriteDirtyBit(xIndex, zIndex);
                        }
                    }
                }
            }

            UpdateNormalVectors(minZ, maxZ, minX, maxX);
            UpdateVertexBuffers();
        }
示例#16
0
 void EnqueueCloudNotification(ModifyAction action, object value)
 {
 }
示例#17
0
        public TerrainHeightMap(Texture2D heightMap, int numChunksHorizontal, int numChunksVertical, GraphicsDevice device)
        {
            mDevice = device;

            mHeight = heightMap.Height;
            mWidth = heightMap.Width;

            mVertices = new VertexPositionColorTextureNormal[mHeight * mWidth];

            mEdgeVertices = new VertexPositionColorTextureNormal[2 * mWidth + 2 * mHeight];

            double[] numQuads = new double[2] { mHeight - 1, mWidth - 1 };
            double[] numChunks = new double[2] { numChunksVertical, numChunksHorizontal };

            int[] numQuadsPerChunk = new int[2];
            for (int dimension = 0; dimension < 2; ++dimension)
            {
                // Maximize number of quads per chunk.
                numQuadsPerChunk[dimension] = (int)Math.Ceiling(numQuads[dimension] / numChunks[dimension]);

                // Trim excess chunks.
                numChunks[dimension] = Math.Ceiling(numQuads[dimension] / numQuadsPerChunk[dimension]);
            }

            mChunkHeight = numQuadsPerChunk[0] + 1;
            mChunkWidth  = numQuadsPerChunk[1] + 1;

            mNumChunksVertical   = (int)numChunks[0];
            mNumChunksHorizontal = (int)numChunks[1];

            mVertexBuffers = new VertexBuffer[mNumChunksVertical, mNumChunksHorizontal];
            mIndexBuffers  = new IndexBuffer [mNumChunksVertical, mNumChunksHorizontal];

            mDirtyChunks = new bool[mNumChunksVertical, mNumChunksHorizontal];

            mEdgeVertexBuffers = new VertexBuffer[4];
            mEdgeIndexBuffers = new IndexBuffer[4];

            mEdgeDirtyChunks = new bool[4];

            mChunkLookupTable = new List<Tuple<int, int>>[mHeight, mWidth];

            InitializeVertices(heightMap);

            UpdateNormalVectors(0, mHeight - 1, 0, mWidth - 1);

            InitializeBuffers();

            mCurrentAction = new ModifyAction();
        }
示例#18
0
 void EnqueueCloudNotification(ModifyAction action, object value)
 {
     //if (IsManaged())
     //    CommandQueue.Enqueue(AppCommands.SyncStatusUpdate, this, ExecutionTrigger.Connection, value, action);
 }
示例#19
0
 void EnqueueCloudNotification(ModifyAction action, object value)
 {
 }
示例#20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VolumeTriggerParameters"/> class for creating a new trigger from an existing <see cref="TriggerType.Volume"/> <see cref="NotificationTrigger"/>.
        /// </summary>
        /// <param name="objectId">The object ID the trigger will apply to.</param>
        /// <param name="sourceTrigger">The notification trigger whose properties should be used.</param>
        /// <param name="action">Whether these parameters will create a new trigger or edit an existing one.</param>
        public VolumeTriggerParameters(int objectId, NotificationTrigger sourceTrigger, ModifyAction action) : base(TriggerType.Volume, objectId, sourceTrigger, action)
        {
            if (action == ModifyAction.Add)
            {
                Channel = sourceTrigger.Channel;
                Period  = sourceTrigger.Period;

                if (sourceTrigger.UnitSize == null)
                {
                    UnitSize = null;
                }
                else
                {
                    UnitSize = sourceTrigger.UnitSize.ToString().ToEnum <TriggerVolumeUnitSize>();
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="StateTriggerParameters"/> class for creating a new trigger from an existing <see cref="TriggerType.State"/> <see cref="NotificationTrigger"/>.
 /// </summary>
 /// <param name="objectId">The object ID the trigger will apply to.</param>
 /// <param name="sourceTrigger">The notification trigger whose properties should be used.</param>
 /// <param name="action">Whether these parameters will create a new trigger or edit an existing one.</param>
 public StateTriggerParameters(int objectId, NotificationTrigger sourceTrigger, ModifyAction action) : base(TriggerType.State, objectId, sourceTrigger, action)
 {
     if (action == ModifyAction.Add)
     {
         OffNotificationAction        = sourceTrigger.OffNotificationAction;
         EscalationNotificationAction = sourceTrigger.EscalationNotificationAction;
         Latency           = sourceTrigger.Latency;
         EscalationLatency = sourceTrigger.EscalationLatency;
         RepeatInterval    = sourceTrigger.RepeatInterval;
         State             = sourceTrigger.StateTrigger;
     }
 }
示例#22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangeTriggerParameters"/> class for creating a new trigger from an existing <see cref="TriggerType.Change"/> <see cref="NotificationTrigger"/>.
 /// </summary>
 /// <param name="objectId">The object ID the trigger will apply to.</param>
 /// <param name="sourceTrigger">The notification trigger whose properties should be used.</param>
 /// <param name="action">Whether these parameters will create a new trigger or edit an existing one.</param>
 public ChangeTriggerParameters(int objectId, NotificationTrigger sourceTrigger, ModifyAction action) : base(TriggerType.Change, objectId, sourceTrigger, action)
 {
 }
示例#23
0
        public void Undo()
        {
            if (mUndoStack.Count == 0)
            {
                return;
            }

            if (mCurrentAction.Heights == null)
            {
                BackupVertices();
            }

            mRedoStack.Push(mCurrentAction);

            mCurrentAction = mUndoStack.Pop();

            RestoreVertices();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TriggerParameters"/> class for creating a new <see cref="NotificationTrigger"/> from an existing one.
        /// </summary>
        /// <param name="type">The type of notification trigger these parameters will manipulate.</param>
        /// <param name="objectId">The ID of the object the notification trigger will apply to.</param>
        /// <param name="sourceTrigger">The notification trigger whose properties should be used as the basis of this trigger.</param>
        /// <param name="action">Whether these parameters will create a new trigger or edit an existing one.</param>
        protected TriggerParameters(TriggerType type, int objectId, NotificationTrigger sourceTrigger, ModifyAction action) : this(type, objectId, action == ModifyAction.Edit ? sourceTrigger.SubId : (int?)null, action)
        {
            if (sourceTrigger == null)
            {
                throw new ArgumentNullException(nameof(sourceTrigger));
            }

            if (sourceTrigger.Type != type)
            {
                throw new ArgumentException($"A NotificationTrigger of type '{sourceTrigger.Type}' cannot be used to initialize trigger parameters of type '{type}'");
            }

            if (action == ModifyAction.Add)
            {
                OnNotificationAction = sourceTrigger.OnNotificationAction;
            }
        }