/// <summary> /// /// </summary> /// <returns></returns> public bool Logout() { Common.UnregisterUserInformation(); ApplicationContextManager.UnregisterMessageLoader(); Common.CurrentDatabase = null; ImageCache.ReleaseInstance(); ProgramScreenCache.ReleaseInstance(); InternalScreenCache.ReleaseIntance(); DatabaseScreenCache.ReleaseInstance(); return(true); }
private Map <string, ScreenDetail> GetScreenDetail(string ScreenCD) { //Hashtable hs = new Hashtable(); InternalScreenCache internals = InternalScreenCache.GetInstance(); InternalScreen screen = internals[ScreenCD]; object obj = Activator.CreateInstance(screen.ClassType, null); EVOFramework.Windows.Forms.EVOForm form = (EVOFramework.Windows.Forms.EVOForm)obj; Map <string, ScreenDetail> mapControl = form.GetControlList(); return(mapControl); }
static void Main(string[] args) { if (RunAutoUpdate(args)) { //ถ้าใน method RunAutoUpdate ทำงาน //แล้ว return true; แปลว่า ให้มัน run autoupdate เฉยๆ ไม่ต้อง new thread //เพราะauto update จะจัดการเปิดโปรแกรมให้ใหม่ //(ซึ่ง autoupdate จะ set param ให้เวลา run อีกรอบ จะทำให้ method return false //แต่ถ้า return false; แปลว่าหา path ไม่เจอ ก็ให้มันทำงานได้เลย } else { //Set default culture to English-United state //set default date to dd/MM/yyyy Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US"); CultureInfo culture = new System.Globalization.CultureInfo("en-US"); culture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy"; culture.DateTimeFormat.ShortTimePattern = "HH:mm"; culture.DateTimeFormat.LongTimePattern = "HH:mm:ss"; culture.DateTimeFormat.DateSeparator = "/"; Thread.CurrentThread.CurrentCulture = culture; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); // Enter life-cycle main form. try { while (true) { LoginForm form = new LoginForm(); if (form.ShowDialog() == DialogResult.Cancel) { return; } //UserController userController = new UserController(); //if (!userController.Login("SYSTEM".ToNZString(), "SYSTEM".ToNZString())) // return; //========================= LoadConfiguration(); #warning Injection to load plugins string path = System.IO.Path.Combine(Application.StartupPath, @"Rubik.Forms.DLL"); InternalScreenCache.GetInstance().LoadScreensFromAssembly(path); try { Assembly tkpFormAsm = Assembly.LoadFile(path); Common.Version.Value = tkpFormAsm.GetName().Version.ToString(); Common.UpdateDate.Value = GetBuildDate(tkpFormAsm.GetName().Version); //FileInfo tkpFileInfo = new FileInfo(path); //Common.UpdateDate.Value = tkpFileInfo.CreationTime.ToString("yyyy/MM/dd"); //Common.UpdateDate.Value = DataDefine.PROGRAM_DATE; } catch (Exception err) { System.Diagnostics.Debug.WriteLine(err.Message); Common.Version.Value = string.Empty; Common.UpdateDate.Value = string.Empty; } // -------------- Thread LoadReportTread = new Thread(new ThreadStart(LoadDummyReport)); LoadReportTread.Start(); // ============== m_menuFrame = new MenuFrame(); Application.Run(m_menuFrame); // if user choose to close menu form, terminate application. if (!m_menuFrame.IsLogout) { return; } } // end while } catch (ValidateException err) { MessageDialog.ShowBusiness(null, err.ErrorResults[0].Message); if (m_menuFrame != null && !m_menuFrame.IsDisposed) { m_menuFrame.Dispose(); } } catch (BusinessException err) { MessageDialog.ShowBusiness(null, err.Error.Message); if (m_menuFrame != null && !m_menuFrame.IsDisposed) { m_menuFrame.Dispose(); } } catch (Exception err) { Console.WriteLine(err.Message); //MessageDialog.ShowSingleItem(null, "Error", err.StackTrace, MessageDialogIcon.Error); ErrorDialog errorDialog = new ErrorDialog(); errorDialog.Message = @"Connection failed. " + System.Environment.NewLine + err.Message; errorDialog.StackTrace = err.StackTrace; errorDialog.ShowDialog(); if (m_menuFrame != null && !m_menuFrame.IsDisposed) { m_menuFrame.Dispose(); } //TODO: Remark LoginForm for customer TAKEI Application.ExitThread(); Application.Restart(); } } }
private void LoadData(string keyFilter) { try { shtScreenList.Columns[(int)eColView.SEL].DataField = ""; shtScreenList.Columns[(int)eColView.SCREEN_CD].DataField = "SCREEN_CD"; shtScreenList.Columns[(int)eColView.SCREEN_NAME].DataField = "SCREEN_NAME"; shtScreenList.Columns[(int)eColView.SCREEN_TYPE].DataField = "SCREEN_TYPE"; shtScreenList.Columns[(int)eColView.IMPORT_STATUS].DataField = "IMPORT_STATUS"; shtScreenList.ActiveSkin = CommonLib.Common.ACTIVE_SKIN; ScreenImportController SIC = new ScreenImportController(); InternalScreenCache internals = InternalScreenCache.GetInstance(); DataTable dt = new DataTable(); dt.Columns.Add("SCREEN_CD"); dt.Columns.Add("SCREEN_NAME"); dt.Columns.Add("SCREEN_TYPE"); dt.Columns.Add("IMPORT_STATUS"); for (int i = 0; i < internals.InternalScreenList.Count; i++) { InternalScreen internalscreen = internals.InternalScreenList[i]; dt.Rows.Add(internalscreen.ScreenAttribute.ScreenCD , internalscreen.ScreenAttribute.ScreenName , internalscreen.ScreenAttribute.ScreenType.ToString() , SIC.IsScreenAlreadyExist(internalscreen.ScreenAttribute.ScreenCD) ? eImportStatus.Import.ToString() : eImportStatus.NotImport.ToString()); } //dt.DefaultView.Sort = "SCREEN_CD"; DataTable dtView = dt.Clone(); if (keyFilter != string.Empty) { //get only the rows you want DataRow[] results = dt.Select(string.Format("SCREEN_CD LIKE '%{0}%' OR SCREEN_NAME LIKE '%{0}%'", keyFilter)); //populate new destination table foreach (DataRow dr in results) { dtView.ImportRow(dr); } } else { foreach (DataRow dr in dt.Rows) { dtView.ImportRow(dr); } } dtView.DefaultView.Sort = "SCREEN_CD ASC"; fpScreenList.DataSource = dtView.DefaultView; int row = shtScreenList.Rows.Count; for (int i = 0; i < row; i++) { if (shtScreenList.Cells[i, (int)eColView.IMPORT_STATUS].Text == eImportStatus.Import.ToString()) { shtScreenList.Cells[i, (int)eColView.IMPORT_STATUS].BackColor = Color.PaleGreen; } else { shtScreenList.Cells[i, (int)eColView.IMPORT_STATUS].BackColor = Color.Salmon; } } shtScreenList.Columns[(int)eColView.SEL].Locked = false; shtScreenList.Columns[(int)eColView.IMPORT_STATUS].Locked = true; shtScreenList.Columns[(int)eColView.SCREEN_CD].Locked = true; shtScreenList.Columns[(int)eColView.SCREEN_NAME].Locked = true; shtScreenList.Columns[(int)eColView.SCREEN_TYPE].Locked = true; } catch (ValidateException err) { for (int i = 0; i < err.ErrorResults.Count; i++) { MessageBox.Show(err.ErrorResults[i].Message.MessageDescription); err.ErrorResults[i].FocusOnControl(); } } catch (BusinessException err) { MessageBox.Show(err.Error.Message.MessageDescription); } catch (Exception ex) { MessageBox.Show(ex.Message); } }