c# - 什么是 CCA 中托管应用程序的应用程序适配器?

标签 c# winforms winapi crm

我是 Microsoft CRM CCA 的新手。目前我面临一些问题。 我创建了一个 winform 并将其托管在我的 Agent Desktop 中。 winform 应该在 winform 的文本区域中显示记事本的内容。如何实现呢?我完全不知道,因为关于这个主题的文档不多。 .....Plz 帮帮我。

最佳答案

这里是完整的代码

using System;
using Microsoft.Uii.Csr;

namespace Microsoft.Uii.QuickStarts
{
    public partial class QsHostedControl : HostedControl
    {
        public QsHostedControl()
        {
            InitializeComponent();
        }

        // Necessary constructor
        public QsHostedControl(Guid appID, string appName, string initString)
            : base(appID, appName, initString)
        {
            InitializeComponent();
        }

        private void QSHostedControl_Load(object sender, EventArgs e) {}

        // This is the context change event handler.
        public override void NotifyContextChange(Context context)
        {
            // This is the context change handler.

            // Populating text fields from context information.
            txtFirstName.Text = context["CustomerFirstName"];
            txtLastName.Text = context["CustomerLastName"];
            txtAddress.Text = context["Street"];
            txtID.Text = context["CustomerID"];

            // Hands control back over to the base class to notify next app of context change.
            base.NotifyContextChange(context);
        }

        protected override void DoAction(RequestActionEventArgs args)
        {
            //Check the action name to see if it's something we know how to handle and perform appropriate work
            switch (args.Action)
            {
                case "UpdateFirstName":
                    txtFirstName.Text = args.Data;
                    break;

                case "UpdateLastName":
                    txtLastName.Text = args.Data;
                    break;                  

            }
        }

        private void updateData_Click(object sender, EventArgs e)
        {
            // This is how you fire an action to other hosted applications. Your DoAction() code
            // in your other application or application adapter will get called via this.
            FireRequestAction(new RequestActionEventArgs("QSExternalApplication", "UpdateFirstName", txtFirstName.Text));
            FireRequestAction(new RequestActionEventArgs("QSExternalApplication", "UpdateLastName", txtLastName.Text));

            FireRequestAction(new RequestActionEventArgs("QSWebApplication", "UpdateFirstName", txtFirstName.Text));
            FireRequestAction(new RequestActionEventArgs("QSWebApplication", "UpdateLastName", txtLastName.Text));
            FireRequestAction(new RequestActionEventArgs("QSWebApplication", "UpdateAddress", txtAddress.Text));
            FireRequestAction(new RequestActionEventArgs("QSWebApplication", "UpdateID", txtID.Text));
        }

        private void btnFireContextChange_Click(object sender, EventArgs e)
        {
            // Get the current context and create a new context object from it.
            string temp = Context.GetContext();
            Context updatedContext = new Context(temp);

            // Update the new context with the changed information.
            updatedContext["CustomerFirstName"] = txtFirstName.Text;
            updatedContext["CustomerLastName"] = txtLastName.Text;

            // Notify everyone of this new context information
            FireChangeContext(new ContextEventArgs(updatedContext));
            // Tell self about this change
            NotifyContextChange(updatedContext);

        }
    }
}

你也可以在sdk中找到它

关于c# - 什么是 CCA 中托管应用程序的应用程序适配器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27702849/

相关文章:

C# - 来自字节数组的 BigInteger 与来自 UInt64 的 BigInteger 产生不同的结果

c# - LINQ 到 XML : What is the most effective way to move nodes up and down

c# - 使用 System.Net.Http.HttpClient 和 MVC 提供防伪 token

c# - Windows 窗体 : add new line to label if text is too long

c++ - C++ Win32API WM_KEYDOWN和按钮

c# - Form.TopMost 有时有效

Lambda 表达式中的 C# 字符串连接

c# - 使用 Emgu CV 转换编解码器

.net - 如何在 C# 中确定面板的完整大小(包括滚动条)

c++ - 使用 WINAPI 如何更改复选框按钮的值?