I need create a workqueue in guidewire, but not find guidewire documentation about this.
Someone can help me please?
Regards,
Douglas Rezende
You need several things:
Make a new Typecode in BatchProcessType typekey (For example MyNewCode). Additionally you need add categories: Schedulable, UIRunnable or APIRunnable according to your need.
Make a new class that extends WorkQueueBase like this
class MyWorkQueue extends WorkQueueBase<Message, StandardWorkItem> {
private final static var _batchProcessType = BatchProcessType.TC_MYNEWCODE
construct() {
super(_batchProcessType, StandardWorkItem, Message)
}
override function findTargets(): Iterator<Message> {
return Query.make(Message).select().iterator()
}
override function processWorkItem(p0: StandardWorkItem) {
var bean = extractTarget(p0)
// My process
}
}
Register the new class in work-queue.xml. You can search in the documentation additional parameters like retryLimit, retryInterval, server, env, maxpollinterval, etc.
<work-queue workQueueClass="example.MyWorkQueue" progressinterval="600000">
<worker instances="1" batchsize="5" />
</work-queue>
Register the new BatchProcessType in scheduler-config.xml (Optional). For it works correctly the typecode needs the Schedulable category (first step)
<ProcessSchedule process="MyNewCode">
<CronSchedule minutes="*/10" />
</ProcessSchedule>
Related
For those familiar with automated testing tools, you know that they all have some kind of "object repository" that stores a mapping of UI elements with identifiers. I have found this to be indispensible and I want to duplicate this for webdriver. Has anyone done this ? Any tips ? Google not helping on this one. C# examples if you can, thanks
I use Webinator (which wraps around WebDriver) but the idea is the same - I usually do a static "Map" class like so:
public static class CollectionMap
{
public static Locator
LocatorTitle = new Locator(FindBy.Id, "Title"),
LocatorDescription = new Locator(FindBy.Id, "Description"),
LocatorSave = new Locator(FindBy.Id, "submit"),
LocatorDelete = new Locator(FindBy.XPath, "//*[contains(#class,'deleteBox')]/a"),
LocatorDeleteConfirm = new Locator(FindBy.Id, "delete-collection-dialogConfirmationLink"),
LocatorCancel = new Locator(FindBy.Id, "cancel");
}
Used like this:
web.Click(CollectionMap.LocatorSave, WaitUntil.AjaxOrPostCompleted());
I am creating multiple classes containing mappings to locators. Each class corresponds to a logical grouping of screen elements.
public class TopLevel
{
public const string username = "ctl00_ctl00_Main_Main_txtUsername";
}
I am trying to build a test against some legacy method that implement out parameters.
Could you give me an example how to do this?
Just assign the out or ref parameter from the test.
Given this interface:
public interface ILegacy
{
bool Foo(out string bar);
}
You can write a test like this:
[TestMethod]
public void Test13()
{
string bar = "ploeh";
var legacyStub = new Mock<ILegacy>();
legacyStub.Setup(l => l.Foo(out bar))
.Returns(true);
Assert.IsTrue(legacyStub.Object.Foo(out bar));
Assert.AreEqual("ploeh", bar);
}
Anything wrong with the second example at the top of https://github.com/moq/moq4/wiki/Quickstart ? You really should be giving examples of what you're trying to do if you're not going to look for things like this.
Incidentally if you want to use moq (currently) to mock the out parameter too you'll also have to do the following hoop jump. Lets say that you wanted to mock an out parameter that returned another mocked object e.g.
var mockServiceA = new Mock<IMyService>();
var mockServiceOutput = new Mock<IMyServiceOutput>();
// This will not work...
mockServiceA.Setup(svc => svc.DoSomething(out mockServiceOutput.Object));
// To have this work you have to do the following
IMyServiceOutput castOutput = mockServiceOutput.Object;
mockServiceA.Setup(svc => svc.DoSomething(out castOutput));
I'm generating emails based off embedded NVelocity templates and would like to do something with dynamically included sections. So my embedded resources are something like this:
DigestMail.vm
_Document.vm
_ActionItem.vm
_Event.vm
My email routine will get a list of objects and will pass each of these along with the proper view to DigestMail.vm:
public struct ItemAndView
{
public string View;
public object Item;
}
private void GenerateWeeklyEmail(INewItems[] newestItems)
{
IList<ItemAndView> itemAndViews = new List<ItemAndView>();
foreach (var item in newestItems)
{
itemAndViews.Add(new ItemAndView
{
View = string.Format("MyAssembly.MailTemplates._{0}.vm", item.GetType().Name),
Item = item
});
}
var context = new Dictionary<string, object>();
context["Recipient"] = _user;
context["Items"] = itemAndViews;
string mailBody = _templater.Merge("MyAssembly.MailTemplates.DigestMail.vm", context);
}
And in my DigestMail.vm template I've got something like this:
#foreach($Item in $Items)
====================================================================
#parse($Item.viewname)
#end
But it's unable to #parse when given the path to an embedded resource like this. Is there any way I can tell it to parse each of these embedded templates?
Hey Jake, is .viewname a property? I'm not seeing you setting it in your code, how about you use the following:
#foreach($Item in $Items)
====================================================================
$Item.viewname
#end
I don't know why you're parsing the $Item.viename rather than just using the above? I'm suggesting this as I've just never needed to parse anything!
Please refer to this post where we've discussed the generation of templates.
Hope this helps!
I'm trying to use a System.Windows.Forms.DataGrid control in my Compact Framework 3.5 Window Mobile Professional 6 SDK based project to show some properties of objects of type Something by binding the DataGrid to a List<SomethingWrapper> instance like this:
public class SomethingWrapper {
private Something data;
public SomethingWrapper(Something data) { this.data = data; }
public string Column1 { get { /* string from this.data */ } }
public string Column2 { get { /* string from this.data */ } }
}
public class SomethingList : List<SomethingWrapper> {
public SomethingList(IEnumerable<Something> items) {
foreach (var item in items) Add(new SomethingWrapper(item));
Sort((a, b) => a.Column2.CompareTo(b.Column2);
}
}
/* ... */
IEnumerable<Something> dataToShow = /* assume this is filled correctly */
SomethingDataGrid.DataSource = new SomethingList(dataToShow);
This seems to work fine: the correct data is shown in the grid with two columns called Column1 and Column2 and sorted on the second column. I want this to be a readonly view of this data, so all is fine.
However, I would like to set column widths and cannot seem to get this to work...
Have tried to obvious: creating TableStyle, creating textbox column style instance per column, adding it to the TableStyle and setting SomethingDataGrid.TableStyle to resulting table style. (This is from memory, or I would also show the exact code I'm using. If needed, I can add that to the question somewhere later today.)
Nothing changes however. I suspect this has something to do with the MappingName on the TableStyle object; all examples I could find yesterday evening seem to be for databinding a DataSet to the DataGrid and setting MappingName to the correct table name in the DataSet. Otherwise, the table style will not do what you expect, which is the behavior I'm seeing.
Question: am I looking in the correct place for a solution to my problem, and if so, what do I need to set TableStyle.MappingName to when binding to a List<T> to show properties of T...?
(Tried to check for possible duplicates, but was unable to find exact matches. Please correct me if I turn out to be wrong there.)
Ah, didn't look well enough after all: duplicate question found. Will try deriving from BindingList<T> and/or using a binding source so I can start calling BindingSource.GetListName(null) to get a MappingName. Hope this will help. If not, I'll be back...
You can do this by creating a DataGridTableStyle
Here is an extension method that I use:
public static void SetColumnStyles<T>(this DataGrid ctrl, T data, params ColumnStyle[] column) where T: class
{
var ts = new DataGridTableStyle();
ts.MappingName = data.GetType().Name;
foreach (var style in column)
{
ts.GridColumnStyles.AddColumn(style.Header, style.Column, style.Width);
}
ctrl.TableStyles.Clear();
ctrl.TableStyles.Add(ts);
}
Then I call it like this:
var newList = queriableData.ToList();
ProductEdit.DataSource = newList;
ProductEdit.SetColumnStyles(newList, new[]
{
new ColumnStyle("Name", 200),
new ColumnStyle("Manufacturer", 100),
new ColumnStyle("Size", 20)
});
where newList is a generic list of objects.
I want to bind a List to a GridView on a web page, but override the way the property names display via annotation. I thought System.ComponentModel would work, but this doesn't seem to work. Is this only meant for Windows Forms?:
using System.ComponentModel;
namespace MyWebApp
{
public class MyCustomClass
{
[DisplayName("My Column")]
public string MyFirstProperty
{
get { return "value"; }
}
public MyCustomClass() {}
}
Then on the page:
protected void Page_Load(object sender, EventArgs e)
{
IList<MyCustomClass> myCustomClasses = new List<MyCustomClass>
{
new MyCustomClass(),
new MyCustomClass()
};
TestGrid.DataSource = myCustomClasses;
TestGrid.DataBind();
}
This renders with "MyFirstProperty" as the column header rather than "My Column." Isn't this supposed to work?
When using .net 4 or later you can use gridview1.enabledynamicdata(typeof(mytype)). I haven't looked at all the types you can use there but I know the [displayname("somename")] works well but the [browsable(false)] doesn't omit the column from the grid. It looks like a knit one slip one from MS. at least you can easily rename column names and to omit a column I just declare a variable instead of using a property. It has the same effect...
Just by the way, using the designer to create columns is the easy way out but to just show a different column name takes way to much time especially with classes with many fields.
What SirDemon said...
The answer appears to be no, you can't. At least not out of the box.
The System.Web.UI.WebControls.GridView uses reflected property's name:
protected virtual AutoGeneratedField CreateAutoGeneratedColumn(AutoGeneratedFieldProperties fieldProperties)
{
AutoGeneratedField field = new AutoGeneratedField(fieldProperties.DataField);
string name = fieldProperties.Name; //the name comes from a PropertyDescriptor
((IStateManager) field).TrackViewState();
field.HeaderText = name; //<- here's reflected property name
field.SortExpression = name;
field.ReadOnly = fieldProperties.IsReadOnly;
field.DataType = fieldProperties.Type;
return field;
}
While System.Windows.Forms.DataGridView uses DisplayName if available:
public DataGridViewColumn[] GetCollectionOfBoundDataGridViewColumns()
{
...
ArrayList list = new ArrayList();
//props is a collection of PropertyDescriptors
for (int i = 0; i < this.props.Count; i++)
{
if (...)
{
DataGridViewColumn dataGridViewColumnFromType = GetDataGridViewColumnFromType(this.props[i].PropertyType);
...
dataGridViewColumnFromType.Name = this.props[i].Name;
dataGridViewColumnFromType.HeaderText = !string.IsNullOrEmpty(this.props[i].DisplayName) ? this.props[i].DisplayName : this.props[i].Name;
}
}
DataGridViewColumn[] array = new DataGridViewColumn[list.Count];
list.CopyTo(array);
return array;
}
Unfortunately, while you can override the CreateAutoGeneratedColumn, neither the missing DisplayName nor underlying property descriptor gets passed, and you can't override CreateAutoGeneratedColumns (although you could CreateColumns).
This means you'd have to iterate over reflected properties yourself and in some other place.
If all you care about is the header text in GridView, just use the HeaderText property of each field you bind. If you're autogenerating the columns, you just set the HeaderText after you've bound the GridView.
If you want a GridView that takes into account some attribute you placed on the properties of your bound class, I believe you'll need to create your own GridView.
I may be wrong, but I've not seen any ASP.NET Grid from control vendors (at least Telerik , Janus Systems and Infragistics) do that. If you do it, maybe sell the idea to them.
Are you using .net4, what you need to do is to set enabledynamicdata on the grid view to true.
You can do it now on asp.net mvc2. It works just like that