private void OnLoadCustomerReceiptTemplate(string obj) { if (string.IsNullOrEmpty(TemplateText.Text) || MessageBox.Show(string.Format(Resources.ReloadPrinterTemplateConfirmation_f, Resources.CustomerReceiptTemplate), Resources.Confirmation, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { TemplateText = new TextDocument(DataCreationService.GetDefaultCustomerReceiptTemplate()); } }
private static IWorkspace PrepareMenu(string fileName) { Assembly ass = Assembly.GetExecutingAssembly(); var lp = new Uri(ass.CodeBase); string pth = Path.GetDirectoryName(lp.LocalPath); pth = Path.Combine(pth, "..\\..\\..\\Magentix.Presentation"); LocalSettings.AppPath = pth; LocalSettings.CurrentLanguage = "tr"; var dataFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\tests"; if (!Directory.Exists(dataFolder)) { Directory.CreateDirectory(dataFolder); } var filePath = string.Format("{0}\\{1}", dataFolder, fileName); if (File.Exists(filePath)) { File.Delete(filePath); } WorkspaceFactory.UpdateConnection(filePath); var dataCreationService = new DataCreationService(); dataCreationService.CreateData(); Thread.Sleep(1); var workspace = WorkspaceFactory.Create(); return(workspace); }
private void OnBatchAddPropertyExecuted(string obj) { var values = InteractionService.UserIntraction.GetStringFromUser( Resources.BatchCreateMenuProperties, Resources.BatchCreateMenuPropertiesDialogHint); var createdMenuProperties = new DataCreationService().BatchCreateMenuProperties(values, Model); foreach (var prop in createdMenuProperties) { Properties.Add(new MenuItemPropertyViewModel(prop)); } }
public override void Up() { var dc = ApplicationContext as DbContext; Create.Column("HideZeroBalanceAccounts").OnTable("AccountScreenValues").AsBoolean().WithDefaultValue(false); Create.Column("DisplayAsTree").OnTable("AccountScreens").AsBoolean().WithDefaultValue(false); Create.Column("ReportPrinterId").OnTable("Terminals").AsInt32().WithDefaultValue(0); if (dc.Database.Connection.ConnectionString.EndsWith(".sdf")) { Delete.ForeignKey("FK_dbo.Terminals_dbo.Printers_ReportPrinter_Id").OnTable("Terminals"); Delete.Index("IX_ReportPrinter_Id").OnTable("Terminals"); } else { Delete.ForeignKey("Terminal_ReportPrinter").OnTable("Terminals"); } Execute.Sql("Update Terminals set ReportPrinterId = ReportPrinter_Id"); Delete.Column("ReportPrinter_Id").FromTable("Terminals"); Create.Column("TransactionPrinterId").OnTable("Terminals").AsInt32().WithDefaultValue(0); Execute.Sql("Update Terminals set TransactionPrinterId = ReportPrinterId"); Create.Column("DocumentTypeId").OnTable("AccountTransactionDocuments").AsInt32().WithDefaultValue(0); Create.Column("PrinterTemplateId").OnTable("AccountTransactionDocumentTypes").AsInt32().WithDefaultValue(0); if (dc != null) { if (dc.Set <PrinterTemplate>().Any(x => x.Name == Resources.CustomerReceiptTemplate)) { return; } var customerReceiptTemplate = new PrinterTemplate { Name = Resources.CustomerReceiptTemplate, Template = DataCreationService .GetDefaultCustomerReceiptTemplate() }; dc.Set <PrinterTemplate>().Add(customerReceiptTemplate); dc.SaveChanges(); var dt1Caption = string.Format(Resources.Customer_f, Resources.Cash); var dt2Caption = string.Format(Resources.Customer_f, Resources.CreditCard); Execute.Sql(string.Format("Update AccountTransactionDocumentTypes set PrinterTemplateId = {0} where Name = '{1}'", customerReceiptTemplate.Id, dt1Caption)); Execute.Sql(string.Format("Update AccountTransactionDocumentTypes set PrinterTemplateId = {0} where Name = '{1}'", customerReceiptTemplate.Id, dt2Caption)); } }
private void OnBatchCreateTablesExecute(string obj) { var values = InteractionService.UserIntraction.GetStringFromUser( Resources.AddMultipleTables, Resources.AddMultipleTableHint); var createdItems = new DataCreationService().BatchCreateTables(values, Workspace); Workspace.CommitChanges(); foreach (var table in createdItems) { Items.Add(CreateNewViewModel(table)); } }
private void OnCreateBatchVoidReasons(string obj) { var values = InteractionService.UserIntraction.GetStringFromUser( Resources.BatchAddVoidReasons, Resources.BatchAddVoidReasonsDialogHint); var createdItems = new DataCreationService().BatchCreateReasons(values, 0, Workspace); Workspace.CommitChanges(); foreach (var mv in createdItems.Select(CreateNewViewModel)) { mv.Init(Workspace); Items.Add(mv); } }
private void OnCreateBatchMenuItems(string value) { var values = InteractionService.UserIntraction.GetStringFromUser( Resources.BatchCreteProducts, Resources.BatchCreateProductsDialogHint); var createdItems = new DataCreationService().BatchCreateMenuItems(values, Workspace); Workspace.CommitChanges(); foreach (var mi in createdItems) { var mv = CreateNewViewModel(mi); mv.Init(Workspace); Items.Add(mv); } }
private static void Main() { Application.EnableVisualStyles(); Application.ApplicationExit += Token.ApplicationExit; Application.SetCompatibleTextRenderingDefault(false); MefBootstrapper.ComposeParts(); var creationService = new DataCreationService(); creationService.CreateData(); var apiHost = LocalSettings.ApiHost; var apiPort = LocalSettings.ApiPort; var httpHost = string.Format("http://{0}:{1}", apiHost, apiPort); var config = new HttpSelfHostConfiguration(httpHost); //GET => http://localhost:8080/api/getToken/{pin} config.Routes.MapHttpRoute("LoginRoute", "api/getToken/{pin}", new { controller = "Login" }); //GET => http://localhost:8080/api/{token}/{controller}/{id} config.Routes.MapHttpRoute("API Default", "api/{token}/{controller}/{id}", new { id = RouteParameter.Optional }); using (var server = new HttpSelfHostServer(config)) { server.Configuration.DependencyResolver = new MefDependencyResolver(MefBootstrapper.Container); server.OpenAsync().Wait(); if (LocalSettings.TokenLifeTime.Ticks > 0) { var tokenGarbageTimer = new Timer { Interval = (int)new TimeSpan(0, 1, 0).TotalMilliseconds }; tokenGarbageTimer.Tick += Token.CollectGarbage; tokenGarbageTimer.Start(); } Application.Run(new FrmMain()); } }
private static IWorkspace PrepareMenu(string fileName) { var pth = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); pth = Path.Combine(pth, "..\\..\\..\\Samba.Presentation"); LocalSettings.AppPath = pth; if (File.Exists(fileName)) { File.Delete(fileName); } WorkspaceFactory.SetDefaultConnectionString(fileName); var dataCreationService = new DataCreationService(); dataCreationService.CreateData(); var workspace = WorkspaceFactory.Create(); return(workspace); }
private PrinterTemplate AddDefaultPrintersAndTerminal() { var customerReceiptTemplate = new PrinterTemplate { Name = Resources.CustomerReceiptTemplate, Template = DataCreationService.GetDefaultCustomerReceiptTemplate() }; _workspace.Add(customerReceiptTemplate); var printer1 = new Printer { Name = Resources.TicketPrinter }; _workspace.Add(printer1); _workspace.CommitChanges(); var t = new Terminal { IsDefault = true, Name = Resources.Server, ReportPrinterId = printer1.Id, TransactionPrinterId = printer1.Id, }; var pm1 = new PrinterMap { PrinterId = printer1.Id, PrinterTemplateId = customerReceiptTemplate.Id }; _workspace.Add(pm1); var pj1 = new PrintJob { Name = Resources.PrintBill, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj1.PrinterMaps.Add(pm1); _workspace.Add(pj1); _workspace.Add(t); return(customerReceiptTemplate); }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MefBootstrapper.ComposeParts(); var creationService = new DataCreationService(); creationService.CreateData(); var config = new HttpSelfHostConfiguration("http://localhost:8080"); config.Routes.MapHttpRoute( "API Default", "api/{controller}/{id}", new { id = RouteParameter.Optional }); using (var server = new HttpSelfHostServer(config)) { server.Configuration.DependencyResolver = new MefDependencyResolver(MefBootstrapper.Container); server.OpenAsync().Wait(); Application.Run(new FrmMain()); } }
protected override void InitializeShell() { LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage); LocalSettings.SetTraceLogPath("app"); InteractionService.UserIntraction = ServiceLocator.Current.GetInstance <IUserInteraction>(); InteractionService.UserIntraction.ToggleSplashScreen(); AppServices.MainDispatcher = Application.Current.Dispatcher; AppServices.MessagingService.RegisterMessageListener(new MessageListener()); if (LocalSettings.StartMessagingClient) { AppServices.MessagingService.StartMessagingClient(); } GenericRuleRegistator.RegisterOnce(); PresentationServices.Initialize(); base.InitializeShell(); try { var creationService = new DataCreationService(); creationService.CreateData(); } catch (Exception e) { if (!string.IsNullOrEmpty(LocalSettings.ConnectionString)) { var connectionString = InteractionService.UserIntraction.GetStringFromUser( "Connection String", Resources.DatabaseErrorMessage + e.Message, LocalSettings.ConnectionString); var cs = String.Join(" ", connectionString); if (!string.IsNullOrEmpty(cs)) { LocalSettings.ConnectionString = cs.Trim(); } AppServices.LogError(e, Resources.CurrentErrorLoggedMessage); } else { AppServices.LogError(e); LocalSettings.ConnectionString = ""; } LocalSettings.SaveSettings(); Environment.Exit(1); } if (string.IsNullOrEmpty(LocalSettings.MajorCurrencyName)) { LocalSettings.MajorCurrencyName = Resources.Dollar; LocalSettings.MinorCurrencyName = Resources.Cent; LocalSettings.PluralCurrencySuffix = Resources.PluralCurrencySuffix; } Application.Current.MainWindow = (Shell)Shell; Application.Current.MainWindow.Show(); InteractionService.UserIntraction.ToggleSplashScreen(); TriggerService.UpdateCronObjects(); RuleExecutor.NotifyEvent(RuleEventNames.ApplicationStarted, new { CommandLineArguments = LocalSettings.StartupArguments }); }
public void Create(DataCreationService dataCreationService, IWorkspace workspace) { this._workspace = workspace; var saleAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Sales) }; var receivableAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Receiveable) }; var paymentAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Payment) }; var discountAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Discount) }; var customerAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Customer) }; _workspace.Add(receivableAccountType); _workspace.Add(saleAccountType); _workspace.Add(paymentAccountType); _workspace.Add(discountAccountType); _workspace.Add(customerAccountType); _workspace.CommitChanges(); var customerEntityType = new EntityType { Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name }; customerEntityType.EntityCustomFields.Add(new EntityCustomField { EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone }); customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]"; //var tableEntityType = new EntityType { Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name }; _workspace.Add(customerEntityType); //_workspace.Add(tableEntityType); _workspace.CommitChanges(); var accountScreen = new AccountScreen { Name = Resources.General }; accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40 }); _workspace.Add(accountScreen); var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = Resources.Sales }; var defaultReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables }; var cashAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Cash }; var creditCardAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard }; var voucherAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Discount }; var defaultRoundingAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Rounding }; _workspace.Add(defaultSaleAccount); _workspace.Add(defaultReceivableAccount); _workspace.Add(defaultDiscountAccount); _workspace.Add(defaultRoundingAccount); _workspace.Add(cashAccount); _workspace.Add(creditCardAccount); _workspace.Add(voucherAccount); _workspace.CommitChanges(); var discountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Discount), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var roundingTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Rounding), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultRoundingAccount.Id }; var saleTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Sale), SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = defaultReceivableAccount.Id }; var paymentTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Payment), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = cashAccount.Id }; var customerAccountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.AccountTransaction), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = customerAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id }; var customerCashPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CashPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = cashAccount.Id }; var customerCreditCardPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = creditCardAccount.Id }; _workspace.Add(saleTransactionType); _workspace.Add(paymentTransactionType); _workspace.Add(discountTransactionType); _workspace.Add(roundingTransactionType); _workspace.Add(customerAccountTransactionType); _workspace.Add(customerCashPaymentType); _workspace.Add(customerCreditCardPaymentType); var discountService = new CalculationType { AccountTransactionType = discountTransactionType, CalculationMethod = 0, DecreaseAmount = true, Name = Resources.Discount }; var roundingService = new CalculationType { AccountTransactionType = roundingTransactionType, CalculationMethod = 2, DecreaseAmount = true, IncludeTax = true, Name = Resources.Round }; var discountSelector = new CalculationSelector { Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign }; discountSelector.CalculationTypes.Add(discountService); discountSelector.AddCalculationSelectorMap(); var roundingSelector = new CalculationSelector { Name = Resources.Round, ButtonHeader = Resources.Round }; roundingSelector.CalculationTypes.Add(roundingService); roundingSelector.AddCalculationSelectorMap(); _workspace.Add(discountService); _workspace.Add(roundingService); _workspace.Add(discountSelector); _workspace.Add(roundingSelector); var screen = new ScreenMenu(); _workspace.Add(screen); var ticketNumerator = new Numerator { Name = Resources.TicketNumerator }; _workspace.Add(ticketNumerator); var orderNumerator = new Numerator { Name = Resources.OrderNumerator }; _workspace.Add(orderNumerator); _workspace.CommitChanges(); var ticketType = new TicketType { Name = Resources.Ticket, TicketNumerator = ticketNumerator, OrderNumerator = orderNumerator, SaleTransactionType = saleTransactionType, ScreenMenuId = screen.Id, }; ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment { EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20 }); var cashPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = cashAccount, Name = cashAccount.Name }; cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var creditCardPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = creditCardAccount, Name = creditCardAccount.Name }; creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var voucherPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = voucherAccount, Name = voucherAccount.Name }; voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var accountPayment = new PaymentType { AccountTransactionType = customerAccountTransactionType, Name = Resources.CustomerAccount }; accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); _workspace.Add(cashPayment); _workspace.Add(creditCardPayment); _workspace.Add(voucherPayment); _workspace.Add(accountPayment); _workspace.Add(ticketType); var warehouseType = new WarehouseType { Name = Resources.Warehouses }; _workspace.Add(warehouseType); _workspace.CommitChanges(); var localWarehouse = new Warehouse { Name = Resources.LocalWarehouse, WarehouseTypeId = warehouseType.Id }; _workspace.Add(localWarehouse); _workspace.CommitChanges(); var department = new Department { Name = Resources.Retail, TicketTypeId = ticketType.Id, WarehouseId = localWarehouse.Id }; _workspace.Add(department); var transactionType = new InventoryTransactionType { Name = Resources.PurchaseTransactionType, TargetWarehouseTypeId = warehouseType.Id, DefaultTargetWarehouseId = localWarehouse.Id }; _workspace.Add(transactionType); var transactionDocumentType = new InventoryTransactionDocumentType { Name = Resources.PurchaseTransaction, InventoryTransactionType = transactionType }; _workspace.Add(transactionDocumentType); AddDefaultUsers(); PrinterTemplate customerReceiptTemplate = AddDefaultPrintersAndTerminal(); new RuleGenerator().GenerateSystemRules(_workspace); dataCreationService.ImportMenus(screen); //dataCreationService.ImportTableResources(tableEntityType, ticketType); //RL - import data and associate with an entity. //C:\Users\Roy Lawson\source\repos\sdselite\SambaPOS-3\Samba.Presentation\bin\Debug\Imports var customerScreen = new EntityScreen { Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id }; customerScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerScreen); var customerTicketScreen = new EntityScreen { Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id }; customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerTicketScreen); var customerCashDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.Cash), ButtonHeader = Resources.Cash, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCashDocument.AddAccountTransactionDocumentTypeMap(); customerCashDocument.TransactionTypes.Add(customerCashPaymentType); var customerCreditCardDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.CreditCard), ButtonHeader = Resources.CreditCard, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCreditCardDocument.AddAccountTransactionDocumentTypeMap(); customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType); _workspace.Add(customerCashDocument); _workspace.Add(customerCreditCardDocument); }
protected override void InitializeShell() { #if DEBUG // Bypass Singleton check #else if (!Mutex.WaitOne(TimeSpan.Zero, true)) { NativeWin32.PostMessage((IntPtr)NativeWin32.HWND_BROADCAST, NativeWin32.WM_SHOWSAMBAPOS, IntPtr.Zero, IntPtr.Zero); Environment.Exit(1); } #endif LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage); InteractionService.UserIntraction = ServiceLocator.Current.GetInstance <IUserInteraction>(); InteractionService.UserIntraction.ToggleSplashScreen(); AppServices.MainDispatcher = Application.Current.Dispatcher; AppServices.MessagingService.RegisterMessageListener(new MessageListener()); if (LocalSettings.StartMessagingClient) { AppServices.MessagingService.StartMessagingClient(); } PresentationServices.Initialize(); base.InitializeShell(); try { GenericRuleRegistator.RegisterOnce(); var creationService = new DataCreationService(); creationService.CreateData(); } catch (Exception e) { if (!string.IsNullOrEmpty(LocalSettings.ConnectionString)) { var connectionString = InteractionService.UserIntraction.GetStringFromUser( "Connection String", "Şu anki bağlantı ayarları ile veri tabanına bağlanılamıyor. Lütfen aşağıdaki bağlantı bilgisini kontrol ederek tekrar deneyiniz.\r\r" + "Hata Mesajı:\r" + e.Message, LocalSettings.ConnectionString); var cs = String.Join(" ", connectionString); if (!string.IsNullOrEmpty(cs)) { LocalSettings.ConnectionString = cs.Trim(); } AppServices.LogError(e, "Programı yeniden başlatınız. Mevcut problem log dosyasına kaydedildi."); } else { AppServices.LogError(e); LocalSettings.ConnectionString = ""; } LocalSettings.SaveSettings(); Environment.Exit(1); } var rm = Container.GetExportedValue <IRegionManager>(); rm.RegisterViewWithRegion("MessageRegion", typeof(WorkPeriodStatusView)); rm.RegisterViewWithRegion("MessageRegion", typeof(MessageClientStatusView)); Application.Current.MainWindow = (Shell)Shell; Application.Current.MainWindow.Show(); EventServiceFactory.EventService.PublishEvent(EventTopicNames.ShellInitialized); InteractionService.UserIntraction.ToggleSplashScreen(); ServiceLocator.Current.GetInstance <ITriggerService>().UpdateCronObjects(); ServiceLocator.Current.GetInstance <IAutomationService>().NotifyEvent(RuleEventNames.ApplicationStarted, new { }); }
protected override void InitializeShell() { #if DEBUG // Bypass Singleton check #else if (!Mutex.WaitOne(TimeSpan.Zero, true)) { NativeWin32.PostMessage((IntPtr)NativeWin32.HWND_BROADCAST, NativeWin32.WM_SHOWSAMBAPOS, IntPtr.Zero, IntPtr.Zero); Environment.Exit(1); } #endif Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; System.Net.ServicePointManager.Expect100Continue = false; LocalizeDictionary.ChangeLanguage(LocalSettings.CurrentLanguage); InteractionService.UserIntraction = ServiceLocator.Current.GetInstance <IUserInteraction>(); InteractionService.UserIntraction.ToggleSplashScreen(); ServiceLocator.Current.GetInstance <IApplicationState>().MainDispatcher = Application.Current.Dispatcher; var logger = ServiceLocator.Current.GetInstance <ILogService>(); var messagingService = ServiceLocator.Current.GetInstance <IMessagingService>(); messagingService.RegisterMessageListener(new MessageListener()); if (LocalSettings.StartMessagingClient) { messagingService.StartMessagingClient(); } PresentationServices.Initialize(); base.InitializeShell(); try { var creationService = new DataCreationService(); creationService.CreateData(); } catch (Exception e) { if (!string.IsNullOrEmpty(LocalSettings.ConnectionString)) { var connectionString = InteractionService.UserIntraction.GetStringFromUser( "Connection String", string.Format(Resources.ConnectionStringError, e.Message), LocalSettings.ConnectionString); var cs = String.Join(" ", connectionString); if (!string.IsNullOrEmpty(cs)) { LocalSettings.ConnectionString = cs.Trim(); } logger.LogError(e, Resources.RestartAppError); } else { logger.LogError(e); LocalSettings.ConnectionString = ""; } LocalSettings.SaveSettings(); Environment.Exit(1); } var rm = Container.GetExportedValue <IRegionManager>(); rm.RegisterViewWithRegion("MessageRegion", typeof(WorkPeriodStatusView)); rm.RegisterViewWithRegion("MessageRegion", typeof(MessageClientStatusView)); Application.Current.MainWindow = (Shell)Shell; if (LocalizeDictionary.Instance.Culture.TextInfo.IsRightToLeft) { Application.Current.MainWindow.FlowDirection = FlowDirection.RightToLeft; } ServiceLocator.Current.GetInstance <ITriggerService>().UpdateCronObjects(); ServiceLocator.Current.GetInstance <IDeviceService>().InitializeDevices(); InteractionService.UserIntraction.ToggleSplashScreen(); EntityCollectionSortManager.Load(LocalSettings.DocumentPath + "\\CollectionSort.txt"); Application.Current.MainWindow.Show(); EventServiceFactory.EventService.PublishEvent(EventTopicNames.ShellInitialized); Mouse.UpdateCursor(); }
public void Create(DataCreationService dataCreationService, IWorkspace _workspace) { var saleAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Sales) }; var receivableAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Receiveable) }; var paymentAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Payment) }; var discountAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Discount) }; var customerAccountType = new AccountType { Name = string.Format(Resources.Accounts_f, Resources.Customer) }; _workspace.Add(receivableAccountType); _workspace.Add(saleAccountType); _workspace.Add(paymentAccountType); _workspace.Add(discountAccountType); _workspace.Add(customerAccountType); _workspace.CommitChanges(); var customerEntityType = new EntityType { Name = Resources.Customers, EntityName = Resources.Customer, AccountTypeId = customerAccountType.Id, PrimaryFieldName = Resources.Name }; customerEntityType.EntityCustomFields.Add(new EntityCustomField { EditingFormat = "(###) ### ####", FieldType = 0, Name = Resources.Phone }); customerEntityType.AccountNameTemplate = "[Name]-[" + Resources.Phone + "]"; var tableEntityType = new EntityType { Name = Resources.Tables, EntityName = Resources.Table, PrimaryFieldName = Resources.Name }; _workspace.Add(customerEntityType); _workspace.Add(tableEntityType); _workspace.CommitChanges(); var accountScreen = new AccountScreen { Name = Resources.General }; accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = saleAccountType.Name, AccountTypeId = saleAccountType.Id, DisplayDetails = true, SortOrder = 10 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = receivableAccountType.Name, AccountTypeId = receivableAccountType.Id, DisplayDetails = true, SortOrder = 20 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = discountAccountType.Name, AccountTypeId = discountAccountType.Id, DisplayDetails = true, SortOrder = 30 }); accountScreen.AccountScreenValues.Add(new AccountScreenValue { AccountTypeName = paymentAccountType.Name, AccountTypeId = paymentAccountType.Id, DisplayDetails = true, SortOrder = 40 }); _workspace.Add(accountScreen); var defaultSaleAccount = new Account { AccountTypeId = saleAccountType.Id, Name = Resources.Sales }; var defaultReceivableAccount = new Account { AccountTypeId = receivableAccountType.Id, Name = Resources.Receivables }; var cashAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Cash }; var creditCardAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.CreditCard }; var voucherAccount = new Account { AccountTypeId = paymentAccountType.Id, Name = Resources.Voucher }; var defaultDiscountAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Discount }; var defaultRoundingAccount = new Account { AccountTypeId = discountAccountType.Id, Name = Resources.Rounding }; _workspace.Add(defaultSaleAccount); _workspace.Add(defaultReceivableAccount); _workspace.Add(defaultDiscountAccount); _workspace.Add(defaultRoundingAccount); _workspace.Add(cashAccount); _workspace.Add(creditCardAccount); _workspace.Add(voucherAccount); _workspace.CommitChanges(); var discountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Discount), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultDiscountAccount.Id }; var roundingTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Rounding), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = discountAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = defaultRoundingAccount.Id }; var saleTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Sale), SourceAccountTypeId = saleAccountType.Id, TargetAccountTypeId = receivableAccountType.Id, DefaultSourceAccountId = defaultSaleAccount.Id, DefaultTargetAccountId = defaultReceivableAccount.Id }; var paymentTransactionType = new AccountTransactionType { Name = string.Format(Resources.Transaction_f, Resources.Payment), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id, DefaultTargetAccountId = cashAccount.Id }; var customerAccountTransactionType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.AccountTransaction), SourceAccountTypeId = receivableAccountType.Id, TargetAccountTypeId = customerAccountType.Id, DefaultSourceAccountId = defaultReceivableAccount.Id }; var customerCashPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CashPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = cashAccount.Id }; var customerCreditCardPaymentType = new AccountTransactionType { Name = string.Format(Resources.Customer_f, Resources.CreditCardPayment), SourceAccountTypeId = customerAccountType.Id, TargetAccountTypeId = paymentAccountType.Id, DefaultTargetAccountId = creditCardAccount.Id }; _workspace.Add(saleTransactionType); _workspace.Add(paymentTransactionType); _workspace.Add(discountTransactionType); _workspace.Add(roundingTransactionType); _workspace.Add(customerAccountTransactionType); _workspace.Add(customerCashPaymentType); _workspace.Add(customerCreditCardPaymentType); var discountService = new CalculationType { AccountTransactionType = discountTransactionType, CalculationMethod = 0, DecreaseAmount = true, Name = Resources.Discount }; var roundingService = new CalculationType { AccountTransactionType = roundingTransactionType, CalculationMethod = 2, DecreaseAmount = true, IncludeTax = true, Name = Resources.Round }; var discountSelector = new CalculationSelector { Name = Resources.Discount, ButtonHeader = Resources.DiscountPercentSign }; discountSelector.CalculationTypes.Add(discountService); discountSelector.AddCalculationSelectorMap(); var roundingSelector = new CalculationSelector { Name = Resources.Round, ButtonHeader = Resources.Round }; roundingSelector.CalculationTypes.Add(roundingService); roundingSelector.AddCalculationSelectorMap(); _workspace.Add(discountService); _workspace.Add(roundingService); _workspace.Add(discountSelector); _workspace.Add(roundingSelector); var screen = new ScreenMenu(); _workspace.Add(screen); var ticketNumerator = new Numerator { Name = Resources.TicketNumerator }; _workspace.Add(ticketNumerator); var orderNumerator = new Numerator { Name = Resources.OrderNumerator }; _workspace.Add(orderNumerator); _workspace.CommitChanges(); var ticketType = new TicketType { Name = Resources.Ticket, TicketNumerator = ticketNumerator, OrderNumerator = orderNumerator, SaleTransactionType = saleTransactionType, ScreenMenuId = screen.Id, }; ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment { EntityTypeId = tableEntityType.Id, EntityTypeName = tableEntityType.Name, SortOrder = 10 }); ticketType.EntityTypeAssignments.Add(new EntityTypeAssignment { EntityTypeId = customerEntityType.Id, EntityTypeName = customerEntityType.Name, SortOrder = 20 }); var cashPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = cashAccount, Name = cashAccount.Name }; cashPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var creditCardPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = creditCardAccount, Name = creditCardAccount.Name }; creditCardPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var voucherPayment = new PaymentType { AccountTransactionType = paymentTransactionType, Account = voucherAccount, Name = voucherAccount.Name }; voucherPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); var accountPayment = new PaymentType { AccountTransactionType = customerAccountTransactionType, Name = Resources.CustomerAccount }; accountPayment.PaymentTypeMaps.Add(new PaymentTypeMap()); _workspace.Add(cashPayment); _workspace.Add(creditCardPayment); _workspace.Add(voucherPayment); _workspace.Add(accountPayment); _workspace.Add(ticketType); var warehouseType = new WarehouseType { Name = Resources.Warehouses }; _workspace.Add(warehouseType); _workspace.CommitChanges(); var localWarehouse = new Warehouse { Name = Resources.LocalWarehouse, WarehouseTypeId = warehouseType.Id }; _workspace.Add(localWarehouse); _workspace.CommitChanges(); var department = new Department { Name = Resources.Restaurant, TicketTypeId = ticketType.Id, WarehouseId = localWarehouse.Id }; _workspace.Add(department); var transactionType = new InventoryTransactionType { Name = Resources.PurchaseTransactionType, TargetWarehouseTypeId = warehouseType.Id, DefaultTargetWarehouseId = localWarehouse.Id }; _workspace.Add(transactionType); var transactionDocumentType = new InventoryTransactionDocumentType { Name = Resources.PurchaseTransaction, InventoryTransactionType = transactionType }; _workspace.Add(transactionDocumentType); var role = new UserRole("Admin") { IsAdmin = true, DepartmentId = 1 }; _workspace.Add(role); var u = new User("Administrator", "1234") { UserRole = role }; _workspace.Add(u); var ticketPrinterTemplate = new PrinterTemplate { Name = Resources.TicketTemplate, Template = DataCreationService.GetDefaultTicketPrintTemplate() }; var kitchenPrinterTemplate = new PrinterTemplate { Name = Resources.KitchenOrderTemplate, Template = DataCreationService.GetDefaultKitchenPrintTemplate() }; var customerReceiptTemplate = new PrinterTemplate { Name = Resources.CustomerReceiptTemplate, Template = DataCreationService.GetDefaultCustomerReceiptTemplate() }; _workspace.Add(ticketPrinterTemplate); _workspace.Add(kitchenPrinterTemplate); _workspace.Add(customerReceiptTemplate); var printer1 = new Printer { Name = Resources.TicketPrinter }; var printer2 = new Printer { Name = Resources.KitchenPrinter }; var printer3 = new Printer { Name = Resources.InvoicePrinter }; _workspace.Add(printer1); _workspace.Add(printer2); _workspace.Add(printer3); _workspace.CommitChanges(); var t = new Terminal { IsDefault = true, Name = Resources.Server, ReportPrinterId = printer1.Id, TransactionPrinterId = printer1.Id, }; var pm1 = new PrinterMap { PrinterId = printer1.Id, PrinterTemplateId = ticketPrinterTemplate.Id }; _workspace.Add(pm1); var pj1 = new PrintJob { Name = Resources.PrintBill, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj1.PrinterMaps.Add(pm1); _workspace.Add(pj1); var pm2 = new PrinterMap { PrinterId = printer2.Id, PrinterTemplateId = kitchenPrinterTemplate.Id }; var pj2 = new PrintJob { Name = Resources.PrintOrdersToKitchenPrinter, WhatToPrint = (int)WhatToPrintTypes.Everything, }; pj2.PrinterMaps.Add(pm2); _workspace.Add(pj2); _workspace.Add(t); new RuleGenerator().GenerateSystemRules(_workspace); dataCreationService.ImportMenus(screen); dataCreationService.ImportTableResources(tableEntityType, ticketType); var customerScreen = new EntityScreen { Name = string.Format(Resources.Customer_f, Resources.Search), DisplayMode = 1, EntityTypeId = customerEntityType.Id, TicketTypeId = ticketType.Id }; customerScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerScreen); var customerTicketScreen = new EntityScreen { Name = Resources.CustomerTickets, DisplayMode = 0, EntityTypeId = customerEntityType.Id, StateFilter = Resources.NewOrders, ColumnCount = 6, RowCount = 6, TicketTypeId = ticketType.Id }; customerTicketScreen.EntityScreenMaps.Add(new EntityScreenMap()); _workspace.Add(customerTicketScreen); var customerCashDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.Cash), ButtonHeader = Resources.Cash, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.Cash), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCashDocument.AddAccountTransactionDocumentTypeMap(); customerCashDocument.TransactionTypes.Add(customerCashPaymentType); var customerCreditCardDocument = new AccountTransactionDocumentType { Name = string.Format(Resources.Customer_f, Resources.CreditCard), ButtonHeader = Resources.CreditCard, DefaultAmount = string.Format("[{0}]", Resources.Balance), DescriptionTemplate = string.Format(Resources.Payment_f, Resources.CreditCard), MasterAccountTypeId = customerAccountType.Id, PrinterTemplateId = customerReceiptTemplate.Id }; customerCreditCardDocument.AddAccountTransactionDocumentTypeMap(); customerCreditCardDocument.TransactionTypes.Add(customerCreditCardPaymentType); _workspace.Add(customerCashDocument); _workspace.Add(customerCreditCardDocument); }
private static IWorkspace PrepareMenu(string fileName) { var pth = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); pth = Path.Combine(pth, "..\\..\\..\\Samba.Presentation"); LocalSettings.AppPath = pth; if (File.Exists(fileName)) File.Delete(fileName); WorkspaceFactory.SetDefaultConnectionString(fileName); var dataCreationService = new DataCreationService(); dataCreationService.CreateData(); var workspace = WorkspaceFactory.Create(); return workspace; }
private static IWorkspace PrepareMenu(string fileName) { Assembly ass = Assembly.GetExecutingAssembly(); var lp = new Uri(ass.CodeBase); string pth = Path.GetDirectoryName(lp.LocalPath); pth = Path.Combine(pth, "..\\..\\..\\Samba.Presentation"); LocalSettings.AppPath = pth; LocalSettings.CurrentLanguage = "tr"; var dataFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\tests"; if (!Directory.Exists(dataFolder)) Directory.CreateDirectory(dataFolder); var filePath = string.Format("{0}\\{1}", dataFolder, fileName); if (File.Exists(filePath)) File.Delete(filePath); WorkspaceFactory.UpdateConnection(filePath); var dataCreationService = new DataCreationService(); dataCreationService.CreateData(); Thread.Sleep(1); var workspace = WorkspaceFactory.Create(); return workspace; }