/// <summary>
 ///     Initializes a new instance of the <see cref="Configuration" /> class.
 /// </summary>
 /// <param name="positiveButton">The positive button text</param>
 /// <param name="positiveResult">The positive result</param>
 /// <param name="negativeButton">The negative button text</param>
 /// <param name="negativeResult">The negative result</param>
 public Configuration(string positiveButton, MessageResult positiveResult, string negativeButton, MessageResult negativeResult)
 {
     PositiveButton = positiveButton;
     PositiveResult = positiveResult;
     NegativeButton = negativeButton;
     NegativeResult = negativeResult;
 }
Esempio n. 2
0
 /// <summary>
 /// Creates a new instance of MessageResult
 /// </summary>
 /// <param name="result">Result</param>
 /// <param name="callId">CallId</param>
 /// <returns>returns a new instance of MessageResult</returns>
 public static MessageResult CreateInstance(MethodResult result, string callId)
 {
     MessageResult msg = new MessageResult();
     msg.result = result;
     msg.callId = callId;
     return msg;
 }
 public string GetButtonText(MessageResult forWhichResponse)
 {
     string buttonText = String.Empty;
     switch (forWhichResponse)
     {
         case MessageResult.Abort:
             buttonText = _buttonAbortText;
             break;
         case MessageResult.Cancel:
             buttonText = _buttonCancelText;
             break;
         case MessageResult.Close:
             buttonText = _buttonCloseText;
             break;
         case MessageResult.Ignore:
             buttonText = _buttonIgnoreText;
             break;
         case MessageResult.No:
             buttonText = _buttonNoText;
             break;
         case MessageResult.Ok:
             buttonText = _buttonOkText;
             break;
         case MessageResult.Retry:
             buttonText = _buttonRetryText;
             break;
         case MessageResult.Yes:
             buttonText = _buttonYesText;
             break;
         default:
             break;
     }
     return buttonText;
 }
 private MessageResult ShowMessage(string messageBoxText, string caption, MessageButton button, MessageImage icon,
     MessageResult defaultResult)
 {
     DialogResult result = MessageBox.Show(messageBoxText, caption, ConvertButtons(button), ConvertImage(icon),
         ConvertDefaultResult(button, defaultResult));
     return ConvertResult(result);
 }
 MessageResult IMessageBoxService.Show(string messageBoxText, string caption, MessageButton button, MessageIcon icon, MessageResult defaultResult) {
     var owner = AssociatedObject.With(x => Window.GetWindow(x));
     if(owner == null)
         return MessageBox.Show(messageBoxText, caption, button.ToMessageBoxButton(), icon.ToMessageBoxImage(), defaultResult.ToMessageBoxResult()).ToMessageResult();
     else
         return MessageBox.Show(owner, messageBoxText, caption, button.ToMessageBoxButton(), icon.ToMessageBoxImage(), defaultResult.ToMessageBoxResult()).ToMessageResult();
 }
Esempio n. 6
0
        bool DoExecute(MessageResult ctx, IObserverHandler<IMessage> handler, AtomicInteger barrier)
        {
            var e = new MessageReceivingEventArgs (ctx, handler.Target);
            try
            {
                ListnerManager.OnReceiving(e);
                if (!e.Ignored)
                    ctx.results.Add(DelegateInvoker.Invoke<IMessage>(handler, ctx.Request.Sender, ctx.Request.ToMessage()));

                
                return true;
            }
            catch (Exception ex)
            {
                var re = new MessageExceptionEventArgs (ctx,ex);
                ListnerManager.OnReceivingException(re);
                ctx.InnerExceptions.Add(ex);
                return !re.Canceled; 
            }
            finally
            {
                barrier--;

                if (barrier == 0)
                {
                    ListnerManager.OnReceived(new MessageEventArgs(ctx));
                    ListnerManager.OnSent(e);
                    OnCompleted(ctx);
                }
                else
                    ListnerManager.OnReceived(new MessageEventArgs(ctx));
                
                e = null;
            }
        }
 public MessageResult Show(string messageBoxText, string caption, MessageButton button, MessageResult defaultResult) {
     MessageBoxTest = messageBoxText;
     Caption = caption;
     Button = button;
     DefaultResult = defaultResult;
     ShowCount++;
     return Result;
 }
 public Task<MessageResult> ShowAsync(string messageBoxText, string caption = "",
     MessageButton button = MessageButton.Ok, MessageImage icon = MessageImage.None,
     MessageResult defaultResult = MessageResult.None, IDataContext context = null)
 {
     if (_threadManager.IsUiThread)
         return ToolkitExtensions.FromResult(ShowMessage(messageBoxText, caption, button, icon, defaultResult));
     var tcs = new TaskCompletionSource<MessageResult>();
     _threadManager.InvokeOnUiThreadAsync(
         () => tcs.SetResult(ShowMessage(messageBoxText, caption, button, icon, defaultResult)));
     return tcs.Task;
 }
 public Task<MessageResult> ShowAsync(string message, string caption = "",
     MessageButton button = MessageButton.Ok, MessageImage icon = MessageImage.None,
     MessageResult defaultResult = MessageResult.None, IDataContext context = null)
 {
     var tcs = new TaskCompletionSource<MessageResult>();
     if (_threadManager.IsUiThread)
         ShowMessage(message, caption, button, tcs);
     else
         _threadManager.InvokeOnUiThreadAsync(() => ShowMessage(message, caption, button, tcs));
     return tcs.Task;
 }
Esempio n. 10
0
        public IMessageResponse Publish(IMessageRequest req)
        {
            CheckNotDisposed();

            var ctx = new MessageResult(req);
            Queue.Enqueue(ctx);
            if (req.IsAsync)
            {
                ThreadPool.QueueUserWorkItem(s => Executor.Execute());
                return ctx;
            }
            return Executor.Execute();
        }
Esempio n. 11
0
 public void Setup_ShowWarning(MessageResult result,Action callback=null)
 {
     Mock.Setup(
         p =>
             p.ShowWarning(It.IsAny<IntPtr>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<MessageButtons>()))
         .Callback(() =>
         {
             MessagesCount++;
             if (callback != null)
                 callback();
         })
         .Returns(result);
 }
 private void DoSmth()
 {
     Thread.Sleep(1000);
     var bld = new StringBuilder(1000);
     for (int i = 0; i < 1000; i++)
     {
         bld.Append(i);
         bld.Append(@"\n");
     }
     var result = new MessageResult();
     result.Message = bld.ToString();
     _beginGetInventoryItems(result);
 }
        private void ShowMessage(string messageBoxText, string caption, MessageButton button,
            MessageResult defaultResult,
            TaskCompletionSource<MessageResult> tcs)
        {
            var messageDialog = new MessageDialog(messageBoxText, caption);
            switch (button)
            {
                case MessageButton.Ok:
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Ok, tcs));
                    break;
                case MessageButton.OkCancel:
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Ok, tcs));
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Cancel, tcs));
                    break;
                case MessageButton.YesNo:
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Yes, tcs));
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.No, tcs));
                    break;
                case MessageButton.YesNoCancel:
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Yes, tcs));
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.No, tcs));
                    if (MvvmApplication.Current.Platform.Platform != PlatformType.WinPhone)
                        messageDialog.Commands.Add(CreateUiCommand(MessageResult.Cancel, tcs));
                    break;
                case MessageButton.AbortRetryIgnore:
                    if (MvvmApplication.Current.Platform.Platform == PlatformType.WinPhone)
                        throw ExceptionManager.EnumOutOfRange("button", button);

                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Abort, tcs));
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Retry, tcs));
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Ignore, tcs));
                    break;
                case MessageButton.RetryCancel:
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Retry, tcs));
                    messageDialog.Commands.Add(CreateUiCommand(MessageResult.Cancel, tcs));
                    break;
                default:
                    tcs.SetResult(MessageResult.None);
                    return;
            }
            for (int i = 0; i < messageDialog.Commands.Count; i++)
            {
                if (defaultResult == (MessageResult)messageDialog.Commands[i].Id)
                {
                    messageDialog.DefaultCommandIndex = (uint)i;
                    break;
                }
            }
            messageDialog.ShowAsync();
        }
Esempio n. 14
0
        void Dispatch(MessageResult ctx)
        {
            var handlers = Subject.Subscriber.Observers;

            var syncHandlers = handlers.Where(i => i.Value == SubscribeMode.Sync).Select(i => i.Key).ToArray();
            var asyncHandlers = handlers.Where(i => i.Value == SubscribeMode.Async).Select(i => i.Key).ToArray();

            var handlerCount = syncHandlers.Length + asyncHandlers.Length;
            var barrier = new AtomicInteger(handlerCount);

            foreach (var item in syncHandlers)
            {
                if (!DoExecute(ctx, item, barrier))
                    break;
            }


            Paraller.ForEach(asyncHandlers, handler => DoExecute(ctx, handler, barrier));
        }
Esempio n. 15
0
        private Task<bool> HandleServerCommands(MessageResult result)
        {
            for (int i = 0; i < result.Messages.Count; i++)
            {
                for (int j = result.Messages[i].Offset; j < result.Messages[i].Offset + result.Messages[i].Count; j++)
                {
                    Message message = result.Messages[i].Array[j];

                    // Only handle server commands
                    if (ServerSignal.Equals(message.Key))
                    {
                        // Uwrap the command and raise the event
                        var command = _serializer.Parse<ServerCommand>(message.Value);
                        OnCommand(command);
                    }
                }
            }

            return TaskAsyncHelper.True;
        }
        private void OnMessageReceived(MessageResult msgResult)
        {
            MatchmakingMessageEventHandler handler = null;

            switch (msgResult)
            {
                case MessageResult.GameFound:
                    handler = GameFoundEvent;
                    break;

                case MessageResult.GameNotFound:
                    handler = GameNotFoundEvent;
                    break;
            }

            if (handler != null)
            {
                handler(this);
            }
        }
        public Task<MessageResult> ShowAsync(string messageBoxText, string caption = "",
            MessageButton button = MessageButton.Ok, MessageImage icon = MessageImage.None,
            MessageResult defaultResult = MessageResult.None, IDataContext context = null)
        {
            bool success;
            MessageBoxButton buttons = ConvertMessageBoxButtons(button, out success);
            Should.BeSupported(success, "The MessageBoxAdapter doesn't support {0} value", button);

            if (_threadManager.IsUiThread)
            {
                MessageBoxResult result = MessageBox.Show(messageBoxText, caption, buttons);
                return ToolkitExtensions.FromResult(ConvertMessageBoxResult(result, button));
            }
            var tcs = new TaskCompletionSource<MessageResult>();
            _threadManager.InvokeOnUiThreadAsync(() =>
            {
                MessageBoxResult result = MessageBox.Show(messageBoxText, caption, buttons);
                tcs.SetResult(ConvertMessageBoxResult(result, button));
            });
            return tcs.Task;
        }
        public string Localize(MessageResult button) {
            switch(button) {
                case MessageResult.OK:
                    return "OK";
                case MessageResult.Cancel:
                    return "Cancel";
                case MessageResult.Yes:
                    return "Yes";
                case MessageResult.No:
                    return "No";
#if NETFX_CORE
                case MessageResult.Close:
                    return "Close";
                case MessageResult.Ignore:
                    return "Ignore";
                case MessageResult.Retry:
                    return "Retry";
                case MessageResult.Abort:
                    return "Abort";
#endif
            }
            return string.Empty;
        }
Esempio n. 19
0
 public virtual async Task <bool> OpenChannel(MessageResult e)
 {
     return(false);
 }
Esempio n. 20
0
        public override async Task Render(MessageResult result)
        {
            ButtonForm bf = new ButtonForm();

            switch (this.PickerMode)
            {
            case eMonthPickerMode.day:

                var month = this.VisibleMonth;

                string[] dayNamesNormal  = this.Culture.DateTimeFormat.ShortestDayNames;
                string[] dayNamesShifted = Shift(dayNamesNormal, (int)this.FirstDayOfWeek);

                bf.AddButtonRow(new ButtonBase("<<", "prev"), new ButtonBase(this.Culture.DateTimeFormat.MonthNames[month.Month - 1] + " " + month.Year.ToString(), "monthtitle"), new ButtonBase(">>", "next"));

                bf.AddButtonRow(dayNamesShifted.Select(a => new ButtonBase(a, a)).ToList());

                //First Day of month
                var firstDay = new DateTime(month.Year, month.Month, 1);

                //Last Day of month
                var lastDay = firstDay.LastDayOfMonth();

                //Start of Week where first day of month is (left border)
                var start = firstDay.StartOfWeek(this.FirstDayOfWeek);

                //End of week where last day of month is (right border)
                var end = lastDay.EndOfWeek(this.FirstDayOfWeek);

                for (int i = 0; i <= ((end - start).Days / 7); i++)
                {
                    var lst = new List <ButtonBase>();
                    for (int id = 0; id < 7; id++)
                    {
                        var d = start.AddDays((i * 7) + id);
                        if (d <firstDay | d> lastDay)
                        {
                            lst.Add(new ButtonBase("-", "m-" + d.Day.ToString()));
                            continue;
                        }

                        var day = d.Day.ToString();

                        if (d == DateTime.Today)
                        {
                            day = "(" + day + ")";
                        }

                        lst.Add(new ButtonBase((this.SelectedDate == d ? "[" + day + "]" : day), "d-" + d.Day.ToString()));
                    }
                    bf.AddButtonRow(lst);
                }

                break;

            case eMonthPickerMode.month:

                bf.AddButtonRow(new ButtonBase("<<", "prev"), new ButtonBase(this.VisibleMonth.Year.ToString("0000"), "yeartitle"), new ButtonBase(">>", "next"));

                var months = this.Culture.DateTimeFormat.MonthNames;

                var buttons = months.Select((a, b) => new ButtonBase((b == this.SelectedDate.Month - 1 && this.SelectedDate.Year == this.VisibleMonth.Year ? "[ " + a + " ]" : a), "m-" + (b + 1).ToString()));

                bf.AddSplitted(buttons, 2);

                break;

            case eMonthPickerMode.year:

                bf.AddButtonRow(new ButtonBase("<<", "prev"), new ButtonBase("Year", "yearstitle"), new ButtonBase(">>", "next"));

                var starti = Math.Floor(this.VisibleMonth.Year / 10f) * 10;

                for (int i = 0; i < 10; i++)
                {
                    var m = starti + (i * 2);
                    bf.AddButtonRow(new ButtonBase((this.SelectedDate.Year == m ? "[ " + m.ToString() + " ]" : m.ToString()), "y-" + m.ToString()), new ButtonBase((this.SelectedDate.Year == (m + 1) ? "[ " + (m + 1).ToString() + " ]" : (m + 1).ToString()), "y-" + (m + 1).ToString()));
                }

                break;
            }


            if (this.MessageId != null)
            {
                var m = await this.Device.Edit(this.MessageId.Value, this.Title, bf);
            }
            else
            {
                var m = await this.Device.Send(this.Title, bf);

                this.MessageId = m.MessageId;
            }
        }
Esempio n. 21
0
 public static List<UICommand> GenerateFromMessageButton(MessageButton dialogButtons, IMessageButtonLocalizer buttonLocalizer, MessageResult? defaultButton = null, MessageResult? cancelButton = null) {
     return GenerateFromMessageButton(dialogButtons, false, buttonLocalizer, defaultButton, cancelButton);
 }
Esempio n. 22
0
 private IUICommand CreateUiCommand(MessageResult result, TaskCompletionSource<MessageResult> tcs)
 {
     string text = GetButtonText(result);
     return new UICommand(text, command => tcs.SetResult((MessageResult)command.Id)) { Id = result };
 }
Esempio n. 23
0
 /// <summary>
 /// Returns the result and closes the message
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void CButton_OnClick(object sender, RoutedEventArgs e)
 {
     CButton button = (CButton)sender;
     if (button.Content == "OK")
     {
         Result = MessageResult.OK;
     }
     else if (button.Content == "Yes")
     {
         Result = MessageResult.Yes;
     }
     else if (button.Content == "No")
     {
         Result = MessageResult.No;
     }
     else if (button.Content == "Cancel")
     {
         Result = MessageResult.Cancel;
     }
     else if (button.Content == "Ignore")
     {
         Result = MessageResult.Ignore;
     }
     else if (button.Content == "Retry")
     {
         Result = MessageResult.Retry;
     }
     emptyWindow.Close();
 }
Esempio n. 24
0
        public async override Task Render(MessageResult result)
        {
            if (!this.RenderNecessary)
            {
                return;
            }

            //Check for rows and column limits
            CheckGrid();

            this.RenderNecessary = false;

            Message m = null;

            ButtonForm form = this.ButtonsForm;

            if (this.EnableSearch && this.SearchQuery != null && this.SearchQuery != "")
            {
                form = form.FilterDuplicate(this.SearchQuery, true);
            }
            else
            {
                form = form.Duplicate();
            }

            if (this.EnablePaging)
            {
                form = GeneratePagingView(form);
            }

            if (this.HeadLayoutButtonRow != null && HeadLayoutButtonRow.Count > 0)
            {
                form.InsertButtonRow(0, this.HeadLayoutButtonRow);
            }

            if (this.SubHeadLayoutButtonRow != null && SubHeadLayoutButtonRow.Count > 0)
            {
                if (this.IsNavigationBarVisible)
                {
                    form.InsertButtonRow(2, this.SubHeadLayoutButtonRow);
                }
                else
                {
                    form.InsertButtonRow(1, this.SubHeadLayoutButtonRow);
                }
            }

            switch (this.KeyboardType)
            {
            //Reply Keyboard could only be updated with a new keyboard.
            case eKeyboardType.ReplyKeyboard:

                if (this.MessageId != null)
                {
                    if (form.Count == 0)
                    {
                        await this.Device.HideReplyKeyboard();

                        this.MessageId = null;
                        return;
                    }

                    if (this.DeletePreviousMessage)
                    {
                        await this.Device.DeleteMessage(this.MessageId.Value);
                    }
                }

                if (form.Count == 0)
                {
                    return;
                }


                var rkm = (ReplyKeyboardMarkup)form;
                rkm.ResizeKeyboard  = this.ResizeKeyboard;
                rkm.OneTimeKeyboard = this.OneTimeKeyboard;
                m = await this.Device.Send(this.Title, rkm, disableNotification : true, parseMode : MessageParseMode, MarkdownV2AutoEscape : false);

                break;

            case eKeyboardType.InlineKeyBoard:

                if (this.MessageId != null)
                {
                    m = await this.Device.Edit(this.MessageId.Value, this.Title, (InlineKeyboardMarkup)form);
                }
                else
                {
                    m = await this.Device.Send(this.Title, (InlineKeyboardMarkup)form, disableNotification : true, parseMode : MessageParseMode, MarkdownV2AutoEscape : false);
                }

                break;
            }

            if (m != null)
            {
                this.MessageId = m.MessageId;
            }
        }
Esempio n. 25
0
        public JsonResult CreateExam([FromBody] ExamForCreationDto exam)
        {
            string functionName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            try
            {
                //Check value enter from the form
                if (exam == null)
                {
                    Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.notInformationExam));
                    return(Json(MessageResult.GetMessage(MessageType.NOT_INFORMATION_EXAM)));
                }

                if (!ModelState.IsValid)
                {
                    Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.notFound));
                    return(Json(MessageResult.GetMessage(MessageType.NOT_FOUND)));
                }

                GroupOwnerEntity groupOwner = _groupOwnerRepository.GetGroupOwnerByGroupId(exam.GroupId);
                //Map data enter from the form to exam entity
                var finalExam = Mapper.Map <PPT.Database.Entities.ExamEntity>(exam);

                //This is query insert exam
                _examRepository.CreateExam(finalExam);

                if (!_examRepository.Save())
                {
                    Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.badRequest));

                    return(Json(MessageResult.GetMessage(MessageType.BAD_REQUEST)));
                }
                GroupEntity groupEntity = _groupRepository.GetGroupByExam(finalExam);

                List <GroupMemberEntity> listGroupMembers = _groupMemberRepository.GetGroupMemberByGroupId(groupEntity.GroupId);
                if (listGroupMembers.Count() > 0)
                {
                    AccountExamEntity accountExamEntity1 = new AccountExamEntity();
                    accountExamEntity1.Exam      = finalExam;
                    accountExamEntity1.AccountId = groupOwner.AccountId;
                    accountExamEntity1.ExamId    = finalExam.ExamId;
                    accountExamEntity1.IsStatus  = "Empty";
                    _accountExamRepository.CreateAccountExam(accountExamEntity1);
                    _accountExamRepository.Save();
                    foreach (var item in listGroupMembers)
                    {
                        AccountExamEntity accountExamEntity = new AccountExamEntity();
                        accountExamEntity.Exam      = finalExam;
                        accountExamEntity.AccountId = item.AccountId;
                        accountExamEntity.Account   = item.Account;
                        accountExamEntity.ExamId    = finalExam.ExamId;
                        accountExamEntity.IsStatus  = "Empty";
                        _accountExamRepository.CreateAccountExam(accountExamEntity);
                        _accountExamRepository.Save();
                    }
                }
                else
                {
                    AccountExamEntity accountExamEntity = new AccountExamEntity();
                    accountExamEntity.Exam      = finalExam;
                    accountExamEntity.AccountId = groupOwner.AccountId;
                    accountExamEntity.ExamId    = finalExam.ExamId;
                    accountExamEntity.IsStatus  = "Empty";
                    _accountExamRepository.CreateAccountExam(accountExamEntity);
                    _accountExamRepository.Save();
                }
                Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.createdExam));
                return(Json(MessageResult.GetMessage(MessageType.CREATED_EXAM)));
            }
            catch (Exception ex)
            {
                Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(ex.Message));
                return(Json(MessageResult.ShowServerError(ex.Message)));
            }
        }
Esempio n. 26
0
        public async override Task Action(MessageResult result, string value = null)
        {
            if (result.Handled)
            {
                return;
            }

            if (!result.IsFirstHandler)
            {
                return;
            }

            await result.ConfirmAction(this.ConfirmationText ?? "");

            //Find clicked button depending on Text or Value (depending on markup type)
            switch (this.KeyboardType)
            {
            case eKeyboardType.InlineKeyBoard:

                var button = HeadLayoutButtonRow?.FirstOrDefault(a => a.Value == result.RawData)
                             ?? SubHeadLayoutButtonRow?.FirstOrDefault(a => a.Value == result.RawData)
                             ?? ButtonsForm.ToList().FirstOrDefault(a => a.Value == result.RawData);

                if (button == null)
                {
                    switch (result.RawData)
                    {
                    case "$previous$":

                        if (this.CurrentPageIndex > 0)
                        {
                            this.CurrentPageIndex--;
                        }

                        this.Updated();

                        break;

                    case "$next$":

                        if (this.CurrentPageIndex < this.PageCount - 1)
                        {
                            this.CurrentPageIndex++;
                        }

                        this.Updated();

                        break;
                    }


                    return;
                }

                await OnButtonClicked(new ButtonClickedEventArgs(button));

                result.Handled = true;

                break;
            }
        }
Esempio n. 27
0
 MessageResult IMessageBoxService.Show(string messageBoxText, string caption, MessageButton button, MessageIcon icon, MessageResult defaultResult)
 {
     MessageBoxText = messageBoxText;
     Caption        = caption;
     Button         = button;
     Icon           = icon;
     DefaultResult  = defaultResult;
     return(Result);
 }
Esempio n. 28
0
 public OnAddMessage(MessageResult message)
     : base("onAddMessage", message)
 {
 }
Esempio n. 29
0
        static void Main(string[] args)
        {
            Console.WriteLine("************");
            Console.WriteLine("*****开始发送******");

            //String result;
            String app_key       = "_";
            String master_secret = "_";
            //int sendno = 9;

            HashSet <DeviceEnum> set = new HashSet <DeviceEnum>();

            set.Add(DeviceEnum.Android);
            set.Add(DeviceEnum.IOS);
            JPushClient client = new JPushClient(app_key, master_secret, 0, set, true);

            MessageResult result = null;

            NotificationParams  notifyParams = new NotificationParams();
            CustomMessageParams customParams = new CustomMessageParams();

            //notifyParams.

            //传入json字符串


            String extras = null;


            extras = "{\"ios\":{\"badge\":88, \"sound\":\"happy\"}}";


            //extras中有中文请用HttpUtility.UrlEncode编码
            //System.Web.HttpUtility.UrlEncode(notificationContent, Encoding.UTF8);

            Console.WriteLine("*****发送带tag通知******");

            /**
             *发送类型
             * APP_KEY      通知
             * TAG           TAG
             * ALIAS       ALIAS
             * REGISTRATION_ID  REGISTRATION_ID
             */
            notifyParams.ReceiverType = ReceiverTypeEnum.APP_KEY;

            notifyParams.SendNo = 256;
            //notifyParams.OverrideMsgId = "1";

            result = client.sendNotification("酷派tag111111", notifyParams, extras);
            Console.WriteLine("sendNotification by tag:**返回状态:" + result.getErrorCode().ToString() +
                              "  **返回信息:" + result.getErrorMessage() +
                              "  **Send No.:" + result.getSendNo() +
                              "  msg_id:" + result.getMessageId() +
                              "  频率次数:" + result.getRateLimitQuota() +
                              "  可用频率:" + result.getRateLimitRemaining() +
                              "  重置时间:" + result.getRateLimitReset());



            Console.WriteLine("*****发送带tag消息******");

            //customParams.addPlatform(DeviceEnum.Android);
            customParams.ReceiverType  = ReceiverTypeEnum.TAG;
            customParams.ReceiverValue = "tag_api";

            customParams.SendNo = 256;
            result = client.sendCustomMessage("send custom mess by tag", "tag notify content", customParams, extras);
            Console.WriteLine("sendCustomMessage:**返回状态:" + result.getErrorCode().ToString() +
                              "  **返回信息:" + result.getErrorMessage() +
                              "  **Send No.:" + result.getSendNo() +
                              "  msg_id:" + result.getMessageId() +
                              "  频率次数:" + result.getRateLimitQuota() +
                              "  可用频率:" + result.getRateLimitRemaining() +
                              "  重置时间:" + result.getRateLimitReset());


            Console.WriteLine();

            String         msg_ids        = "1613113584,1229760629,1174658841,1174658641";
            ReceivedResult receivedResult = client.getReceivedApi(msg_ids);

            Console.WriteLine("Report Result:");
            foreach (ReceivedResult.Received re in receivedResult.ReceivedList)
            {
                Console.WriteLine("getReceivedApi************msgid=" + re.msg_id + "  ***andriod received=" + re.android_received + " ***ios received=" + re.ios_apns_sent);
            }
            Console.WriteLine();
        }
Esempio n. 30
0
        private async Task <dynamic> UploadAsync(HttpRequestMessage request, [FromUri] UploadFileDto model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            try
            {
                var mr          = new MessageResult();
                var fileUrls    = new List <string>();
                var httpRequest = HttpContext.Current.Request;
                foreach (string httpFile in httpRequest.Files)
                {
                    var postedFile = httpRequest.Files[httpFile];
                    if (postedFile != null && postedFile.ContentLength > 0)
                    {
                        var    fileName  = postedFile.FileName;
                        string extension = GetFileExtension(fileName);
                        bool   isAllowed = CheckAllowedExtensions(extension);
                        if (!isAllowed)
                        {
                            mr.Message = "不支持的文件格式:" + extension;
                            mr.Success = false;
                            return(await Task.FromResult(mr));
                        }

                        int maxM             = 10;
                        int MaxContentLength = 1024 * 1024 * maxM; //Size = 10 MB   //todo
                        if (postedFile.ContentLength > MaxContentLength)
                        {
                            mr.Message = string.Format("超出上传最大限制:{0}M", maxM);
                            mr.Success = false;
                            return(await Task.FromResult(mr));
                        }

                        var server     = HttpContext.Current.Server;
                        var saveFolder = server.MapPath(model.VirtualFolder.TrimEnd('/'));

                        var theFileName = fileName;
                        if (!string.IsNullOrWhiteSpace(model.FileName))
                        {
                            theFileName = model.FileName;
                        }
                        var savePath = Path.Combine(saveFolder, theFileName);
                        //Deletion exists file
                        if (File.Exists(savePath))
                        {
                            File.Delete(savePath);
                        }
                        MakeSureFolderExist(saveFolder);

                        postedFile.SaveAs(savePath);
                        var fileUrl = string.Format("{0}/{1}", model.VirtualFolder.TrimEnd('/'), theFileName);
                        fileUrls.Add(fileUrl);
                    }
                    else
                    {
                        fileUrls.Add(null);
                    }
                }
                mr.Message = "上传完成";
                mr.Success = true;
                mr.Data    = fileUrls;
                return(await Task.FromResult(mr));
            }
            catch (Exception ex)
            {
                return(request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Esempio n. 31
0
 static MessageResult()
 {
     Empty = new MessageResult();
 }
 string IMessageButtonLocalizer.Localize(MessageResult button)
 {
     return(localizer.Localize(button.ToMessageBoxResult()));
 }
Esempio n. 33
0
 public virtual async Task <bool> OpenGroup(MessageResult e)
 {
     return(false);
 }
Esempio n. 34
0
 public override Task Action(MessageResult message)
 {
     return(base.Action(message));
 }
Esempio n. 35
0
 protected override MessageResultException GetException()
 {
     return(new MessageResultException(ProductId, Message, MessageResult.Error(ResultMessage)));
 }
Esempio n. 36
0
 public override Task PreLoad(MessageResult message)
 {
     return(base.PreLoad(message));
 }
Esempio n. 37
0
 private MessageResult AppendLogsAndResult(bool success, string message, object data = null)
 {
     AppendLogs(message);
     return(MessageResult.Create(success, message, data));
 }
Esempio n. 38
0
 public override Task Render(MessageResult message)
 {
     return(base.Render(message));
 }
Esempio n. 39
0
        public Task <MessageResult> ShowDialog(string Title, string Message, bool SetCancelable = false, bool SetInverseBackgroundForced = false, MessageResult PositiveButton = MessageResult.OK, MessageResult NegativeButton = MessageResult.NONE, MessageResult NeutralButton = MessageResult.NONE, int IconAttribute = Android.Resource.Attribute.AlertDialogIcon)
        {
            var tcs = new TaskCompletionSource <MessageResult>();

            var builder = new AlertDialog.Builder(mcontext);

            builder.SetIconAttribute(IconAttribute);
            builder.SetTitle(Title);
            builder.SetMessage(Message);
            builder.SetInverseBackgroundForced(SetInverseBackgroundForced);
            builder.SetCancelable(SetCancelable);

            builder.SetPositiveButton((PositiveButton != MessageResult.NONE) ? PositiveButton.ToString() : string.Empty, (senderAlert, args) =>
            {
                tcs.SetResult(PositiveButton);
            });
            builder.SetNegativeButton((NegativeButton != MessageResult.NONE) ? NegativeButton.ToString() : string.Empty, delegate
            {
                tcs.SetResult(NegativeButton);
            });
            builder.SetNeutralButton((NeutralButton != MessageResult.NONE) ? NeutralButton.ToString() : string.Empty, delegate
            {
                tcs.SetResult(NeutralButton);
            });

            mcontext.RunOnUiThread(() => builder.Show());


            return(tcs.Task);
        }
        public IEnumerable <IResult> Save()
        {
            UpdateMarkups();
            UpdatePriceTags();
            var error = Settings.Value.Validate(validateMarkups: HaveAddresses);

            if (error?.Count > 0)
            {
                if (Session != null)
                {
                    Session.FlushMode = FlushMode.Never;
                }
                GoToErrorTab(error.First()[0]);
                yield return(MessageResult.Warn(error.First()[1]));

                yield break;
            }

            if (passwordUpdated)
            {
                Settings.Value.Password = password;
            }
            if (diadokPasswordUpdated)
            {
                Settings.Value.DiadokPassword = diadokPassword;
            }
            if (sbisPasswordUpdated)
            {
                Settings.Value.SbisPassword = sbisPassword;
            }

            if (App.Current != null)
            {
                StyleHelper.BuildStyles(App.Current.Resources, Styles);
            }

            if (Session != null)
            {
                IsCredentialsChanged = Session.IsChanged(Settings.Value, s => s.Password) ||
                                       Session.IsChanged(Settings.Value, s => s.UserName);
                if (Session.IsChanged(Settings.Value, s => s.GroupWaybillsBySupplier) &&
                    Settings.Value.GroupWaybillsBySupplier)
                {
                    foreach (var dirMap in DirMaps)
                    {
                        try {
                            Directory.CreateDirectory(dirMap.Dir);
                        }
                        catch (Exception e) {
                            Log.Error($"Не удалось создать директорию {dirMap.Dir}", e);
                        }
                    }
                }

                if (Session.IsChanged(Settings.Value, x => x.JunkPeriod))
                {
                    yield return(new Models.Results.TaskResult(Query(s => DbMaintain.CalcJunk(s, Settings.Value))));
                }

                Session.FlushMode = FlushMode.Auto;
                Settings.Value.ApplyChanges(Session);
                SynchronizeSpecialMarkUps();
            }
            TryClose();
        }
Esempio n. 41
0
        public override async Task Action(MessageResult result, String value = null)
        {
            await result.ConfirmAction();

            switch (result.RawData)
            {
            case "next":

                switch (this.PickerMode)
                {
                case eMonthPickerMode.day:
                    this.VisibleMonth = this.VisibleMonth.AddMonths(1);
                    break;

                case eMonthPickerMode.month:
                    this.VisibleMonth = this.VisibleMonth.AddYears(1);
                    break;

                case eMonthPickerMode.year:
                    this.VisibleMonth = this.VisibleMonth.AddYears(10);
                    break;
                }


                break;

            case "prev":

                switch (this.PickerMode)
                {
                case eMonthPickerMode.day:
                    this.VisibleMonth = this.VisibleMonth.AddMonths(-1);
                    break;

                case eMonthPickerMode.month:
                    this.VisibleMonth = this.VisibleMonth.AddYears(-1);
                    break;

                case eMonthPickerMode.year:
                    this.VisibleMonth = this.VisibleMonth.AddYears(-10);
                    break;
                }

                break;

            case "monthtitle":

                if (this.EnableMonthView)
                {
                    this.PickerMode = eMonthPickerMode.month;
                }

                break;

            case "yeartitle":

                if (this.EnableYearView)
                {
                    this.PickerMode = eMonthPickerMode.year;
                }

                break;

            case "yearstitle":

                if (this.EnableMonthView)
                {
                    this.PickerMode = eMonthPickerMode.month;
                }

                this.VisibleMonth = this.SelectedDate;

                break;

            default:

                int day = 0;
                if (result.RawData.StartsWith("d-") && int.TryParse(result.RawData.Split('-')[1], out day))
                {
                    this.SelectedDate = new DateTime(this.VisibleMonth.Year, this.VisibleMonth.Month, day);
                }

                int month = 0;
                if (result.RawData.StartsWith("m-") && int.TryParse(result.RawData.Split('-')[1], out month))
                {
                    this.SelectedDate = new DateTime(this.VisibleMonth.Year, month, 1);
                    this.VisibleMonth = this.SelectedDate;

                    if (this.EnableDayView)
                    {
                        this.PickerMode = eMonthPickerMode.day;
                    }
                }

                int year = 0;
                if (result.RawData.StartsWith("y-") && int.TryParse(result.RawData.Split('-')[1], out year))
                {
                    this.SelectedDate = new DateTime(year, SelectedDate.Month, SelectedDate.Day);
                    this.VisibleMonth = this.SelectedDate;

                    if (this.EnableMonthView)
                    {
                        this.PickerMode = eMonthPickerMode.month;
                    }
                }

                break;
            }
        }
 protected virtual string GetButtonText(MessageResult button)
 {
     return button.ToString();
 }
 MessageResult IMessageBoxService.Show(string messageBoxText, string caption, MessageButton button, MessageResult defaultResult) {
     return MessageBox.Show(messageBoxText, caption, button.ToMessageBoxButton()).ToMessageResult();
 }
Esempio n. 44
0
 protected virtual string GetButtonText(MessageResult button)
 {
     return(button.ToString());
 }
Esempio n. 45
0
        static UICommand CreateDefaultButonCommand(MessageResult result, bool usePlatformSpecificTag, Func<MessageResult, string> getButtonCaption) {
#if !NETFX_CORE
            object tag = usePlatformSpecificTag ? result.ToMessageBoxResult() : (object)result;
#else
            object tag = result;
#endif
            return new UICommand() {
                Id = tag,
                Caption = getButtonCaption(result),
                Command = null,
                Tag = tag,
            };
        }
Esempio n. 46
0
 MessageResult IMessageBoxService.Show(string messageBoxText, string caption, MessageButton button, MessageIcon icon, MessageResult defaultResult) {
     return XtraMessageBox.Show(messageBoxText, caption, button.ToMessageBoxButtons(), icon.ToMessageBoxIcon(), defaultResult.ToMessageBoxDefaultButton(button)).ToMessageResult();
 }
Esempio n. 47
0
        static List<UICommand> GenerateFromMessageButton(MessageButton dialogButtons, bool usePlatformSpecificTag, IMessageButtonLocalizer buttonLocalizer, MessageResult? defaultButton, MessageResult? cancelButton) {
            List<UICommand> commands = new List<UICommand>();
            if(dialogButtons == MessageButton.OK) {
                UICommand okCommand = CreateDefaultButonCommand(MessageResult.OK, usePlatformSpecificTag, buttonLocalizer.Localize);
                okCommand.IsDefault = defaultButton == null || defaultButton == MessageResult.OK;
                okCommand.IsCancel = cancelButton == MessageResult.OK;

                commands.Add(okCommand);
                return commands;
            }
            if(dialogButtons == MessageButton.OKCancel) {
                UICommand okCommand = CreateDefaultButonCommand(MessageResult.OK, usePlatformSpecificTag, buttonLocalizer.Localize);
                UICommand cancelCommand = CreateDefaultButonCommand(MessageResult.Cancel, usePlatformSpecificTag, buttonLocalizer.Localize);
                okCommand.IsDefault = defaultButton == null || defaultButton == MessageResult.OK;
                cancelCommand.IsDefault = defaultButton == MessageResult.Cancel;
                okCommand.IsCancel = cancelButton == MessageResult.OK;
                cancelCommand.IsCancel = cancelButton == null || cancelButton == MessageResult.Cancel;

                commands.Add(okCommand);
                commands.Add(cancelCommand);
                return commands;
            }
            if(dialogButtons == MessageButton.YesNo) {
                UICommand yesCommand = CreateDefaultButonCommand(MessageResult.Yes, usePlatformSpecificTag, buttonLocalizer.Localize);
                UICommand noCommand = CreateDefaultButonCommand(MessageResult.No, usePlatformSpecificTag, buttonLocalizer.Localize);
                yesCommand.IsDefault = defaultButton == null || defaultButton == MessageResult.Yes;
                noCommand.IsDefault = defaultButton == MessageResult.No;
                yesCommand.IsCancel = cancelButton == MessageResult.Yes;
                noCommand.IsCancel = cancelButton == null || cancelButton == MessageResult.No;

                commands.Add(yesCommand);
                commands.Add(noCommand);
                return commands;
            }
            if(dialogButtons == MessageButton.YesNoCancel) {
                UICommand yesCommand = CreateDefaultButonCommand(MessageResult.Yes, usePlatformSpecificTag, buttonLocalizer.Localize);
                UICommand noCommand = CreateDefaultButonCommand(MessageResult.No, usePlatformSpecificTag, buttonLocalizer.Localize);
                UICommand cancelCommand = CreateDefaultButonCommand(MessageResult.Cancel, usePlatformSpecificTag, buttonLocalizer.Localize);
                yesCommand.IsDefault = defaultButton == null || defaultButton == MessageResult.Yes;
                noCommand.IsDefault = defaultButton == MessageResult.No;
                cancelCommand.IsDefault = defaultButton == MessageResult.Cancel;
                yesCommand.IsCancel = cancelButton == MessageResult.Yes;
                noCommand.IsCancel = cancelButton == null || cancelButton == MessageResult.No;
                cancelCommand.IsCancel = cancelButton == null || cancelButton == MessageResult.Cancel;

                commands.Add(yesCommand);
                commands.Add(noCommand);
                commands.Add(cancelCommand);
                return commands;
            }
#if NETFX_CORE
            if(dialogButtons == MessageButton.AbortRetryIgnore) {
                UICommand abortCommand = CreateDefaultButonCommand(MessageResult.Abort, usePlatformSpecificTag, buttonLocalizer.Localize);
                UICommand retryCommand = CreateDefaultButonCommand(MessageResult.Retry, usePlatformSpecificTag, buttonLocalizer.Localize);
                UICommand ignoreCommand = CreateDefaultButonCommand(MessageResult.Ignore, usePlatformSpecificTag, buttonLocalizer.Localize);
                abortCommand.IsDefault = defaultButton == null || defaultButton == MessageResult.Abort;
                retryCommand.IsDefault = defaultButton == MessageResult.Retry;
                ignoreCommand.IsDefault = defaultButton == MessageResult.Ignore;
                abortCommand.IsCancel = cancelButton == MessageResult.Abort;
                retryCommand.IsCancel = cancelButton == null || cancelButton == MessageResult.Retry;
                ignoreCommand.IsCancel = cancelButton == null || cancelButton == MessageResult.Ignore;

                commands.Add(abortCommand);
                commands.Add(retryCommand);
                commands.Add(ignoreCommand);
                return commands;
            }
            if(dialogButtons == MessageButton.Close) {
                UICommand closeCommand = CreateDefaultButonCommand(MessageResult.Close, usePlatformSpecificTag, buttonLocalizer.Localize);
                closeCommand.IsDefault = defaultButton == null || defaultButton == MessageResult.Close;
                closeCommand.IsCancel = cancelButton == MessageResult.Close;

                commands.Add(closeCommand);
                return commands;
            }
            if(dialogButtons == MessageButton.RetryCancel) {
                UICommand retryCommand = CreateDefaultButonCommand(MessageResult.Retry, usePlatformSpecificTag, buttonLocalizer.Localize);
                UICommand cancelCommand = CreateDefaultButonCommand(MessageResult.Cancel, usePlatformSpecificTag, buttonLocalizer.Localize);
                retryCommand.IsDefault = defaultButton == null || defaultButton == MessageResult.Retry;
                cancelCommand.IsDefault = defaultButton == MessageResult.Cancel;
                retryCommand.IsCancel = cancelButton == MessageResult.Retry;
                cancelCommand.IsCancel = cancelButton == null || cancelButton == MessageResult.Cancel;

                commands.Add(retryCommand);
                commands.Add(cancelCommand);
                return commands;
            }
#endif
            return commands;
        }
 private static MessageBoxDefaultButton ConvertDefaultResult(MessageButton buttons, MessageResult results)
 {
     switch (results)
     {
         case MessageResult.Ok:
             return MessageBoxDefaultButton.Button1;
         case MessageResult.Cancel:
             if (buttons == MessageButton.YesNoCancel)
                 return MessageBoxDefaultButton.Button3;
             return MessageBoxDefaultButton.Button2;
         case MessageResult.No:
             return MessageBoxDefaultButton.Button2;
         case MessageResult.Yes:
             return MessageBoxDefaultButton.Button1;
         case MessageResult.Abort:
             return MessageBoxDefaultButton.Button1;
         case MessageResult.Retry:
             if (buttons == MessageButton.AbortRetryIgnore)
                 return MessageBoxDefaultButton.Button2;
             return MessageBoxDefaultButton.Button1;
         case MessageResult.Ignore:
             return MessageBoxDefaultButton.Button3;
         default:
             return MessageBoxDefaultButton.Button1;
     }
 }
 string IMessageButtonLocalizer.Localize(MessageResult button) {
     return localizer.Localize(button.ToMessageBoxResult());
 }
Esempio n. 50
0
        public async override Task Load(MessageResult result)
        {
            if (this.KeyboardType != eKeyboardType.ReplyKeyboard)
            {
                return;
            }

            if (!result.IsFirstHandler)
            {
                return;
            }

            var button = HeadLayoutButtonRow?.FirstOrDefault(a => a.Text.Trim() == result.MessageText)
                         ?? SubHeadLayoutButtonRow?.FirstOrDefault(a => a.Text.Trim() == result.MessageText)
                         ?? ButtonsForm.ToList().FirstOrDefault(a => a.Text.Trim() == result.MessageText);

            if (button == null)
            {
                if (result.MessageText == null)
                {
                    return;
                }

                if (result.MessageText == PreviousPageLabel)
                {
                    if (this.CurrentPageIndex > 0)
                    {
                        this.CurrentPageIndex--;
                    }

                    this.Updated();
                }
                else if (result.MessageText == NextPageLabel)
                {
                    if (this.CurrentPageIndex < this.PageCount - 1)
                    {
                        this.CurrentPageIndex++;
                    }

                    this.Updated();
                }
                else if (this.EnableSearch)
                {
                    if (result.MessageText.StartsWith("🔍"))
                    {
                        //Sent note about searching
                        if (this.SearchQuery == null)
                        {
                            await this.Device.Send(this.SearchLabel);
                        }

                        this.SearchQuery = null;
                        this.Updated();
                        return;
                    }

                    this.SearchQuery = result.MessageText;

                    if (this.SearchQuery != null && this.SearchQuery != "")
                    {
                        this.CurrentPageIndex = 0;
                        this.Updated();
                    }
                }



                return;
            }


            await OnButtonClicked(new ButtonClickedEventArgs(button));

            //Remove button click message
            if (this.DeletePreviousMessage)
            {
                await Device.DeleteMessage(result.MessageId);
            }

            result.Handled = true;
        }
Esempio n. 51
0
 private void SetResult(MessageResult result)
 {
     this.Result = result;
     TryClose();
 }
Esempio n. 52
0
        public static int InvokeCustomAction(int sessionHandle, string entryPoint,
                                             IntPtr remotingDelegatePtr)
        {
            Session    session = null;
            string     assemblyName, className, methodName;
            MethodInfo method;

            try
            {
                MsiRemoteInvoke remotingDelegate = (MsiRemoteInvoke)
                                                   Marshal.GetDelegateForFunctionPointer(
                    remotingDelegatePtr, typeof(MsiRemoteInvoke));
                RemotableNativeMethods.RemotingDelegate = remotingDelegate;

                sessionHandle = RemotableNativeMethods.MakeRemoteHandle(sessionHandle);
                session       = new Session((IntPtr)sessionHandle, false);
                if (String.IsNullOrEmpty(entryPoint))
                {
                    throw new ArgumentNullException("entryPoint");
                }

                if (!CustomActionProxy.FindEntryPoint(
                        session,
                        entryPoint,
                        out assemblyName,
                        out className,
                        out methodName))
                {
                    return((int)ActionResult.Failure);
                }
                session.Log("Calling custom action {0}!{1}.{2}", assemblyName, className, methodName);

                method = CustomActionProxy.GetCustomActionMethod(
                    session,
                    assemblyName,
                    className,
                    methodName);
                if (method == null)
                {
                    return((int)ActionResult.Failure);
                }
            }
            catch (Exception ex)
            {
                if (session != null)
                {
                    try
                    {
                        session.Log("Exception while loading custom action:");
                        session.Log(ex.ToString());
                    }
                    catch (Exception) { }
                }
                return((int)ActionResult.Failure);
            }

            try
            {
                // Set the current directory to the location of the extracted files.
                Environment.CurrentDirectory =
                    AppDomain.CurrentDomain.BaseDirectory;

                object[] args = new object[] { session };
                if (DebugBreakEnabled(new string[] { entryPoint, methodName }))
                {
                    string message = String.Format(
                        "To debug your custom action, attach to process ID {0} (0x{0:x}) and click OK; otherwise, click Cancel to fail the custom action.",
                        System.Diagnostics.Process.GetCurrentProcess().Id
                        );

                    MessageResult button = NativeMethods.MessageBox(
                        IntPtr.Zero,
                        message,
                        "Custom Action Breakpoint",
                        (int)MessageButtons.OKCancel | (int)MessageIcon.Asterisk | (int)(MessageBoxStyles.TopMost | MessageBoxStyles.ServiceNotification)
                        );

                    if (MessageResult.Cancel == button)
                    {
                        return((int)ActionResult.UserExit);
                    }
                }

                ActionResult result = (ActionResult)method.Invoke(null, args);
                session.Close();
                return((int)result);
            }
            catch (InstallCanceledException)
            {
                return((int)ActionResult.UserExit);
            }
            catch (Exception ex)
            {
                session.Log("Exception thrown by custom action:");
                session.Log(ex.ToString());
                return((int)ActionResult.Failure);
            }
        }
Esempio n. 53
0
 public MessageResultAdapter(global::MessageVault.MessageResult result)
 {
     _result = result;
 }
Esempio n. 54
0
 string IMessageButtonLocalizer.Localize(MessageResult button)
 {
     return(new DefaultMessageButtonLocalizer().Localize(button));
 }
        private void ShowMessage(string messageBoxText, string caption, MessageButton button, MessageImage icon,
            MessageResult defaultResult,
            TaskCompletionSource<MessageResult> tcs)
        {
#if XAMARIN_FORMS
            var activity = global::Xamarin.Forms.Forms.Context;
#else
            var activity = PlatformExtensions.CurrentActivity as IActivityView;
#endif
            Should.BeSupported(activity != null, "The current top activity is null.");
            AlertDialog.Builder builder = new AlertDialog.Builder((Context)activity)
                .SetTitle(caption)
                .SetMessage(messageBoxText)
                .SetCancelable(false);
            switch (button)
            {
                case MessageButton.Ok:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Ok),
                        (sender, args) => tcs.TrySetResult(MessageResult.Ok));
                    break;
                case MessageButton.OkCancel:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Ok),
                        (sender, args) => tcs.TrySetResult(MessageResult.Ok));
                    builder.SetNegativeButton(GetButtonText(MessageResult.Cancel),
                        (sender, args) => tcs.TrySetResult(MessageResult.Cancel));
                    break;
                case MessageButton.YesNo:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Yes),
                        (sender, args) => tcs.TrySetResult(MessageResult.Yes));
                    builder.SetNegativeButton(GetButtonText(MessageResult.No),
                        (sender, args) => tcs.TrySetResult(MessageResult.No));
                    break;
                case MessageButton.YesNoCancel:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Yes),
                        (sender, args) => tcs.TrySetResult(MessageResult.Yes));
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                    {
                        builder.SetNegativeButton(GetButtonText(MessageResult.No),
                            (sender, args) => tcs.TrySetResult(MessageResult.No));
                        builder.SetNeutralButton(GetButtonText(MessageResult.Cancel),
                            (sender, args) => tcs.TrySetResult(MessageResult.Cancel));
                    }
                    else
                    {
                        builder.SetNeutralButton(GetButtonText(MessageResult.No),
                            (sender, args) => tcs.TrySetResult(MessageResult.No));
                        builder.SetNegativeButton(GetButtonText(MessageResult.Cancel),
                            (sender, args) => tcs.TrySetResult(MessageResult.Cancel));
                    }
                    break;
                case MessageButton.AbortRetryIgnore:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Abort),
                        (sender, args) => tcs.TrySetResult(MessageResult.Abort));
                    builder.SetNeutralButton(GetButtonText(MessageResult.Retry),
                        (sender, args) => tcs.TrySetResult(MessageResult.Retry));
                    builder.SetNegativeButton(GetButtonText(MessageResult.Ignore),
                        (sender, args) => tcs.TrySetResult(MessageResult.Ignore));
                    break;
                case MessageButton.RetryCancel:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Retry),
                        (sender, args) => tcs.TrySetResult(MessageResult.Retry));
                    builder.SetNegativeButton(GetButtonText(MessageResult.Cancel),
                        (sender, args) => tcs.TrySetResult(MessageResult.Cancel));
                    break;
                default:
                    throw new ArgumentOutOfRangeException("button");
            }
            int? drawable = GetIconResource(icon);
            if (drawable != null)
                builder.SetIcon(drawable.Value);
            AlertDialog dialog = builder.Create();
#if !XAMARIN_FORMS
            EventHandler<Activity, EventArgs> handler = null;
            handler = (sender, args) =>
            {
                ((IActivityView)sender).Mediator.Destroyed -= handler;
                tcs.TrySetResult(defaultResult);
            };
            activity.Mediator.Destroyed += handler;
#endif
            dialog.Show();
        }
Esempio n. 56
0
 public InputMessageResult(string input, MessageResult messageResult)
 {
     Input         = input;
     MessageResult = messageResult;
 }
Esempio n. 57
0
        private async Task Client_TryMessage(object sender, MessageResult e)
        {
            DeviceSession ds = e.Device;

            if (ds == null)
            {
                ds = await this.Sessions.StartSession <T>(e.DeviceId);

                e.Device = ds;

                ds.LastMessage = e.Message;

                OnSessionBegins(new SessionBeginEventArgs(e.DeviceId, ds));
            }

            ds.LastAction  = DateTime.Now;
            ds.LastMessage = e.Message;

            //Is this a bot command ?
            if (e.IsBotCommand && this.BotCommands.Count(a => "/" + a.Command == e.BotCommand) > 0)
            {
                var sce = new BotCommandEventArgs(e.BotCommand, e.BotCommandParameters, e.Message, ds.DeviceId, ds);
                await OnBotCommand(sce);

                if (sce.Handled)
                {
                    return;
                }
            }

            FormBase activeForm = null;

            int i = 0;

            //Should formulars get navigated (allow maximum of 10, to dont get loops)
            do
            {
                i++;

                //Reset navigation
                ds.FormSwitched = false;

                activeForm = ds.ActiveForm;

                //Pre Loading Event
                await activeForm.PreLoad(e);

                //Send Load event to controls
                await activeForm.LoadControls(e);

                //Loading Event
                await activeForm.Load(e);

                //Is Attachment ? (Photo, Audio, Video, Contact, Location, Document)
                if (e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Contact | e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Document | e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Location |
                    e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Photo | e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Video | e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Audio)
                {
                    await activeForm.SentData(new DataResult(e));
                }

                //Render Event
                if (!ds.FormSwitched)
                {
                    await activeForm.RenderControls(e);

                    await activeForm.Render(e);
                }

                e.IsFirstHandler = false;
            } while (ds.FormSwitched && i < this.GetSetting(eSettings.NavigationMaximum, 10));
        }
Esempio n. 58
0
        public MessageResult Validate(SimpleProcessInfo info)
        {
            var success = SimpleProcessInfo.Validate(info, out var message);

            return(MessageResult.Create(success, message, info));
        }
Esempio n. 59
0
        private Task<bool> HandleServerCommands(MessageResult result)
        {
            result.Messages.Enumerate(m => ServerSignal.Equals(m.Key),
                                      m =>
                                      {
                                          var command = _serializer.Parse<ServerCommand>(m.Value);
                                          OnCommand(command);
                                      });

            return TaskAsyncHelper.True;
        }
Esempio n. 60
0
        private async void Client_TryAction(object sender, MessageResult e)
        {
            DeviceSession ds = e.Device;

            if (ds == null)
            {
                ds = await this.Sessions.StartSession <T>(e.DeviceId);

                e.Device = ds;
            }

            ds.LastAction  = DateTime.Now;
            ds.LastMessage = e.Message;

            FormBase activeForm = null;

            int i = 0;

            //Should formulars get navigated (allow maximum of 10, to dont get loops)
            do
            {
                i++;

                //Reset navigation
                ds.FormSwitched = false;

                activeForm = ds.ActiveForm;

                //Pre Loading Event
                await activeForm.PreLoad(e);

                //Send Load event to controls
                await activeForm.LoadControls(e);

                //Loading Event
                await activeForm.Load(e);

                //Action Event
                if (!ds.FormSwitched)
                {
                    //Send Action event to controls
                    await activeForm.ActionControls(e);

                    //Send Action event to form itself
                    await activeForm.Action(e);

                    if (!e.Handled)
                    {
                        var uhc = new UnhandledCallEventArgs(e.Message.Text, e.RawData, ds.DeviceId, e.MessageId, e.Message, ds);
                        OnUnhandledCall(uhc);

                        if (uhc.Handled)
                        {
                            e.Handled = true;
                            if (!ds.FormSwitched)
                            {
                                break;
                            }
                        }
                    }
                }

                //Render Event
                if (!ds.FormSwitched)
                {
                    await activeForm.RenderControls(e);

                    await activeForm.Render(e);
                }

                e.IsFirstHandler = false;
            } while (ds.FormSwitched && i < this.GetSetting(eSettings.NavigationMaximum, 10));
        }