예제 #1
0
        private void _worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                App.Current.Dispatcher.Invoke(() => // <--- HERE
                {
                    Logs.Instance.Info("try to fetch sharepoint list columns");

                    IsColumnLoading = true;
                    foreach (SpList spList in GetSupportedLists.Where(x => x.IsChecked))
                    {
                        ClientContextSp clientContext = _connect.GetClientContextSp;
                        // clientContext.Credentials;// new NetworkCredential(txtUsername.Text.Trim(), txtPasssword.Password.Trim(), txtDomain.Text.Trim());

                        List oList = clientContext.Web.Lists.GetById(spList.Id);


                        var fields = oList.Fields;
                        clientContext.Load(oList);

                        clientContext.Load(fields);

                        clientContext.ExecuteQuery();
                        spList.Columns.Clear();
                        foreach (Field item in fields)
                        {
                            if (item.TypeAsString.IsValidTypeToConvert())
                            {
                                spList.Columns.Add(new Column //(null, true)
                                {
                                    DefaultValue       = item.DefaultValue,
                                    DisplayName        = item.TypeDisplayName,
                                    InternalName       = item.InternalName,
                                    Type               = item.TypeAsString,
                                    EnforceUniqueValue = item.EnforceUniqueValues,
                                    Required           = item.Required,
                                    Title              = item.Title
                                });
                            }
                            //Console.WriteLine(
                            //    "TypeAsString: {0} , Title: {1} ,  DefaultValue: {2} ,  Required: {3} , EnforceUniqueValues:{4}",
                            //    item.TypeAsString, item.Title, item.DefaultValue, item.Required, item.EnforceUniqueValues);
                        }
                    }
                    Logs.Instance.Info("end fetching SPList columns");
                });
            }
            catch (Exception ex)
            {
                _worker.CancelAsync();
                Logs.Instance.Error(ex);
            }
            finally
            {
                IsColumnLoading = false;
            }
        }
예제 #2
0
        public override bool Next()
        {
            if (!ExistList.Any(x => x.IsChecked && x.IsSupport))
            {
                _mainViewModel.ShowMessage("Please select any supported list types.");
                return(false);
            }

            GetSupportedLists.Clear();

            foreach (var spList in ExistList.Where(x => x.IsSupport && x.IsChecked))
            {
                foreach (Column column in spList.Columns)
                {
                    column.IsChecked = false;
                }
                GetSupportedLists.Add(spList);
            }
            this.BindColumns();

            return(base.Next());
        }
예제 #3
0
 public override bool Prev()
 {
     GetSupportedLists.Clear();
     ExistList.Clear();
     return(base.Prev());
 }
예제 #4
0
 public bool IsAnyColumnSelected()
 {
     return(GetSupportedLists.Any(x => x.Columns.Any(c => c.IsChecked)));
 }