I have two custom activity(CodeActivity) classes that derived from CodeActivity. One activity is placed on the TFS build process template(xaml). This CodeActivity is calling my other custom CodeActivity using WorkflowInvoker.Invoke method. When I call the second CodeActivity, it's being called under different CodeActivityContext. Why is that? For that reason, when I write message into second CodeActivity's Context, its not shown in build process. Is there any way to call the second codeActivity under my first CodeActivity's CodeActivityContext? My Second CodeActivity also calls another custom CodeActivity. I want to call all of them in the same CodeActivityContext. How can I do that?
Can anybody help me please?
NOTE: All of my CodeActivity is derived from one base class of CodeActivity.
Isn't it possible to derive from NativeActivity? Then you can use the ScheduleAction method from the NativeActivityContext. That's what we did for our custom activities that had to invoke other activities (child activities that where dropped onto this activity).
Related
Background - a library should execute some user defined methods inside an isloate.
Passing an object to an isolate is impossible by design.
I tried to create a dart class by refelction (mirros) and its name. Some static methods are annotated and the code can pickup the right method inside the isolate. This works only if all code resides in one file. By sperating the code like alibrary the isolate is impossible to find the user class. Any idea?
I am Java developer - the java thread model is so easy. Ok, there some pitfalls - but the Dart isolate model is so restricted.
So I am writing an ASP.NET Core MVC application where users should be able to upload an Excel file, when a file gets uploaded I need to read the uploaded file an create a Model of the data inside the file.
I am currently creating this model in my Controller method but this made my method quite long.
My current solution is creating a class inside my Controller which deals with creating a model from an Excel file but I feel like this is the wrong way to do it.
So my question is: What is the right place to put the code that reads my excel file and puts it inside a model?
You should create a new .NET Standard library and create there the class that builds the model.
The recommended way is to use the class as an implementation and an interface (IExcelModelBuilder) that exposes all the public methods of that class (ExcelModelBuilder). This way you can inject this service into your controller constructor and, as a bonus, you can easily unit test it too.
You can read more about Dependency Injection in .NET Core.
You can register the service in your startup file:
// This method gets called by the runtime.
// Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
{...}
services.AddTransient<IExcelModelBuilder, ExcelModelBuilder>();
}
Step 1:Create a new .NET Standard library (Services)
Step 2:Add the reference into the mvc application of that library.
Step 3:Step two create a class that will be dealing with all the stuff like that if you have a limited number of tasks to perform ,
but if you want to separate it and wants a generic solution then Create an Interface (IUpload) and then implement all its methods in a class (Upload).also register the service in your startup file:
I've this two lines on all the action() in the controller so I want to move it to init() so it will get called each time. It doesn't work so I tried __construct and it won't work as it says "PHP Fatal error: Uncaught Error: Call to a member function get() on null"
Maybe that can be done in factory and you still call getServiceLocator in factory class? If I can do it within controller that will be even better as that's less step to do and is that possible to do it in controller so every action will have that?
$view_helper = $this->getServiceLocator()->get('viewhelpermanager');
$view_helper->get('headScript')->appendFile(....);
Only two solutions exist:
You can do an abstract controller, and use the viewhelpermanager as dependency in your constructor. This means you will need to pass the viewhelpermanager in all the subclasses factories and not forget to call the parent construct and so on when creating the object.
You can use a delegator in the service manager and an abstract controller that contains a setViewHelperManager method and a viewhelpermanager (or worst, a trait :) and a ViewHelperManagerAwareInterface and an initializer), and do a "soft dependency", but that's a wrong way to do things in terms of maintenance (code readability).
Why don't you write your own view helper and make that include the js file(s). You can then use this in all the view.phtml files that require these files. If you need to change/add/remove js files then just do this in your view helper, obviously this change will reflect in all your views that use it.
This keeps the view stuff away from your controller.
Hope this helps.
I am a newbie to Grails and still learning the ropes! The application that i work on uses services.
My task is to add a new method in one of the services and have it get called from clients.
This new method is going to be pretty long and i don't want all the method body to be in the service class.
I would like to add another method in a place other than this service to do all the calculations for this new method.
Which is the best place to add a method like that? Should i add a new domain? Or just a controller class?
I don't want any of the information in the new method to be saved to database.
A sample code look like this:
class MyService {
String getDomainName(String ID) {
return domainNameGenerator(ID);
}
}
Now i want to put the domainNameGenerator method into another place.
Place your standalone code in src/groovy or src/java depending on the actual language of your code, but there's nothing wrong with putting code in the service class itself. If the new class and the service package is the same, you don't even have to add an import.
In IDEA 14 how do you stop base methods from showing up in the UI for an extended class?
As you can see in the image below (grails project) I have extended the Register Controller. While my class only has a register and verifyRegistration method, the UI lists all of the methods of the base class. If I double-click on one of the other methods (for example: forgotPassword) IDEA will open that method in the base class (in this case by opening the groovy file contained in the spring-security-ui plugin). Unless you are very careful you are likely to inadvertently edit the base method (ex: register) rather than your extended version.
Is there some way to stop IDEA from doing this? Ideally I should only see the actual methods (register, verifyRegistration) in the tree view to the left.
Thanks,