public static void Compute(ref string path, ref DownloadFileInfo file, OnResult on_result) { if (File.Exists(path)) { FunapiManager.instance.StartCoroutine(AsyncCompute(path, file, on_result)); return; } DebugUtils.Log("MD5Async.Compute - Can't find a file.\npath: {0}", path); if (on_result != null) on_result(path, file, false); }
protected void SetResult(SA_TestResult result) { m_result = result; OnResult.Invoke(this, m_result); }
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"); ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; //发送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); } } }); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { OnResult r = (OnResult)resultCode; base.OnActivityResult(requestCode, resultCode, data); switch (requestCode) { case 0: if (data == null) { return; } if (resultCode == Result.Ok) { Android.Net.Uri chosenImageUri = data.Data; /* * XxmsApp.Api.Droid.XMessages.currentSound?.Stop(); * XxmsApp.Api.Droid.XMessages.currentSound = Android.Media.RingtoneManager.GetRingtone(this, chosenImageUri); * XxmsApp.Api.Droid.XMessages.currentSound.Play(); * ReceiveActivityResult?.Invoke(chosenImageUri, XxmsApp.Api.Droid.XMessages.currentSound); * //*/ Dependencies.Player.currentMelody?.Stop(); var player = Dependencies.Player.currentMelody = new Android.Media.MediaPlayer(); /* * player.Reset(); * player.SetDataSource(chosenImageUri.Scheme + ":" + chosenImageUri.SchemeSpecificPart); * // player.SetDataSource(this, chosenImageUri); // player.SetDataSource(context, Urim); * player.Prepare(); * var duration = player.Duration; * player.Start();//*/ ReceiveActivityResult?.Invoke(chosenImageUri, player); //*/ } // String name = data.GetStringExtra("name"); break; case (int)OnResult.EmailSent: Toast.MakeText(this, "Спасибо вам за обратную связь", ToastLength.Long).Show(); break; case (int)OnResult.SetDefaultApp: // XMessages.UpdateMessageStates(); if (Api.LowLevelApi.Instance.IsDefault) { Toast.MakeText(this, "Спасибо, что вы с нами", ToastLength.Long).Show(); } break; default: break; } }
static IEnumerator AsyncCompute(string path, DownloadFileInfo file, OnResult on_result) { MD5 md5 = MD5.Create(); int length, read_bytes; byte[] buffer = new byte[kBlockSize]; string md5hash = ""; FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); if (stream.Length > 0) { if (file.hash_front.Length > 0) { length = (stream.Length < kBlockSize) ? (int)stream.Length : kBlockSize; read_bytes = stream.Read(buffer, 0, length); md5.TransformFinalBlock(buffer, 0, read_bytes); md5hash = MakeHashString(md5.Hash); if (md5hash != file.hash_front || length == stream.Length) { stream.Close(); if (on_result != null) on_result(path, file, md5hash == file.hash_front && md5hash == file.hash); yield break; } md5.Clear(); md5 = MD5.Create(); stream.Position = 0; yield return new WaitForEndOfFrame(); } int sleep_count = 0; while (stream.Position < stream.Length) { length = (stream.Position + kBlockSize > stream.Length) ? (int)(stream.Length - stream.Position) : kBlockSize; read_bytes = stream.Read(buffer, 0, length); if (stream.Position < stream.Length) { md5.TransformBlock(buffer, 0, read_bytes, buffer, 0); } else { md5.TransformFinalBlock(buffer, 0, read_bytes); break; } ++sleep_count; if (sleep_count % kMaxSleepCount == 0) yield return new WaitForEndOfFrame(); } } else { md5.TransformFinalBlock(buffer, 0, 0); } stream.Close(); md5hash = MakeHashString(md5.Hash); if (on_result != null) on_result(path, file, md5hash == file.hash); }
private void GetDataExecute() { ProcessMod[] processes = ProcessMod.GetProcesses(); OnResult?.Invoke(this, processes.ToList()); }
public void CallStatic(string methodName, params object[] args) { this.LogMethodCall(methodName); OnResult callback = null; IDictionary <string, object> result; IDictionary <string, object> methodArguments = null; int callbackID = -1; if (args.Length == 1) { var jsonParams = (string)args[0]; if (jsonParams != null) { methodArguments = MiniJSON.Json.Deserialize(jsonParams) as IDictionary <string, object>; string callbackStr; if (methodArguments.TryGetValue(Constants.CallbackIdKey, out callbackStr)) { callbackID = int.Parse(callbackStr); } } } if (callbackID == -1) { // There was no callback so just return; return; } if (methodName == "AppInvite") { callback = this.MobileFacebook.OnAppInviteComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "GetAppLink") { callback = this.Facebook.OnGetAppLinkComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "AppRequest") { callback = this.Facebook.OnAppRequestsComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "FeedShare") { callback = this.Facebook.OnShareLinkComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "ShareLink") { callback = this.Facebook.OnShareLinkComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "GameGroupCreate") { callback = this.Facebook.OnGroupCreateComplete; result = MockResults.GetGroupCreateResult(callbackID, this.ResultExtras); } else if (methodName == "GameGroupJoin") { callback = this.Facebook.OnGroupJoinComplete; result = MockResults.GetGenericResult(callbackID, this.ResultExtras); } else if (methodName == "LoginWithPublishPermissions" || methodName == "LoginWithReadPermissions") { callback = this.Facebook.OnLoginComplete; string permissions; methodArguments.TryGetValue(AndroidFacebook.LoginPermissionsKey, out permissions); result = MockResults.GetLoginResult( callbackID, permissions, this.ResultExtras); } else if (methodName == "RefreshCurrentAccessToken") { callback = this.MobileFacebook.OnRefreshCurrentAccessTokenComplete; result = MockResults.GetLoginResult( callbackID, string.Empty, this.ResultExtras); } else { throw new NotImplementedException("Not implemented for " + methodName); } callback(result.ToJson()); }
static void asyncCompute(string path, DownloadFileInfo file, OnResult on_result) #endif { MD5 md5 = MD5.Create(); int length, read_bytes; byte[] buffer = new byte[kBlockSize]; string md5hash = ""; FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); if (stream.Length > 0) { if (file.hash_front.Length > 0) { length = (stream.Length < kBlockSize) ? (int)stream.Length : kBlockSize; read_bytes = stream.Read(buffer, 0, length); md5.TransformFinalBlock(buffer, 0, read_bytes); md5hash = FunapiUtils.BytesToHex(md5.Hash); if (md5hash != file.hash_front || length == stream.Length) { stream.Close(); if (on_result != null) { on_result(path, file, md5hash == file.hash_front && md5hash == file.hash); } #if !NO_UNITY yield break; #else return; #endif } md5.Clear(); md5 = MD5.Create(); stream.Position = 0; #if !NO_UNITY yield return(new WaitForEndOfFrame()); #endif } int sleep_count = 0; while (stream.Position < stream.Length) { length = kBlockSize; if (stream.Position + length > stream.Length) { length = (int)(stream.Length - stream.Position); } read_bytes = stream.Read(buffer, 0, length); if (stream.Position < stream.Length) { md5.TransformBlock(buffer, 0, read_bytes, buffer, 0); } else { md5.TransformFinalBlock(buffer, 0, read_bytes); break; } ++sleep_count; if (sleep_count >= kSleepCountMax) { sleep_count = 0; #if !NO_UNITY yield return(new WaitForEndOfFrame()); #else Thread.Sleep(30); #endif } } } else { md5.TransformFinalBlock(buffer, 0, 0); } stream.Close(); md5hash = FunapiUtils.BytesToHex(md5.Hash); if (on_result != null) { on_result(path, file, md5hash == file.hash); } }
protected void AddResult(string result) { OnResult?.Invoke(result); }
public Persegi(OnResult viewListener) { this.viewListener = viewListener; }
public override void Result(ContactResult point) { base.Result(point); OnResult?.Invoke((BaseMissionObjectController)point.Shape1.GetBody().GetUserData(), (BaseMissionObjectController)point.Shape2.GetBody().GetUserData()); }
/// <summary> /// Makes the cursor emit a judgement result event related to this cursor. /// </summary> public void ReportNewResult(JudgementResult result) { OnResult?.Invoke(result); }
public IEnumerator LoadAssetBundles(OnResult deleCompleted, OnResult deleFailed) { _DebugPrintAssetBundlesList("Load Assets..."); if (_assetBundlesList == null) { LPetUtil.DebugLogf("AssetBundle List is null"); deleFailed(); yield break; } foreach(KeyValuePair<string, AssetBundleInfo> entry in _assetBundlesList) { string assetBundlePath = _GetAssetBundleFullPath(entry.Value); using (WWW www = new WWW(assetBundlePath)) { yield return www; if (www.error != null) { LPetUtil.DebugLogf("WWW errro, server version has an error:" + www.error); deleFailed(); yield break; } entry.Value.asset = www.assetBundle; } } deleCompleted(); }
public IEnumerator DownloadSaveAssetBundles(OnResult deleCompleted, OnResult deleFailed) { _DebugPrintAssetBundlesList("Download and Save Assets"); if (_assetBundlesList == null) { LPetUtil.DebugLogf("AssetBundle List is null"); deleFailed(); yield break; } foreach(KeyValuePair<string, AssetBundleInfo> entry in _assetBundlesList) { string serverAssetPath = Path.Combine(entry.Value.server_url, _GetAssetBundleName(entry.Value)); LPetUtil.DebugLogf("Download Server asset path: <{0}>", serverAssetPath); using (WWW www = new WWW(serverAssetPath)) { yield return www; if (www.error != null) { LPetUtil.DebugLogf("WWW errro, server version has an error:" + www.error); deleFailed(); yield break; } FileStream fs = new FileStream(_GetAssetBundleFullPath(entry.Value), FileMode.Create); fs.Seek(0, SeekOrigin.Begin); fs.Write(www.bytes, 0, www.bytes.Length); fs.Close(); //StartCoroutine(LPetUtil.WriteFile(_GetAssetBundleFullPath(entry.Value), www.bytes, OnWF)); } } deleCompleted(); }
/// <summary> 发起请求 </summary> /// <param name="dto"></param> /// <returns></returns> public async Task <SdkResponseDto> RequestAsync(SdkRequestDto dto) { if (dto.Param != null) { var query = dto.Param.Stringfy(encoding: Encoding.UTF8); dto.Api += $"?{query}"; } var uri = new Uri(new Uri(_gateway), dto.Api); var result = new SdkRequestData { Url = uri.AbsoluteUri, Method = dto.Method, Content = dto.Data, Headers = new Dictionary <string, string>() }; HttpWebResponse resp = null; try { var req = (HttpWebRequest)WebRequest.Create(uri); OnRequest?.Invoke(req); req.AllowAutoRedirect = true; req.Method = dto.Method; req.Timeout = 150 * 1000; foreach (var header in _defaultHeaders) { req.Headers.Add(header.Key, header.Value); } if (dto.Headers != null && dto.Headers.ContainsKey("UserAgent")) { req.UserAgent = dto.Headers["UserAgent"]; dto.Headers.Remove("UserAgent"); } else { req.UserAgent = "SDK Request"; } if (dto.Headers != null && dto.Headers.Any()) { foreach (var header in dto.Headers) { req.Headers.Add(header.Key, header.Value); } } foreach (var key in req.Headers.AllKeys) { if (!result.Headers.ContainsKey(key) && !_defaultHeaders.Keys.Contains(key)) { result.Headers.Add(key, req.Headers.Get(key)); } } if (dto.Data != null) { var reqStream = req.GetRequestStream(); switch (dto.ContentType) { case ContentType.Xml: req.ContentType = "text/xml"; var serializer = new XmlSerializer(dto.Data.GetType()); serializer.Serialize(reqStream, dto.Data); break; case ContentType.Form: req.ContentType = "application/x-www-form-urlencoded"; var content = dto.Data.Stringfy(false); var buffer = Encoding.UTF8.GetBytes(content); await reqStream.WriteAsync(buffer, 0, buffer.Length); break; default: req.ContentType = "application/json"; var json = JsonHelper.ToJson(dto.Data); var jsonBuffer = Encoding.UTF8.GetBytes(json); await reqStream.WriteAsync(jsonBuffer, 0, jsonBuffer.Length); break; } } resp = (HttpWebResponse)req.GetResponse(); var respDto = new SdkResponseDto { Code = resp.StatusCode, ContentType = resp.Headers["Content-Type"] }; result.Code = (int)resp.StatusCode; var stream = resp.GetResponseStream(); if (stream != null) { if (string.Equals("gzip", resp.ContentEncoding, StringComparison.CurrentCultureIgnoreCase)) { stream = new GZipStream(stream, CompressionMode.Decompress); } respDto.Content = stream; result.Result = respDto.Result; } return(respDto); } catch (Exception ex) { result.Exception = ex; throw; } finally { OnResult?.Invoke(result); resp.Dispose(); } }
public static void Compute(MonoBehaviour mono, ref string path, ref DownloadFileInfo file, OnResult on_result) { if (!File.Exists(path)) { FunDebug.LogWarning("MD5Async.Compute - Can't find a file.\npath: {0}", path); if (on_result != null) { on_result(path, file, false); } return; } #if !NO_UNITY mono.StartCoroutine(asyncCompute(path, file, on_result)); #else string path_ = path; DownloadFileInfo file_ = file; mono.StartCoroutine(delegate { asyncCompute(path_, file_, on_result); }); #endif }
static IEnumerator asyncCompute(string path, DownloadFileInfo file, OnResult on_result)
public Lingkaran(OnResult viewListener) { this.viewListener = viewListener; }
private void RaiseOnResult(bool success) { OnResult?.Invoke(success, Result); }
/// <summary> /// Event called when the linked hit cursor has a new judgement result emitted. /// </summary> private void OnHitCursorResult(JudgementResult result) => OnResult?.Invoke(result);
public Segitiga(OnResult viewListener) { this.viewListener = viewListener; }
private void ExecuteResultHandlers() { OnResult?.Invoke(Get()); }
protected virtual void _onResult(UResult result) { OnResult?.Invoke(result); }
protected virtual void FireOnResult(AIResponse response) { OnResult.InvokeSafely(response); }
/// <summary> /// Call the callback with the result. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnSubmit(object sender, EventArgs e) { OnResult?.Invoke(folderBox.Text); }
private void CommandInvoke() { OnResult?.Invoke(this, func.Invoke()); }
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); } }
public override void Result(ContactResult point) { base.Result(point); OnResult?.Invoke((MyModel3D)point.Shape1.GetBody().GetUserData(), (MyModel3D)point.Shape2.GetBody().GetUserData()); }
static IEnumerator AsyncCompute(string path, DownloadFileInfo file, OnResult on_result) { MD5 md5 = MD5.Create(); int length, read_bytes; byte[] buffer = new byte[kBlockSize]; string md5hash = ""; FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); if (stream.Length > 0) { if (file.hash_front.Length > 0) { length = (stream.Length < kBlockSize) ? (int)stream.Length : kBlockSize; read_bytes = stream.Read(buffer, 0, length); md5.TransformFinalBlock(buffer, 0, read_bytes); md5hash = MakeHashString(md5.Hash); if (md5hash != file.hash_front || length == stream.Length) { stream.Close(); if (on_result != null) { on_result(path, file, md5hash == file.hash_front && md5hash == file.hash); } yield break; } md5.Clear(); md5 = MD5.Create(); stream.Position = 0; yield return(new WaitForEndOfFrame()); } int sleep_count = 0; while (stream.Position < stream.Length) { length = (stream.Position + kBlockSize > stream.Length) ? (int)(stream.Length - stream.Position) : kBlockSize; read_bytes = stream.Read(buffer, 0, length); if (stream.Position < stream.Length) { md5.TransformBlock(buffer, 0, read_bytes, buffer, 0); } else { md5.TransformFinalBlock(buffer, 0, read_bytes); break; } ++sleep_count; if (sleep_count % kMaxSleepCount == 0) { yield return(new WaitForEndOfFrame()); } } } else { md5.TransformFinalBlock(buffer, 0, 0); } stream.Close(); md5hash = MakeHashString(md5.Hash); if (on_result != null) { on_result(path, file, md5hash == file.hash); } }
public RechargeResultListener(OnResult onResult) { this.onResult = onResult; }