Exemplo n.º 1
0
        /// <summary>
        /// Method to populate the fist column attribute combobox with list of string attributes
        /// </summary>
        /// <param name="entityLogicalName"></param>
        private void PopulateFirstAttributeList(string entityLogicalName)
        {
            WorkAsync(new WorkAsyncInfo
            {
                // Showing message until background work is completed
                Message = "Retrieving Attributes Information",

                // Main task which will be executed asynchronously
                Work = (worker, args) =>
                {
                    var crmHelper           = new CrmHelper(Service);
                    var pluginControlHelper = new PluginControlHelper();
                    var attributeList       = crmHelper.GetAttributeListFromEntity(entityLogicalName);
                    args.Result             = pluginControlHelper.GetStringAttributes(attributeList);
                },

                // Work is completed, results can be shown to user
                PostWorkCallBack = (args) =>
                {
                    if (args.Error != null)
                    {
                        MessageBox.Show(args.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    // Binding result data to ListBox Control
                    var result = args.Result as List <AttributeMetadata>;
                    selectUniqueAttributeComboBox.Items.Clear();
                    foreach (var attributeMetadata in result)
                    {
                        selectUniqueAttributeComboBox.Items.Add(attributeMetadata);
                    }
                }
            });
        }