예제 #1
0
 void providerResolveId_FetchUserInfoCompleteEvent(object sender, UserInfoFetchCompleteEventArgs args)
 {
     this.IsRefreshing = false;
     ViewModel.Current.Provider.FetchUserInfoCompleteEvent -= new FetchUserInfoComplete(providerResolveId_FetchUserInfoCompleteEvent);
     if (args.Error != null)
     {
         MessageBox.Show(args.Error.ToString());
         return;
     }
     if (args.HasListOfUsers == true) return;
     if (args.ResolvedUser == null)
     {
         MessageBox.Show(string.Format("Could not resolve selected user"));
         this.DialogResult = false;
     }
     else
     {
         UserInfoParam p = (UserInfoParam)this.DataContext;
         p.ResolvedUser = args.ResolvedUser;
         this.DialogResult = true;
     }
 }
예제 #2
0
 public void LongOperationToResolveUserInfo(object param)
 {
     Thread.Sleep(2000);
     UserInfo u=(UserInfo)param;
     UserInfoFetchCompleteEventArgs args = new UserInfoFetchCompleteEventArgs(null, false, null);
     args.ResolvedUser = u;
     u.UserID = 100; //dummy id
     args.HasListOfUsers = false;
     Deployment.Current.Dispatcher.BeginInvoke(delegate()
     {
         FetchUserInfoCompleteEvent(this, args);
     });
 }
예제 #3
0
 void Provider_FetchUserInfoCompleteEvent(object sender, UserInfoFetchCompleteEventArgs args)
 {
     this.IsRefreshing = false;
     ViewModel.Current.Provider.FetchUserInfoCompleteEvent -= new FetchUserInfoComplete(Provider_FetchUserInfoCompleteEvent);
     if (args.Error != null)
     {
         string message = string.Format("Error while fetching list of users. This could be due to the web server not being avaiable at this moment. Error message:{0}", args.Error.Message);
         ViewModel.Current.Status.AddToLog(message, true);
         C1.Silverlight.C1MessageBox.Show(message, Messages.title, C1.Silverlight.C1MessageBoxButton.OK, C1.Silverlight.C1MessageBoxIcon.Error);
         return;
     }
     if (args.HasListOfUsers == false) return;
     this.gridPeopleResults.ItemsSource = args.UserInfoCollection;
 }
예제 #4
0
        public void LongOperationToFetchUserInfo(object param)
        {
            Thread.Sleep(2000);
            string pattern = (string)param;
            UserInfoFetchCompleteEventArgs args = new UserInfoFetchCompleteEventArgs(null, false, null);
            args.UserInfoCollection = new List<UserInfo>();


            int count = 10;
            if (pattern.Equals("exact")) count = 1; //simulate a correct match
            if (pattern.Equals("noexact")) count = 0; //simulate a no-match
            while (count > 0)
            {
                UserInfo u = new UserInfo
                            {
                                DisplayName = string.Format ( "lastname-{0},first: Markets(LDN)",count),
                                Title = "Associate director asset allocation",
                                Department = "Ops - Global COO Team [Global Operations]",
                                AccountName = "INTRANET\\account-"+count.ToString (),
                                UserID=-1
                            };
                args.UserInfoCollection.Add(u); 
                count--;
            }

            args.HasListOfUsers = true;
            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                FetchUserInfoCompleteEvent (this, args);
            });
        }
예제 #5
0
        void wssGroups_GetGroupCollectionFromUserCompleted(object sender, BCheckUserGroups.GetGroupCollectionFromUserCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }
            XElement xresults = e.Result;
            XNamespace ns = "http://schemas.microsoft.com/sharepoint/soap/directory/";

            var query = from x in xresults.Descendants()
                        where x.Name == ns + "User"
                        select new UserInfo
                        {
                            UserID = (int?)x.Attribute("ID") ?? 0,
                            AccountName = (string)x.Attribute("LoginName"),
                            DisplayName = (string)x.Attribute("Name")
                        };

            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                var arg = new UserInfoFetchCompleteEventArgs(e.Error, e.Cancelled, e.UserState) { HasListOfUsers = true, UserInfoCollection = new List<UserInfo>() };
                foreach (UserInfo u in query) arg.UserInfoCollection.Add(u);
                FetchGroupMembershipCompleteEvent(this, arg);
            });
        }
예제 #6
0
        void peopleResolveClient_ResolvePrincipalsCompleted(
                        object sender,
                        BCheck.Data.BCheckPeople.ResolvePrincipalsCompletedEventArgs e)
        {
            UserInfoFetchCompleteEventArgs args;
            if (FetchUserInfoCompleteEvent == null) return;
            args = new UserInfoFetchCompleteEventArgs(e.Error, e.Cancelled, e.UserState);
            args.UserInfoCollection = new List<UserInfo>();
            args.HasListOfUsers = false;
            if ((e.Cancelled == true) || (e.Error != null))
            {

            }
            else
            {
                if (e.Result.Count == 0)
                {
                    args.ResolvedUser = null;
                }
                else
                {
                    UserInfo u = new UserInfo
                    {
                        Title = e.Result[0].Title,
                        UserID = e.Result[0].UserInfoID,
                        Email = e.Result[0].Email,
                        DisplayName = e.Result[0].DisplayName,
                        Department = e.Result[0].Department,
                        AccountName = e.Result[0].AccountName
                    };
                    if (u.UserID < 0)
                        args.ResolvedUser = null;
                    else
                        args.ResolvedUser = u;
                    args.HasListOfUsers = false;
                }
            }

            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                FetchUserInfoCompleteEvent(this, args);
            });
        }
예제 #7
0
        void peopleSearchClient_SearchPrincipalsCompleted(
                    object sender,
            BCheck.Data.BCheckPeople.SearchPrincipalsCompletedEventArgs e)
        {

            UserInfoFetchCompleteEventArgs args;
            if (FetchUserInfoCompleteEvent == null) return;
            args = new UserInfoFetchCompleteEventArgs(e.Error, e.Cancelled, e.UserState);
            args.UserInfoCollection = new List<UserInfo>();
            args.HasListOfUsers = false;
            if ((e.Cancelled == true) || (e.Error != null))
            {

            }
            else
            {
                foreach (BCheck.Data.BCheckPeople.PrincipalInfo p in e.Result)
                {
                    UserInfo u = new UserInfo
                    {
                        AccountName = p.AccountName,
                        Title = p.Title,
                        Department = p.Department,
                        DisplayName = p.DisplayName,
                        Email = p.Email,
                        UserID = p.UserInfoID
                    };

                    args.UserInfoCollection.Add(u);
                }
                args.HasListOfUsers = true;
            }



            Deployment.Current.Dispatcher.BeginInvoke(delegate()
            {
                System.Diagnostics.Debug.Assert(FetchUserInfoCompleteEvent != null);
                FetchUserInfoCompleteEvent(this, args);
            });
        }
예제 #8
0
 void Provider_FetchUserInfoCompleteEvent(object sender, UserInfoFetchCompleteEventArgs args)
 {
     ViewModel.Current.Provider.FetchUserInfoCompleteEvent -= Provider_FetchUserInfoCompleteEvent;
     IsRefreshing = false;
     _tmpuserParam.ResolvedUsers.Clear();
     foreach (UserInfo u in args.UserInfoCollection)
     {
         _tmpuserParam.ResolvedUsers.Add(u); 
     }
     //if too many matches are found then flag an error
     if ((_tmpuserParam.ResolvedUsers.Count == 0) || (_tmpuserParam.ResolvedUsers.Count > 1))
     {
         _tmpuserParam.ResolvedUser = null;
         _tmpuserParam.HasErrors = true;
     }
     
     if (_tmpuserParam.ResolvedUsers.Count ==1)
     {
         _tmpuserParam.ResolvedUser = _tmpuserParam.ResolvedUsers[0];
         _tmpuserParam.HasErrors = false;
     }
     _tmpuserParam = null;
 }