Esempio n. 1
0
 public void SearchUser(string accountName, Action<List<bCheckV2.Helpers.Definitions.User>> reply)
 {
     bCheckV2.Helpers.Definitions.User user = new bCheckV2.Helpers.Definitions.User();
     var request = new RestRequest("SearchUser/" , Method.GET);
     request.AddParameter("accountName", accountName);
     request.UseDefaultCredentials = true;
     client.ExecuteAsync(request, (response) =>
     {
         if (response.ResponseStatus == ResponseStatus.Error)
         {
             int i = 1;
             reply(null);
         }
         else
         {
             var result = JsonConvert.DeserializeObject<List<bCheckV2.Helpers.Definitions.User>>(response.Content);
             reply(result);
         }
     });
 }
Esempio n. 2
0
        List<bCheckV2.Helpers.Definitions.User> ConvertStringToResolvedList(string sData, bool userEntered)
        {
            var newUsers = new List<bCheckV2.Helpers.Definitions.User>();

            if (sData == null)
                sData = "";

            // Check to see if the string data is in the sharepoint format, if it is then break that down
            // and setup the usernames and ids
            string[] spDelims = { SpDelim };
            char[] commaDelims = {','};
            char[] semiDelims = { ';' };

            if (!string.IsNullOrEmpty(sData))
            {
                // Split all the data, if there's more than one item there its found that the user details are in sharepoint
                // format, ie. two items make up 1 user though, the ID first then the username
                string[] aUsers = sData.Split(spDelims, StringSplitOptions.RemoveEmptyEntries);
                   
                if (aUsers.Count() > 1)
                {
                    try
                    {
                        // switch between taking the ID and the username.
                        bool bId = true;
                        int currentId = -1;
                        foreach (string stringBit in aUsers)
                        {
                            // if its time to take the ID store it.
                            if (bId)
                                currentId = Convert.ToInt32(stringBit);
                            else
                            {
                                // if its time to take the username, build the phone ResolveUserInfo object
                                var rUserInfo = new bCheckV2.Helpers.Definitions.User ();
                                var userInfo = new bCheckV2.Helpers.Definitions.User { UserLoginID = stringBit.Trim()};
                                //if (Constants.AlwaysCheckUsers && userEntered)
                                //{
                                //    rUserInfo.UserStatus = ResolveUserInfo.UserStatuss.Waiting;
                                //    rUserInfo.User = userInfo;
                                //    _dataHandlerUser.CheckUser(userInfo, CheckUserDelegate);
                                //}
                                //else
                                //{
                                //    rUserInfo.UserStatus = ResolveUserInfo.UserStatuss.Resolved;
                                //    rUserInfo.User = _dataHandlerUser.AddResolvedUser(userInfo);
                                //}
                                newUsers.Add(rUserInfo);

                            }

                            bId = !bId;
                        }
                    }
                    catch (Exception)
                    {
                        MessageDialog.ShowMessage("You appear to be copying over usernames in the sharepoint format. An error has occured during the paste process. Please ensure the string is in the correct format and try again.");
                    }

                }
                else if (sData.Contains(":"))
                {
                    try
                    {
                        aUsers = sData.Split(semiDelims);
                        foreach (string stringBit in aUsers)
                        {
                            string trimString = stringBit.Trim();
                            var rUserInfo = new bCheckV2.Helpers.Definitions.User();
                            var userInfo = new bCheckV2.Helpers.Definitions.User {UserLoginID = trimString};
                            rUserInfo = userInfo;
                            //_dataHandlerUser.CheckUser(userInfo, CheckUserDelegate);
                            newUsers.Add(rUserInfo);
                        }
                    }
                    catch (Exception)
                    {
                        MessageDialog.ShowMessage("You appear to be copying over usernames in the Active Directory. An error has occured during the paste process. Please ensure all user names are correct seperated with a ';' and try again.");
                    }
                }
                else // otherwise assume its in a comma seperated format and process that.
                {
                    try
                    {
                        aUsers = sData.Split(commaDelims);
                        foreach (string stringBit in aUsers)
                        {
                            string trimString = stringBit.Trim();
                            var rUserInfo = new bCheckV2.Helpers.Definitions.User();
                            var userInfo = new bCheckV2.Helpers.Definitions.User();



                            // Swap them round so that its surname, firstname
                            if (trimString.IndexOf(" ", StringComparison.Ordinal) == -1)
                                userInfo.UserLoginID = trimString;
                            else
                                userInfo.UserLoginID = trimString.Substring(trimString.IndexOf(" ", System.StringComparison.Ordinal) + 1) + ", " + trimString.Substring(0, trimString.IndexOf(" ", System.StringComparison.Ordinal));
                            rUserInfo = userInfo;
                            //_dataHandlerUser.CheckUser(userInfo, CheckUserDelegate);
                            newUsers.Add(rUserInfo);
                        }
                    }
                    catch (Exception)
                    {
                        MessageDialog.ShowMessage("You appear to be copying over usernames. An error has occured during the paste process. Please ensure all user names are correct seperated with a ',' and try again.");
                    
                    }
                }
            }
            if (newUsers.Count == 0)
                return null;
            return newUsers;
        }