Esempio n. 1
0
 public static async ValueTask AddNodeConstructor(string type, NodeConstructor constructorFunc)
 {
     await EventHorizonBlazorInterop.Func <CachedEntity>(
         new object[]
     {
         new string[] { "BABYLON", "Node", "AddNodeConstructor" }, type, constructorFunc
     }
         );
 }
Esempio n. 2
0
        public frmInicial()
        {
            InitializeComponent();
            this.ResizeRedraw = true;

            #if !IsPAF
            this.mnuPrincipal.Items.Remove(mnuMenuFiscal);
            #endif

            //if(isPDV)
            //{
            //    tbtnDAV.Visible = false;
            //    mnuLancamentoDAV.Visible = false;
            //    mnuLancamentoPreVenda.Visible = false;
            //    mnuLancamentoDAVOs.Visible = false;
            //    tbtnVendas.Location = new Point(444, 384);
            //    tbtnCaixa.Location = new Point(235, 384);
            //}
            //else
            //{
            //    mnuMenuFiscal.Visible = false;
            //    tbtnCaixa.Visible = false;
            //    mnuLancamentoVendaCupom.Visible = false;
            //    optBarOutros.Controls.Remove(optBarOutros.tBtnECF);
            //    optBarOutros.Controls.Remove(optBarOutros.touchBtnTEF);
            //    optBarOutros.Location = new Point(848, 237);

            //}

            #if !IsPAF
            mnuPrincipal.Location = new Point(580, 84);
            #else
            mnuPrincipal.Location = new Point(445, 84);
            #endif
            //  ResizeRedraw = true;

            this.LayoutMdi(MdiLayout.ArrangeIcons);

            #region Aplicação dos níveis de acesso

            // Aplica níveis de acesso aos botões
            foreach(Control control in this.Controls)
                this.AplicaNiveisDeAcessoBotoes(control.Controls);

            // Aplica níveis de acesso aos menus
            var nodeConstructor = new NodeConstructor();
            var menuItens = nodeConstructor.BuildListFromMenuStrip(this.mnuPrincipal);
            this.AplicaNiveisDeAcessoMenus(menuItens);

            #endregion

            #region opções caixa
            optbCaixa.tbtnFechar.Click += new System.EventHandler((object o, EventArgs e) =>
            {
                FechamentoCaixa frmFechamento = new FechamentoCaixa();
                frmFechamento.ShowDialog(this);

                labelStatus.Text = frmFechamento.StatusCaixa;
            });

            optbCaixa.tbtnAbrir.Click += new EventHandler((object o, EventArgs e) =>
            {
                frmLogin frmLogin = new frmLogin();

                frmLogin.OnLoginOk += new ComponentModel.LoginHandler((Desktop.ComponentModel.LoginEventArgs args) =>
                {
                    frmAberturaCaixa frmAbertura = new frmAberturaCaixa();
                    frmAbertura.ShowDialog();

                    labelStatus.Text = frmAbertura.StatusCaixa;
                });

                frmLogin.OnLoginCancel += new ComponentModel.LoginHandler((Desktop.ComponentModel.LoginEventArgs args) =>
                {
                    frmLogin.Close();
                });

                frmLogin.ShowDialog();
            });
            #endregion

            #region opções de venda
            optbCaixa.tBtnVenda.Click += new EventHandler((object s, EventArgs e) =>
            {
                IAbreCaixa caixa = null;
                try
                {
                    caixa = new AbreCaixa().PermiteAbrir(Settings.MachineName, DateTime.Now);
                }
                catch(PDVObrigatorio)
                {
                    if(!PDV.Create(true, false).IsNullOrEmpty())
                        caixa = new AbreCaixa().PermiteAbrir(Settings.MachineName, DateTime.Now);
                    else
                    {
                        MessageBox.Show("Não foi possível criar um PDV para esta estação.", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }

                //tem que existir um caixa aberto para este operador.
                if(caixa == null)
                {
                    MessageBox.Show("Não foi permitido abrir o caixa para este PDV.", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                IImpressora impressora = null;

                try
                {
                    impressora = OpenPOS.ECF.ECF.Create(caixa.Caixa.PDV);
                }
                catch(Exception ex)
                {
                    MessageBox.ShowError(ex, false);
                    return;
                }

                frmLoginVendaCF f = new frmLoginVendaCF();
                f.Show(this);
            });

            optBarVenda.tBtnVendaNFe.Click += new EventHandler((object o, EventArgs e) =>
            {
                new frmVendaNFe().Show(this);
            });

            optBarVenda.tBtnVendaManual.Click += new EventHandler((object o, EventArgs e) =>
            {
                new frmVendaNFManual().Show(this);
            });
            #endregion

            #region opções dav
            optBarDAV.tBtnOrcamento.Click += new EventHandler((object o, EventArgs e) =>
            {
                new frmDAV().Show(this);
            });
            optBarDAV.tBtnOrdemServico.Click += new EventHandler((object sender, EventArgs e) =>
            {
                new frmDAVOS().Show(this);
            });
            optBarDAV.tBtnPreVenda.Click += new EventHandler((object sender, EventArgs e) =>
            {
                new frmPreVenda().Show(this);
            });
            #endregion

            #region opções Outros
            optBarOutros.tBtnECF.Click += new EventHandler((object o, EventArgs e) =>
            {
                frmECF f = new frmECF();

                if(!f.IsDisposed)
                    f.ShowDialog(this);
            });

            optBarOutros.touchBtnTEF.Click += new EventHandler((object o, EventArgs e) =>
            {
                frmTEF f = new frmTEF();
                if(!f.IsDisposed)
                    f.ShowDialog(this);
            });
            #endregion

            #region menu relatórios
            IList<Model.Reports.IRelatorio> rels = new Relatorio().Find<Model.Reports.IRelatorio>();

            foreach(var rel in rels)
            {
                ToolStripMenuItem parent = GetMenuItemParent(rel.Grupo.Nome);
                ToolStripMenuItem item = new ToolStripMenuItem
                {
                    Text = rel.Nome,
                    Tag = rel
                };

                item.Click += (sender, e) =>
                {
                    try
                    {
                        RdlManager.OpenViewer(((ToolStripMenuItem)sender).Tag as Model.Reports.IRelatorio);
                    }
                    catch(Exception ex)
                    {
                        MessageBox.ShowError(ex);
                    }
                };

                parent.DropDownItems.Add(item);
                mnuRelatorio.DropDownItems.Add(parent);
            }
            #endregion
        }
Esempio n. 3
0
        private void AplicaNiveisDeAcessoMenus(List<ToolStripMenuItem> itens)
        {
            foreach(ToolStripMenuItem item in itens)
            {
                foreach(INivelAcessoRegra regra in Settings.UsuarioAtual.NivelAcesso.Regras)
                {
                    if(regra.NomeControle.Trim().Equals(item.Name))
                        item.Visible = false;

                    var nc = new NodeConstructor();
                    AplicaNiveisDeAcessoMenus(nc.BuildListFromToolStripMenuItem(item));
                }
            }
        }
Esempio n. 4
0
        private async Task <DialogTurnResult> DispatchStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var intent = stepContext.GetValue <string>("Intent");


            switch (intent)
            {
            case "ProductInformation":
            // TODO (ARREGLAR-HO)

            // Invoquem el mètode d'extensió que hem creat

            /*var productInfo = luisResult.ToProductInfo(Configuration);
             * if (productInfo != null)
             * {
             *  var attachment = CardUtils.CreateCardFromProductInfo(productInfo);
             *  var adaptiveCard = stepContext.Context.Activity.CreateReply();
             *
             *  adaptiveCard.Attachments = new List<Attachment>() { attachment };
             *  await stepContext.Context.SendActivityAsync(adaptiveCard, cancellationToken);
             * }
             * else
             * {
             *  await stepContext.Context.SendActivityAsync(MessageFactory.Text("Sorry, we couldn't find a product matching your requirements."), cancellationToken);
             * }
             * break;*/

            case "OrderProduct":
                var recognizer = stepContext.Result as RecognizerResult ?? null;
                // Invoquem el mètode d'extensió per extreure una comanda del json.
                return(await stepContext.BeginDialogAsync(nameof(OrderProductDialog), recognizer, cancellationToken));

            case "TechnicalAssistance":
                NodeConstructor nbuilder = new NodeConstructor();
                NodeDecisio     arrel    = nbuilder.BuildTree("ExempleArbre.txt");

                return(await stepContext.BeginDialogAsync(nameof(TechnicalAssistanceDialog), arrel, cancellationToken));

            case "ConfirmCart":
                return(await stepContext.BeginDialogAsync(nameof(ConfirmOrderDialog), null, cancellationToken));

            case "AddProductInfo":
                return(await stepContext.BeginDialogAsync(nameof(AddProductInfoDialog), null, cancellationToken));

            case "CheckProducts":
                var task = DisplayAllProductsAsync(stepContext, cancellationToken);

                await stepContext.Context.SendActivityAsync("Wait till I load them all...");

                await task;
                break;

            case "Register":
                var ps = new ProcessStartInfo("https://vitrosepstore.com/en/login?create_account=1")
                {
                    UseShellExecute = true,
                    Verb            = "open"
                };
                Process.Start(ps);
                break;

            case "AskValidation":
                var botId = stepContext.Context.Activity.From.Id;
                var user  = await UserController.GetUserByBotIdAsync(botId);

                if (user != null && user.PrestashopId != null)
                {
                    await NotifyController.RequestValidationAsync(botId);

                    await stepContext.Context.SendActivityAsync("I sent a validation request to a member of our staff");
                }
                else
                {
                    await stepContext.Context.SendActivityAsync("You're not logged in! In order to ask for validation " +
                                                                "you have to log in first (just ask me *I want to log in*), and if you're not registered yet " +
                                                                "ask me to register (*I want to register*) and then log in.\n You can request the validation right after :)");
                }
                break;

            case "ValidateUser":
                return(await stepContext.BeginDialogAsync(nameof(UserValidationDialog), null, cancellationToken));

            case "CartToOrder":


            case "QnA":
                var answer = (string)stepContext.Result;
                await stepContext.Context.SendActivityAsync(MessageFactory.Text(answer), cancellationToken);

                break;
            }

            return(await stepContext.NextAsync(null, cancellationToken));
        }