Exemplo n.º 1
0
 private void ProcessResponse(FetchXmlAction result)
 {
     ClearTheGrid();
     SetupGridColumns(result.Attributes);
     foreach (var entity in result.Entities)
     {
         grid.Rows.Add(EnumerateEntityValues(entity, result).ToArray());
     }
     tcMain.SelectedTab = pageDatatable;
 }
Exemplo n.º 2
0
        private void ProcessFetchXmlQuery(string query)
        {
            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Fetching data...",
                AsyncArgument = query,
                IsCancelable  = true,

                Work = (bw, e) =>
                {
                    var action             = new FetchXmlAction(Service);
                    action.MessageChanged += delegate(object sender, EventArgs eventArgs)
                    {
                        if (SendMessageToStatusBar != null)
                        {
                            SendMessageToStatusBar(this, new StatusBarMessageEventArgs(
                                                       ((FetchXmlAction)sender).Message));
                        }
                    };
                    action.RunFetchXmlQuery(e.Argument.ToString());
                    e.Result = action;
                },
                PostWorkCallBack = e =>
                {
                    if (e.Error == null)
                    {
                        ProcessResponse((FetchXmlAction)e.Result);
                    }
                    else
                    {
                        MessageBox.Show(this, "An error occured: " + e.Error.Message, "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
            });
        }
Exemplo n.º 3
0
        private IEnumerable <string> EnumerateEntityValues(Entity entity, FetchXmlAction fetcher)
        {
            //foreach (string key in entity.Attributes.Keys)
            foreach (KeyValuePair <string, AttributeMetadata> a in fetcher.Attributes)
            {
                if (!entity.Contains(a.Key))
                {
                    yield return(null);

                    if (a.Value.AttributeType == AttributeTypeCode.Lookup)
                    {
                        yield return(null);
                    }
                    continue;
                }
                object value = entity[a.Key];
                yield return(fetcher.FormatObject(value, a.Key));

                if (a.Value.AttributeType == AttributeTypeCode.Lookup)
                {
                    yield return(((EntityReference)value).Name);
                }
            }
        }