public static PrinterManager getInstance()
 {
     lock (synclock)
     {
         if (uniqueInstance == null)
         {
             uniqueInstance = new PrinterManager();
         }
         return(uniqueInstance);
     }
 }
Beispiel #2
0
        public void ExecuteOpenService()
        {
            Log4.PrinterLogger.Info("[A] Press Open Service button...");
            if (!IsServiceBeenOpened)
            {
                //將資料導入到PrinterManager
                Log4.PrinterLogger.Info("   Importing Settings...");
                if (ViewModelLocator.Atom.LaneSelectorHostVM.LaneContainer.Count == 1)
                {
                    Log4.PrinterLogger.Info("   Importing Settings... Lane1");
                    PrinterManager.getInstance().ImportSetting(0
                                                               , (OneLaneSelectorVM)ViewModelLocator.Atom.LaneSelectorHostVM.LaneContainer[0].DataContext
                                                               , (CommonSettingVM)_window.ucLane1_Common.DataContext
                                                               , (SharedFolderSettingVM)_window.ucLane1_SF.DataContext);
                }
                else if (ViewModelLocator.Atom.LaneSelectorHostVM.LaneContainer.Count == 2)
                {
                    Log4.PrinterLogger.Info("   Importing Settings... Lane1");
                    PrinterManager.getInstance().ImportSetting(0
                                                               , (OneLaneSelectorVM)ViewModelLocator.Atom.LaneSelectorHostVM.LaneContainer[0].DataContext
                                                               , (CommonSettingVM)_window.ucLane1_Common.DataContext
                                                               , (SharedFolderSettingVM)_window.ucLane1_SF.DataContext);
                    Log4.PrinterLogger.Info("   Importing Settings... Lane2");
                    PrinterManager.getInstance().ImportSetting(1
                                                               , (OneLaneSelectorVM)ViewModelLocator.Atom.LaneSelectorHostVM.LaneContainer[1].DataContext
                                                               , (CommonSettingVM)_window.ucLane2_Common.DataContext
                                                               , (SharedFolderSettingVM)_window.ucLane2_SF.DataContext);
                }
                //取資料
                if (!ExamineData())
                {
                    IsServiceBeenOpened = false;
                    return;
                }

                try
                {
                    //開啟service
                    PrinterServiceHost.Instance().OpenHost(null);
                    IsServiceBeenOpened = true;
                    Log4.PrinterLogger.Info("================== Service is Opened ==================");
                    ServiceBtnContent = "@CLOSE_SERVICE".Translate();
                }
                catch (Exception e)
                {
                    Log4.PrinterLogger.Info("[X] Service Open Failed!");
                    IsServiceBeenOpened = false;
                }

                //BtnOpenServiceVisible = !IsServiceBeenOpened;

                //清空前面的檢測log 訊息
                _window.lbStatusReporter.Items.Clear();

                if (IsServiceBeenOpened)//已開啟
                {
                    _window.lbStatusReporter.Items.Add("@SERVICE_OPENED".Translate());
                    _window.lbStatusReporter.Items.Add("@LAST_COMMENT".Translate());
                    _window.lbStatusReporter.Items.Add("@LAST_COMMENT2".Translate());
                }
                //Refresh Chart
                _window.ucChartHost.RefreshSelectionChanged();
            }
        }