public UserRepository(SecureDBContext context) { this.context = context; }
public MyUserGroupList() { Context = new SecureDBContext(); // slSecure.DB.GetDB(); }
private async void Button_Click(object sender, RoutedEventArgs e) { #if R23 // new Dialog.WaterPowerDiagram(1, true).Show(); if (txtAccount.Text == "david" && pwdPassword.Password == "1234") { (App.Current as App).UserID = "david"; (App.Current as App).UserName = "******"; this.NavigationService.Navigate(new Uri(string.Format("/Main.xaml?userid={0}&username={1}", "david", "david"), UriKind.Relative)); return; } slWCFModule.SSOService.SsoWebServiceClient client = new slWCFModule.SSOService.SsoWebServiceClient(); client.loginCompleted += (s, a) => { if (a.Error != null) { MessageBox.Show("本機可能未授權或連線異常"); return; } var res = a.Result; if (!res.status) MessageBox.Show("帳號密碼錯誤"); else { if (res.userValue.roles.SingleOrDefault(n => n == "SVWS_Admin") != null) { (App.Current as App).UserID = "ssoadmin"; // (App.Current as App).UserName = res.userValue.login; (App.Current as App).UserName = res.userValue.properies.Where(n => n.name == "name").Select(n => n.value).FirstOrDefault(); this.NavigationService.Navigate(new Uri(string.Format("/Main.xaml?userid={0}&username={1}", "ssoadmin", (App.Current as App).UserName), UriKind.Relative)); } else if (res.userValue.roles.SingleOrDefault(n => n == "SVWS_User") != null) { (App.Current as App).UserID = "ssonormal"; //(App.Current as App).UserName = res.userValue.login; (App.Current as App).UserName = res.userValue.properies.Where(n => n.name == "name").Select(n=>n.value).FirstOrDefault(); this.NavigationService.Navigate(new Uri(string.Format("/Main.xaml?userid={0}&username={1}", "ssonormal", (App.Current as App).UserName), UriKind.Relative)); // this.NavigationService.Navigate(new Uri(string.Format("/Main.xaml?userid={0}&username={1}", "ssoadmin", "SSO管理者"), UriKind.Relative)); } else { MessageBox.Show("非授權帳號"); client.logoutAsync(); // this.NavigationService.Navigate(new Uri("/Login.xaml", UriKind.Relative)); } } }; client.loginAsync("SVWS", txtAccount.Text.Trim(), pwdPassword.Password.Trim()); //================normal R23 ============================ //SecureDBContext db = new SecureDBContext();//DB.GetDB(); //EntityQuery<tblUser> q = db.GetTblUserQuery().Where(n => n.UserID == txtAccount.Text.Trim() && n.Password == pwdPassword.Password.Trim()); ////var result= await db.LoadAsync<tblUser>(q); //LoadOperation<tblUser> lo = db.Load(q); //lo.Completed += (s, a) => //{ // if (lo.Error != null) // { // MessageBox.Show(lo.Error.Message); // return; // } // tblUser user = lo.Entities.FirstOrDefault(); // if (user == null) // { // MessageBox.Show("帳號密碼錯誤!"); // return; // } // (App.Current as App).UserID = user.UserID; // (App.Current as App).UserName = user.UserName; // this.NavigationService.Navigate(new Uri(string.Format("/Main.xaml?userid={0}&username={1}", user.UserID, user.UserName), UriKind.Relative)); //}; #else SecureDBContext db = new SecureDBContext();//DB.GetDB(); EntityQuery<tblUser> q = db.GetTblUserQuery().Where(n => n.UserID == txtAccount.Text.Trim() && n.Password == pwdPassword.Password.Trim()); //var result= await db.LoadAsync<tblUser>(q); LoadOperation<tblUser> lo = db.Load(q); lo.Completed += (s, a) => { if (lo.Error != null) { MessageBox.Show(lo.Error.Message); return; } tblUser user = lo.Entities.FirstOrDefault(); if (user == null) { MessageBox.Show("帳號密碼錯誤!"); return; } (App.Current as App).UserID = user.UserID; (App.Current as App).UserName = user.UserName; this.NavigationService.Navigate(new Uri(string.Format("/Main.xaml?userid={0}&username={1}", user.UserID, user.UserName), UriKind.Relative)); }; #endif //tblUser user = result.FirstOrDefault(); //if (user == null) //{ // MessageBox.Show("帳號密碼錯誤!"); // return; //} //(App.Current as App).UserID = user.UserID; //(App.Current as App).UserName = user.UserName; //this.NavigationService.Navigate(new Uri(string.Format("/Main.xaml?userid={0}&username={1}", user.UserID, user.UserName), UriKind.Relative)); }
// 使用者巡覽至這個頁面時執行。 protected async override void OnNavigatedTo(NavigationEventArgs e) { #if R23 this.chkIsWindowsAlarm.Visibility = Visibility; #endif SecureDBContext db = new SecureDBContext();// DB.GetDB(); try { EntityQuery<tblSysParameter> qry = db.GetTblSysParameterQuery().Where(n => n.VariableName == "TimeoutReturnPage"); var result = await db.LoadAsync(qry); tblSysParameter sysparam = result.FirstOrDefault(); if (sysparam != null) { tmr.Interval = TimeSpan.FromMinutes(double.Parse(sysparam.VariableValue)); tmr.Tick += tmr_Tick; tmr.Start(); } // Microsoft.Expression.Interactivity.Layout.FluidMoveBehavior bev = new Microsoft.Expression.Interactivity.Layout.FluidMoveBehavior(); EntityQuery<vwUserMenuAllow> q = db.GetVwUserMenuAllowQuery().Where(n => n.UserID == Util.GetICommon().GetUserID() && n.IsAllow == true); var UserMenus = await db.LoadAsync(q); var res = from n in UserMenus group n by n.GroupName into g select new UserGroupMenu() { GroupMenu = g.Key, Menus = g.OrderBy(k => k.MenuOrder).ToList() }; this.acdMenu.ItemsSource = res; #if R23 this.frameMain.Navigate(new Uri("/Forms/R23/Monitor.xaml", UriKind.Relative)); #else this.frameMain.Navigate(new Uri("/Forms/R23/Monitor.xaml", UriKind.Relative)); // this.frameMain.Navigate(new Uri("/Forms/Monitor.xaml", UriKind.Relative)); #endif } catch { ;} txtTitle.DataContext = new tblMenu() { MenuName = "門禁監控" }; this.acdMenu.SelectedIndex =1; client = new MyClient("CustomBinding_ISecureService",true); client.OnRegistEvent +=async (s) => { await HookAlarmEvent(); client.OnAlarm += client_OnAlarm; }; this.txtCCTVCnt1.Text = this.NavigationContext.QueryString["username"]; // await client.RegistAndGetKey(); //client.SecureService.HookAlarmEventCompleted += (s, a) => // { // }; }
public PayrollRepository(SecureDBContext secureDBContext) { this.secureDBContext = secureDBContext; }
public CustomerRepository(SecureDBContext dbcontext) { this.dbcontext = dbcontext; }
/// <summary> /// 預先讀取當前資料庫各地的機房資料。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Loaded(object sender, RoutedEventArgs e) { SecureDBContext db = new SecureDBContext(); var Engine_Room_Data = from n in db.GetTblEngineRoomConfigQuery() select n; LoadOperation<tblEngineRoomConfig> lo_ERD = db.Load<tblEngineRoomConfig>(Engine_Room_Data); lo_ERD.Completed += (o_ERD, e_ERD) => { if (lo_ERD.Entities.Count() != 0) { foreach (tblEngineRoomConfig _entity in lo_ERD.Entities) { this.Engine_Room_combobox.Items.Add(new ComboBoxItem() { VerticalContentAlignment = System.Windows.VerticalAlignment.Center, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center, Content = _entity.ERName, Tag = _entity.ERID }); } } else { MessageBox.Show("查詢不到各地區的機房資料!", "錯誤", MessageBoxButton.OK); } }; // this.DBContext.tblEngineRoomConfigs.Clear(); }
private void Engine_Room_combobox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox me = sender as ComboBox; Int32 _erid; string _ername = (me.SelectedItem as ComboBoxItem).Content as string; //this.Selection_List.Items.Clear(); this.Item_Collection.Clear(); if (me.SelectedIndex != -1) { _erid = Convert.ToInt32((me.SelectedItem as ComboBoxItem).Tag); SecureDBContext db1=new SecureDBContext(); var RTU = from n in db1.GetTblControllerConfigQuery() where n.ERID == _erid && ( n.ControlType == 3 || n.ControlType==6 || n.ControlType==7 || n.ControlType==8 || n.ControlType==9 || n.ControlType==10) select n; LoadOperation<tblControllerConfig> lo_RTU = db1.Load<tblControllerConfig>(RTU); lo_RTU.Completed += (o_RTU, e_RTU) => { if (lo_RTU.Entities.Count() != 0) { // It is posible if this company has more than 1 RTU. foreach (tblControllerConfig _controller in lo_RTU.Entities) { SecureDBContext db2 = new SecureDBContext(); var ItemConfig = from n in db2.GetTblItemConfigQuery() where n.ControlID == _controller.ControlID && n.Type == "AI" select n; LoadOperation<tblItemConfig> lo_item = db2.Load<tblItemConfig>(ItemConfig); lo_item.Completed += (o_item, e_item) => { if (lo_item.Entities.Count() != 0) { foreach (tblItemConfig _item in lo_item.AllEntities) { if (this.Compare_Collection.Count != 0) { Sensor snr = ( from n in this.Compare_Collection where n.ItemID == _item.ItemID select n).FirstOrDefault() ; if (snr==null) this.Item_Collection.Add( new Sensor(_ername, _controller.ControlID, _item.ItemID, _item.ItemName, _item.Unit)); } else { this.Item_Collection.Add( new Sensor(_ername, _controller.ControlID, _item.ItemID, _item.ItemName, _item.Unit)); } } // Binding this.Selection_List.ItemsSource = this.Item_Collection; } //else { MessageBox.Show(_ername + "底下的" + _controller.ControlID + "並沒有可用的感知器!"); } }; // this.DBContext.tblItemConfigs.Clear(); } } else { MessageBox.Show("找不到ER ID: " + _erid + " 的 RTU資料!"); } }; // this.DBContext.tblControllerConfigs.Clear(); } }