I want to create an ext.js store that can be shared across c# projects. I defined my store in the Services project under Scripts/Store/Hierarchies.js. The store is named NCS.store.Hierarchies.
Ext.define('NCS.store.Hierarchies', {
requires: [
'Ext.data.proxy.Proxy',
'Ext.data.Operation',
'Ext.data.reader.Json',
'NCS.store.SelectedHierarchies'
],
In a different c# project I now want to reference this store-
Ext.widget({
id: 'hierarchyPanel',
xtype: 'panel',
border: true,
frame: true,
title: 'Hierarchy Selector',
layout: {
type: 'hbox',
pack: 'start',
align: 'stretch'
},
collapsible: true,
items: NCS.store.Hierarchies.getComboArray().concat(
Ext.create('Ext.Button', {
id: 'hierarchyClear',
text: 'Clear'
})),
renderTo: this.constants.hierarchiesId,
listeners: {
show: {
fn: function (t, o) {
t.doLayout();
}
}
}
});
How do I properly reference this store? Currently I'm getting a not found error (it's looking in the current c# project url instead of the one that actually contains the store).
> GET
> http://localhost/Orchard/NCS.Reporting.PODS/NCS/store/Hierarchies.js?_dc=1405085182757
> 404 (Not Found)
I think it should be looking
http://localhost/Orchard/NCS.Services.PODS/NCS/store/Hierarchies.js?_dc=1405085182757
Also since it's looking under NCS/store I'm wondering if I need to change the folder layout to match my naming convention.
I would consider mapping the folder where the scripts are stored as a virtual directory in IIS so that the web server can serve them in response to web requests.
You can use the ExtJs Loader object -
// load up all of our dependencies
Ext.Loader.setConfig({
enabled: true,
paths: {
'NCS': Config.RootUrl + 'Modules/NCS.Services.PODS/Scripts'
}
});
I need to specify where to find NCS for ExtJS to locate the correct file. Now that I have the NCS path loaded I can use the code above to reference NCS.store.Hierarchies.
Related
I am planning to use Playwright .NET to perform automated UI testing in a C# dotnet project. The issue is that I would like to have global configuration that can be set rather than needing to define the same settings repeatedly in the context of each test, but I cannot seem to find any working examples.
The documentation at playwright.dev implies that I should be able to simply include a "playwright.config.js" file at the root of the project, but no clear definition of what the content of that file should be. I have experimented with the example provided for Playwright Node.js, using:
import { PlaywrightTestConfig } from '#playwright/test';
const config: PlaywrightTestConfig = {
use: {
// Browser options
headless: false,
slowMo: 50,
// Context options
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
// Artifacts
screenshot: 'only-on-failure',
//video: 'retry-with-video',
},
outputDir: "C:\\stuff\\screenshots",
preserverOutput: 'always',
quiet: false,
};
export default config;
However, these settings do not seem to be applied and there is no indication that the playwright.config.js file is either loading or failing.
Any help or a simple example to get me pointed in the right direction would be much appreciated.
LaunchAsync expects a BrowserTypeLaunchOptions class. You could have that object serialized in a JSON file, parse it and pass that options instance as an argument.
I'm building a self-host application in C# using Service Stack. I'd like the application to share content based on some configuration data.
During AppHost.Configure I'd like to read-in a configuration file and recursively share several directories. The directories may be local or shared folders depending on each element in the configuration.
For example, if my config looks like this:
[
{
"sourceId": "TEST1",
"contentPath": "\\\\nas01\\files"
},
{
"sourceId": "TEST2",
"contentPath": "d:\\files"
}
]
I'd like the directories to be recursively accessible like this:
http://localhost/TEST1/....
http://localhost/TEST2/....
Reading the config file is no problem, really, I just want to know the right way to map these directories so I can use the built-in static handling capabilities of ServiceStack.
So I guess my question is:
What's the right way, in Service Stack, to map a static content directory at run-time?
Many thanks!
-Z
New support for FileSystem Mapping was added in this commit which will now let you register file system mappings by overriding GetVirtualFileSources() in your AppHost, e.g:
public override List<IVirtualPathProvider> GetVirtualFileSources()
{
var existingProviders = base.GetVirtualFileSources();
existingProviders.Add(new FileSystemMapping(this, "TEST1", "\\\\nas01\\files"));
existingProviders.Add(new FileSystemMapping(this, "TEST2", "d:\\files"));
return existingProviders;
}
This change is available from v4.5.5+ that's now available on MyGet.
I'm using the .NET Client Libraries for VSTS/TFS 2015 to programmatically create a build definition based off of a template that I've grabbed in another team project.
I can get a build definition template (2.0) by using:
BuildDefinitionTemplate builddeftemplate = buildHttpClient.GetTemplateAsync(teamProject, templateId).Result;
And I can create a build definition by using:
BuildDefinition builddef = new BuildDefinition();
builddef.Project = newTeamProject;
But there doesn't look like a way to pass in a template as a property of the build definition, nor create a build definition from the template.
When looking at the documentation for the REST API, the GET request actually looks like it returns a lot of JSON:
{
"id": "vsBuild",
"name": "Visual Studio",
"canDelete": false,
"category": "Build",
"iconTaskId": "71a9a2d3-a98a-4caa-96ab-affca411ecda",
"description": "Build and run tests using Visual Studio. This template requires that Visual Studio be installed on the build agent.",
"template": {
"build": [
{
"enabled": true,
"continueOnError": false,
"alwaysRun": false,
"task": {
"id": "71a9a2d3-a98a-4caa-96ab-affca411ecda",
"versionSpec": "*"
},
"inputs": {
"solution": "**\\*.sln",
"msbuildLocation": "",
"vsLocation": "",
"msbuildArgs": "",
"platform": "$(BuildPlatform)",
"configuration": "$(BuildConfiguration)",
"clean": "false"
}
},
...
So I think that it might be possible to only grab parts of the returned template as a JSON object and pass through a POST of the build definition with those parts, but it seems like that would have to solely be the REST API route.
Is this possible with the .NET Client Libraries? Or is there an easier way that I might have missed?
There isn't a way to pass in a template as a property of the build definition. However, there's another way to achieve it. You can clone/import/export build definition between team projects through .net libraries.
var cred = new VssCredentials(new WindowsCredential(new NetworkCredential(username, password)));
var buildClient = new BuildHttpClient(new Uri(collectionURL, UriKind.Absolute), cred);
var buildDef = (await buildClient.GetDefinitionAsync(sourceProj, buildDefId)) as BuildDefinition;
buildDef.Project = null;
buildDef.Name += "_clone";
await buildClient.CreateDefinitionAsync(buildDef, targetProj);
From above code you can authenticate to the team server and retreive the build definition object from the source project by the providing project name and the build definition id.
And then you need to remove the reference to the project. Since build definition contains a reference to the project it would not be possible to import it into a different project. Finally create a new build definition in target project providing the definition objecte retreived from previous project.
Next step is to export the build definition to a file so we can latter import it. By using a json serializer to serialize the build definition and save it to a file.
var buildDef = (await buildClient.GetDefinitionAsync(project, buildDefId)) as BuildDefinition;
buildDef.Project = null;
File.WriteAllText(filePath, JsonConvert.SerializeObject(buildDef));
Finally add a import method, more details please refer this link
if (!File.Exists(filePath))
throw new FileNotFoundException("File does not exist!", filePath);
Console.WriteLine($"Importing build definition from file '{filePath}' to '{project}' project.");
var buildDef = JsonConvert.DeserializeObject<BuildDefinition>(File.ReadAllText(filePath));
buildDef.Name = newBuildName;
await buildClient.CreateDefinitionAsync(buildDef, project);
I'd like to create an Azure Function that is triggered when a new message is added to a topic/subscription.
For the moment I've created an Azure Function using the ServiceBusQueueTrigger C# Template and I've set the Queue Name to
topicPath + "/Subscriptions/" + subscriptionName
But I've got this exception:
Microsoft.ServiceBus: Cannot get entity 'topic-test/Subscriptions/subscription-test' because it is not of type QueueDescription. Check that you are using method(s) with the correct entity type. System.Runtime.Serialization: Error in line 1 position 1762. Expecting element 'QueueDescription' from namespace 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'.. Encountered 'None' with name '', namespace ''. .
I thought the Azure Function was using the MessagingFactory.CreateMessageReceiver to initialize the message pump but not.
Is there any support for topic/subscription for the moment ?
Yes topics are supported, but our UI and templates are behind on that unfortunately - we'll be releasing some updates soon addressing these issues.
For now, you can use the Advanced Editor to edit your trigger binding directly. There you can specify your subscriptionName and topicName values. Here's an example:
{
"bindings": [
{
"type": "serviceBusTrigger",
"name": "message",
"direction": "in",
"subscriptionName": "subscription-test",
"topicName": "topic-test",
}
]
}
In general, since Azure Functions is build atop the WebJobs SDK, our various bindings are mapped directly to their SDK counterparts. For example serviceBusTrigger maps to ServiceBusTriggerAttribute which has SubscriptionName/TopicName properties. Therefore, expect to see the same properties in the Function metadata model.
I've been working on converting my ElasticSearch (ES) 0.9 code to work with ES 1.0. This has required an upgrade of NEST to the latest pre-release version.
I've been trying to bulk index a set of child documents. I've set up their mapping as:
"stocks": {
"_parent": {
"type": "products"
},
"_timestamp": {
"enabled": true
},
"properties": {
"id": {
"type": "integer",
"index": "not_analyzed"
},
"stock": {
"type": "integer",
"index": "not_analyzed"
}
}
}
This was created in ES 0.9. When I've put this into ES 1.0, it automatically adds a Routing property with 'Required' set to 'true'. A search on Google suggests that this was always required to enable a parent-child document setup but the property never explicitly appeared when I examined the documents in my 0.9 shard.
"Ok..." I think to myself. Next, I have the following code block for NEST:
var bulkParams = postQueue.Select(p => new BulkParameters<Stock>(p) { Parent = p.id.ToString()});
IElasticsearchResponse c = ec.IndexMany(bulkParams, null, "stocks").ConnectionStatus;
This returns a NullReferenceException. After some guesswork I added the Id parameter into the BulkParameters:
var bulkParams = postQueue.Select(p => new BulkParameters<Stock>(p) { Id = p.id.ToString(), Parent = p.id.ToString()});
Which seems to work, but the request returns a error response from ES:
400 Bad Request with JSON error message:
error=RoutingMissingException[routing is required for [test_index]/[stocks]/[xx]]
(where xx is the id of the document)
I'm assuming I have to insert a Routing string somewhere, but I do not know where. I've tried adding a 'Routing' parameter into the BulkParameters but that did not work at all. Can anyone please advise?
The support for IndexMany() with wrapped BulkParameters has been removed in NEST 1.0.0 beta 1
If you want to use a bulk with more advanced parameters you now have to use the Bulk() command.
The beta sadly still shipped with the BulkParameters class in the assembly
This has since been removed in the develop branch and will be released in the next beta update.
So what happens now is that you are actually indexing "bulkparameters``1``" type documents and not "stock" with proper individual bulk metadata set.
See here for an example on how to use Bulk() to index many objects at once while configuring advanced parameters for individual items.