private void Application_Startup(object sender, StartupEventArgs e) { string dir = System.IO.Directory.GetCurrentDirectory(); string finalDir = dir.Substring(0, dir.LastIndexOf('\\')); log4net.GlobalContext.Properties["LogFileName"] = finalDir + "\\log\\IntDesign"; log4net.Config.XmlConfigurator.Configure(); Resources.MergedDictionaries.Add(LoadComponent(new Uri("SkinContent;component/SkinContent.xaml", UriKind.Relative)) as ResourceDictionary); Log.Info("Startup Application..."); System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); AssemblyName assembly = Assembly.GetExecutingAssembly().GetName(); if (Process.GetProcessesByName(assembly.Name).Length > 1) { Log.ErrorFormat("{0} is already running.", assembly.Name); Current.Shutdown(); } else { this.viewModel = new MainViewModel(); viewModel.PropertyChanged += viewModel_PropertyChanged; login = new View.Login(viewModel); login.Show(); } }
//ListViewItem 클릭시 Page 전환 기능 private void ListViewItem_Selected(object sender, RoutedEventArgs e) { if (sender == LoginItem) { var login = new View.Login(); pageControl.NavigationService.Navigate(login); } if (sender == HomeItem) { var home = new View.Home(); pageControl.NavigationService.Navigate(home); } if (sender == CalenadarItem) { var calenadar = new View.Calendar(); pageControl.NavigationService.Navigate(calenadar); } if (sender == NoticeItem) { var notice = new View.Notice(); pageControl.NavigationService.Navigate(notice); } if (sender == BindingItem) { var binding = new View.Binding(); pageControl.NavigationService.Navigate(binding); } if (sender == SignOutItem) { Application.Current.Shutdown(); } }
public LoginViewModel(View.Login Login) { this.Login = Login; login = new Login(this); CurrentUser = new UserEntity(); }
public override bool Login() { List <string> list = new List <string>(); list.Add(View.Main.Instance.Name); if (!View.SplashScreen.InstanceIsNull) { list.Add(View.SplashScreen.Instance.Name); } //list.Add(UI.SelectArchive.Instance.Name); this.CloseForms(list.ToArray()); System.Windows.Forms.DialogResult result; using (View.Login login = new View.Login()) { result = login.ShowDialog(); } if (result == System.Windows.Forms.DialogResult.OK) { Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString); Model.Common.User membership = dc.Users.Where(t => t.Code == Setting.User.ThisProgram.GetCurrentUser <Model.Common.User>().Code).Single(); membership.LastLogin = DateTime.Now; if (membership.isGuest) { try { DateTime Expire = Convert.ToDateTime(membership.Expire); DateTime Today = ConvertTo_PersianOREnglish_Date.GetEglishDate(DataAccess.CommonDataAccess.GetNewInstance().Connection.GetServerPersianDate()); if (Today >= Expire) { membership.Visible = Options.SettingInitializer.GetUserSetting().HashData(membership.Code.ToString() + (int)Njit.Program.Setting.UserSetting.UserStates.Inactive); dc.SubmitChanges(); MessageBox.Show("تاریخ انقضا پنل کاربری شما به اتمام رسیده است."); Logout(); } } catch { MessageBox.Show("تاریخ انقضا پنل کاربری شما در سیستم درست وارد نشده است. به مدیر سیستم اطلاع داده تا تاریخ انقضا پنل کاربریتان را تغییر بدهد. "); } } //اگر ادمین باشد نیازی نیست if (!Setting.User.ThisProgram.IsMembershipInAdministartorRole(Setting.User.ThisProgram.GetCurrentUser <Model.Common.User>())) { if (membership.isLogin == true && membership.IPAddress == null) { MessageBox.Show(" با اطلاعات وارد شده یک کاربر دیگر وجود دارد در غیر اینصورت از مدیر سیستم بخواهید تا اطلاعات شما را ویرایش کند."); Logout(); } if (membership.isLogin == true && membership.IPAddress != Setting.Program.GetMacAddress().ToString()) { MessageBox.Show(" با اطلاعات وارد شده یک کاربر دیگر وجود دارد در غیر اینصورت از مدیر سیستم بخواهید تا اطلاعات شما را ویرایش کند."); Logout(); } } membership.IPAddress = Setting.Program.GetMacAddress().ToString(); membership.isLogin = true; dc.SubmitChanges(); AddLog(dc, UserOparatesPlaceNames.None, UserOparatesNames.ورود_به_سیستم, null, null); if (View.SelectArchive.Instance.Visible == false) { View.SelectArchive.Instance.Show(View.Main.Instance); } this.Load(); //View.Main.Instance.StartCheckLock(); return(true); } return(false); }
public LoginController(View.Login viewlogin) { this.viewlogin = viewlogin; modellogin = new Model.LoginModel(); }
private void MainWindow_Load(object sender, EventArgs e) { View.Login login = new View.Login(); login.ShowDialog(this); }
private bool LLamarPantallaIngreso() { View.Login Login = new View.Login(); Login.ShowDialog(); if (Login.Aceptado) { // indicar un usario Generico AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.UnauthenticatedPrincipal); // Crear una identidad con el nombre de usuario IIdentity usuario = new GenericIdentity(Login.Usuario.Text, "Database"); //Crear lista roles String[] roles = { "Usuario", "Administrador" }; // Crear La credencial GenericPrincipal credencial = new GenericPrincipal(usuario, roles); // Asignar e sta credencial a la aplicacion System.Threading.Thread.CurrentPrincipal = credencial; } return Login.Aceptado; }