private async Task ResumeAfterQnaMakerDialog(IDialogContext context, IAwaitable <object> result) { var messageResult = await result; if (messageResult.ToString().ToLower().Contains("nomatch")) { var messageActivity = context.MakeMessage(); await context.PostAsync(MessageUtility.GetSimpleTextMessage(messageActivity, "We could not find answer to your question")); //await context.PostAsync(GetMessage(context, "")); await context.PostAsync(MessageUtility.GetWelcomeOptionsMessage((Activity)context.Activity, "Please click on the below options")); context.Done("null"); } else if (messageResult.ToString().ToLower().Contains("retailer")) { await context.PostAsync(MessageUtility.GetWelcomeOptionsMessage((Activity)context.Activity, "Looking for")); context.Done("null"); } else { context.Wait(MessageReceivedAsync); } }
public MessageEditor() { InitializeComponent(); byte[] mediaModeCodes = (byte[])Enum.GetValues(typeof(PosEntryMediaModeBytes)); byte[] pinModeCodes = (byte[])Enum.GetValues(typeof(PosEntryPinModeBytes)); this.PosEntryMode.Items.Clear(); for (int i = 0; i < mediaModeCodes.Length; i++) { for (int j = 0; j < pinModeCodes.Length; j++) { byte[] value = new byte[2]; value[0] = (byte)(mediaModeCodes[i] >> 4); value[1] = (byte)((mediaModeCodes[i] << 4) | (pinModeCodes[j] & 0x0f)); this.PosEntryMode.AddItem(value, MessageUtility.HexToString(value).Substring(1)); } } byte[] conditionCodes = (byte[])Enum.GetValues(typeof(PosConditionCodeBytes)); this.PosConditionCode.Items.Clear(); for (int i = 0; i < conditionCodes.Length; i++) { byte[] value = new byte[] { conditionCodes[i] }; this.PosConditionCode.AddItem(value, MessageUtility.HexToString(value)); } }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; try { if (message.Text.ToLower().Contains("retailer finder") || message.Text.ToLower().Contains("retailer")) { try { await context.Forward(Chain.From(() => FormDialog.FromForm(RetailerFinderFormDialog.BuildForm)), ResumeAfterFormDialog, message, CancellationToken.None); } catch (Exception) { await context.PostAsync(MessageUtility.GetWelcomeOptionsMessage((Activity)context.Activity.AsMessageActivity(), $"We could not find retailers for your location. Please try with another Zip/City/State by selecting 'Retailer Finder'.")); } } else if (message.Text.ToLower().Contains("faq")) { await context.PostAsync(MessageUtility.GetSimpleTextMessage(context.MakeMessage(), "Please enter your question")); await context.Forward(new BasicQnAMakerDialog(), ResumeAfterQnaMakerDialog, message, CancellationToken.None); } else { await context.Forward(new SimpleMessageDialog(), ResumeAfterSimpleMessageDialog, message, CancellationToken.None); } } catch (Exception ex) { } }
public async Task <JsonResult> Test() { try { NotificationManagerHub.Test(); return(Success("")); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> GetByOwnerID(string id, string api) { try { var data = SecurityCodeGeneratorService.GetByOwnerID(id, Guid.Parse(api)); return(Success(SecurityCodeVM.MToVM(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> GetByUserID(string id) { try { var data = CloudRoomParticipantsService.GetByUserID(Guid.Parse(id)); return(Success(CloudRoomParticipantsVM.MsToVMs(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public void GetMbapHeader() { var message = new WriteMultipleRegistersRequest(3, 1, MessageUtility.CreateDefaultCollection <RegisterCollection, ushort>(0, 120)); message.TransactionId = 45; Assert.Equal <byte[]>(new byte[] { 0, 45, 0, 0, 0, 247, 3 }, ModbusIpTransport.GetMbapHeader(message)); }
public async Task <JsonResult> UploadImage1() { try { var path = Request.Form["path"]; var fileName = Guid.NewGuid().ToString(); foreach (string file in Request.Files) { var fileContent = Request.Files[file]; if (fileContent != null && fileContent.ContentLength > 0) { //before uploading image make sure it does not exist in path // get a stream var stream = fileContent.InputStream; // and optionally write the file to disk if (!Directory.Exists(Path.Combine(Server.MapPath("~/UPLOADS/" + path)))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/UPLOADS/" + path))); } var uploadPath = Path.Combine(Server.MapPath("~/UPLOADS/" + path), fileName + ".png"); using (var fileStream = System.IO.File.Create(uploadPath)) { stream.CopyTo(fileStream); } } } return(Json(new { success = true, data = "UPLOADS/" + path + "/" + fileName + ".png" })); } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); } }
public async Task <JsonResult> GetByLocationRadius(string lon, string lat, string cat, string api, string rad) { try { var data = LocationStorageService.GetByCategoryLocationRadius(float.Parse(lon) + float.Parse(rad), float.Parse(lat) + float.Parse(rad), cat, Guid.Parse(api)); return(Success(LocationStorageVM.MsToVMs(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public Response0410 Execute(Request0400 request) { if (request == null) { if (ProcessErrorNotification != null) { ProcessErrorNotification(); } return(null); } DateTime now = DateTime.Now; Response0410 response = new RespReversal0410(); response.TransactionDate = now; response.TransactionTime = now; response.RetrievalReferenceNumber = MessageUtility.HexToString(request.SystemAuditTraceNumber); response.ResponseCode = ResponseCode.COMPLETED_SUCCESSFULLY; if (ProcessReversal != null) { ProcessReversal(new ReqReversal0400(request), (RespReversal0410)response); } //ProcessReversal = null; return(response); }
public void CreateDefaultCollection() { RegisterCollection col = MessageUtility.CreateDefaultCollection <RegisterCollection, ushort>(3, 5); Assert.AreEqual(5, col.Count); Assert.AreEqual(new ushort[] { 3, 3, 3, 3, 3 }, col.ToArray()); }
public async Task <JsonResult> GetByID(string id, string api) { try { var data = IS_ItemCategoryService.GetByID(Guid.Parse(id), Guid.Parse(api)); return(Success(IS_ItemCategoryVM.MToVM(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public override string ResponseHandle() { List <String> invalids = new List <string>(); List <String> valids = new List <string>(); if (this.failure > 0) { for (int row = 0; row < this.results.Count; row++) { if (!String.IsNullOrEmpty(this.results[row].error)) { invalids.Add(Devices[row]); } } } valids = Devices.Where(a => !invalids.Any(m => m == a)).ToList(); ResponseBack response = new ResponseBack() { Type = Type, Success = valids, Fail = invalids }; return(MessageUtility.JsonToString(response)); //return JsonConvert.SerializeObject(response); //return base.ResponseHandle(); }
public async Task <JsonResult> GetByID(string id, string ii, string sid) { try { var data = IS_ItemStockService.GetByID(Guid.Parse(id), Guid.Parse(ii), Guid.Parse(sid)); return(Success(IS_ItemStockVM.MToVM(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> GetByCategory(string cat, string api) { try { var data = LocationStorageService.GetByCategory(cat, Guid.Parse(api)); return(Success(LocationStorageVM.MsToVMs(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> GetByID(string id, string api) { try { var data = LocationStorageService.GetByIDAPI(Guid.Parse(id), Guid.Parse(api)); return(Success(LocationStorageVM.MToVM(data))); }catch { return(Failed(MessageUtility.ServerError())); } }
private void ClosePersonList() { _navigationUtility.ClosePage(this); MessageUtility <Data.Person> .InvokeMethod(new Data.Person { Id = 1, Title = "Tit" }); }
public Response0210 Execute(Request0200 request) { if (request == null) { ProcessErrorNotification?.Invoke(); return(null); } DateTime now = DateTime.Now; Response0210 response = new Response0210(); if (request.ProcessingCode.TransactionType == TransactionTypeCodeBytes.CASH_WITHDRAWAL) { response = new RespCashWithdrawal0210(); } else if (request.ProcessingCode.TransactionType == TransactionTypeCodeBytes.PAYMENT) { response = new RespPayment0210(); } else if (request.ProcessingCode.TransactionType == TransactionTypeCodeBytes.TRANSFER) { response = new RespTransfer0210(); } response.TransactionDate = now; response.TransactionTime = now; response.RetrievalReferenceNumber = MessageUtility.HexToString(request.SystemAuditTraceNumber); response.ResponseCode = ResponseCode.COMPLETED_SUCCESSFULLY; response.MessageAuthenticationCode = new byte[8]; if (request.TransferData != null) { response.TransferData = request.TransferData; //It's just default value, it must be queried from db in the delegates defined above response.TransferData.BeneficiaryName = "BENEFICIARY NAME GENERATED"; response.TransferData.IssuerInstitutionId = "4442"; response.TransferData.CardholderAccountNumber = "1234567890123456"; response.TransferData.CardholderName = "CARD HOLDER NAME GENERATED"; } if (request.ProcessingCode.TransactionType == TransactionTypeCodeBytes.CASH_WITHDRAWAL) { ProcessCashWithdrawal?.Invoke(new ReqCashWithdrawal0200(request), (RespCashWithdrawal0210)response); } else if (request.ProcessingCode.TransactionType == TransactionTypeCodeBytes.PAYMENT) { ProcessPayment?.Invoke(new ReqPayment0200(request), (RespPayment0210)response); } else if (request.ProcessingCode.TransactionType == TransactionTypeCodeBytes.TRANSFER) { ProcessTransfer?.Invoke(new ReqTransfer0200(request), (RespTransfer0210)response); } //ProcessCashWithdrawal = null; //ProcessPayment = null; //ProcessTransfer = null; return(response); }
private void btnSend_Click(object sender, EventArgs e) { if (_isAttributeConfig != chkConfig.Checked) { if (!LoadConfig()) { return; } } byte[] reqMsg = null; if (_reqModel == null) { String sReq = txtRequest.Text.Trim(); if (String.IsNullOrEmpty(sReq)) { return; } Regex ws = new Regex(@"\s+"); sReq = ws.Replace(sReq, ""); reqMsg = MessageUtility.StringToHex(sReq, true); if (reqMsg == null) { MessageBox.Show("Invalid hexadecimal string."); } } try { _client = new MessageClient(txtServerHost.Text, int.Parse(txtServerPort.Text), null, this.PrintModel); _client.IsSslEnabled = chkSsl.Checked; /*if (_client.IsSslEnabled) * { * _client.ClientCertificates = _certificates; * _client.CertificateSelectionCallback = this.LocalCertificateSelectionCallback; * _client.CertificateValidationCallback = this.RemoteCertificateValidationCallback; * }*/ if (_reqModel == null) { Thread thread = new Thread(_client.SendBytes); thread.Start(reqMsg); } else { _client.Model = _reqModel; _client.SendModel(); } } catch (Exception ex) { MessageBox.Show("Cannot connect to the server." + Environment.NewLine + ex.Message); } finally { btnStop_Click(sender, e); } }
public async Task <JsonResult> GetByRoomID() { try { var id = Guid.Parse(Request.Form["id"]); var data = MessagingConversationService.GetByRoomID(id); return(Success(MessagingConversationVM.MsToVMs(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> GetByMostViewed(string take, string longi, string lat) { try { //most viewed ads near your location var data = ItemService.GetByMostViewedItem(int.Parse(take), float.Parse(longi), float.Parse(lat)); return(Success(ItemsViewModel.MsToVMs(data))); } catch { return(Failed(MessageUtility.ServerError())); } }
public void AddElementsToBodyTest() { Message message = MessageUtilityTests.GetSampleMessage(); List <KeyValuePair <string, string> > queryOptions = MessageUtilityTests.GetSampleQueryOptions(); MessageUtility.AddMessageQueryOptions(ref message, queryOptions); MessageUtilityTests.CompareSampleMessage(message); }
public async Task <JsonResult> Test1() { try { var test = Request.Form["test"]; var test2 = Request.Form["test2"]; return(Success("Test1: " + test + " Test2: " + test2)); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> SendMessage() { try { return(Success("")); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> CancelRequest() { try { var rid = Request.Form["RID"]; RequestService.UpdateStatus(true, rid.ToString()); return(Json(new { success = true })); } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); } }
static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); ILog log = LogManager.GetLogger(typeof(Program)); try { log.Info(LogFormat.Message("", "Application_start", LogStatus.Success, "")); MultiLanguageManager.SetDefaultLabelsDictionary <DSW.Localisation.Labels.Dictionary>(); MultiLanguageManager.SetDefaultMessageDictionary <DSW.Localisation.Messages.Dictionary>(); if (SingleInstanceApplication.IsExist()) { FormUtility.EnableTaskBar(false); FormUtility.EnableTaskBar(true); MessageUtility.DisplayErrorMsg(MultiLanguageManager.Messages.GetString(DSW.Localisation.Messages.Dictionary.Common.HT_COM_MS029), MultiLanguageManager.Messages.GetString(DSW.Localisation.Messages.Dictionary.Common.HT_COM_CAP001)); log.Info(LogFormat.Message("", "Application_end", LogStatus.Failed, DSW.Localisation.Messages.Dictionary.Common.HT_COM_MS029)); Application.Exit(); return; } FormUtility.EnableTaskBar(false); AppDataService.SetSettingApiAddress(Setting.ApiAddress); var appModule = new AppModule(); var mvvmApplication = new MvvmApplication(appModule); mvvmApplication.Run <StocktakeNewView>(); FormUtility.EnableTaskBar(true); log.Info(LogFormat.Message("", "Application_end", LogStatus.Success, "")); LogManager.Shutdown(); } catch (Exception ex) { log.Info(LogFormat.Message("", "Application_end", LogStatus.Failed, ex.Message + Environment.NewLine + ex.StackTrace)); LogManager.Shutdown(); FormUtility.EnableTaskBar(false); FormUtility.EnableTaskBar(true); MessageUtility.DisplayErrorMsg(ex.Message, MultiLanguageManager.Messages.GetString(DSW.Localisation.Messages.Dictionary.Common.HT_COM_CAP001)); Application.Exit(); } }
public async Task <JsonResult> GetByID(string id, string aid) { try { var data = ImageLinkStorageService.GetByID(Guid.Parse(id), Guid.Parse(aid)); return(Success(ImageLinkStorageVM.MToVM(data))); } catch { return(Failed(MessageUtility.ServerError() + " " + id + " " + aid)); } }
/// <summary> /// Converts the specified <paramref name="parameters"/> into an outbound /// <see cref="Message"/>. For query requests with query properties, stores the query /// parameters either in the To/Via or the message body. /// </summary> /// <param name="messageVersion">The version of the message to use.</param> /// <param name="parameters">The parameters passed to the client operation.</param> /// <returns>The message to send.</returns> public Message SerializeRequest(MessageVersion messageVersion, object[] parameters) { Message request = this._innerFormatter.SerializeRequest(messageVersion, parameters); object queryProperty = null; object includeTotalCountProperty = null; if (OperationContext.Current != null) { OperationContext.Current.OutgoingMessageProperties.TryGetValue(WebDomainClient <object> .QueryPropertyName, out queryProperty); OperationContext.Current.OutgoingMessageProperties.TryGetValue(WebDomainClient <object> .IncludeTotalCountPropertyName, out includeTotalCountProperty); } List <KeyValuePair <string, string> > queryOptions = new List <KeyValuePair <string, string> >(); if (queryProperty != null) { foreach (ServiceQueryPart queryPart in QuerySerializer.Serialize((IQueryable)queryProperty)) { queryOptions.Add( new KeyValuePair <string, string>( queryPart.QueryOperator, queryPart.Expression)); } } if (includeTotalCountProperty != null) { queryOptions.Add( new KeyValuePair <string, string>("includeTotalCount", includeTotalCountProperty.ToString())); } if (queryOptions.Count > 0) { Debug.Assert(OperationContext.Current != null, "OpeartionContext.Current cannot be null at this point."); if (MessageUtility.IsHttpPOSTMethod(OperationContext.Current.OutgoingMessageProperties)) { MessageUtility.AddMessageQueryOptions(ref request, queryOptions); } else { MessageUtility.AddQueryToUrl(ref request, queryOptions); } } if (request.Headers.To.AbsoluteUri.Length > WebHttpQueryClientMessageFormatter.MaximumUriLength) { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resource.WebDomainClient_MaximumUriLengthExceeded, WebHttpQueryClientMessageFormatter.MaximumUriLength)); } return(request); }
public async Task <JsonResult> Uploads(string org, string src) { try { var fname = Guid.NewGuid(); var path = Path.Combine(Server.MapPath("~/UPLOADS/" + org), fname.ToString() + ".png"); byte[] bytes = Convert.FromBase64String(src); System.IO.File.WriteAllBytes(path, bytes); return(Success("Upload: " + org + " " + src + " " + Path.Combine(Server.MapPath("~/UPLOADS/" + org)))); } catch { return(Failed(MessageUtility.ServerError())); } }
public async Task <JsonResult> NotifyInvitationAccepted() { try { var cid = Request.Form["cid"]; var username = Request.Form["uname"]; SignalRClients.NotifyInvitationAccepted(cid, username); return(Json(new { success = true })); } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); } }