Exemple #1
0
 public static Module AddNewModule(ConfigurationModelManager configurationModelManager, int terminalCode, int moduleCode, string moduleName, string moduleDescription)
 {
     Module T = CreateModule(moduleCode, moduleName);
     T.Description = moduleDescription;
     T.Terminals.Add(configurationModelManager.Terminals.First(t => t.Code == terminalCode));
     configurationModelManager.AddToModules(T);
     configurationModelManager.SaveChanges();
     return T;
 }
        public static Terminal AddNewTerminal(ConfigurationModelManager configurationModelManager, int terminalCode, string terminalName)
        {
            Terminal T = CreateTerminal(terminalCode, terminalName, true, terminalCode == 0);
            T.IsSyncronized = false;
            configurationModelManager.AddToTerminals(T);
            configurationModelManager.SaveChanges();

            return T;
        }
 protected override void ImportProcess(PackProcessEventArgs args)
 {
     base.ImportProcess(args);
     var packInfo = (ExportEntitiesPackInfo)args.PackInfo;
     using (var ent = new ConfigurationModelManager())
     {
         packInfo.MergeTables(ent);
         ent.SaveChanges();
     }
 }
        public bool InitializeTerminal()
        {
            bool initialized = false;
            using (var conf = new ConfigurationModelManager())
            {
                ZeroBusiness.Entities.Configuration.Terminal T = conf.Terminals.FirstOrDefault(t => t.Code == Terminal.Instance.Code);
                if (T == null)
                {
                    ZeroBusiness.Entities.Configuration.Terminal.AddNewTerminal(conf, Terminal.Instance.Code, Terminal.Instance.TerminalName);
                }
                else
                {
                    _isTerminalZero = T.IsTerminalZero;
                    if (Terminal.Instance.Code == 0 && !T.IsTerminalZero)
                    {
                        T.IsTerminalZero = true;
                        conf.SaveChanges();
                    }
                }
                ConfigurationModelManager.CreateTerminalProperties(conf, Terminal.Instance.Code);

                Terminal.Instance.Client.ModuleList.ForEach(c =>
                {
                    c.TerminalStatus = GetModuleStatus(c);
                    c.Initialize();
                });

                if (Terminal.Instance.Client.ModuleList.Any(c => c.TerminalStatus == ModuleStatus.NeedsSync))
                {
                    Terminal.Instance.Client.Notifier.SetUserMessage(true, "Algunas configuraciones pueden no estar actualizadas,\n"
                                                    + "por favor conectese con el servidor lo antes posible!");
                }
                else
                {
                    initialized = true;
                }

                Terminal.Instance.Client.Notifier.SetUserMessage(false, "Registrando impresoras");
                if (!TerminalPrinters.Instance.Load(LoadPrintersConfig(conf)))
                {
                    System.Diagnostics.Trace.Fail(TerminalPrinters.Instance.Error);
                    Terminal.Instance.Client.Notifier.SendNotification(TerminalPrinters.Instance.Error);
                }
            }

            return initialized;
        }