private async void ButtonClicked_Login(object sender, EventArgs e) { Content.InputTransparent = true; Content.BackgroundColor = Color.Gray; if (Connectivity.NetworkAccess != NetworkAccess.Internet) { await DisplayAlert($"Sem conexão com a internet!", "Tente novamente mais tarde.", "OK"); return; } try { LoginController loginController = new LoginController(); CallbackStatus status = new CallbackStatus(); await loginController.Login(EntryLogin.Text, EntryPassword.Text); status = loginController.status; User user = new User(); Content.InputTransparent = false; Content.BackgroundColor = Color.White; if (loginController.Id > 0) { user = await UserController.GetAPI((int)loginController.Id); Application.Current.MainPage = new AdmMasterDetail(user); } else { await DisplayAlert($"{ status.CurrentStatus.CallbackStatusToText()}", status.CallbackMessage, "OK"); } }catch { await DisplayAlert($"Problemas na rede!", "Tente novamente mais tarde.", "OK"); } }
public void ChangeCallbackStatus(CallbackStatus callbackStatus, string reason) { var oldStatus = CallbackStatus; this.CallbackStatus = callbackStatus; this.DomainEvents.Add(new PaymentOrderCallbackStatusChangedEventData(this, oldStatus, reason)); }
public virtual ERP_CallbackResultType NotifyStartAdvance(string erpFormCode, bool isSubmit) { Logger.logger.DebugFormat("NotifyStartAdvance_erpFormCode:{0},{1}", erpFormCode, isSubmit); try { string[] toErpString = CallbackStatus.Split(','); ERP_CallbackResultInfo erpback = InvokeService_ERP.InvokeServiceAdvance(new CallbackInfo() { FormCode = erpFormCode, FormType = GetErpFormType().ToString(), Status = !isSubmit?"":toErpString[2], ArrayParam = isSubmit ? new List <string>() : new List <string>() { "CHECK_STATUS" } // }); Logger.logger.DebugFormat("erpback:{0}", erpback.Log); return(erpback.ResultType); } catch (Exception ex) { Logger.logger.DebugFormat("NO:ex:{0}\r\n{1}", ex.Message, ex.StackTrace); return(ERP_CallbackResultType.ERP服务器异常); } }
public async static Task <CallbackStatus> AddAPI(User item) { // await GetAllDatabaseAPI(classURL); CallbackStatus status; HttpResponseMessage result = new HttpResponseMessage(); try { using (HttpClient client = new HttpClient() { Timeout = new TimeSpan(0, 2, 0) }) { string serializedItem = JsonConvert.SerializeObject(item); StringContent content = new StringContent(serializedItem, Encoding.UTF8, "application/json"); result = await client.PostAsync($"{StaticsInfo.ApiURL}/{StaticsInfo.EcoPointURL}", content); } if (result.IsSuccessStatusCode) { status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.FINISHED, "Item adicionado com sucesso."); } else { status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.FINISHED, "Não foi possível adicionar os dados."); } } catch (Exception ex) { status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.ERROR, $"{ex.Message} {ex.InnerException}"); } return(status); }
public async Task <CallbackStatus> UpdateDatabaseAPI(string classURL, T item) { CallbackStatus status; using (HttpClient client = new HttpClient() { Timeout = new TimeSpan(0, 2, 0) }) { string serializedItem = JsonConvert.SerializeObject(item); StringContent content = new StringContent(serializedItem, Encoding.UTF8, "application/json"); HttpResponseMessage responseMessage = await client.PutAsync($"{StaticsInfo.ApiURL}/{classURL}", content); if (responseMessage.IsSuccessStatusCode) { status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.FINISHED, "O item foi atualizado com sucesso."); } else { status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.FINISHED, $"Falha ao atualizar o item. {responseMessage.StatusCode}"); return(status); } } return(status); }
public override void Deserialize(NetworkReader _reader) { base.Deserialize(_reader); callbackId = _reader.ReadInt32(); status = (CallbackStatus)_reader.ReadByte(); var msgType = Type.GetType(_reader.ReadString()); Assert.IsNotNull(msgType); message = (InsightMessageBase)Activator.CreateInstance(msgType); message.Deserialize(_reader); }
private CallbackStatus NativeCallback(ResourceEntry resource, IntPtr user_ctx) { CallbackStatus ret = CallbackStatus.CONTINUE; if (_callback != null) { ret = _callback(resource, _userData); } return(ret); }
/// <summary> /// 可以继续覆盖重写 /// </summary> /// <param name="k2_workflowId"></param> /// <param name="dataFields"></param> /// <returns></returns> public override Pkurg.PWorldBPM.FinallyDisposeServices.ExecuteResultInfo DoServiceEvent(int k2_workflowId, SerializableDictionary <string, string> dataFields) { Logger.logger.DebugFormat("Params:{0},{1}", k2_workflowId, dataFields.Keys.Count); foreach (KeyValuePair <string, string> item in dataFields) { Logger.logger.DebugFormat("df:{0}-{1}", item.Key, item.Value); } Pkurg.PWorldBPM.FinallyDisposeServices.ExecuteResultInfo info = new Pkurg.PWorldBPM.FinallyDisposeServices.ExecuteResultInfo(); try { string erpFormCode = GetErpFormIdByWorkflowId(k2_workflowId, dataFields); string[] toErpString = CallbackStatus.Split(','); string resultString = dataFields["IsPass"] == "1" ? toErpString[0] : toErpString[1]; Logger.logger.DebugFormat("Proc:{0},{1}", erpFormCode, resultString); if (BeforeNotify(k2_workflowId, dataFields)) { ERP_CallbackResultInfo resultInfo = InvokeService_ERP.InvokeServiceAdvance(new CallbackInfo() { FormCode = erpFormCode, FormType = GetErpFormType().ToString(), Status = resultString }); AfterNotify(k2_workflowId, dataFields, resultInfo); if (resultInfo.ResultType == ERP_CallbackResultType.调用成功) { info.IsSuccess = true; } else { info.IsSuccess = false; info.ExecException = "接口调用成功,erp接口返回失败:" + resultInfo.resultXml; } } else { info.IsSuccess = false; } } catch (Exception ex) { info.ExecException = ex.StackTrace; info.IsSuccess = false; } Logger.logger.DebugFormat("Result:{0}", info.IsSuccess); Logger.logger.DebugFormat("Result-e:{0}", info.ExecException); if (!IsDebug) { DoSendEmail(k2_workflowId); } return(info); }
private async void BtnAddMaterial_Clicked(object sender, EventArgs e) { if(!Validate()){ await DisplayAlert($"Ocorreu um erro!","Alguns campos nulos não são aceitos.", "OK"); return; } try { Material material = new Material(MaterialEntry.Text, DescritionEntry.Text); CallbackStatus status = await MaterialController.AddAPI(material); await DisplayAlert($"{ status.CurrentStatus.CallbackStatusToText()}", status.CallbackMessage, "OK"); } catch{ await DisplayAlert($"Ocorreu um erro ao adicionar novo material!", "Tente novamente mais tarde.", "OK"); } }
private void OnLogin(InsightMessageBase _message, CallbackStatus _status) { if (!(_message is LoginMsg)) { return; } if (_status == CallbackStatus.Success) { gameObject.SetActive(false); } else { statusText.text = $"Login : {_status}"; } }
private async void BtnAddService_Clicked(object sender, EventArgs e) { if (!Validate()) { await DisplayAlert("Ocorreu um erro!", "Campos não podem ser nulos.", "OK"); return; } Job job = new Job(UserController.CurrentUser.Id, TitleEntry.Text, UserController.CurrentUser.Phones.First().Number.ToString(), DescritionServiceEntry.Text, "0", DateTime.UtcNow, filePath); UserController.CurrentUser.Jobs.Add(job); CallbackStatus status = await JobController.AddAPI(UserController.CurrentUser); await DisplayAlert($"{ status.CurrentStatus.CallbackStatusToText()}", status.CallbackMessage, "OK"); }
public async Task <CallbackStatus> Login(string login, string password) { int?responseData = null; string json = $"{{ \"Login\":\"{login}\", \"Password\":\"{password}\" }}"; try { HttpRequestMessage request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri($"{StaticsInfo.ApiURL}/{StaticsInfo.LoginURL}"), Content = new StringContent(json, Encoding.UTF8, "application/json") }; using (HttpClient client = new HttpClient() { Timeout = new TimeSpan(0, 2, 0) }) { using (HttpResponseMessage response = await client.SendAsync(request)) { if (response.IsSuccessStatusCode) { string dataString = response.Content.ReadAsStringAsync().Result; //responseData = JsonConvert.DeserializeObject<int?>(dataString); int i; if (int.TryParse(dataString, out i)) { responseData = i; status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.FINISHED, "Login realizado com sucesso."); } else { responseData = null; status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.FINISHED, "Não foi possível realizar o login. \n Revise suas informações!"); } } else { status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.FINISHED_WITH_ERROR, $"Não foi possível realizar o login: {response.StatusCode}"); } } } }catch (Exception ex) { status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.ERROR, $"{ex.Message} {ex.InnerException}"); } Id = responseData; return(status); }
private CallbackStatus NativeCallback(IntPtr entryPtr, IntPtr userCtx) { CallbackStatus ret = CallbackStatus.CONTINUE; if (_callback == null) { return(ret); } DirEntryBase b = Marshal.PtrToStructure <DirEntryBase>(entryPtr); DirEntry dentry = new DirEntry { FileName = b.FileName, DosName = b.DosName, FullPath = b.FullPath, Depth = b.Depth, SecurityDescriptor = b.SecurityDescriptor, Attributes = b.Attributes, ReparseTag = b.ReparseTag, NumLinks = b.NumLinks, NumNamedStreams = b.NumNamedStreams, HardLinkGroupId = b.HardLinkGroupId, CreationTime = b.CreationTime, LastWriteTime = b.LastWriteTime, LastAccessTime = b.LastAccessTime, UnixUserId = b.UnixUserId, UnixGroupId = b.UnixGroupId, UnixMode = b.UnixMode, UnixRootDevice = b.UnixRootDevice, ObjectId = b.ObjectId, Streams = new StreamEntry[b.NumNamedStreams + 1], }; IntPtr baseOffset = IntPtr.Add(entryPtr, Marshal.SizeOf <DirEntryBase>()); for (int i = 0; i < dentry.Streams.Length; i++) { IntPtr offset = IntPtr.Add(baseOffset, i * Marshal.SizeOf <StreamEntry>()); dentry.Streams[i] = Marshal.PtrToStructure <StreamEntry>(offset); } ret = _callback(dentry, _userData); return(ret); }
private async void BtnAddEcoPonto_Clicked(object sender, EventArgs e) { if (!Validate()) { await DisplayAlert("Ocorreu um erro!", "Revise suas informações, alguns campos não podem ser nulos.", "OK"); return; } try { Eco = new EcoPoint(NameEcoPontoEntry.Text, DescritionEcoPontoEntry.Text, Materials.SelectedItems.ToList(), new Address(CepEcoPontoEntry.Text, RuaEcoPontoEntry.Text, NumberEcoPontoEntry.Text, ComplementEcoPontoEntry.Text, BairroEcoPontoEntry.Text, CityEcoPontoEntry.Text, StateEcoPontoEntry.Text), new Phone(PhoneEcoPontoEntry.Text)); UserController.CurrentUser.EcoPoints.Add(Eco); CallbackStatus status = await EcoPointController.AddAPI(UserController.CurrentUser); await DisplayAlert($"{ status.CurrentStatus.CallbackStatusToText()}", status.CallbackMessage, "OK"); } catch { await DisplayAlert("Ocorreu um erro ao tentar adicionar novo ecoponto!", "Tente novamente mais tarde.", "OK"); } }
private void OnReceiveGameList(InsightMessageBase _message, CallbackStatus _status) { if (!(_message is GameListMsg message)) { return; } switch (_status) { case CallbackStatus.Success: { SetGameList(message.gamesArray); } break; case CallbackStatus.Error: case CallbackStatus.Timeout: break; default: throw new ArgumentOutOfRangeException(); } }
public async Task <CallbackStatus> DeleteDatabaseAPI(string classURL, int id) { CallbackStatus status; using (HttpClient client = new HttpClient() { Timeout = new TimeSpan(0, 2, 0) }) { HttpResponseMessage responseMessage = await client.DeleteAsync($"{StaticsInfo.ApiURL}/{classURL}/{id}"); if (responseMessage.IsSuccessStatusCode) { status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.FINISHED, "O item foi deletado com sucesso."); } else { status = new CallbackStatus(StaticsInfo.CALLBACK_STATUS.FINISHED, $"Falha ao excluir o item. {responseMessage.StatusCode}"); return(status); } } return(status); }
private async void BtnAdicionarUser_Clicked(object sender, EventArgs e) { bool canPass = await Validate(); if (!canPass) { return; } try { Content.BackgroundColor = Color.Gray; Content.InputTransparent = true; if (PasswordEntry.Text == ConfPasswordEntry.Text) { User user = new User(FullNameEntry.Text, CpfEntry.Text, EmailEntry.Text, AboutEntry.Text, BirthdayEntry.Date, ColetorCheckbox.Checked, DoadorCheckbox.Checked, UsernameEntry.Text, PasswordEntry.Text); Address address = new Address(CepEntry.Text, RuaEntry.Text, NumberEntry.Text, ComplementEntry.Text, BairroEntry.Text, CityEntry.Text, StateEntry.Text); Phone phone = new Phone(PhoneEntry.Text); user.Addresses.Add(address); user.Phones.Add(phone); CallbackStatus status = new CallbackStatus(); status = await UserController.AddAPI(user); await DisplayAlert($"{ status.CurrentStatus.CallbackStatusToText()}", status.CallbackMessage, "OK"); if (Application.Current.MainPage.GetType() == typeof(Login)) { await Navigation.PopModalAsync(); } } else { await DisplayAlert("Erro", "Senhas digitadas não conferem!", "Ok"); Content.BackgroundColor = Color.White; Content.InputTransparent = false; } } catch { await DisplayAlert("Ocorreu um erro ao tentar adicionar novo usuário!", "Tente novamente mais tarde!", "Ok"); } }
protected override void PushNotification(Guid DocumentId, Guid ProviderId, CallbackStatus status, string externaldocumentid = null, Guid? signeeref = null, Guid? externaluniqueid = null) { string content = string.Format("{0} ({1})",status, Request.Url.ToString()); HttpContext.Cache.Add(DocumentId.ToString(), content, null, DateTime.Now.AddMinutes(5), System.Web.Caching.Cache.NoSlidingExpiration,System.Web.Caching.CacheItemPriority.Normal,null); }
private void OnChangeServer(InsightMessageBase _callbackMsg, CallbackStatus _status) { OnChangeServer(_callbackMsg); }
public APIException(CallbackStatus status) : base(status.Message) { ErrorCode = status.Code; }
public PaymentOrderCallbackStatusChangedEventData(PaymentOrder paymentOrder, CallbackStatus oldStatus) { PaymentOrder = paymentOrder; OldStatus = oldStatus; }
public PaymentOrderCallbackStatusChangedEventData(PaymentOrder paymentOrder, CallbackStatus oldStatus, string reason) { PaymentOrder = paymentOrder; OldStatus = oldStatus; Reason = reason; }
/// <summary> /// Creates a new instance of <see cref="CallbackEventArgs" />. /// </summary> /// <param name="status">The status of the service call.</param> /// <param name="exception">The associated exception, if any.</param> public CallbackEventArgs(CallbackStatus status = CallbackStatus.Successful, Exception exception = null) { Status = status; Exception = exception; }
void HandleCallbackHandler(CallbackStatus status, NetworkReader reader) { }
protected void ReceiveResponse(InsightMessageBase _callbackMsg, CallbackStatus _status) { OnReceiveResponse?.Invoke(_callbackMsg, _status); }
public InsightMessage(InsightMessage _insightMsg) { status = _insightMsg.status; message = _insightMsg.message; }