private void addItem(string content) { var item = new WorkItemInfo(); item.WorkerType = "TEST1"; item.SetParam("TestProperty", "Test"); getClient().SendWorkItem(item); }
/// <summary> /// Queue a work item /// </summary> /// <param name="workItemInfo">Work item information</param> /// <param name="callback">A callback to execute</param> /// <param name="state"> /// The context object of the work item. Used for passing arguments to the work item. /// </param> /// <returns>Returns a work item result</returns> public IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { PreQueueWorkItem(); WorkItem workItem = WorkItemFactory.CreateWorkItem(this, WIGStartInfo, workItemInfo, callback, state); Enqueue(workItem); return(workItem.GetWorkItemResult()); }
/// <summary> /// Queue a work item /// </summary> /// <param name = "workItemInfo">Work item information</param> /// <param name = "callback">A callback to execute</param> /// <param name = "state"> /// The context object of the work item. Used for passing arguments to the work item. /// </param> /// <returns>Returns a work item result</returns> public IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { WorkItem workItem = WorkItemFactory.CreateWorkItem(this, _workItemsGroupStartInfo, workItemInfo, callback, state); EnqueueToSTPNextWorkItem(workItem); return(workItem.GetWorkItemResult()); }
public WorkItemInfo(WorkItemInfo workItemInfo) { UseCallerCallContext = workItemInfo.UseCallerCallContext; DisposeOfStateObjects = workItemInfo.DisposeOfStateObjects; CallToPostExecute = workItemInfo.CallToPostExecute; PostExecuteWorkItemCallback = workItemInfo.PostExecuteWorkItemCallback; Timeout = workItemInfo.Timeout; }
protected override FeatureDTO CreateEntityDTO(WorkItemInfo workItem) { FeatureDTO featureDto = base.CreateEntityDTO(workItem); featureDto.ProjectName = workItem.TpProjectName; featureDto.ProjectID = workItem.TpProjectId; return(featureDto); }
public WorkItemInfo(WorkItemInfo workItemInfo) { UseCallerCallContext = workItemInfo.UseCallerCallContext; UseCallerHttpContext = workItemInfo.UseCallerHttpContext; DisposeOfStateObjects = workItemInfo.DisposeOfStateObjects; CallToPostExecute = workItemInfo.CallToPostExecute; PostExecuteWorkItemCallback = workItemInfo.PostExecuteWorkItemCallback; WorkItemPriority = workItemInfo.WorkItemPriority; }
protected override RequestDTO CreateEntityDTO(WorkItemInfo workItem) { RequestDTO requestDto = base.CreateEntityDTO(workItem); requestDto.ProjectName = workItem.TpProjectName; requestDto.ProjectID = workItem.TpProjectId; return(requestDto); }
public WorkItemInfo(WorkItemInfo workItemInfo) { UseCallerCallContext = workItemInfo.UseCallerCallContext; UseCallerHttpContext = workItemInfo.UseCallerHttpContext; DisposeOfStateObjects = workItemInfo.DisposeOfStateObjects; PostExecuteWorkItemCallback = workItemInfo.PostExecuteWorkItemCallback; WorkItemPriority = workItemInfo.WorkItemPriority; Timeout = workItemInfo.Timeout; }
protected override BugDTO CreateEntityDTO(WorkItemInfo workItem) { BugDTO bugDto = base.CreateEntityDTO(workItem); bugDto.ProjectName = workItem.TpProjectName; bugDto.ProjectID = workItem.TpProjectId; return(bugDto); }
/// <summary> /// Initialize the callback holding object. /// </summary> /// <param name="workItemsGroup">The workItemGroup of the workitem</param> /// <param name="workItemInfo">The WorkItemInfo of te workitem</param> /// <param name="callback">Callback delegate for the callback.</param> /// <param name="state">State with which to call the callback delegate.</param> /// /// We assume that the WorkItem object is created within the thread /// that meant to run the callback public WorkItem(IWorkItemsGroup workItemsGroup, WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { _workItemsGroup = workItemsGroup; _workItemInfo = workItemInfo; _callback = callback; _state = state; _workItemResult = new WorkItemResult(this); Initialize(); }
public WorkItemInfo(WorkItemInfo workItemInfo) { _useCallerCallContext = workItemInfo._useCallerCallContext; _useCallerHttpContext = workItemInfo._useCallerHttpContext; _disposeOfStateObjects = workItemInfo._disposeOfStateObjects; _callToPostExecute = workItemInfo._callToPostExecute; _postExecuteWorkItemCallback = workItemInfo._postExecuteWorkItemCallback; _workItemPriority = workItemInfo._workItemPriority; }
protected override UserStoryDTO CreateEntityDTO(WorkItemInfo workItem) { UserStoryDTO userStoryDto = base.CreateEntityDTO(workItem); userStoryDto.ProjectName = workItem.TpProjectName; userStoryDto.ProjectID = workItem.TpProjectId; return(userStoryDto); }
public void Azure_SendAndGet_SQSWorkItem() { addItem("Test"); WorkItemInfo item = getNextItem(); Assert.IsNotNull(item); Assert.IsNotNull(item.ExtraParams); Assert.AreEqual(item.GetParamOrDefault("TestProperty"), "Test"); }
public WorkItemInfo(WorkItemInfo workItemInfo) { _useCallerCallContext = workItemInfo._useCallerCallContext; _useCallerHttpContext = workItemInfo._useCallerHttpContext; _disposeOfStateObjects = workItemInfo._disposeOfStateObjects; _callToPostExecute = workItemInfo._callToPostExecute; _postExecuteWorkItemCallback = workItemInfo._postExecuteWorkItemCallback; _workItemPriority = workItemInfo._workItemPriority; }
/// <summary> /// Create a new work item /// </summary> /// <param name="workItemsGroup">The WorkItemsGroup of this workitem</param> /// <param name="wigStartInfo">Work item group start information</param> /// <param name="workItemInfo">Work item info</param> /// <param name="callback">A callback to execute</param> /// <returns>Returns a work item</returns> public static WorkItem CreateWorkItem(IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemInfo workItemInfo, WorkItemCallback callback) { return(CreateWorkItem( workItemsGroup, wigStartInfo, workItemInfo, callback, null)); }
private void InitFields( TDto tpEntityDto, WorkItemInfo workItem, Dictionary <string, WorkItemsFieldsMapper.NamesPair[]> fieldsMapping) { foreach (var mapping in fieldsMapping) { InitField(tpEntityDto, workItem, mapping); } }
protected virtual TDto CreateEntityDTO(WorkItemInfo workItem) { var tpEntityDto = new TDto(); var mapping = WorkItemsFieldsMapper.Instance.GetMappingForWorkItemType(workItem.WorkItemType); InitFields(tpEntityDto, workItem, mapping); return(tpEntityDto); }
/// <summary> /// Utility method to assert that a work item is in /// the right step and map after we've processed it. /// </summary> /// <param name="item">Item.</param> /// <param name="map">name of map</param> /// <param name="step">name of step</param> public static void AssertRightPlaces(WorkItemInfo item , String map , String step ) { Assert.IsNotNull(item); Console.WriteLine(item.StepName + " vs " + step); Assert.AreEqual(item.StepName, step); Assert.AreEqual(item.MapName, map); }
//IWorkItemResult QueueWorkItem(WorkItemCallback callback); public static void TestQueueWorkItemCall(IWorkItemsGroup wig) { WorkItemInfo wii = new WorkItemInfo(); WorkItemInfoComparer wiic = new WorkItemInfoComparer(wii); IWorkItemResult wir = wig.QueueWorkItem(wiic.CompareWorkItemInfo); bool success = (bool)wir.Result; Assert.IsTrue(success); }
//IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state); public static void TestQueueWorkItemCallStat(IWorkItemsGroup wig) { object state = new object(); WorkItemInfo wii = new WorkItemInfo(); WorkItemInfoComparer wiic = new WorkItemInfoComparer(wii, state); IWorkItemResult wir = wig.QueueWorkItem((WorkItemCallback)wiic.CompareWorkItemInfo, state); bool success = (bool)wir.Result; Assert.IsTrue(success); }
//IWorkItemResult QueueWorkItem(WorkItemCallback callback, WorkItemPriority workItemPriority); public static void TestQueueWorkItemCallPrio(IWorkItemsGroup wig) { WorkItemInfo wii = new WorkItemInfo { WorkItemPriority = WorkItemPriority.AboveNormal }; WorkItemInfoComparer wiic = new WorkItemInfoComparer(wii); IWorkItemResult wir = wig.QueueWorkItem(wiic.CompareWorkItemInfo, WorkItemPriority.AboveNormal); Assert.IsTrue((bool)wir.Result); }
public WorkItemInfo SendWorkItem(WorkItemInfo workItem) { string queueSuffix = workItem.WorkerType; string finalQueueName; AmazonSQSClient sqsClient = constructSqsClient(ConfigurationManager.AppSettings[AWSSQSConfigOptions.AWSQueueURL], queueSuffix, out finalQueueName); JObject jObj = JObject.FromObject(workItem); var resTask = sqsClient.SendMessageAsync(finalQueueName, jObj.ToString()); resTask.Wait(); workItem.SetParam("MessageId", resTask.Result.MessageId); return(workItem); }
private DatabaseChange Change(XElement xChange, DatabaseChanges changes) { var xLastChangeType = xChange.Element("ChangeTypes").Elements().LastOrDefault(); //var lastChangeType = ChangeTypes.None; //if (null != xLastChangeType) //lastChangeType = (ChangeTypes)Enum.Parse(typeof(ChangeTypes), xLastChangeType.Value); var filename = Path.Combine(changes.RootDatabaseFolder, xChange.Element("FilePath").Value); var fileType = this.KnownFileTypes.GetTypeForFilenameExt(filename); var ext = fileType.GetFileExtensionForFile(filename); // Type is set via Extension // File is set via Filename var change = new DatabaseChange { Schema = xChange.Attribute("Schema").Value, Filename = filename, //FilePath = filename.Replace(changes.RootDatabaseFolder, string.Empty), FilePath = xChange.Element("FilePath").Value, Extension = ext, FirstChanged = DateTime.Parse(xChange.Element("FirstChanged").Value), LastChanged = DateTime.Parse(xChange.Element("LastChanged").Value), IsAttachment = Convert.ToBoolean(xChange.Element("IsAttachment").Value), IsManualAdd = Convert.ToBoolean(xChange.Element("IsManualAdd").Value) }; var xServerItem = xChange.Element("ServerItem"); if (null != xServerItem) { change.ServerItem = xServerItem.Value; } var xChangeTypes = xChange.Element("ChangeTypes"); xChangeTypes.Elements().ToList().ForEach(x => change.AddChangeType((ChangeTypes)Enum.Parse(typeof(ChangeTypes), x.Value))); var xTasks = xChange.Element("Tasks"); xTasks.Elements().ToList().ForEach(xTask => { var taskInfo = new WorkItemInfo { AssignedTo = xTask.Attribute("AssignedTo").Value, Id = Convert.ToInt32(xTask.Attribute("Id").Value), State = xTask.Attribute("State").Value, Title = xTask.Attribute("Title").Value }; change.AddTask(taskInfo); }); return(change); }
/// <summary> /// Create a new work item /// </summary> /// <param name = "wigStartInfo">Work item group start information</param> /// <param name = "workItemInfo">Work item info</param> /// <param name = "callback">A callback to execute</param> /// <returns>Returns a work item</returns> public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemInfo workItemInfo, WorkItemCallback callback) { return CreateWorkItem( workItemsGroup, wigStartInfo, workItemInfo, callback, null); }
public void DeleteWorkItem(WorkItemInfo workItem) { if (!waitingItems.ContainsKey(workItem.Key)) { return; } getWaitingItems(workItem.WorkerType) .TryRemove(workItem.Key , out Tuple <DateTime, WorkItemInfo> temp); refreshWaitingItems(); }
public WorkItem(IWorkItemsGroup workItemsGroup, WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { this._workItemsGroup = workItemsGroup; this._workItemInfo = workItemInfo; if (this._workItemInfo.UseCallerCallContext || this._workItemInfo.UseCallerHttpContext) { this._callerContext = CallerThreadContext.Capture(this._workItemInfo.UseCallerCallContext, this._workItemInfo.UseCallerHttpContext); } this._callback = callback; this._state = state; this._workItemResult = new WorkItem.WorkItemResult(this); this.Initialize(); }
public void ReleaseWorkItem(WorkItemInfo workItem) { string queueSuffix = workItem.WorkerType; string finalQueueName; AmazonSQSClient sqsClient = constructSqsClient(ConfigurationManager.AppSettings[AWSSQSConfigOptions.AWSQueueURL], queueSuffix, out finalQueueName); var resTask = sqsClient.ChangeMessageVisibilityAsync(finalQueueName, workItem.GetParamOrDefault("ReceiptHandle"), 1); resTask.Wait(); if (resTask.Result.HttpStatusCode != System.Net.HttpStatusCode.OK) { throw new InvalidOperationException("The item was not correctly deleted, error code=" + resTask.Result.HttpStatusCode, resTask.Exception); } }
private bool CompareWorkItemInfo(WorkItemInfo wii1, WorkItemInfo wii2) { bool equal = true; equal = equal && (wii1.CallToPostExecute == wii2.CallToPostExecute); equal = equal && (wii1.DisposeOfStateObjects == wii2.DisposeOfStateObjects); equal = equal && (wii1.PostExecuteWorkItemCallback == wii2.PostExecuteWorkItemCallback); equal = equal && (wii1.UseCallerCallContext == wii2.UseCallerCallContext); equal = equal && (wii1.UseCallerHttpContext == wii2.UseCallerHttpContext); equal = equal && (wii1.WorkItemPriority == wii2.WorkItemPriority); return(equal); }
//IWorkItemResult QueueWorkItem(WorkItemCallback callback, WorkItemPriority workItemPriority); public static void TestQueueWorkItemCallPrio(IWorkItemsGroup wig) { WorkItemInfo wii = new WorkItemInfo(); wii.WorkItemPriority = WorkItemPriority.AboveNormal; WorkItemInfoComparer wiic = new WorkItemInfoComparer(wii); IWorkItemResult wir = wig.QueueWorkItem((WorkItemCallback)wiic.CompareWorkItemInfo, WorkItemPriority.AboveNormal); bool success = (bool)wir.Result; Assert.IsTrue(success); }
//IWorkItemResult QueueWorkItem(WorkItemCallback callback, object state, WorkItemPriority workItemPriority); public static void TestQueueWorkItemCallStatPrio(IWorkItemsGroup wig) { object state = new object(); WorkItemInfo wii = new WorkItemInfo(); wii.WorkItemPriority = WorkItemPriority.AboveNormal; WorkItemInfoComparer wiic = new WorkItemInfoComparer(wii, state); IWorkItemResult wir = wig.QueueWorkItem(wiic.CompareWorkItemInfo, state, WorkItemPriority.AboveNormal); bool success = (bool)wir.Result; Assert.IsTrue(success); }
private static bool IsFieldsEqual(WorkItemInfo workItem, WorkItemInfo workItemChanged, string field) { PropertyInfo workItemPropertyInfo = typeof(WorkItemInfo).GetProperty(field); if (workItemPropertyInfo == null) { throw new Exception("Wrong fields mapping."); } var workItemValue = workItemPropertyInfo.GetValue(workItem, null) as string; var changedValue = workItemPropertyInfo.GetValue(workItemChanged, null) as string; return(workItemValue == changedValue); }
private static bool IsItemChanged(WorkItemInfo workItem, WorkItemInfo workItemChanged) { if (!IsFieldsEqual(workItem, workItemChanged, "Title")) { return(true); } if (!IsFieldsEqual(workItem, workItemChanged, "Description")) { return(true); } return(false); }
/// <summary> /// 队列 /// </summary> /// <param name="callBack"></param> /// <param name="userstate"></param> public ThreadEx QueueWorkItem(WaitCallback callBack, object userstate) { WorkItemInfo info = new WorkItemInfo(); info.AutoResetEvent = new AutoResetEvent(false); handlerStack.Add(info.AutoResetEvent); info.WaitCallback = callBack; info.UserState = userstate; ThreadPool.QueueUserWorkItem((state) => { WorkItemInfo workItemInfo = (WorkItemInfo)state; try { workItemInfo.WaitCallback(workItemInfo.UserState); } finally { workItemInfo.AutoResetEvent.Set(); } }, info); return this; }
private void chkListWorkItems_SelectedIndexChanged(object sender, EventArgs e) { int wi = ExtractWorkItemFromDescription(((CheckedListBox)sender).SelectedItem.ToString()); WorkItemInfo wiAzDo = WorkitemInfoHandler.GetDataForWorkItem(wi); lstDebugInfoOnWorkItem.Items.Clear(); if (wiAzDo != null) { lstDebugInfoOnWorkItem.Items.Add(wiAzDo.Id); lstDebugInfoOnWorkItem.Items.Add(wiAzDo.Title); lstDebugInfoOnWorkItem.Items.Add(wiAzDo.Description); lstDebugInfoOnWorkItem.Items.Add(wiAzDo.State); } }
/// <summary> /// Create a new work item /// </summary> /// <param name="wigStartInfo">Work item group start information</param> /// <param name="callback">A callback to execute</param> /// <param name="state"> /// The context object of the work item. Used for passing arguments to the work item. /// </param> /// <returns>Returns a work item</returns> public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemCallback callback, object state) { ValidateCallback(callback); var workItemInfo = new WorkItemInfo(); workItemInfo.UseCallerCallContext = wigStartInfo.UseCallerCallContext; workItemInfo.UseCallerHttpContext = wigStartInfo.UseCallerHttpContext; workItemInfo.PostExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback; workItemInfo.CallToPostExecute = wigStartInfo.CallToPostExecute; workItemInfo.DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects; var workItem = new WorkItem( workItemsGroup, workItemInfo, callback, state); return workItem; }
/// <summary> /// Create a new work item /// </summary> /// <param name = "wigStartInfo">Work item group start information</param> /// <param name = "callback">A callback to execute</param> /// <param name = "state"> /// The context object of the work item. Used for passing arguments to the work item. /// </param> /// <param name = "postExecuteWorkItemCallback"> /// A delegate to call after the callback completion /// </param> /// <param name = "callToPostExecute">Indicates on which cases to call to the post execute callback</param> /// <param name = "workItemPriority">The work item priority</param> /// <returns>Returns a work item</returns> public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemCallback callback, object state, PostExecuteWorkItemCallback postExecuteWorkItemCallback, CallToPostExecute callToPostExecute, WorkItemPriority workItemPriority) { ValidateCallback(callback); ValidateCallback(postExecuteWorkItemCallback); WorkItemInfo workItemInfo = new WorkItemInfo { UseCallerCallContext = wigStartInfo.UseCallerCallContext, UseCallerHttpContext = wigStartInfo.UseCallerHttpContext, PostExecuteWorkItemCallback = postExecuteWorkItemCallback, CallToPostExecute = callToPostExecute, WorkItemPriority = workItemPriority, DisposeOfStateObjects = wigStartInfo.DisposeOfStateObjects }; WorkItem workItem = new WorkItem( workItemsGroup, workItemInfo, callback, state); return workItem; }
/// <summary> /// Create a new work item /// </summary> /// <param name = "wigStartInfo">Work item group start information</param> /// <param name = "workItemInfo">Work item information</param> /// <param name = "callback">A callback to execute</param> /// <param name = "state"> /// The context object of the work item. Used for passing arguments to the work item. /// </param> /// <returns>Returns a work item</returns> public static WorkItem CreateWorkItem( IWorkItemsGroup workItemsGroup, WIGStartInfo wigStartInfo, WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { ValidateCallback(callback); ValidateCallback(workItemInfo.PostExecuteWorkItemCallback); WorkItem workItem = new WorkItem( workItemsGroup, new WorkItemInfo(workItemInfo), callback, state); return workItem; }
/// <summary> /// Queue a work item /// </summary> /// <param name="workItemInfo">Work item information</param> /// <param name="callback">A callback to execute</param> /// <param name="state"> /// The context object of the work item. Used for passing arguments to the work item. /// </param> /// <returns>Returns a work item result</returns> public IWorkItemResult QueueWorkItem(WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { WorkItem workItem = WorkItemFactory.CreateWorkItem(this, _workItemsGroupStartInfo, workItemInfo, callback, state); EnqueueToSTPNextWorkItem(workItem); return workItem.GetWorkItemResult(); }
/// <summary> /// Initialize the callback holding object. /// </summary> /// <param name="workItemsGroup"></param> /// <param name="workItemInfo"></param> /// <param name="callback">Callback delegate for the callback.</param> /// <param name="state">State with which to call the callback delegate.</param> /// /// We assume that the WorkItem object is created within the thread /// that meant to run the callback public WorkItem( IWorkItemsGroup workItemsGroup, WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { _workItemsGroup = workItemsGroup; _workItemInfo = workItemInfo; if (_workItemInfo.UseCallerCallContext || _workItemInfo.UseCallerHttpContext) { _callerContext = CallerThreadContext.Capture(_workItemInfo.UseCallerCallContext, _workItemInfo.UseCallerHttpContext); } _callback = callback; _state = state; _workItemResult = new WorkItemResult(this); Initialize(); }
/// <summary> /// Initialize the callback holding object. /// </summary> /// <param name="workItemsGroup">The workItemGroup of the workitem</param> /// <param name="workItemInfo">The WorkItemInfo of te workitem</param> /// <param name="callback">Callback delegate for the callback.</param> /// <param name="state">State with which to call the callback delegate.</param> /// /// We assume that the WorkItem object is created within the thread /// that meant to run the callback public WorkItem( IWorkItemsGroup workItemsGroup, WorkItemInfo workItemInfo, WorkItemCallback callback, object state) { _workItemsGroup = workItemsGroup; _workItemInfo = workItemInfo; #if !(_WINDOWS_CE) && !(_SILVERLIGHT) && !(WINDOWS_PHONE) if (_workItemInfo.UseCallerCallContext || _workItemInfo.UseCallerHttpContext) { _callerContext = CallerThreadContext.Capture(_workItemInfo.UseCallerCallContext, _workItemInfo.UseCallerHttpContext); } #endif _callback = callback; _state = state; _workItemResult = new WorkItemResult(this); Initialize(); }