static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.ApplicationExit += Application_ApplicationExit; AppLog = new Ultra.Log.ApplicationLog(); __start: string con = string.Empty; BaseSurface vw; vw = Lanucher.Start("Ultra.Login.LoginView");//.ShowDialog(); con = Lanucher.ConnectonString; if (!CanConnDb(con)) { MsgBox.ShowMessage("无法连接至服务器", "无法连接至服务器!"); } using (var db = new Database()) { var dte = db.ExecuteScalar <DateTime>("select getdate()"); TimeSync.Default.StartSync(dte); } var dt = vw.ShowDialog(); if (dt == DialogResult.OK)//登录成功 { if (null == args || args.Length < 1) { vw = Lanucher.Start("Ultra.Login.MainView"); } else { vw = Lanucher.Start(args[0]); } } else if (dt == DialogResult.Cancel)//退出 { return; } dt = vw.ShowDialog(); if (dt == DialogResult.No) { Lanucher.Clean("OfficeSkins.Register()"); goto __start; } }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (null == args || args.Length < 1) { return; } //Path.GetDirectoryName(Application.StartupPath); var vm = Lanucher.Start(args[0]); var date = (DateTime)SqlHelper.ExecuteScalar(Lanucher.ConnectonString, System.Data.CommandType.Text, "select getdate()"); TimeSync.Default.StartSync(date); vm.Cacher.Put <t_user>("CurrentUser", new t_user() { UserName = "******", Guid = Guid.NewGuid() }); vm.Cacher.Put <string>("CurUser", "admin"); Application.Run(vm); }
private void MainView_Load(object sender, EventArgs e) { Common.GetMACs(out LocalMAC); Common.GetLocalIpv4(out LocalIP); //try { RemoteIP = Common.GetRemoteIP(); } catch { RemoteIP = string.Empty; } RemoteIP = string.Empty; //检查登录是否是被授权的 if ((this.CurUser.IgnoreCaseEqual("admin"))) { barBtnSysMnu.Visibility = BarItemVisibility.Always; } else { barBtnSysMnu.Visibility = BarItemVisibility.Never; } this.barLabel.Caption = this.CurUser; var skinGallery = new DevExpress.XtraBars.Ribbon.GalleryDropDown(); skinGallery.Manager = this.barManager1; this.barSkin.ButtonStyle = BarButtonStyle.DropDown; this.barSkin.DropDownControl = skinGallery; this.barSkin.ActAsDropDown = true; skinGallery.Gallery.ItemClick += (obj, se) => { this.OptConfig.Set <string>("SkinName", se.Item.Caption); Lanucher.ReLoadSkinName(); }; SkinHelper.InitSkinGalleryDropDown(skinGallery); var mnustyle = OptConfig.Get <string>("Menu"); if (mnustyle == "Taobao") { barChkTaobao.Checked = true; } else { barChkSys.Checked = true; } SqlConnectionStringBuilder bld = new SqlConnectionStringBuilder(ConnString); barStaticItem2.Caption = string.Format("{0} {1}", bld.DataSource.ToString(), bld.InitialCatalog); barStaticItem2.Caption += " " + RemoteIP; //同步服务器时间 var serverTime = (DateTime)SqlHelper.ExecuteScalar(ConnString, CommandType.Text, "select getdate()"); TimeSync.Default.StartSync(serverTime); //var t = new Thread(() => { // while (true) { // Thread.Sleep(1000); // if (this.IsDisposed) // return; // while (!this.IsHandleCreated) { } // this.Invoke(new Action(() => { // barStaticItem3.Caption = TimeSync.Default.CurrentSyncTime.ToString("yyyy-MM-dd HH:mm:ss"); // })); // } //}); //t.IsBackground = true; //t.Start(); //加载菜单 LoadMenu(); if (string.Compare(OptConfig.Get <string>("Menu"), "taobao", true) == 0) { barChkTaobao.Checked = true; barChkSys.Checked = false; foreach (NavBarGroup gp in navMenu.Groups) { gp.Expanded = true; } } else { barChkSys.Checked = true; barChkTaobao.Checked = false; } var w = OptConfig.Get <int>("MenuWidth"); if (w > 0) { this.navMenu.Width = w; } try { var mpv = Lanucher.Start("Ultra.MainPage.MainView"); if (null != mpv) { mpv.MdiParent = this; mpv.Show(); } } catch { } var threg = new Thread(() => { RegSelfLogin(); }); threg.IsBackground = true; threg.Start(); }
private void MainView_Load(object sender, EventArgs e) { Common.GetMACs(out LocalMAC); Common.GetLocalIpv4(out LocalIP); //try { RemoteIP = Common.GetRemoteIP(); } catch { RemoteIP = string.Empty; } RemoteIP = string.Empty; //检查登录是否是被授权的 if (!IsAllowLogin()) { SqlHelper.ExecuteNonQuery(ConnString, CommandType.Text, Sql_AddLoginFail, new SqlParameter("@LoginMAC", LocalMAC), new SqlParameter("@ExternalIP", RemoteIP), new SqlParameter("@LocalIP", LocalIP), new SqlParameter("@UserName", CurUser) ); this.Invoke(new Action(() => { this.navMenu.Enabled = false; this.bar1.Visible = false; this.Text += " 未被授权的登录"; })); return; } if ((this.CurUser.IgnoreCaseEqual("admin"))) { barBtnSysMnu.Visibility = BarItemVisibility.Always; } else { barBtnSysMnu.Visibility = BarItemVisibility.Never; } this.barLabel.Caption = this.CurUser; var skinGallery = new DevExpress.XtraBars.Ribbon.GalleryDropDown(); skinGallery.Manager = this.barManager1; this.barSkin.ButtonStyle = BarButtonStyle.DropDown; this.barSkin.DropDownControl = skinGallery; this.barSkin.ActAsDropDown = true; skinGallery.Gallery.ItemClick += (obj, se) => { this.OptConfig.Set <string>("SkinName", se.Item.Caption); Lanucher.ReLoadSkinName(); }; SkinHelper.InitSkinGalleryDropDown(skinGallery); var mnustyle = OptConfig.Get <string>("Menu"); if (mnustyle == "Taobao") { barChkTaobao.Checked = true; } else { barChkSys.Checked = true; } SqlConnectionStringBuilder bld = new SqlConnectionStringBuilder(ConnString); barStaticItem2.Caption = string.Format("{0} {1}", bld.DataSource.ToString(), bld.InitialCatalog); barStaticItem2.Caption += " " + RemoteIP; //同步服务器时间 var serverTime = (DateTime)SqlHelper.ExecuteScalar(ConnString, CommandType.Text, "select getdate()"); TimeSync.Default.StartSync(serverTime); var t = new Thread(() => { while (true) { Thread.Sleep(1000); if (this.IsDisposed) { return; } while (!this.IsHandleCreated) { } this.Invoke(new Action(() => { barStaticItem3.Caption = TimeSync.Default.CurrentSyncTime.ToString("yyyy-MM-dd HH:mm:ss"); })); } }); t.IsBackground = true; t.Start(); t = new Thread(() => { while (true) { Thread.Sleep(60 * 1000); if (SqlHelper.ExecuteScalar(ConnString, CommandType.Text, "select 1 from t_forcedoffline where LoginMAC=@LoginMAC", new SqlParameter("@LoginMAC", LocalMAC)) != null) { MsgBox.ShowMessage("", "您已被管理员强制下线!"); GC.Collect(); System.Diagnostics.Process.GetCurrentProcess().Kill(); } } }); t.IsBackground = true; t.Start(); //加载菜单 LoadMenu(); if (string.Compare(OptConfig.Get <string>("Menu"), "taobao", true) == 0) { barChkTaobao.Checked = true; barChkSys.Checked = false; foreach (NavBarGroup gp in navMenu.Groups) { gp.Expanded = true; } } else { barChkSys.Checked = true; barChkTaobao.Checked = false; } var w = OptConfig.Get <int>("MenuWidth"); if (w > 0) { this.navMenu.Width = w; } try { var mpv = Lanucher.Start("LS.ERP.MainPage.MainView"); if (null != mpv) { mpv.MdiParent = this; mpv.Show(); } } catch { } var threg = new Thread(() => { RegSelfLogin(); }); threg.IsBackground = true; threg.Start(); }
private void Refc(string cls, string mod, TreeListNode mnu) { try { var pth = Path.Combine(Lanucher.AppDir, mod); var md5 = string.Empty; if (File.Exists(pth)) { md5 = ByteStringUtil.ByteArrayToHexStr(HashDigest.FileDigest(pth)); } var m = Lanucher.Start(cls, mod); var ip = m as ISurfacePermission; if (null == ip) { return; } var toolbar = ip.ToolBarItems; var grids = ip.Grids; var btns = ip.ButtonItems; if (null != toolbar && toolbar.Count > 0) { var td = mnu.Nodes.Add(new object[] { "主按钮" }); foreach (var ti in toolbar) { var tds = td.Nodes.Add(new object[] { ti.Caption }); tds.Tag = new t_rolepermit { ControlName = ti.Name, TextName = ti.Caption, CtlType = (int)EnCtlType.ToolBarItems, IsEnabled = false, ClsName = cls, AsmName = mod, AsmMD5 = md5 }; } } if (null != grids && grids.Count > 0) { foreach (var ti in grids) { var td = mnu.Nodes.Add(new object[] { ti.Name }); td.Tag = new t_rolepermit { ControlName = ti.Gv.Name, TextName = ti.Name, CtlType = (int)EnCtlType.Grids, IsEnabled = false, ClsName = cls, AsmName = mod, AsmMD5 = md5 }; foreach (DevExpress.XtraGrid.Columns.GridColumn col in ti.Gv.Columns) { var tdc = td.Nodes.Add(new object[] { col.Caption }); tdc.Tag = new t_rolepermit { ControlName = col.Name, ParentCtlName = ti.Gv.Name, TextName = col.Caption, CtlType = (int)EnCtlType.GridCol, IsEnabled = false, ClsName = cls, AsmName = mod, AsmMD5 = md5 }; } } } if (null != btns && btns.Count > 0) { var td = mnu.Nodes.Add(new object[] { "自定义按钮" }); foreach (var ti in btns) { var tds = td.Nodes.Add(new object[] { string.IsNullOrEmpty(ti.Text) ? ti.Name : ti.Text /*ti.Name*/ }); tds.Tag = new t_rolepermit { ControlName = ti.Name, TextName = ti.Text, CtlType = (int)EnCtlType.ButtonItems, IsEnabled = false, ClsName = cls, AsmName = mod, AsmMD5 = md5 }; } } } catch //(Exception) { //throw; } }