Ejemplo n.º 1
0
    public SectionSearchHandler()
    {
        scenesSearchHandler = new SearchHandler <ISearchInfo>(scenesSortTypes, (item) =>
        {
            bool result = true;
            if (filterContributor)
            {
                result = item.isContributor;
            }
            if (filterOperator && result)
            {
                result = item.isOperator;
            }
            if (filterOwner && result)
            {
                result = item.isOwner;
            }
            return(result);
        });

        scenesSearchHandler.OnSearchChanged += list =>
        {
            OnUpdated?.Invoke();
            OnResult?.Invoke(list);
        };
    }
Ejemplo n.º 2
0
 public void OnFailure(Java.Lang.Exception e)
 {
     OnResult?.Invoke(this, new ResultEventArgs
     {
         Result = "Inviting friend failed due to an error: " + e.Message
     });
 }
Ejemplo n.º 3
0
        private void PingCompletedCallback(object sender, PingCompletedEventArgs e)
        {
            if (!e.Reply.Address.Equals(default(IPAddress))) //Happens some times that the ip is 0 // && (e.Reply.Status == IPStatus.Success)
            {
                OnResult?.Invoke(this, e);
            }
            else
            {
                Logger.Log($"Invalid pingreply from pingObject");
            }

            var nextScanAddress = GetNext();

            if (nextScanAddress != null)
            {
                ((System.Net.NetworkInformation.Ping)sender).SendAsync(nextScanAddress, (int)TimeOut.TotalMilliseconds,
                                                                       new byte[32].Propagate((byte)'#'), _pingOptions);
            }
            else
            {
                lock (LockObject)
                {
                    _runningPingScanners--;

                    var pingCompleted = _runningPingScanners >= 0 && AddressCollectionQueue.IsEmpty;

                    if (pingCompleted)
                    {
                        OnPingFinished?.Invoke(this, new EventArgs());
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void OnEvent(Java.Lang.Object value, FirebaseFirestoreException error)
        {
            var snapshotQuery = (QuerySnapshot)value;

            if (!snapshotQuery.IsEmpty)
            {
                foreach (DocumentSnapshot snap in snapshotQuery.Documents)
                {
                    friendId = snap.Id.ToString();
                    DocumentReference documentReference =
                        FirebaseBackend.FirebaseBackend
                        .GetFireStore()
                        .Collection("invitations")
                        .Document(friendId);

                    documentReference.Update(currentUserID, true)
                    .AddOnSuccessListener(this)
                    .AddOnFailureListener(this);
                }
            }
            else
            {
                OnResult?.Invoke(this, new ResultEventArgs
                {
                    Result = "No user with such email"
                });
            }
        }
Ejemplo n.º 5
0
        private IEnumerator SendRequest()
        {
            if (repeatCount <= 0)
            {
                repeatCount = 1;
            }
            repeatCount--;

            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                HasConnection = false;
            }
            else
            {
                UnityWebRequest request = new UnityWebRequest("http://google.com")
                {
                    timeout = 10
                };
                yield return(request.SendWebRequest());

                HasConnection = request.error == null;
            }

            //IsChecked = true;

            if (HasConnection || repeatCount == 0)
            {
                CancelInvoke(nameof(StartChecking));
                IsBlocked = false;
            }

            OnResult?.Invoke(HasConnection);
            //OnResult = null;
        }
Ejemplo n.º 6
0
 public async Task GetResult(string val)
 {
     if (OnResult != null)
     {
         await OnResult.Invoke(val);
     }
 }
Ejemplo n.º 7
0
 private void Cancel()
 {
     OnResult?.Invoke(null);
     _otpListener?.Stop();
     DialogResult = false;
     Hide();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Call the registered callback when the required code length was reached.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CodeBoxChanged(object sender, EventArgs e)
 {
     if (codeBox.Text.Length >= length)
     {
         OnResult?.Invoke(codeBox.Text);
     }
 }
Ejemplo n.º 9
0
Archivo: GameHub.cs Proyecto: b-hub/RPS
        public void Fight(string id, int move)
        {
            if (id == Id1)
            {
                if (_move1.HasValue)
                {
                    throw new Exception("Player has already chosen a move");
                }
                _move1 = move;
            }
            else if (id == Id2)
            {
                if (_move2.HasValue)
                {
                    throw new Exception("Player has already chosen a move");
                }
                _move2 = move;
            }
            else
            {
                throw new Exception($"Player {id} does not belong to this game");
            }

            if (_move1.HasValue && _move2.HasValue)
            {
                var winningId = GetWinner();
                _move1 = null;
                _move2 = null;
                _results.Add(winningId);

                OnResult?.Invoke(this, playerId => GetResultFor(playerId, winningId));
            }
        }
 //Callback handler when load text success
 protected override void ReceiveResult(string text)
 {
     if (OnResult != null)
     {
         OnResult.Invoke(text);
     }
 }
Ejemplo n.º 11
0
 public void OnSuccess(Java.Lang.Object result)
 {
     OnResult?.Invoke(this, new ResultEventArgs
     {
         Result = "Invitation sent"
     });
 }
Ejemplo n.º 12
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            var currentTime = _pingStopwatch.ElapsedTicks;
            var elapsedTime = 0;

            var bytesRead = _socket.EndReceive(ar);

            if (ar.AsyncState is byte[] buffer)
            {
                var ipHeader = new IpHeader(buffer, bytesRead);
                if (ipHeader.ProtocolType == ProtocolType.Icmp && !_receivedIps.ContainsKey(ipHeader.RawSourceAddress))
                {
                    UpdateLastResult();
                    _receivedIps[ipHeader.RawSourceAddress] = true;

                    var icParsed = new IcmpPacket(ipHeader.Data, ipHeader.MessageLength);

                    if (MeasureTime)
                    {
                        // ReSharper disable once AssignNullToNotNullAttribute
                        var parsedTime = BitConverter.ToInt64(icParsed.Data.Array, icParsed.Data.Offset);
                        elapsedTime = TimeSpan.FromTicks(currentTime - parsedTime).Milliseconds;
                    }

                    var pingReplyObject =
                        TypeHelper.Construct <PingReply>(buffer, bytesRead, ipHeader.SourceAddress, elapsedTime);
                    var pingCompletedArgs =
                        TypeHelper.Construct <PingCompletedEventArgs>(pingReplyObject, new Exception(), false, this);

                    OnResult?.Invoke(this, pingCompletedArgs);
                }
            }
        }
        public UICallNeighborPanel(short callerNID, VM vm)
        {
            VM = vm;
            var nb    = Content.Get().Neighborhood;
            var neigh = nb.GetNeighborByID(callerNID);
            var rels  = neigh.Relationships.Keys;

            //var rels = nb.Neighbors.NeighbourByID.Keys;

            foreach (var to in rels)
            {
                var tn     = nb.GetNeighborByID((short)to);
                var family = tn.PersonData?.ElementAt((int)VMPersonDataVariable.TS1FamilyNumber) ?? 0;
                var gender = tn.PersonData?.ElementAt((int)VMPersonDataVariable.Gender) ?? 0; //can't call pets
                if (family != 0 && gender < 2)
                {
                    List <short> famList = null;
                    if (!NeighborsByFamilyID.TryGetValue(family, out famList))
                    {
                        famList = new List <short>();
                        NeighborsByFamilyID[family] = famList;
                    }

                    famList.Add((short)to);
                }
            }

            FamilyList             = new UITouchStringList();
            FamilyList.Size        = new Microsoft.Xna.Framework.Vector2(320, 350);
            FamilyList.BackingList = NeighborsByFamilyID.Select(x => nb.GetFamilyString((ushort)x.Key).GetString(0)).ToList();
            FamilyList.Refresh();
            FamilyList.OnSelectionChange += FamilyList_OnSelectionChange;
            Add(FamilyList);

            NeighbourList                    = new UITouchStringList();
            NeighbourList.Size               = new Microsoft.Xna.Framework.Vector2(320, 350);
            NeighbourList.Position           = new Microsoft.Xna.Framework.Vector2(370, 0);
            NeighbourList.OnSelectionChange += NeighbourList_OnSelectionChange;
            Add(NeighbourList);

            var cancelButton = new UIBigButton(false);

            cancelButton.Caption        = "Cancel";
            cancelButton.Position       = new Microsoft.Xna.Framework.Vector2(370 + 385, 135);
            cancelButton.OnButtonClick += (btn) => { OnResult?.Invoke(-1); };
            cancelButton.Width          = 275;
            Add(cancelButton);

            CallButton                = new UIBigButton(true);
            CallButton.Caption        = "Call";
            CallButton.Position       = new Microsoft.Xna.Framework.Vector2(370 + 385, 255);
            CallButton.OnButtonClick += (btn) => { OnResult?.Invoke(SelectedNeighbour); };
            CallButton.Width          = 275;
            Add(CallButton);

            NeighbourList_OnSelectionChange((NeighborsByFamilyID.Count == 0)?-2:-1);

            OnResult += (res) => { CallButton.Disabled = true; cancelButton.Disabled = true; };
        }
        protected override void OnCommandSuccess(string obj)
        {
            UnSubscribe();
            var response = JsonUtility.FromJson <ResponseModel>(obj);

            WriteToken(response.data);
            OnResult?.Invoke(response);
        }
Ejemplo n.º 15
0
 protected void NotifyComplete(bool success)
 {
     IsShowing = false;
     OnComplete?.Invoke();
     OnResult?.Invoke(null, success);
     NotifyState();
     Load();
 }
Ejemplo n.º 16
0
        private void GetData(object source = null, ElapsedEventArgs args = null)
        {
            //Console.WriteLine("tick");
            //GetDataExecute();
            ProcessMod[] processes = ProcessMod.GetProcesses();

            OnResult?.Invoke(this, processes.ToList());
        }
 public UICallNeighborAlert(short callerNID, VM vm)
 {
     Caption = "Call Neighbour";
     SetHeight(490);
     NPanel           = new UICallNeighborPanel(callerNID, vm);
     NPanel.Position  = new Microsoft.Xna.Framework.Vector2((Width - 1030) / 2, 110);
     NPanel.OnResult += (res) => { OnResult?.Invoke(res); Close(); };
     Add(NPanel);
 }
Ejemplo n.º 18
0
        protected override void OnCommandSuccess(string obj)
        {
            UnSubscribe();
            Debug.Log($"In Check Success {obj}");

            var response = JsonUtility.FromJson <ResponseModel>(obj);

            OnResult?.Invoke(response);
        }
Ejemplo n.º 19
0
        private void CloseWithResult(bool dialogResult)
        {
            if (dialogResult)
            {
                OnResult?.Invoke(this, VM.InputText);
            }

            //DialogResult = dialogResult;
            Close();
        }
Ejemplo n.º 20
0
        void OnTick(object sender, EventArgs e)
        {
            if (Delay == -1 && done)
            {
                return;
            }
            done = true;
            var result = DoWhenTicket(reader.ReadScreen());

            OnResult?.Invoke(this, new ImageProcessorEventArgs <Result>(result));
        }
Ejemplo n.º 21
0
        public UISelectSkinAlert(VMAvatar target, string type, VM vm)
        {
            var pet = type == "cat" || type == "dog";

            Caption = pet ? "Adopt a Pet" : "Please Select Outfit";
            SetHeight(600);
            NPanel           = new UISelectSkinPanel(target, type, vm);
            NPanel.Position  = new Microsoft.Xna.Framework.Vector2((Width - 1030) / 2, 110);
            NPanel.OnResult += (res) => { OnResult?.Invoke(res); Close(); };
            Add(NPanel);
        }
        public override int Bench(int threads)
        {
            foreach (var crystalBenchmark in _crystalBenchmarks)
            {
                Results[crystalBenchmark.Name] = crystalBenchmark.Bench(threads);

                OnResult?.Invoke(this,
                                 new KeyValuePair <string, int>(crystalBenchmark.Name, Results[crystalBenchmark.Name]));
            }

            return(Results.Values.Sum());
        }
        //Callback handler when load text success
        protected override void ReceiveResult(string text)
        {
            if (targetText != null)
            {
                targetText.text = text;
            }

            if (OnResult != null)
            {
                OnResult.Invoke(text);
            }
        }
Ejemplo n.º 24
0
        public UISelectSkinPanel(VMAvatar target, string type, VM vm)
        {
            this.vm = vm;
            if (target != null)
            {
                BaseGUID       = target.Object.OBJ.GUID;
                CollectionType = type;
                var bodyStrings = target.Object.Resource.Get <FSO.Files.Formats.IFF.Chunks.STR>(target.Object.OBJ.BodyStringID);
                type = bodyStrings.GetString(1).Substring(4);
                type = type.Substring(0, type.IndexOf('_'));

                CurrentSkin = bodyStrings.GetString(14);
            }
            else
            {
                Pet = true;
                if (type == "cat")
                {
                    BaseGUID = 0x7BEA0977;
                }
                else if (type == "dog")
                {
                    BaseGUID = 0x4A70DF92;
                }
            }
            Camera           = new BasicCamera(GameFacade.GraphicsDevice, new Vector3(5, 1, 0), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            Camera.NearPlane = 0.001f;
            Scene            = new _3DTargetScene(GameFacade.GraphicsDevice, Camera, new Point(1030, 500), (GlobalSettings.Default.AntiAlias > 0)?8:0);
            Scene.Initialize(GameFacade.Scenes);

            InitializeLot();
            PopulateSimType(type);

            OKButton                = new UIBigButton(true);
            OKButton.Caption        = GameFacade.Strings.GetString("142", "0");
            OKButton.Position       = new Microsoft.Xna.Framework.Vector2((515 + 300) - 137, 370);
            OKButton.OnButtonClick += (btn) => { OnResult?.Invoke(ResultInd); };
            OKButton.Width          = 275;
            Add(OKButton);

            CancelButton                = new UIBigButton(true);
            CancelButton.Caption        = GameFacade.Strings.GetString("142", "1");
            CancelButton.Position       = new Microsoft.Xna.Framework.Vector2((515 - 300) - 137, 370);
            CancelButton.OnButtonClick += (btn) => { OnResult?.Invoke(-1); };
            CancelButton.Width          = 275;
            Add(CancelButton);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Executed when the login button is clicked.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnLogin(object sender, EventArgs e)
 {
     try
     {
         OnResult?.Invoke(new LoginCredentials()
         {
             Username   = usernameBox.Text,
             Password   = passwordBox.Text,
             RemotePath = new Uri(remotePathBox.Text),
             CopyPath   = new Uri(copyPathBox.Text)
         });
     }
     catch
     {
         // Ignored, because it will be a UriFormatException or a ArgumentNullException
     }
 }
Ejemplo n.º 26
0
        public void TryAcceptOtp(string otp)
        {
            if (otp.Length != 6)
            {
                Log.Error("Malformed OTP: {Otp}", otp);

                Dispatcher.Invoke(() =>
                {
                    OtpInputPrompt.Text       = ViewModel.OtpInputPromptBadLoc;
                    OtpInputPrompt.Foreground = Brushes.Red;
                    Storyboard myStoryboard   = (Storyboard)OtpInputPrompt.Resources["InvalidShake"];
                    Storyboard.SetTarget(myStoryboard.Children.ElementAt(0), OtpInputPrompt);
                    myStoryboard.Begin();
                    OtpTextBox.Focus();
                });

                return;
            }

            _ignoreCurrentOtp = false;
            OnResult?.Invoke(otp);

            Dispatcher.Invoke(() =>
            {
                if (_ignoreCurrentOtp)
                {
                    Storyboard myStoryboard = (Storyboard)OtpInputPrompt.Resources["InvalidShake"];
                    Storyboard.SetTarget(myStoryboard.Children.ElementAt(0), OtpInputPrompt);
                    myStoryboard.Begin();
                    OtpTextBox.Focus();
                }
                else
                {
                    _otpListener?.Stop();
                    DialogResult = true;
                    Hide();
                }
            });
        }
Ejemplo n.º 27
0
        internal bool TryConsume(ref ulong result, bool block, AutoResetEvent wakeSignal = null)
        {
            lock (_lock)
            {
                if (Disposed)
                {
                    return(true);
                }

                if (ClearCounter || Type == QueryTarget.Timestamp)
                {
                    result = 0;
                }

                long queryResult;

                if (block)
                {
                    queryResult = _counter.AwaitResult(wakeSignal);
                }
                else
                {
                    if (!_counter.TryGetResult(out queryResult))
                    {
                        return(false);
                    }
                }

                result += (ulong)queryResult;

                _result = result;

                OnResult?.Invoke(this, result);

                Dispose(); // Return the our resources to the pool.

                return(true);
            }
        }
Ejemplo n.º 28
0
        private void Check()
        {
            Task.Run(() =>
            {
                OnInfo?.Invoke(this, "检查更新。");

                var ApiUrl = "https://api.github.com/repos/zyzsdy/biliroku/releases";
                var wc     = new WebClient();
                wc.Headers.Add("Accept: application/json;q=0.9,*/*;q=0.5");
                wc.Headers.Add("User-Agent: " + Ver.UA);
                wc.Headers.Add("Accept-Language: zh-CN,zh;q=0.8,en;q=0.6,ja;q=0.4");

                //发送HTTP请求获取Release信息
                string releaseJson = null;

                try
                {
                    var releaseByte = wc.DownloadData(ApiUrl);
                    releaseJson     = System.Text.Encoding.GetEncoding("UTF-8").GetString(releaseByte);
                }
                catch (Exception e)
                {
                    OnInfo?.Invoke(this, "检查更新失败:" + e.Message);
                }

                //提取最新版的release信息
                if (releaseJson != null)
                {
                    try
                    {
                        var releaseObj  = JArray.Parse(releaseJson);
                        var releaseNote = releaseObj[0];
                        var tag         = releaseNote["tag_name"].ToString();
                        var url         = releaseNote["html_url"].ToString();
                        Version verCurrent, verNew;
                        verCurrent = Version.Parse(Ver.VER);
                        if (Version.TryParse(tag, out verNew))
                        {
                            if (verNew > verCurrent)
                            {
                                try
                                {
                                    OnResult?.Invoke(this, new UpdateResultArgs
                                    {
                                        version = tag,
                                        url     = url
                                    });
                                }catch (Exception e)
                                {
                                    OnInfo?.Invoke(this, "发现新版本,但是出了点罕见错误:" + e.Message);
                                }

                                OnInfo?.Invoke(this, "发现新版本" + tag + ",下载地址:" + url);
                            }
                            else
                            {
                                OnInfo?.Invoke(this, "当前已是最新版本。");
                            }
                        }
                        else
                        {
                            OnInfo?.Invoke(this, "版本信息无法解析。");
                        }
                    }
                    catch (Exception e)
                    {
                        OnInfo?.Invoke(this, "更新信息解析失败:" + e.Message);
                        OnInfo?.Invoke(this, releaseJson);
                    }
                }
            });
        }
Ejemplo n.º 29
0
 public void Check(int repeatCount = 1)
 {
     OnResult?.Invoke(false);
     OnResult = null;
 }
Ejemplo n.º 30
0
        public void UpdateSettings(Guid userId, string userFullName, Entity settings)
        {
            try
            {
                currentUserId = GetCallerId(service);
                SetCallerId(userId, service);
                var records = service.RetrieveMultiple(new QueryByAttribute("usersettings")
                {
                    Attributes = { UserSettings.Fields.SystemUserId },
                    Values     = { userId },
                });

                var userSetting = records.Entities.FirstOrDefault();

                if (userSetting == null)
                {
                    return;
                }

                if (settings.GetAttributeValue <int?>(UserSettings.Fields.AdvancedFindStartupMode) >= 1)
                {
                    userSetting[UserSettings.Fields.AdvancedFindStartupMode] =
                        settings.GetAttributeValue <int?>(UserSettings.Fields.AdvancedFindStartupMode);
                }

                if (settings.GetAttributeValue <int?>(UserSettings.Fields.AutoCreateContactOnPromote) >= 0)
                {
                    userSetting[UserSettings.Fields.AutoCreateContactOnPromote] =
                        settings.GetAttributeValue <int?>(UserSettings.Fields.AutoCreateContactOnPromote);
                }

                if (settings.GetAttributeValue <int?>(UserSettings.Fields.DefaultCalendarView) >= 0)
                {
                    userSetting[UserSettings.Fields.DefaultCalendarView] =
                        settings.GetAttributeValue <int?>(UserSettings.Fields.DefaultCalendarView);
                }

                if (settings.GetAttributeValue <string>(UserSettings.Fields.HomepageArea) != "No change")
                {
                    userSetting[UserSettings.Fields.HomepageArea] =
                        settings.GetAttributeValue <string>(UserSettings.Fields.HomepageArea);
                }

                if (settings.GetAttributeValue <string>(UserSettings.Fields.HomepageSubarea) != "No change")
                {
                    userSetting[UserSettings.Fields.HomepageSubarea] =
                        settings.GetAttributeValue <string>(UserSettings.Fields.HomepageSubarea);
                }

                if (settings.GetAttributeValue <OptionSetValue>(UserSettings.Fields.IncomingEmailFilteringMethod)
                    .Value >= 0)
                {
                    userSetting[UserSettings.Fields.IncomingEmailFilteringMethod] =
                        settings.GetAttributeValue <OptionSetValue>(UserSettings.Fields.IncomingEmailFilteringMethod);
                }

                if (settings.GetAttributeValue <int?>(UserSettings.Fields.PagingLimit).HasValue)
                {
                    userSetting[UserSettings.Fields.PagingLimit] =
                        settings.GetAttributeValue <int?>(UserSettings.Fields.PagingLimit).Value;
                }

                if (settings.GetAttributeValue <int?>(UserSettings.Fields.TimeZoneCode) >= 0)
                {
                    userSetting[UserSettings.Fields.TimeZoneCode] =
                        settings.GetAttributeValue <int?>(UserSettings.Fields.TimeZoneCode);
                }

                if (!string.IsNullOrEmpty(settings.GetAttributeValue <string>(UserSettings.Fields.WorkdayStartTime)) &&
                    settings.GetAttributeValue <string>(UserSettings.Fields.WorkdayStartTime) != "No change")
                {
                    userSetting[UserSettings.Fields.WorkdayStartTime] =
                        settings.GetAttributeValue <string>(UserSettings.Fields.WorkdayStartTime);
                }

                if (!string.IsNullOrEmpty(settings.GetAttributeValue <string>(UserSettings.Fields.WorkdayStopTime)) &&
                    settings.GetAttributeValue <string>(UserSettings.Fields.WorkdayStopTime) != "No change")
                {
                    userSetting[UserSettings.Fields.WorkdayStopTime] =
                        settings.GetAttributeValue <string>(UserSettings.Fields.WorkdayStopTime);
                }

                if (settings.GetAttributeValue <OptionSetValue>(UserSettings.Fields.ReportScriptErrors).Value >= 1)
                {
                    userSetting[UserSettings.Fields.ReportScriptErrors] =
                        settings.GetAttributeValue <OptionSetValue>(UserSettings.Fields.ReportScriptErrors);
                }

                if (settings.GetAttributeValue <bool?>(UserSettings.Fields.IsSendAsAllowed).HasValue)
                {
                    userSetting[UserSettings.Fields.IsSendAsAllowed] =
                        settings.GetAttributeValue <bool?>(UserSettings.Fields.IsSendAsAllowed).Value;
                }

                if (settings.GetAttributeValue <bool?>(UserSettings.Fields.IsResourceBookingExchangeSyncEnabled)
                    .HasValue)
                {
                    userSetting[UserSettings.Fields.IsResourceBookingExchangeSyncEnabled] = settings
                                                                                            .GetAttributeValue <bool?>(UserSettings.Fields.IsResourceBookingExchangeSyncEnabled).Value;
                }

                if (settings.GetAttributeValue <bool?>(UserSettings.Fields.IsAutoDataCaptureEnabled).HasValue)
                {
                    userSetting[UserSettings.Fields.IsAutoDataCaptureEnabled] = settings
                                                                                .GetAttributeValue <bool?>(UserSettings.Fields.IsAutoDataCaptureEnabled).Value;
                }

                if (settings.GetAttributeValue <int?>(UserSettings.Fields.UILanguageId).HasValue)
                {
                    userSetting[UserSettings.Fields.UILanguageId] =
                        settings.GetAttributeValue <int?>(UserSettings.Fields.UILanguageId).Value;
                }

                if (settings.GetAttributeValue <int?>(UserSettings.Fields.HelpLanguageId).HasValue)
                {
                    userSetting[UserSettings.Fields.HelpLanguageId] =
                        settings.GetAttributeValue <int?>(UserSettings.Fields.HelpLanguageId).Value;
                }

                if (settings.GetAttributeValue <EntityReference>(UserSettings.Fields.TransactionCurrencyId) != null)
                {
                    userSetting[UserSettings.Fields.TransactionCurrencyId] =
                        settings.GetAttributeValue <EntityReference>(UserSettings.Fields.TransactionCurrencyId);
                }

                if (settings.GetAttributeValue <bool?>(UserSettings.Fields.GetStartedPaneContentEnabled).HasValue)
                {
                    userSetting[UserSettings.Fields.GetStartedPaneContentEnabled] = settings
                                                                                    .GetAttributeValue <bool?>(UserSettings.Fields.GetStartedPaneContentEnabled).Value;
                }

                if (settings.GetAttributeValue <bool?>(UserSettings.Fields.UseCrmFormForAppointment).HasValue)
                {
                    userSetting[UserSettings.Fields.UseCrmFormForAppointment] = settings
                                                                                .GetAttributeValue <bool?>(UserSettings.Fields.UseCrmFormForAppointment).Value;
                }

                if (settings.GetAttributeValue <bool?>(UserSettings.Fields.UseCrmFormForContact).HasValue)
                {
                    userSetting[UserSettings.Fields.UseCrmFormForContact] = settings
                                                                            .GetAttributeValue <bool?>(UserSettings.Fields.UseCrmFormForContact).Value;
                }

                if (settings.GetAttributeValue <bool?>(UserSettings.Fields.UseCrmFormForEmail).HasValue)
                {
                    userSetting[UserSettings.Fields.UseCrmFormForEmail] =
                        settings.GetAttributeValue <bool?>(UserSettings.Fields.UseCrmFormForEmail).Value;
                }

                if (settings.GetAttributeValue <bool?>(UserSettings.Fields.UseCrmFormForTask).HasValue)
                {
                    userSetting[UserSettings.Fields.UseCrmFormForTask] =
                        settings.GetAttributeValue <bool?>(UserSettings.Fields.UseCrmFormForTask).Value;
                }

                if (settings.GetAttributeValue <Guid?>(UserSettings.Fields.DefaultDashboardId).HasValue)
                {
                    userSetting[UserSettings.Fields.DefaultDashboardId] =
                        settings.GetAttributeValue <Guid?>(UserSettings.Fields.DefaultDashboardId);
                }

                if (settings.GetAttributeValue <int?>(UserSettings.Fields.LocaleId).HasValue)
                {
                    userSetting[UserSettings.Fields.LocaleId] =
                        settings.GetAttributeValue <int?>(UserSettings.Fields.LocaleId).Value;
                }

                if (settings.GetAttributeValue <OptionSetValue>(UserSettings.Fields.DefaultSearchExperience).Value >= 0)
                {
                    userSetting[UserSettings.Fields.DefaultSearchExperience] =
                        settings.GetAttributeValue <OptionSetValue>(UserSettings.Fields.DefaultSearchExperience);
                }

                if (settings.GetAttributeValue <bool?>(UserSettings.Fields.IsEmailConversationViewEnabled).HasValue)
                {
                    userSetting[UserSettings.Fields.IsEmailConversationViewEnabled] =
                        settings.GetAttributeValue <bool>(UserSettings.Fields.IsEmailConversationViewEnabled);
                }

                if (userSetting.Attributes.Count > 1)
                {
                    service.Update(userSetting);

                    OnResult?.Invoke(this, new UserUpdateEventArgs
                    {
                        Success  = true,
                        UserName = userFullName
                    });
                }
            }
            catch (Exception e)
            {
                // If the user is disabled, they can't be updated - raise error and ask if processing should continue
                if (e.Message.StartsWith("The user with SystemUserId") && e.Message.EndsWith("is disabled"))
                {
                    OnResult?.Invoke(this, new UserUpdateEventArgs
                    {
                        Success  = false,
                        UserName = userFullName,
                        Message  = "The user is disabled. User settings cannot be updated"
                    });

                    if (!ignoreDisabledUsers)
                    {
                        ContinueIgnoreOrAbort(userFullName, "UserIsDisabled");
                    }
                }
                // If the user has no security roles, they can't be updated - raise error and ask if processing should continue
                else if (e.Message.Contains("no roles are assigned to user"))
                {
                    OnResult?.Invoke(this, new UserUpdateEventArgs
                    {
                        Success  = false,
                        UserName = userFullName,
                        Message  = "The user has no roles assigned. User settings cannot be updated"
                    });

                    if (!ignoreUserWithoutRoles)
                    {
                        ContinueIgnoreOrAbort(userFullName, "UserHasNoSecurityRoles");
                    }
                }
                // Some other unexpected error has occured
                else
                {
                    OnResult?.Invoke(this, new UserUpdateEventArgs
                    {
                        Success  = false,
                        UserName = userFullName,
                        Message  = e.Message
                    });
                }
            }
            finally
            {
                // Reset callerid to the logged in user so later queries don't fail
                SetCallerId(currentUserId, service);
            }
        }