public PeriodicalViewModel(PeriodicalControl periodicalControl) { int i = 0; this.control = periodicalControl; while (i < 10) { MarCodeList.Add(new MarCodeInfo() { PICBG = new BitmapImage(new Uri("02.png", UriKind.RelativeOrAbsolute)), VisibleState = System.Windows.Visibility.Hidden, VisibleState1 = System.Windows.Visibility.Hidden, VisibleState2 = System.Windows.Visibility.Hidden, VisibleState3 = System.Windows.Visibility.Hidden }); i++; } GetPlaceListDAL listDAL = new GetPlaceListDAL(); object errorMsg = null; if (listDAL.GetPlaceList(ref errorMsg)) { string placeId = ConfigurationManager.AppSettings["PlaceId"]; RetrunInfo retrunInfo = errorMsg as RetrunInfo; PlaceList = retrunInfo.result as List <PlaceInfo>; if (PlaceList.Count > 0) { if (!string.IsNullOrEmpty(placeId)) { foreach (PlaceInfo info in PlaceList) { if (info.id == placeId) { Place = info; } } ServerSetting.Place = Place.PlaceName; } else { try { Place = PlaceList[0]; ServerSetting.Place = Place.PlaceName; Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); //首先打开配置文件 cfa.AppSettings.Settings["PlaceId"].Value = Place.id; cfa.Save(ConfigurationSaveMode.Modified); //保存配置文件 ConfigurationManager.RefreshSection("appSettings"); //刷新配置文件 } catch { } } } } }
public PeriodicalChangeControl(MainControl mainControl, string id) { InitializeComponent(); this.mainControl = mainControl; ServerSetting.OldEPClist.Clear(); ServerSetting.EPClist.Clear(); thread = new Thread(new ThreadStart(() => { while (true) { if (ServerSetting.rfid.IsOpen()) { ServerSetting.rfid.Start(); } this.Dispatcher.BeginInvoke((Action) delegate { lock (ServerSetting.EPClist) { if (ServerSetting.EPClist.Count == 0) { // EPC.Clear(); } else { string epc = ServerSetting.EPClist.Dequeue(); ServerSetting.EPClist.Enqueue(epc); EPC.Text = epc; } } }); Thread.Sleep(500); } })); thread.IsBackground = true; Task.Run(() => { object errorMsg = id; SelectOneDAL selectOneDAL = new SelectOneDAL(); if (selectOneDAL.SelectOne(ref errorMsg)) { RetrunInfo info = errorMsg as RetrunInfo; if (info.TrueOrFalse) { this.Dispatcher.BeginInvoke((Action) delegate { PeriodicalsInfo periodicalsInfo = info.result as PeriodicalsInfo; Name.Text = periodicalsInfo.name; fkTypeCode.Text = periodicalsInfo.fkTypeCode; fkTypeName.Text = periodicalsInfo.fkTypeName; fkPressName.Text = periodicalsInfo.fkPressName; unifyNum.Text = periodicalsInfo.unifyNum; parallelTitle.Text = periodicalsInfo.parallelTitle; postIssueNumber.Text = periodicalsInfo.postIssueNumber; openBook.Text = periodicalsInfo.openBook; issnPrice.Text = periodicalsInfo.issnPrice; releaseCycle.Text = periodicalsInfo.releaseCycle; remark.Text = periodicalsInfo.remark; fkCataPeriodicalId = periodicalsInfo.id; this.id = periodicalsInfo.collectionInfo.id; code.Text = periodicalsInfo.collectionInfo.code; callNumber.Text = periodicalsInfo.collectionInfo.callNumber; issn.Text = periodicalsInfo.issn; Remark.Text = periodicalsInfo.pNInfo.remark; price.Text = periodicalsInfo.pNInfo.price; page.Text = periodicalsInfo.pNInfo.page; aNumber.Content = periodicalsInfo.pNInfo.aNumber; sNumber.Text = periodicalsInfo.pNInfo.sNumber; date.Text = periodicalsInfo.pNInfo.publicationDateStr; periodicalTbNumberId = periodicalsInfo.pNInfo.fkCataPeriodicalId; ISBNbookListInfo = new ISBNbookListInfo() { fkTypeCode = periodicalsInfo.collectionInfo.callNumber.Split('/')[0].ToString(), OrderNum = periodicalsInfo.collectionInfo.callNumber.Split('/')[1].ToString() }; EPC.Text = periodicalsInfo.collectionInfo.RFID; if (periodicalsInfo.collectionInfo.available.Equals("0")) { available.IsChecked = false; } else { available.IsChecked = true; } if (periodicalsInfo.collectionInfo.lendingPermission.Equals("0")) { lendingPermission.IsChecked = false; } else { lendingPermission.IsChecked = true; } GetPlaceListDAL listDAL = new GetPlaceListDAL(); List <PlaceInfo> PlaceList = new List <PlaceInfo>(); if (listDAL.GetPlaceList(ref errorMsg)) { RetrunInfo retrunInfo = errorMsg as RetrunInfo; PlaceList = retrunInfo.result as List <PlaceInfo>; place.ItemsSource = PlaceList; } foreach (var place in PlaceList) { if (place.id == periodicalsInfo.collectionInfo.placeCode) { this.place.SelectedItem = place; } } }); } else { if (ServerSetting.IsOverDue) { ErrorPage errorPage = new ErrorPage(info.result.ToString(), mainControl.mainWindow); DialogHelper.ShowDialog(errorPage); } else { MessageBox.Show("失败提示:" + info.result.ToString()); } } } else { MessageBox.Show("失败提示:" + errorMsg.ToString()); } }); }
public BIssueSubscription_Control(MainControl mainControl, string id) { InitializeComponent(); EPC.IsReadOnly = true; this.mainControl = mainControl; this.EditId = id; if (!string.IsNullOrEmpty(id)) { IsEdit = true; } string placeId = ConfigurationManager.AppSettings["PlaceId"]; GetPlaceListDAL listDAL = new GetPlaceListDAL(); object errorMsg = null; ServerSetting.OldEPClist.Clear(); ServerSetting.EPClist.Clear(); PlaceInfo Place = new PlaceInfo(); List <PlaceInfo> PlaceList = new List <PlaceInfo>(); if (listDAL.GetPlaceList(ref errorMsg)) { RetrunInfo retrunInfo = errorMsg as RetrunInfo; PlaceList = retrunInfo.result as List <PlaceInfo>; place.ItemsSource = PlaceList; if (PlaceList.Count > 0) { if (!string.IsNullOrEmpty(placeId)) { foreach (PlaceInfo info in PlaceList) { if (info.id == placeId) { Place = info; } } mainControl.info.Place = Place.PlaceName; ServerSetting.Place = Place.PlaceName; place.SelectedItem = Place; } else { try { Place = PlaceList[0]; mainControl.info.Place = Place.PlaceName; ServerSetting.Place = Place.PlaceName; Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); //首先打开配置文件 cfa.AppSettings.Settings["PlaceId"].Value = Place.id; cfa.Save(ConfigurationSaveMode.Modified); //保存配置文件 ConfigurationManager.RefreshSection("appSettings"); //刷新配置文件 place.SelectedItem = Place; } catch { } } } } mainControl.thread = new Thread(new ThreadStart(() => { while (true) { if (ServerSetting.rfid.IsOpen()) { ServerSetting.rfid.Start(); } this.Dispatcher.BeginInvoke((Action) delegate { lock (ServerSetting.EPClist) { if (ServerSetting.EPClist.Count == 0) { // EPC.Clear(); } else { if (string.IsNullOrEmpty(EPC.Text)) { string epc = ServerSetting.EPClist.Dequeue(); ServerSetting.EPClist.Enqueue(epc); EPC.Text = epc; } if (!string.IsNullOrEmpty(EditId)) { string epc = ServerSetting.EPClist.Dequeue(); ServerSetting.EPClist.Enqueue(epc); EPC.Text = epc; } } } }); Thread.Sleep(500); } })); mainControl.thread.IsBackground = true; Task.Run(() => { if (!string.IsNullOrEmpty(id)) { errorMsg = id; SelectHDOneDAL selectHDOneDAL = new SelectHDOneDAL(); if (selectHDOneDAL.SelectHDOne(ref errorMsg)) { this.Dispatcher.BeginInvoke((Action) delegate { backBtn.Visibility = Visibility.Visible; RetrunInfo info = errorMsg as RetrunInfo; if (info.TrueOrFalse) { PeriodicalsInfo periodicalsInfo = info.result as PeriodicalsInfo; this.info = periodicalsInfo; Name.Text = periodicalsInfo.name; fkTypeCode.Text = periodicalsInfo.fkTypeCode; fkTypeName.Text = periodicalsInfo.fkTypeName; fkPressName.Text = periodicalsInfo.fkPressName; unifyNum.Text = periodicalsInfo.unifyNum; parallelTitle.Text = periodicalsInfo.parallelTitle; postIssueNumber.Text = periodicalsInfo.postIssueNumber; openBook.Text = periodicalsInfo.openBook; issnPrice.Text = periodicalsInfo.issnPrice; releaseCycle.Text = periodicalsInfo.releaseCycle; remark.Text = periodicalsInfo.remark; this.id = periodicalsInfo.id; hkPrice.Text = periodicalsInfo.collectionInfo.hkPrice; hkRemark.Text = periodicalsInfo.collectionInfo.hkRemark; code.Text = periodicalsInfo.collectionInfo.code; callNumber.Text = periodicalsInfo.collectionInfo.callNumber; issnMsg.Visibility = Visibility.Hidden; issn.Text = periodicalsInfo.issn; EditId = periodicalsInfo.collectionInfo.id; ISBNbookListInfo = new ISBNbookListInfo() { fkTypeCode = periodicalsInfo.collectionInfo.callNumber.Split('/')[0].ToString(), OrderNum = periodicalsInfo.collectionInfo.callNumber.Split('/')[1].ToString() }; EPC.Text = periodicalsInfo.collectionInfo.RFID; grid.ItemsSource = periodicalsInfo.pNInfos; if (periodicalsInfo.collectionInfo.available.Equals("0")) { available.IsChecked = false; } else { available.IsChecked = true; } if (periodicalsInfo.collectionInfo.lendingPermission.Equals("0")) { lendingPermission.IsChecked = false; } else { lendingPermission.IsChecked = true; } foreach (var place in PlaceList) { if (place.id == periodicalsInfo.collectionInfo.placeCode) { this.place.SelectedItem = place; } } } else { if (ServerSetting.IsOverDue) { ErrorPage errorPage = new ErrorPage(info.result.ToString(), mainControl.mainWindow); DialogHelper.ShowDialog(errorPage); } else { MessageBox.Show("失败提示:" + info.result.ToString()); } } }); } else { MessageBox.Show(errorMsg.ToString()); } } }); }