Example #1
0
        public static async Task <IUserMessage> SendPrivateInteractiveMessageAsync
        (
            this InteractiveService @this,
            [NotNull] SocketCommandContext context,
            [NotNull] UserFeedbackService feedback,
            [NotNull] IInteractiveMessage interactiveMessage
        )
        {
            if (!(await context.User.GetOrCreateDMChannelAsync() is ISocketMessageChannel userChannel))
            {
                throw new InvalidOperationException("Could not create DM channel for target user.");
            }

            try
            {
                await feedback.SendConfirmationAsync(context, "Loading...");
            }
            catch (HttpException hex) when(hex.WasCausedByDMsNotAccepted())
            {
                await feedback.SendWarningAsync(context, "You don't accept DMs from non-friends on this server, so I'm unable to do that.");

                throw new InvalidOperationException("User does not accept DMs from non-friends.");
            }
            finally
            {
                await((IDMChannel)userChannel).CloseAsync();
            }

            if (!context.IsPrivate)
            {
                await feedback.SendConfirmationAsync(context, "Please check your private messages.");
            }

            return(await SendInteractiveMessageAsync(@this, context, interactiveMessage, userChannel));
        }
Example #2
0
        public static async Task <IUserMessage> SendInteractiveMessageAsync
        (
            this InteractiveService @this,
            [NotNull] SocketCommandContext context,
            [NotNull] IInteractiveMessage interactiveMessage,
            [CanBeNull] ISocketMessageChannel channel = null
        )
        {
            channel = channel ?? context.Channel;

            var message = await interactiveMessage.DisplayAsync(channel);

            if (interactiveMessage.ReactionCallback is null)
            {
                return(message);
            }

            @this.AddReactionCallback(message, interactiveMessage.ReactionCallback);

            if (interactiveMessage.Timeout.HasValue)
            {
                // ReSharper disable once AssignmentIsFullyDiscarded
                _ = Task.Delay(interactiveMessage.Timeout.Value).ContinueWith(c =>
                {
                    @this.RemoveReactionCallback(interactiveMessage.Message);
                    interactiveMessage.Message.DeleteAsync();
                });
            }

            return(message);
        }
Example #3
0
 public ErrorMessageViewModel(ErrorMessageModelBase errorMessageModel, IInteractiveMessage interactiveMessage = null)
 {
     this.errorMessageModel             = errorMessageModel ?? throw new ArgumentNullException(nameof(errorMessageModel));
     this.interactiveMessage            = interactiveMessage;
     errorMessageModel.PropertyChanged += (sender, e) => {
         OnPropertyChanged(nameof(CanSendErrorReportManually));
         OnPropertyChanged(nameof(IsEmailValid));
     };
     CreateSendReportCommand();
 }
Example #4
0
        public SendMessangeViewModel(IUnitOfWorkFactory unitOfWorkFactory, int[] employeeIds, NotificationManagerService notificationManager, IInteractiveMessage interactive, INavigationManager navigation) : base(navigation)
        {
            this.notificationManager = notificationManager ?? throw new ArgumentNullException(nameof(notificationManager));
            this.interactive         = interactive ?? throw new ArgumentNullException(nameof(interactive));
            Title = "Отправка уведомлений " + NumberToTextRus.FormatCase(employeeIds.Length, "{0} сотруднику", "{0} сотрудникам", "{0} сотрудникам");

            uow = unitOfWorkFactory.CreateWithoutRoot();

            Templates = uow.GetAll <MessageTemplate>().ToList();
            employees = uow.GetById <EmployeeCard>(employeeIds);
        }
Example #5
0
 public SQLDBUpdater(UpdateConfiguration configuration, INavigationManager navigation, IGuiDispatcher gui, BaseParameters.ParametersService parametersService, IApplicationInfo applicationInfo, DbConnection connection, MySqlConnectionStringBuilder connectionStringBuilder, IUserService userService, IUnitOfWorkFactory unitOfWorkFactory, IInteractiveMessage interactiveMessage)
 {
     this.configuration           = configuration ?? throw new ArgumentNullException(nameof(configuration));
     this.navigation              = navigation ?? throw new ArgumentNullException(nameof(navigation));
     this.gui                     = gui ?? throw new ArgumentNullException(nameof(gui));
     this.parametersService       = parametersService ?? throw new ArgumentNullException(nameof(parametersService));
     this.connection              = connection ?? throw new ArgumentNullException(nameof(connection));
     this.connectionStringBuilder = connectionStringBuilder ?? throw new ArgumentNullException(nameof(connectionStringBuilder));
     this.userService             = userService ?? throw new ArgumentNullException(nameof(userService));
     this.unitOfWorkFactory       = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
     this.interactiveMessage      = interactiveMessage ?? throw new ArgumentNullException(nameof(interactiveMessage));
 }
Example #6
0
        private async Task RemoveMessageAsync(IInteractiveMessage message)
        {
            try
            {
                await this._interactiveMessagesSemaphore.WaitAsync();

                this._interactiveMessages.Remove(message);
            }
            finally
            {
                this._interactiveMessagesSemaphore.Release();
            }
        }
Example #7
0
 public UnallocatedBalancesJournalFilterViewModel(
     ILifetimeScope scope,
     INavigationManager navigationManager,
     IInteractiveMessage interactiveMessage,
     ITdiTab journalTab,
     params Action <UnallocatedBalancesJournalFilterViewModel>[] filterParams)
 {
     Scope               = scope ?? throw new ArgumentNullException(nameof(scope));
     NavigationManager   = navigationManager ?? throw new ArgumentNullException(nameof(navigationManager));
     _interactiveMessage = interactiveMessage ?? throw new ArgumentNullException(nameof(interactiveMessage));
     JournalTab          = journalTab ?? throw new ArgumentNullException(nameof(journalTab));
     Refilter(filterParams);
 }
Example #8
0
        /// <summary>
        /// Sends an interactive message to the given channel and deletes it after a certain timeout.
        /// </summary>
        /// <param name="channel">The channel to send the message to.</param>
        /// <param name="message">The message to send.</param>
        /// <param name="timeout">The timeout after which the embed will be deleted. Defaults to 15 seconds.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public async Task SendInteractiveMessageAndDeleteAsync
        (
            [NotNull] IMessageChannel channel,
            [NotNull] IInteractiveMessage message,
            [CanBeNull] TimeSpan?timeout = null
        )
        {
            timeout = timeout ?? TimeSpan.FromSeconds(15.0);

            _trackedMessages.Add(message);
            await message.SendAsync(this, channel);

            _delayedActions.DelayUntil(() => DeleteInteractiveMessageAsync(message), timeout.Value);
        }
Example #9
0
        public async Task SendInteractiveMessageAsync
        (
            [NotNull] IMessageChannel channel,
            [NotNull] IInteractiveMessage message
        )
        {
            _trackedMessages.Add(message);
            await message.SendAsync(this, channel);

            while (_trackedMessages.Contains(message))
            {
                await Task.Delay(TimeSpan.FromSeconds(5));
            }
        }
Example #10
0
 public ExcelImportViewModel(
     IImportModel importModel,
     IUnitOfWorkFactory unitOfWorkFactory,
     INavigationManager navigation,
     IInteractiveMessage interactiveMessage,
     ProgressInterceptor progressInterceptor,
     IValidator validator = null) : base(unitOfWorkFactory, navigation, validator)
 {
     ImportModel              = importModel ?? throw new ArgumentNullException(nameof(importModel));
     this.interactiveMessage  = interactiveMessage ?? throw new ArgumentNullException(nameof(interactiveMessage));
     this.progressInterceptor = progressInterceptor;
     Title = importModel.ImportName;
     importModel.PropertyChanged += ImportModel_PropertyChanged;
 }
Example #11
0
 public SendMessageViewModel(
     IUnitOfWorkFactory unitOfWorkFactory,
     INavigationManager navigation,
     IInteractiveMessage interactive,
     ProstorSmsService prostorSmsService,
     OrderMessagesModel orderMessages,
     IValidator validator = null) : base(navigation)
 {
     this.interactive       = interactive ?? throw new ArgumentNullException(nameof(interactive));
     this.prostorSmsService = prostorSmsService ?? throw new ArgumentNullException(nameof(prostorSmsService));
     this.orderMessages     = orderMessages ?? throw new ArgumentNullException(nameof(orderMessages));
     IsModal        = true;
     Title          = "Отправка СМС";
     WindowPosition = QS.Dialog.WindowGravity.Center;
     MessageText    = orderMessages.DefaultMessage;
 }
Example #12
0
        public async Task SendInteractiveMessageAsync(IInteractiveMessage message)
        {
            try
            {
                await this._interactiveMessagesSemaphore.WaitAsync();

                message.Exited += RemoveMessageAsync;
                message.AddServiceProvider(_provider);
                this._interactiveMessages.Add(message);
                await message.SetUpAsync();
            }
            finally
            {
                this._interactiveMessagesSemaphore.Release();
            }
        }
        public TdiNavigationManager(
            TdiNotebook tdiNotebook,
            IViewModelsPageFactory viewModelsFactory,
            IInteractiveMessage interactive,
            IPageHashGenerator hashGenerator = null,
            ITdiPageFactory tdiPageFactory   = null,
            AutofacViewModelsGtkPageFactory viewModelsGtkPageFactory = null,
            IGtkViewResolver viewResolver = null)
            : base(interactive, hashGenerator)
        {
            this.tdiNotebook                 = tdiNotebook ?? throw new ArgumentNullException(nameof(tdiNotebook));
            this.tdiPageFactory              = tdiPageFactory;
            this.viewModelsFactory           = viewModelsFactory ?? throw new ArgumentNullException(nameof(viewModelsFactory));
            this.viewModelsGtkWindowsFactory = viewModelsGtkPageFactory;
            this.viewResolver                = viewResolver;

            tdiNotebook.TabClosed += TdiNotebook_TabClosed;
        }
Example #14
0
        public Task <bool> RunAsync(IServiceProvider services,
                                    IInteractiveMessage interactive,
                                    CancellationToken cancellationToken = default)
        {
            if (interactive == null && !CanRunStateless)
            {
                throw new InvalidOperationException($"Cannot initialize trigger {GetType()} in stateless mode.");
            }

            // create action object
            var action = _actionFactory(services);

            action.Trigger     = this;
            action.Interactive = interactive;
            action.Context     = services.GetRequiredService <IReactionContext>();

            // trigger the action
            return(action.RunAsync(cancellationToken));
        }
 protected NavigationManagerBase(IInteractiveMessage interactive, IPageHashGenerator hashGenerator = null)
 {
     this.hashGenerator      = hashGenerator;
     this.interactiveMessage = interactive ?? throw new ArgumentNullException(nameof(interactive));
 }
Example #16
0
 /// <summary>
 /// Deletes an interactive message.
 /// </summary>
 /// <param name="message">The message to delete.</param>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 public Task <OperationResult> DeleteInteractiveMessageAsync(IInteractiveMessage message)
 {
     _trackedMessages.Remove(message);
     return(message.DeleteAsync());
 }
Example #17
0
        void ConfigureDlg()
        {
            AutofacScope  = MainClass.AppDIContainer.BeginLifetimeScope();
            interactive   = AutofacScope.Resolve <IInteractiveMessage>();
            navigation    = AutofacScope.Resolve <INavigationManager>();
            orderMessages = AutofacScope.Resolve <OrderMessagesModel>(new TypedParameter(typeof(WorkOrder), Entity));
            validator     = AutofacScope.Resolve <IValidator>();

            labelCreated.LabelProp = $"{Entity.CreatedDate} - {Entity.CreatedBy?.Name}";

            this.Title = String.Format(GetTitleFormat(Entity.OrderTypeClass), UoW.IsNew ? "???" : Entity.Id.ToString(), Entity.Date, Entity.Hour);

            comboStatus.ItemsList = OrderStateRepository.GetStates(UoW, Entity.OrderTypeClass);
            comboStatus.Binding.AddBinding(Entity, e => e.OrderState, w => w.SelectedItem).InitializeFromSource();

            comboMark.ItemsList = UoW.GetAll <CarBrand>();
            if (Entity.CarModel != null)
            {
                comboMark.SelectedItem = Entity.CarModel.Brand;
            }
            comboModel.Binding.AddBinding(Entity, e => e.CarModel, w => w.SelectedItem).InitializeFromSource();

            if (Entity.OrderTypeClass.IsShowAdditionalWidgets)
            {
                comboManufacturer.ShowSpecialStateNot = true;
                comboManufacturer.ItemsList           = UoW.GetAll <Manufacturer>();

                comboStock.ShowSpecialStateNot = true;
                comboStock.ItemsList           = UoW.GetAll <Warehouse>();
            }
            else
            {
                labelGlass.Visible     = labelManufacturer.Visible = comboManufacturer.Visible = labelStock.Visible =
                    comboStock.Visible = labelEurocode.Visible = entryEurocode.Visible = false;
            }

            comboYear.Model      = new ListStore(typeof(string));
            comboYear.TextColumn = 0;

            for (int year = 1980; year <= DateTime.Today.Year; year++)
            {
                comboYear.AppendText(year.ToString());
            }

            comboYear.Binding.AddBinding(Entity, e => e.CarYearText, w => w.Entry.Text).InitializeFromSource();
            comboManufacturer.Binding.AddBinding(Entity, e => e.Manufacturer, w => w.SelectedItem).InitializeFromSource();
            comboStock.Binding.AddBinding(Entity, e => e.Stock, w => w.SelectedItem).InitializeFromSource();
            entryPhone.Binding.AddBinding(Entity, e => e.Phone, w => w.Text).InitializeFromSource();
            entryEurocode.Binding.AddBinding(Entity, e => e.Eurocode, w => w.Text).InitializeFromSource();

            textviewComment.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource();

            yradioInstallNone.BindValueWhenActivated                     = yradioTintingNone.BindValueWhenActivated
                                                                         = yradioArmoringNone.BindValueWhenActivated = yradioPastingNone.BindValueWhenActivated = Warranty.None;
            yradioInstall6Month.BindValueWhenActivated                   = yradioTinting6Month.BindValueWhenActivated
                                                                         = yradioArmoring6Month.BindValueWhenActivated = yradioPasting6Month.BindValueWhenActivated = Warranty.SixMonth;
            yradioInstall1Year.BindValueWhenActivated                    = yradioTinting1Year.BindValueWhenActivated
                                                                         = yradioArmoring1Year.BindValueWhenActivated = yradioPasting1Year.BindValueWhenActivated = Warranty.OneYear;
            yradioInstall2Year.BindValueWhenActivated                    = yradioTinting2Year.BindValueWhenActivated
                                                                         = yradioArmoring2Year.BindValueWhenActivated = yradioPasting2Year.BindValueWhenActivated = Warranty.TwoYear;
            yradioInstall3Year.BindValueWhenActivated                    = yradioTinting3Year.BindValueWhenActivated
                                                                         = yradioArmoring3Year.BindValueWhenActivated = yradioPasting3Year.BindValueWhenActivated = Warranty.ThreeYear;
            yradioInstallIndefinitely.BindValueWhenActivated             = yradioTintingIndefinitely.BindValueWhenActivated
                                                                         = yradioArmoringIndefinitely.BindValueWhenActivated = yradioPastingIndefinitely.BindValueWhenActivated = Warranty.Indefinitely;
            yradioInstallNoWarranty.BindValueWhenActivated               = yradioTintingNoWarranty.BindValueWhenActivated
                                                                         = yradioArmoringNoWarranty.BindValueWhenActivated = yradioPastingNoWarranty.BindValueWhenActivated = Warranty.NoWarranty;

            yradioInstallNone.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstall6Month.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstall1Year.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstall2Year.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstall3Year.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstallIndefinitely.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();
            yradioInstallNoWarranty.Binding.AddBinding(Entity, e => e.WarrantyInstall, w => w.BindedValue).InitializeFromSource();

            yradioTintingNone.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTinting6Month.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTinting1Year.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTinting2Year.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTinting3Year.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTintingIndefinitely.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();
            yradioTintingNoWarranty.Binding.AddBinding(Entity, e => e.WarrantyTinting, w => w.BindedValue).InitializeFromSource();

            yradioArmoringNone.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoring6Month.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoring1Year.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoring2Year.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoring3Year.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoringIndefinitely.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();
            yradioArmoringNoWarranty.Binding.AddBinding(Entity, e => e.WarrantyArmoring, w => w.BindedValue).InitializeFromSource();

            yradioPastingNone.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPasting6Month.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPasting1Year.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPasting2Year.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPasting3Year.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPastingIndefinitely.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();
            yradioPastingNoWarranty.Binding.AddBinding(Entity, e => e.WarrantyPasting, w => w.BindedValue).InitializeFromSource();

            CellRendererToggle CellPay = new CellRendererToggle();

            CellPay.Activatable = true;
            CellPay.Toggled    += onCellPayToggled;

            Gtk.CellRendererSpin CellCost = new CellRendererSpin();
            CellCost.Editable = true;
            CellCost.Digits   = 2;
            Adjustment adjCost = new Adjustment(0, 0, 100000000, 100, 1000, 0);

            CellCost.Adjustment = adjCost;
            CellCost.Edited    += OnCostSpinEdited;

            treeviewCost.AppendColumn("", CellPay, "active", 1);
            treeviewCost.AppendColumn("Название", new CellRendererText(), "text", 2);
            treeviewCost.AppendColumn("Стоимость", CellCost, RenderPriceColumn);

            setInTablePerformers();

            ((CellRendererToggle)treeviewCost.Columns[0].CellRenderers[0]).Activatable = true;

            treeviewCost.Model = ServiceListStore;
            treeviewCost.ShowAll();
            //fixme Изменить запрос
            var sql = "SELECT ser.id, ser.name, ser.price FROM services ser " +
                      "JOIN service_order_type ordt on ser.id = ordt.id_service " +
                      "JOIN order_type ord on ord.id = ordt.id_type_order " +
                      "WHERE ord.name = @order_type ORDER BY ord.name";
            var cmd = new MySqlCommand(sql, QSMain.connectionDB);

            cmd.Parameters.AddWithValue("@order_type", Entity.OrderTypeClass.Name.ToString());
            using (MySqlDataReader rdr = cmd.ExecuteReader())
            {
                while (rdr.Read())
                {
                    ServiceListStore.AppendValues(rdr.GetInt32("id"),
                                                  false,
                                                  rdr.GetString("name"),
                                                  DBWorks.GetDouble(rdr, "price", 0),
                                                  (long)-1,
                                                  false, false, false
                                                  );
                }
            }

            ytreeOtherOrders.ColumnsConfig = ColumnsConfigFactory.Create <WorkOrder>()
                                             .AddColumn("Тип").AddTextRenderer(x => x.OrderTypeClass.Name) // x.OrderType.GetEnumTitle()
                                             .AddColumn("Состояние").AddTextRenderer(x => x.OrderState != null ? x.OrderState.Name : null)
                                             .AddSetter((c, x) => c.Background = x.OrderState != null ? x.OrderState.Color : null)
                                             .AddColumn("Дата").AddTextRenderer(x => x.Date.ToShortDateString())
                                             .AddColumn("Марка").AddTextRenderer(x => x.CarModel != null ? x.CarModel.Brand.Name : null)
                                             .AddColumn("Модель").AddTextRenderer(x => x.CarModel != null ? x.CarModel.Name : null)
                                             .AddColumn("Еврокод").AddTextRenderer(x => x.Eurocode)
                                             .AddColumn("Производитель").AddTextRenderer(x => x.Manufacturer != null ? x.Manufacturer.Name : null)
                                             .AddColumn("Сумма").AddTextRenderer(x => x.Pays.Sum(p => p.Cost).ToString("C"))
                                             .AddColumn("Комментарий").AddTextRenderer(x => x.Comment)
                                             .AddColumn("Номер").AddTextRenderer(x => x.Id.ToString())
                                             .Finish();

            ytreeEuroCode.ColumnsConfig = ColumnsConfigFactory.Create <StoreItem>()
                                          .AddColumn("Еврокод").AddTextRenderer(x => x.EuroCode)
                                          .AddColumn("Производитель").AddTextRenderer(x => x.Manufacturer.Name)
                                          .AddColumn("Количество").AddNumericRenderer(x => x.Amount)
                                          .AddColumn("Цена").AddNumericRenderer(x => x.Cost)
                                          .Finish();

            buttonPrint.Sensitive    = !Entity.OrderTypeClass.IsOtherType;
            buttonSMSHistory.Visible = orderMessages.CountSentMessages() > 0;
            TestCanSave();
            SetEuroCode();

            Entity.PropertyChanged += Entity_PropertyChanged;
        }
        public static bool NHibernateFlushAfterException(Exception exception, IApplicationInfo application, UserBase user, IInteractiveMessage interactiveMessage)
        {
            var nhEx = ExceptionHelper.FindExceptionTypeInInner <NHibernate.AssertionFailure>(exception);

            if (nhEx != null && nhEx.Message.Contains("don't flush the Session after an exception occurs"))
            {
                interactiveMessage.ShowMessage(ImportanceLevel.Error, "В этом диалоге ранее произошла ошибка, в следстивии ее программа не может " +
                                               "сохранить данные. Закройте этот диалог и продолжайте работу в новом.");
                return(true);
            }
            return(false);
        }
        public static bool MySqlException1366IncorrectStringValue(Exception exception, IApplicationInfo application, UserBase user, IInteractiveMessage interactiveMessage)
        {
            var mysqlEx = ExceptionHelper.FindExceptionTypeInInner <MySqlException>(exception);

            if (mysqlEx != null && mysqlEx.Number == 1366)
            {
                interactiveMessage.ShowMessage(ImportanceLevel.Error, "При сохранении в базу данных произошла ошибка «Incorrect string value», " +
                                               "обычно это означает что вы вставили в поле диалога какие-то символы не поддерживаемые текущей кодировкой поля таблицы. " +
                                               "Например вы вставили один из символов Эмодзи, при этом кодировка полей в таблицах у вас трех-байтовая utf8, " +
                                               "для того чтобы сохранять такие символы в MariaDB\\MySQL базу данных, вам необходимо преобразовать все таблицы в " +
                                               "четырех-байтовую кодировку utf8mb4. Кодировка utf8mb4 используется по умолчанию в новых версиях MariaDB.");
                return(true);
            }
            return(false);
        }
        public static bool MySqlException1055OnlyFullGroupBy(Exception exception, IApplicationInfo application, UserBase user, IInteractiveMessage interactiveMessage)
        {
            var mysqlEx = ExceptionHelper.FindExceptionTypeInInner <MySqlException>(exception);

            if (mysqlEx != null && mysqlEx.Number == 1055)
            {
                interactiveMessage.ShowMessage(ImportanceLevel.Error, "На сервере MariaDB\\MySQL включен режим 'only_full_group_by', " +
                                               "для нормальной работы программы нужно удалить это значение из опции sql_mode. Обычно по умолчанию этот режим " +
                                               "отключен, проверьте свой конфигурационный файл my.cnf");
                return(true);
            }
            return(false);
        }
Example #21
0
        public static bool MySqlExceptionConnectionTimeoutHandler(Exception exception, IApplicationInfo application, UserBase user, IInteractiveMessage interactiveMessage)
        {
            var mysqlEx    = ExceptionHelper.FindExceptionTypeInInner <MySqlException>(exception);
            var exceptions = new[] { 1159, 1161 };

            if (mysqlEx != null && exceptions.Contains(mysqlEx.Number))
            {
                interactiveMessage.ShowMessage(ImportanceLevel.Error, "Возникла проблема с подключением к серверу, попробуйте снова.");
                return(true);
            }
            return(false);
        }
Example #22
0
        public static bool NHibernateStaleObjectStateExceptionHandler(Exception exception, IApplicationInfo application, UserBase user, IInteractiveMessage interactiveMessage)
        {
            var staleObjectStateException = ExceptionHelper.FindExceptionTypeInInner <NHibernate.StaleObjectStateException>(exception);

            if (staleObjectStateException != null)
            {
                var type       = OrmConfig.FindMappingByFullClassName(staleObjectStateException.EntityName).MappedClass;
                var objectName = DomainHelper.GetSubjectNames(type);

                string message;

                switch (objectName?.Gender)
                {
                case GrammaticalGender.Feminine:
                    message = "Сохраняемая <b>{0}</b> c номером <b>{1}</b> была кем то изменена.";
                    break;

                case GrammaticalGender.Neuter:
                    message = "Сохраняемое <b>{0}</b> c номером <b>{1}</b> было кем то изменено.";
                    break;

                case GrammaticalGender.Masculine:
                default:
                    message = "Сохраняемый <b>{0}</b> c номером <b>{1}</b> был кем то изменен.";
                    break;
                }
                message = String.Format(message + "\nВаши изменения не будут записаны, чтобы не потерять чужие изменения. \nПереоткройте вкладку.", objectName?.Nominative ?? type.Name, staleObjectStateException.Identifier);

                interactiveMessage.ShowMessage(QS.Dialog.ImportanceLevel.Warning, message);
                return(true);
            }
            return(false);
        }
Example #23
0
 public GtkWindowsNavigationManager(IViewModelsPageFactory viewModelsFactory, IInteractiveMessage interactive, IGtkViewResolver viewResolver, IPageHashGenerator hashGenerator = null)
     : base(interactive, hashGenerator)
 {
     this.viewModelsFactory = viewModelsFactory ?? throw new ArgumentNullException(nameof(viewModelsFactory));
     this.viewResolver      = viewResolver;
 }
Example #24
0
 public Task DeleteInteractiveMessageAsync([NotNull] IInteractiveMessage message)
 {
     _trackedMessages.Remove(message);
     return(message.DeleteAsync());
 }