示例#1
0
        /// <summary>
        /// Process loading of file in CRM, this method responsible to read the lines of files and process further.
        /// </summary>
        /// <param name="stringBuilder"></param>
        private void ProcessLoadFile(ref StringBuilder stringBuilder)
        {
            string[] lines = File.ReadAllLines(fileNameTextBox.Text);
            stringBuilder.AppendLine("Start reading the file");
            var lineCount = lines.Count();

            stringBuilder.AppendLine($"No of lines in the file : {lineCount}");
            if (lineCount == 0)
            {
                stringBuilder.AppendLine("File is empty, no lines to prcoess");
            }
            if (lineCount > 1000)
            {
                stringBuilder.AppendLine($"There are more than 1000 lines in the file, only first 1000 will be processed");
                lines = lines.Take(1000).ToArray();
            }
            if (lineCount > 0)
            {
                var delimeter           = delimeterTextBox.Text;
                var pluginControlHelper = new PluginControlHelper();
                var keyValuePairs       = pluginControlHelper.CreateDictionaryListForLoad(lines, delimeter, ref stringBuilder);
                if (keyValuePairs.Count > 0)
                {
                    ProcessLoadInCrm(keyValuePairs, ref stringBuilder);
                }
            }
        }
示例#2
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);
                    }
                }
            });
        }