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);
        }
Example #2
0
        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());
            }
        }
Example #3
0
        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);
        }
Example #4
0
        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());
            }
        }
Example #5
0
        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());
            }
        }
Example #6
0
        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());
            }
        }
Example #7
0
        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();
        }
Example #8
0
        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 });
        }
Example #9
0
 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;
 }
Example #10
0
 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;
 }
Example #11
0
        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 { });
        }