Pass Data Between Custom Native Activity in WorkFlow - c#

I'm writing a workflow designer and I want to Send A Data From An Activity To Others without using Inargument on my custom activity so
I write A custom Native Activity and add a property to my context like this
context.Properties.Add("Name",Value );
and for calling the property i use this code:
var dynamicinarg = (string)context.Properties.Find("Name");
but when im Debugging it the dynamicinarg is null .
how can i fix it?

Related

WebView2, expose JavaScript API under window instead of window.chrome.webview.hostObjects

When using WebView2 it's possible to call C# methods from JavaScript on the web page by exposing a C# class in WebView2 under window.chrome.webview.hostObjects.sync.NameOfMyApiInterface.
Where you can name the NameOfMyApiInterface what ever you like using:
this.MyWebView2Control.CoreWebView2.AddHostObjectToScript("NameOfMyApiInterface", this);
But I've seen those using other 3rd party Chromium browser plugins putting their API directly under window, like window.NameOfMyApiInterface.
Is this possible using WebView2?
Yes. Although calls to CoreWebView2.AddHostObjectToScript will create proxy objects in script on chrome.webview.hostObjects, you can copy those objects wherever you like. You can make a property on window and have it point to the same proxy object.
For example, if you have an object NameOfMyApiInterface that has a property named Property with value "Example":
console.log(chrome.webview.hostObjects.sync.NameOfMyApiInterface.Property); // 'Example'
window.NameOfMyApiInterface = chrome.webview.hostObjects.sync.NameOfMyApiInterface;
console.log(window.NameOfMyApiInterface.Property); // 'Example'
If you call CoreWebView2.AddHostObjectToScript before navigating to the page that will use NameOfMyApiInterface, you can update that page to do the assignment at the top before other script runs. Or if you don't own or can't update the page, you can use CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync to add the line of script that does the assignment to run before any other script in that page.

DevExpress MVVM - Shared ViewModel & EventToCommand

I'm using DevExpress to add MVVM to my WinForms application. I have a form that contains a ViewModel, which is given to all of its user controls via constructor parameter.
DataBindings are working fine, but I want to add functionality to a ribbonbar by adding EventToCommand behaviour to the usercontrols toolbar item (BarButtonItem).
I do my bindings like this:
MVVMContext context = new MVVMContext();
context.ViewModelType = typeof(MyViewModel);
context.WithEvent<MyViewModel, EventArgs>(cmdA, "ItemClick")
.EventToCommand(x => x.SomeMethod());
context.WithEvent<MyViewModel, EventArgs>(cmdB, "ItemClick")
.EventToCommand(x => x.SomeOtherMethod());
context.SetViewModel(typeof(MyViewModel), viewModel);
viewModel is an instance of MyViewModel that contains the data and is received in the user controls constructor from the form.
However, when running the application, both buttons work but seem to bind to a separate instance of MyViewModel. How can I use the instance that I already have? Thanks!
Since you have passed the ViewModel instance from the external binding context you should set up your MVVMContext as follows:
// View(UserControl) side:
MVVMContext context = new MVVMContext();
// make sure that the MVVMContext will be destroyed when the UserControl destroyed
context.ContainerControl = this; // your View(UserControl)
context.SetViewModel(typeof(MyViewModel), viewModel);
This way prevent the automatic creation of the MyViewModel instance (the automatic creation is used when the context.ViewModelType is specified).
Then you can use the MVVMContext API as usual.
In your case, you can use the BindCommand instead of EventToCommand because of it specially designed to work with button-objects(like a BarButtonItems).
And, I strongly recommend you use the Fluent API which provides very clean and maintainable code:
var fluent = context.OfType<MyViewModel>();
fluent.BindCommand(cmdA, x => x.SomeMethod());
fluent.BindCommand(cmdB, x => x.SomeOtherMethod());

Trigger Plugin or Workflow when marketing list member has been removed

Im using Marketinglists in Dynamics CRM 2013 with MemberTyp Contact.
When I remove one of these contacts, I want to trigger a workflow and/or plugin which is doing some logic - is this possible?
I guess I need the event which is fired when I remove a contact from the MarketingList.
I tried to develop a plugin with Post-Operation, Update on the Marketinglist entity, but I couldnt find a way how to get the specific contactc guid, which has been removed.
Does someone have an idea?
You need to register a Plugin step on the Disassociate message. This is not registered to a specific entity and will fire anytime a disassociation event occurs.
Then in the plugin code you write should check to see if the relationship being disassociated is the one you are interested in (you can look this information up in CRM's metadata/system customizer):
if (context.InputParameters.Contains(“Relationship”)) {
relationshipName = context.InputParameters[“Relationship”].ToString();
}
// Check the “Relationship Name” with your intended one
if (relationshipName != “{YOUR RELATION NAME}”) {
return;
}
For more details, include the source of the code: https://rajeevpentyala.wordpress.com/2013/04/17/associatedisassociate-plugin-messages-in-crm/

Set InArgument when launching a workflow programmatically

Is there any way to set the value of a workflow's InArgument parameter from another workflow when launching it programmatically ?
Here's how I launch it:
var req = new ExecuteWorkflowRequest { WorkflowId = new Guid(WorkflowGuids.RenewalWorkflowId), EntityId = theContact.Id };
service.Execute(req);
I can catch the EntityId value back in the other workflow in context.PrimaryEntityId but I am at a loss as to how to populated the arguments and retrieve them on the other side.
Is this possible ? Thanks.
InArgument are defined at step level, not at workflow level.
When a workflow is executed (by a trigger, on-demand or by code) you have the record Id.
You can create a custom workflow activity to fetch other data related (or not connected at all) with your record Id and make it as OutArgument so will be available as input for the InArgument you want to set.

Xamarin/Mvvmcross: Open a different view controller when a iOS push notification is received

I have found this question asked using Objective-c but I am unable to translate it into C#
e.g.
open-specific-view-when-opening-app-from-notification
Basically I want to do this:
public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo)
{
string alert = (aps[new NSString("alert")] as NSString).ToString();
Debug.WriteLine ("I want to open a specific ViewController and pass in my alert");
}
I am actually using mvvmcross to manage my View navigation. So ideally I want to somehow implement this navigation using mvvmcross. In mvvmcross I would navigate to my ViewControler by doing this:
this.ShowViewModel<SpecificControllerViewModel>();
Thanks
if you look to the parameters of ShowViewModel(), it has a way to pass values to the view-model
this is described here along with examples
You can achieve that in few ways.
You could use a custom message. A view-model can register to receive the message and you send it from the ReceivedRemoteNotification Read here about messenger in MvvmCross.
Or, you can call ShowViewModel. If you look to how ShowViewModel is implemented here, it uses a IMvxViewDispatcher singleton service, so you could have the following utility method:
static void ShowViewModel<T>(object parameter) where T : IMvxViewModel
{
var viewDispatcher = Mvx.Resolve<IMvxViewDispatcher>();
var request = MvxViewModelRequest.GetDefaultRequest(typeof(T));
request.ParameterValues = ((object)parameter).ToSimplePropertyDictionary();
viewDispatcher.ShowViewModel(request);
}
I posted about this on my blog here.
I think the 2nd way can work even in the case when the notification is received when app is not running (received by FinishedLaunching)

Categories

Resources