日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
Winform開(kāi)發(fā)框架之系統(tǒng)登錄實(shí)現(xiàn)

在業(yè)務(wù)系統(tǒng)的操作過(guò)程中,有時(shí)候,用戶(hù)需要切換用戶(hù)進(jìn)行重新登錄,這種情況有時(shí)候是因?yàn)橐粋€(gè)人管理多個(gè)用戶(hù)賬號(hào),希望通過(guò)不同的賬號(hào)登錄進(jìn)行管理不同的資料,另一種情況是酒店的換班操作,另一個(gè)人接替前面的人進(jìn)行系統(tǒng)維護(hù)管理。這種重新登錄其實(shí)也是一種友好的操作之一,試想一下,換個(gè)賬號(hào)登錄,就需要推出系統(tǒng),重新尋找運(yùn)行程序才可以,而且如果系統(tǒng)啟動(dòng)較慢一點(diǎn)的,還需要等待,所以實(shí)現(xiàn)重新登錄,有時(shí)候也是必要的。因此實(shí)現(xiàn)這個(gè)功能,也是體現(xiàn)我們開(kāi)發(fā)的系統(tǒng)注重細(xì)節(jié)的表現(xiàn)。

站在用戶(hù)的角度思考問(wèn)題,與客戶(hù)深入溝通,找到白銀網(wǎng)站設(shè)計(jì)與白銀網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶(hù)體驗(yàn)好的作品,建站類(lèi)型包括:網(wǎng)站建設(shè)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名申請(qǐng)、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋白銀地區(qū)。

另外,自動(dòng)登錄(其實(shí)是接受通過(guò)命令行參數(shù)進(jìn)行登錄)也是很常見(jiàn)的,有時(shí)候,讓客戶(hù)端記住用戶(hù)的賬號(hào)密碼,我們?cè)诤笈_(tái)通過(guò)調(diào)動(dòng)命令行方式進(jìn)行登錄,讓系統(tǒng)程序接收到相關(guān)的參數(shù)值即可進(jìn)行登錄了。

1、系統(tǒng)重新登錄實(shí)現(xiàn)

大致的思路,就是登錄系統(tǒng)后,在系統(tǒng)菜單中有一項(xiàng)重新登錄的功能入口,單擊可以要求客戶(hù)重新輸入密碼進(jìn)行登錄,如下所示。

代碼實(shí)現(xiàn)就是通過(guò)把初始化的時(shí)候,用戶(hù)相關(guān)的操作放到一個(gè)函數(shù)里面,保證重新執(zhí)行這個(gè)函數(shù)操作就能重新刷新登錄用戶(hù)信息即可。如下所示。

在InitUserRelated函數(shù)里面,我們把用戶(hù)相關(guān)的初始化操作放在里面,其中包括顯示登錄用戶(hù)信息、用戶(hù)可操作按鈕或者菜單、首頁(yè)信息等相關(guān)項(xiàng)目,代碼如下所示。

  
 
 
 
  1. /// 
  2. /// 初始化用戶(hù)相關(guān)的系統(tǒng)信息
  3. /// 
  4. private void InitUserRelated()
  5. {
  6.     ChildWinManagement.LoadMdiForm(this, typeof(FirstPage));//歡迎頁(yè)面
  7.     #region 初始化系統(tǒng)名稱(chēng)
  8.     try
  9.     {
  10.         string Manufacturer = config.AppConfigGet("Manufacturer");
  11.         string ApplicationName = config.AppConfigGet("ApplicationName");
  12.         string AppWholeName = string.Format("{0}-{1}    ", Manufacturer, ApplicationName);
  13.         Portal.gc.gAppUnit = Manufacturer;
  14.         Portal.gc.gAppMsgboxTitle = AppWholeName;
  15.         Portal.gc.gAppWholeName = AppWholeName;
  16.         this.Text = AppWholeName + "      ";
  17.         this.notifyIcon1.BalloonTipText = AppWholeName;
  18.         this.notifyIcon1.BalloonTipTitle = AppWholeName;
  19.         this.notifyIcon1.Text = AppWholeName;
  20.         string userName = Portal.gc.LoginInfo.RealName;
  21.         if (string.IsNullOrEmpty(userName))
  22.         {
  23.             userName = Portal.gc.LoginInfo.Name;
  24.         }
  25.         UserStatus = string.Format("當(dāng)前用戶(hù):{0}({1})", userName, Portal.gc.RoleInfo.RoleName);
  26.         CommandStatus = string.Format("歡迎使用 {0}", Portal.gc.gAppWholeName);
  27.     }
  28.     catch { }
  29.     #endregion
  30.     InitAuthorizedUI();//根據(jù)權(quán)限屏蔽
  31.     InitSkinGallery();
  32.     UserLookAndFeel.Default.SetSkinStyle("Office 2010 Blue");
  33. }

其中InitAuthorizedUI就是判斷用戶(hù)有哪些權(quán)限的函數(shù),根據(jù)權(quán)限系統(tǒng)獲取到的功能點(diǎn),在這里對(duì)界面元素進(jìn)行重新刷新,有權(quán)限的就顯示,沒(méi)有的就隱藏即可,如下所示。

  
 
 
 
  1. /// 
  2. /// 根據(jù)權(quán)限屏蔽功能
  3. /// 
  4. private void InitAuthorizedUI()
  5. {
  6.     this.tool_Report.Enabled = Portal.gc.HasFunction("Report");
  7.     this.tool_Dict.Enabled = Portal.gc.HasFunction("Dictionary");
  8.     this.tool_ItemDetail.Enabled = Portal.gc.HasFunction("ItemDetail");
  9.     this.tool_Purchase.Enabled = Portal.gc.HasFunction("Purchase");
  10.     this.tool_StockSearch.Enabled = Portal.gc.HasFunction("StockSearch");
  11.     this.tool_TakeOut.Enabled = Portal.gc.HasFunction("TakeOut");
  12.     this.tool_WareHouse.Enabled = Portal.gc.HasFunction("WareHouse");
  13.     //this.menu_run_systemLog.Enabled = Portal.gc.HasFunction("LoginLog");
  14.     this.tool_Settings.Enabled = Portal.gc.HasFunction("Parameters");
  15.     this.tool_MonthlyStatistic.Enabled = Portal.gc.HasFunction("MonthlyStatistic");
  16.     this.tool_AnnualStatistic.Enabled = Portal.gc.HasFunction("AnnualStatistic");
  17.     this.tool_ClearAll.Enabled = Portal.gc.HasFunction("ClearAllData");
  18.     this.tool_ImportItemDetail.Enabled = Portal.gc.HasFunction("ImportItemDetail");
  19. }

這樣封裝好后,我們需要重新登錄就方便了,我們?cè)谥匦碌卿浀牟藛尾僮骼锩妫瑢?shí)現(xiàn)代碼如下所示。

  
 
 
 
  1. private void btnRelogin_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
  2. {
  3.     if (MessageDxUtil.ShowYesNoAndWarning("您確定需要重新登錄嗎?") != DialogResult.Yes)
  4.         return;
  5.     Portal.gc.MainDialog.Hide();
  6.     Login dlg = new Login();
  7.     dlg.StartPosition = FormStartPosition.CenterScreen;
  8.     if (DialogResult.OK == dlg.ShowDialog())
  9.     {
  10.         if (dlg.bLogin)
  11.         {
  12.             CloseAllDocuments();
  13.             InitUserRelated();
  14.         }
  15.     }
  16.     dlg.Dispose();
  17.     Portal.gc.MainDialog.Show();
  18. }

實(shí)現(xiàn)上面的操作過(guò)程,基本上就完成了重新登錄的操作了。

2、系統(tǒng)自動(dòng)登錄實(shí)現(xiàn)

系統(tǒng)自動(dòng)登錄有時(shí)候很必要,在用戶(hù)自己絕對(duì)信任的電腦上,自動(dòng)登錄對(duì)用戶(hù)來(lái)說(shuō),很方便友好的,君不見(jiàn),QQ如此、旺旺如此等等。其實(shí)實(shí)現(xiàn)思路就是通過(guò)給exe執(zhí)行文件傳遞登錄參數(shù)即可,必要時(shí)登錄的參數(shù)值還可以進(jìn)行加密,給第三方進(jìn)行運(yùn)行調(diào)用,以前就做過(guò)一個(gè)在Web上自動(dòng)啟動(dòng)桌面程序Visio應(yīng)用軟件的操作,其實(shí)原理就是一樣,通過(guò)傳遞參數(shù)給執(zhí)行文件實(shí)現(xiàn)的。

  
 
 
 
  1. [STAThread]
  2. static void Main(string[] args)
  3. {
  4.     Application.EnableVisualStyles();
  5.     Application.SetCompatibleTextRenderingDefault(false);
  6.     if (args.Length > 0)
  7.     {
  8.         LoginByArgs(args);
  9.     }
  10.     else
  11.     {
  12.         LoginNormal(args);
  13.     }
  14. }
  
 
 
 
  1. /// 
  2.         /// 使用參數(shù)化登錄
  3.         /// 
  4.         /// 
  5.         private static void LoginByArgs(string[] args)
  6.         {
  7.             CommandArgs commandArgs = CommandLine.Parse(args);
  8.             if (commandArgs.ArgPairs.Count > 0)
  9.             {
  10.                 #region 獲取用戶(hù)參數(shù)
  11.                 string userName = string.Empty;
  12.                 string identity = string.Empty;
  13.                 foreach (KeyValuePair pair in commandArgs.ArgPairs)
  14.                 {
  15.                     if ("U".Equals(pair.Key, StringComparison.OrdinalIgnoreCase))
  16.                     {
  17.                         userName = pair.Value;
  18.                     }
  19.                     if ("P".Equals(pair.Key, StringComparison.OrdinalIgnoreCase))
  20.                     {
  21.                         identity = pair.Value;
  22.                     }
  23.                 } 
  24.                 #endregion
  25.                 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(identity))
  26.                 {
  27.                     bool bLogin = Portal.gc.LoginByIdentity(userName.Trim(), identity);
  28.                     if (bLogin)
  29.                     {
  30.                         ShowMainDialog();
  31.                     }
  32.                     else
  33.                     {
  34.                         LoginNormal(args);
  35.                     }
  36.                 }
  37.             }
  38.         }

有時(shí)候,即使覺(jué)得用戶(hù)不需要通過(guò)命令行登錄,那么我們自己為了避免開(kāi)發(fā)過(guò)程中,啟動(dòng)程序時(shí)候,總是需要輸入用戶(hù)賬號(hào)密碼的問(wèn)題,也可以使用模擬自動(dòng)登錄的方式解決。

我們只需要在項(xiàng)目的屬性里面輸入內(nèi)置的用戶(hù)名密碼,這樣我們測(cè)試起來(lái)就不用登錄那么麻煩了。

以上就是Winform開(kāi)發(fā)框架中對(duì)于系統(tǒng)重新登錄以及系統(tǒng)自動(dòng)登錄(命令行登錄)的思想思路及方式,歡迎大家提供更好的思路及技巧,或者進(jìn)行探討,謝謝支持。


網(wǎng)站題目:Winform開(kāi)發(fā)框架之系統(tǒng)登錄實(shí)現(xiàn)
網(wǎng)頁(yè)地址:http://m.5511xx.com/article/cohigpp.html