public static AsyncLoadableResult <TClosure> Begin(TClosure closure, ErrorDelegate error, AsyncCallback userCallback, object state) { var result = new AsyncLoadableResult <TClosure>(closure, error, userCallback, state); result.CheckSynchronousCompletion(); return(result); }
private void Login() { if (!_isLogining) { _isLogining = true; SysUser user = null; try { SysUser loginUser = new SysUser(); loginUser.UserAccount = txtAccount.Text.Trim(); loginUser.UserPassword = txtPassword.Text.Trim(); List <Object> list = this.FindList <Object>("com.ccf.bip.biz.system.user.service.UserService", "login", new object[] { loginUser }); user = list[0] as SysUser; Globals.Tocken = list[1].ToString(); //Thread.Sleep(3000); LoginDelegate deg = new LoginDelegate(CompleteLogin); this.Invoke(deg, user); } catch (Exception ex) { ErrorDelegate errDeg = new ErrorDelegate(OnError); this.Invoke(errDeg, ex.Message); } } }
//type = a:1/10, b:1/100, c:1/1000 public Player_HeroSkillEditCommand( string playerId,string authToken,string herotype,HeroData hd, CompleteDelegate completeDelegate, ErrorDelegate errorDelegate) { Hashtable batchHash = new Hashtable (); batchHash.Add ("authKey", authToken); ArrayList commands = new ArrayList(); Hashtable command = new Hashtable (); command.Add ("action", "player.heroSkillEdit"); command.Add ("time", TimeUtils.UnixTime); ArrayList activeSkillIDList = new ArrayList(){"a","b","c"}; ArrayList passiveSkillIDList = new ArrayList(){"d","e","f"}; command.Add ("args", new Hashtable () { { "playerId", playerId },{"herotype",herotype},{"as",activeSkillIDList},{"ps",passiveSkillIDList}}); command.Add ("requestId", 123); commands.Add(command); batchHash.Add("commands",commands); batch = MiniJSON.jsonEncode(batchHash); //////// this.onComplete = delegate(Hashtable t){ completeDelegate(t); }; ///////// this.onError = delegate(string err_code,string err_msg, Hashtable data){ errorDelegate(err_code,err_msg,data); }; }
// function for thread public void ConnectTo() { // flag to prevent more than one notification per ring bool alerted = false; ErrorDelegate erDel = new ErrorDelegate(ShowURLError); AlertDelegate delInst = new AlertDelegate(Alert); using (var client = new HttpClient()) { Console.WriteLine("Starting connection."); client.Timeout = TimeSpan.FromSeconds(3); while (true) { try { //Console.WriteLine(serverURL); var response = client.GetAsync(serverURL).Result; if (response.IsSuccessStatusCode) { this.BeginInvoke(erDel, false); if (!successConnection) { successConnection = true; this.BeginInvoke(delInst, "Connected to server.", Form_Alert.enmType.Success); Console.WriteLine("Connected"); } var responseContent = response.Content; // by calling .Result you are synchronously reading the result int rung = Int16.Parse(responseContent.ReadAsStringAsync().Result); if (rung == 1 && !alerted) { alerted = true; //AlertDelegate delInst = new AlertDelegate(Alert); this.BeginInvoke(delInst, "Someone is at the door!", Form_Alert.enmType.Rung); } else if (rung == 0 && alerted) { alerted = false; } } } // IF we lose connection to the server catch { this.BeginInvoke(erDel, true); if (successConnection || firstTimeUser) { firstTimeUser = false; Console.WriteLine("Disconnected"); //AlertDelegate delInst = new AlertDelegate(Alert); this.BeginInvoke(delInst, "Lost connection to server.", Form_Alert.enmType.Error); } successConnection = false; } } } }
//type = a:1/10, b:1/100, c:1/1000 public Player_HerosUpdateCommand( string playerId,string authToken, CompleteDelegate completeDelegate, ErrorDelegate errorDelegate) { Hashtable batchHash = new Hashtable (); batchHash.Add ("authKey", authToken); ArrayList commands = new ArrayList(); Hashtable command = new Hashtable (); command.Add ("action", "player.heroUpdate"); command.Add ("time", TimeUtils.UnixTime); ArrayList heros = new ArrayList(); for(int i=0; i< UserInfo.heroDataList.Count; i++) { HeroData heroD = UserInfo.heroDataList[i] as HeroData; heros.Add(heroD.dumpDynamicData()); } command.Add ("args", new Hashtable () { { "playerId", playerId } ,{"bpack", EquipManager.Instance.dumpDynamicData()} ,{"heros", heros} }); command.Add ("requestId", 123); commands.Add(command); batchHash.Add("commands",commands); batch = MiniJSON.jsonEncode(batchHash); //////// this.onComplete = delegate(Hashtable t){ completeDelegate(t); }; ///////// this.onError = delegate(string err_code,string err_msg, Hashtable data){ errorDelegate(err_code,err_msg,data); }; }
////////////////////////////////////////////////////////////// public UBSModuleDelegates(SendMessageDelegate pSendMessageFunction, GetAvailableModuleNamesDelegate pGetAvailableModulesFunction, GetModule pGetModule, LogDelegate pLogFunction, WriteConsoleDelegate pWriteConsoleFunction, NotifyDelegate pNotifyFunction, ErrorDelegate pErrorFunction, ExecutionTimeDelegate pExecutionTimeFunction, SetGlobalParameterDelegate pSetGlobalParameterFunction, GetGlobalParameterDelegate pGetGlobalParameterFunction, GoToModuleDelegate pGoToModuleFunction, ButtonColorDelegate pButtonColoFunction) { SendMessageFunction = pSendMessageFunction; GetAvailableModulesFunction = pGetAvailableModulesFunction; GetModule = pGetModule; LogFunction = pLogFunction; WriteConsoleFunction = pWriteConsoleFunction; NotifyFunction = pNotifyFunction; ErrorFunction = pErrorFunction; ExecutionTimeFunction = pExecutionTimeFunction; SetGlobalParameterFunction = pSetGlobalParameterFunction; GetGlobalParameterFunction = pGetGlobalParameterFunction; GoToModuleFunction = pGoToModuleFunction; ButtonColorFunction = pButtonColoFunction; }
//type = a:1/10, b:1/100, c:1/1000 public Test_GetGameContentCommand( string playerId,string authToken, CompleteDelegate completeDelegate, ErrorDelegate errorDelegate) { Hashtable batchHash = new Hashtable (); batchHash.Add ("authKey", authToken); ArrayList commands = new ArrayList(); Hashtable command = new Hashtable (); command.Add ("action", "player.content.get"); command.Add ("time", TimeUtils.UnixTime); command.Add ("args", new Hashtable () { { "playerId", playerId }}); command.Add ("requestId", 123); commands.Add(command); batchHash.Add("commands",commands); batch = MiniJSON.jsonEncode(batchHash); //////// this.onComplete = delegate(Hashtable t){ completeDelegate(t); }; ///////// this.onError = delegate(string err_code,string err_msg, Hashtable data){ errorDelegate(err_code,err_msg,data); }; }
//type = a:1/10, b:1/100, c:1/1000 public Player_PackageUpdateCommand( string playerId,string authToken, CompleteDelegate completeDelegate, ErrorDelegate errorDelegate) { Hashtable batchHash = new Hashtable (); batchHash.Add ("authKey", authToken); ArrayList commands = new ArrayList(); Hashtable command = new Hashtable (); command.Add ("action", "player.bpackUpdate"); command.Add ("time", TimeUtils.UnixTime); command.Add ("args", new Hashtable () { { "playerId", playerId },{"bpack", EquipManager.Instance.dumpDynamicData()}}); command.Add ("requestId", 123); commands.Add(command); batchHash.Add("commands",commands); batch = MiniJSON.jsonEncode(batchHash); //////// this.onComplete = delegate(Hashtable t){ completeDelegate(t); }; ///////// this.onError = delegate(string err_code,string err_msg, Hashtable data){ errorDelegate(err_code,err_msg,data); }; }
//--------------------------------------------------------------------------- // Parser methode wrappers //--------------------------------------------------------------------------- #region Parser methode wrappers public Parser() { m_parser = mupCreate(); Debug.Assert(m_parser != null, "Parser object is null"); m_errCallback = new ErrorDelegate(RaiseException); mupSetErrorHandler(m_parser, m_errCallback); }
//type = a:1/10, b:1/100, c:1/1000 public Auth_GetAutoTokenCommand( string playerId,string secret, CompleteDelegate completeDelegate, ErrorDelegate errorDelegate) { Hashtable batchHash = new Hashtable (); batchHash.Add ("authKey", AuthUtils.generateRequestToken (playerId, secret)); ArrayList commands = new ArrayList(); Hashtable command = new Hashtable (); command.Add ("action", "auth.getAuthToken"); command.Add ("time", TimeUtils.UnixTime); command.Add ("args", new Hashtable () { { "playerId", playerId }, { "secret", secret }}); // command.Add ("expectedStatus",""); command.Add ("requestId", 123); // command.Add ("token", ""); commands.Add(command); batchHash.Add("commands",commands); batch = MiniJSON.jsonEncode(batchHash); //////// this.onComplete = delegate(Hashtable t){ //{"requestId":null,"messages":{},"result":"aWeha_JMFgzaF5zWMR3tnObOtLZNPR4rO70DNdfWPvc.eyJ1c2VySWQiOiIyMCIsImV4cGlyZXMiOiIxMzg1NzA5ODgyIn0","status":0} Hashtable completeParam = new Hashtable(); completeParam.Add("result",t["result"]); completeDelegate(completeParam); }; ///////// this.onError = delegate(string err_code,string err_msg, Hashtable data){ errorDelegate(err_code,err_msg,data); }; }
public Parser() { m_parser = mecCreate(); Debug.Assert(m_parser != null, "Parser object is null"); m_errCallback = new ErrorDelegate(RaiseException); mecSetErrorHandler(m_parser, m_errCallback); }
public SocketPlugin() { socketStorage = SocketStorage.CreateSocketStorage(); dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; dataConsumeDelegate = DataConsumer; closeEventDelegate = CloseEventHandler; errorDelegate = ErrorHandler; }
private static void createRecord(ref List <Person> persons, int i, double errorCount, string language) { ErrorDelegate[] ErrorFunctions = new ErrorDelegate[3] { insertSymbol, removeSymbol, replaceSymbol }; addError(ErrorFunctions, ref persons, i, errorCount, language); }
public CFGViewerApp(MessageDelegate msgDelegator, ImageUpdateDelegate imgDelegator, ErrorDelegate errDelegator) { OnMessage += msgDelegator; OnImageUpdate += imgDelegator; OnError += errDelegator; }
private static void PhraseRecognitionSystem_InvokeErrorEvent(SpeechError errorCode) { ErrorDelegate onError = OnError; if (onError != null) { onError(errorCode); } }
public static void OnIncomingErrorEvent(string error) { ErrorDelegate handler = IncomingErrorEvent; if (handler != null) { handler(error); } }
public Parser(EBaseType eType) { StaticDLLInit.Init(); m_parser = mupCreate((int)eType); Debug.Assert(m_parser != null, "Parser object is null"); m_errCallback = new ErrorDelegate(RaiseException); mupSetErrorHandler(m_parser, m_errCallback); }
public override DataReader AddHandler(ErrorDelegate errorHandler) { Log.Enter(nameof(ErrorDelegate)); ErrorHandler += errorHandler; Log.Exit(); return(this); }
public override DataPresenter AddHandlers(EosDelegate eosHandler, ErrorDelegate errorHandler) { Log.Enter(); EosHandler += eosHandler; ErrorHandler += errorHandler; Log.Exit(); return(this); }
public SocketServerAdapter( ISocketStorage socketStorage, DataConsumeDelegate dataConsumeDelegate, CloseEventDelegate closeEventDelegate, ErrorDelegate errorDelegate) { this.socketStorage = socketStorage; this.dataConsumeDelegate = dataConsumeDelegate; this.closeEventDelegate = closeEventDelegate; this.errorDelegate = errorDelegate; }
public AsyncLoadableResult(TClosure closure, ErrorDelegate error, AsyncCallback userCallback, object state) : base(userCallback, state) { ThrowHelper.ThrowIfNull(closure, "closure"); ThrowHelper.ThrowIfNull(error, "error"); _error = error; Closure = closure; Closure.Loaded += OnLoaded; }
public void RaiseErrorEvent(LexicalInfo info, String message) { SetHasError(); ErrorDelegate errorDelegate = (ErrorDelegate)_events[ErrorEvent]; if (errorDelegate != null) { errorDelegate(info, message); } }
/// <summary> /// Method called from across the data access layer to log errors /// encountered in the /// </summary> /// <param name="exceptionDTO"></param> public static void PublishException(CustomException exceptionDTO) { //Create the delegate ErrorDelegate dgtErrors = new ErrorDelegate(SaveErrorMessage); //Call the beginInvoke function IAsyncResult tag = dgtErrors.BeginInvoke(exceptionDTO, null, null); //Calling endInvoke dgtErrors.EndInvoke(tag); }
/// <summary> /// Method called from across the data access layer to log errors /// encountered in the /// </summary> /// <param name="exceptionDTO"></param> public static void PublishException(CustomException exceptionDTO, SqlConnection connection) { //Create the delegate ErrorDelegate dgtErrors = new ErrorDelegate(SaveErrorMessage); //Call the beginInvoke function IAsyncResult tag = dgtErrors.BeginInvoke(exceptionDTO, connection, null, null); //Calling endInvoke dgtErrors.EndInvoke(tag); }
//--------------------------------------------------------------------------- // Parser methode wrappers //--------------------------------------------------------------------------- #region Parser methode wrappers /// <summary> /// 缺省情况下使用双精度型数据类型解析数据 /// </summary> public ExpressionParser() { m_parser = mupCreate((int)ParseDataType.DOUBLE); Debug.Assert(m_parser != null, "Parser object is null"); m_errCallback = RaiseException; mupSetErrorHandler(m_parser, m_errCallback); DefineInfixOprt("!", Not, EPrec.prLOGIC); DefineFun("ABS", ABS, true); DefineFun("rint", rint, true); RegisterFuncs(); }
void RegistErrorHandler(string code, string id, string tips, ErrorDelegate func) { BumErrorInfo info = new BumErrorInfo(); info.ErrorCode = code; info.ErrorID = id; info.ErrorTips = tips; info.ErrorHandler = func; ErrorCodeMap.Add(code, info); ErrorIdMap.Add(id, info); }
private static string createRecord(string cleanRecord, double errorCount, string language) { StringBuilder record = new StringBuilder(cleanRecord); ErrorDelegate[] ErrorFunctions = new ErrorDelegate[3] { insertSymbol, removeSymbol, replaceSymbol }; addError(ErrorFunctions, record, errorCount, language); return(record.ToString()); }
private void SendError(Socket socket, Subheader sh, ErrorDelegate del) { PacketWriter pw = new PacketWriter(); pw.WriteInt((int)Header.Error); pw.WriteInt((int)sh); if (del != null) { del.Invoke(pw); } SendCustom(socket, pw.GetBytes(BUFFER_LENGTH)); }
public Main() { InitializeComponent(); LogDelegateInstance = new LogDelegate(_Log); ErrorDelegateInstance = new ErrorDelegate(_Error); StartServer sserver = new StartServer(_StartServer); Thread serverConnection = new Thread(new ThreadStart(sserver)); serverConnection.Start(); //Thread.Sleep(5000); }
/// <summary> /// Triggers the Error event. /// </summary> private void OnError(Exception ex) { ErrorDelegate handler = Error; if (handler != null) { handler(ex); } else { log.Error(ex); } }
/// <summary> Initializes a new instance of the <see cref="GeocoderBase"/> class. Adds a new layer which can /// later contain the geocoding results to the map. </summary> /// <param name="errorDelegate"> The delegate method to call in case of an error. </param> /// <param name="successDelegate"> The delegate method to call to propagate results. </param> /// <param name="map"> The map where the result layer is added to. </param> public GeocoderBase(ErrorDelegate errorDelegate, SuccessDelegate successDelegate, IMap map) { this.errorDelegate = errorDelegate; this.successDelegate = successDelegate; PinColor = Colors.Blue; #region doc:add result layer ContentLayer = new ShapeLayer("Addresses") { SpatialReferenceId = "PTV_MERCATOR" }; map.Layers.Add(ContentLayer); #endregion }
private void OnAdbErrorHandler(object sender, EventArgs e) { string message = (string)sender; if (this.InvokeRequired) { ErrorDelegate rd = new ErrorDelegate(OnAdbErrorDelegate); this.Invoke(rd, new object[] { message }); } else { OnAdbErrorDelegate(message); } }
/// <summary> /// writes any error messages to the status textbox /// </summary> /// <param name="KeyOfSender"></param> /// <param name="ErrorMsg"></param> public void Error(string KeyOfSender, string ErrorMsg) { if (this.InvokeRequired == false) { string msg = ErrorMsg; this.Text = "Error: " + msg; MessageBox.Show("Error: " + msg); } else { ErrorDelegate errDeleg = new ErrorDelegate(Error); this.BeginInvoke(errDeleg, new object[] { KeyOfSender, ErrorMsg }); } }
////////////////////////////////////////////////////////////// public void AppendDelegates(UBSModuleDelegates module_delegates) { this.SendMessageFunction = module_delegates.SendMessageFunction; this.GetAvailableModulesFunction = module_delegates.GetAvailableModulesFunction; this.GetModuleFunction = module_delegates.GetModule; this.LogFunction = module_delegates.LogFunction; this.WriteConsoleFunction = module_delegates.WriteConsoleFunction; this.NotifyFunction = module_delegates.NotifyFunction; this.ErrorFunction = module_delegates.ErrorFunction; this.ExecutionTimeFunction = module_delegates.ExecutionTimeFunction; this.SetGlobalParameterFunction = module_delegates.SetGlobalParameterFunction; this.GetGlobalParameterFunction = module_delegates.GetGlobalParameterFunction; this.GoToModuleFunction = module_delegates.GoToModuleFunction; this.ButtonColorFunction = module_delegates.ButtonColorFunction; }
private static IEnumerator PostRequest(string uri, string data = "", CompleteDelegate completeDelegate = null, ErrorDelegate errorDelegateUri = null) { using (var www = UnityWebRequest.Post(uri, data)) { yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); errorDelegateUri?.Invoke(www.error); } else { Debug.Log("Upload complete!"); completeDelegate?.Invoke(uri); } } }
public ActionResult InitialiseRefonteLaunch() { string success = "true"; string description = "data modified"; ErrorDelegate errorDelegate = new ErrorDelegate(WriteLogError); string logFilePath = Path.Combine(Server.MapPath("~/uploads"), string.Format("LogRefonte{0}.txt", DateTime.Now.ToString("yyyyMMddHHmmss"))); if (LAUNCH_REFONTE_RECUEIL) { List<ErrorLogRefonte> errosLogs = new List<ErrorLogRefonte>(); /* parent : 314 */ int[] idOptionAttributes314 = new int[] { 194, 195, 196, 197, 198, 199, 774 }; ExecuteChangeStructData(314, idOptionAttributes314, "Designation", ref errosLogs); /* parent : 325 */ int[] idOptionAttributes325 = new int[] { 207, 208, 209, 210, 211, 212, 213, 214 }; ExecuteChangeStructData(325, idOptionAttributes325, "Designation", ref errosLogs); if (errosLogs.Any()) { List<string> errors = new List<string>(); errosLogs.ForEach(x => { string error = string.Format("{0} => [{1}] : {2}", DateTime.Now.ToString("dd/MM/yyyy HH:ss"), x.SourceIdParent, x.Description); errors.Add(error); }); success = "false"; description = string.Format("some error on launch script - Error count : {0} - See error at :{1}", errors.Count, logFilePath); errorDelegate(logFilePath, errors); return Json(new { Success = success, Description = description }, JsonRequestBehavior.AllowGet); } } List<string> dones = new List<string>() { string.Format("{0} => {1}", DateTime.Now.ToString("dd/MM/yyyy HH:ss"), "DONE") }; errorDelegate(logFilePath, dones); return Json(new { Success = success, Description = description }, JsonRequestBehavior.AllowGet); }
public static void Generate(bool condition, string description, ErrorDelegate del) { if (condition == true) { Random ran = new Random(); if (ran.Next() % 10 == 0) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("\n\n\t**********************************************************************************************************\n"); sb.AppendFormat("\t SIMULATING ERROR: {0}\n", description); sb.AppendFormat("\t**********************************************************************************************************\n"); Platform.Log(LogLevel.Error, sb.ToString()); if (del!=null) del(); else { throw new Exception("Simulated Random Exception"); } } } }
public LoadRequest(string url, object customParam = null, string type = "", DownCompleteDelegate completeFunc = null, ErrorDelegate errorFunc = null, ProcessDelegate processFunc = null) { requestURL = url; fileType = type; completeFunction = completeFunc; if (completeFunc != null) { customParams.Add(customParam); } if (errorFunc != null) { errorFunction = errorFunc; } if (processFunc != null) { processFunction = processFunc; } wwwObject = new WWW(requestURL); wwwObject.threadPriority = ThreadPriority.Normal; }
public static void Generate(bool condition, string description, ErrorDelegate del) { if (condition == true) { Random ran = new Random(); if (ran.Next() % 10 == 0) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("\n\n\t**********************************************************************************************************\n"); sb.AppendFormat("\t SIMULATING ERROR: {0}\n", description); sb.AppendFormat("\t**********************************************************************************************************\n"); Platform.Log(LogLevel.Error, sb.ToString()); if (del != null) { del(); } else { throw new Exception("Simulated Random Exception"); } } } }
/// <summary> /// Unregister a previously registered session error delegate. /// </summary> /// <param name='del'> /// The delegate to be unregistered. /// </param> public void UnregisterErrorDelegate(ErrorDelegate del) { errorDelegate -= del; }
public FileCommand( string fileName , CompleteDelegate completeDelegate, ErrorDelegate errorDelegate) { this.fileName = fileName; this.onComplete = completeDelegate; this.onError = errorDelegate; }
private void ErrorResponse(WebException wex, bool isWebException) { this.mTimer.Enabled = false; if (((Control) this.mRequestSender).InvokeRequired) { ErrorDelegate method = new ErrorDelegate(this.ErrorResponse); ((Control) this.mRequestSender).Invoke(method, new object[] { wex, isWebException }); } else { try { this.mTrace.WriteString(this.mTracekind, string.Format("# {0,-16} : status[{1}]", "ErrorResponse", this.mStatus)); if (isWebException) { if (wex.Status == WebExceptionStatus.RequestCanceled) { if (this.mIsTimeout) { this.mIsTimeout = false; this.mTrace.WriteString(this.mTracekind, string.Format("- {0,-16} : error[{1}]", "ErrorResponse", HttpCause.Timeout)); HttpExceptionEx ex = new HttpExceptionEx(this.mStatus, HttpCause.Timeout, wex); this.OnNetworkError(this, this.mSendkey, ex); } else { this.mTrace.WriteString(this.mTracekind, string.Format("- {0,-16} : error[{1}]", "ErrorResponse", HttpCause.UserCancel)); HttpExceptionEx ex2 = new HttpExceptionEx(this.mStatus, HttpCause.UserCancel, wex); this.OnNetworkError(this, this.mSendkey, ex2); } } else { this.mTrace.WriteString(this.mTracekind, string.Format("- {0,-16} : error[{1}]", "ErrorResponse", HttpCause.WebException)); HttpExceptionEx ex3 = new HttpExceptionEx(this.mStatus, HttpCause.WebException, wex); this.OnNetworkError(this, this.mSendkey, ex3); } } else { this.mTrace.WriteString(this.mTracekind, string.Format("- {0,-16} : error[{1}]", "ErrorResponse", HttpCause.Exception)); HttpExceptionEx ex4 = new HttpExceptionEx(this.mStatus, HttpCause.Exception, wex); this.OnNetworkError(this, this.mSendkey, ex4); } } finally { this.Status = HttpStatus.Idle; } } }
protected static extern void mupSetErrorHandler(IntPtr a_pParser, ErrorDelegate errFun);