/// <summary>
 /// 保存服务授权文件到本地(Host服务根目录)
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool SaveFunctionAuthorize(FunctionAuthorizeInfo model)
 {
     IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService();
     try
     {
         return seatService.SaveFunctionAuthorize(model);
     }
     catch (Exception ex)
     {
         SeatManageComm.WriteLog.Write("保存授权文件失败:" + ex.Message);
         throw new Exception("保存授权文件失败:" + ex.Message);
     }
     finally
     {
         ICommunicationObject ICommObjectService = seatService as ICommunicationObject;
         try
         {
             if (ICommObjectService.State == CommunicationState.Faulted)
             {
                 ICommObjectService.Abort();
             }
             else
             {
                 ICommObjectService.Close();
             }
         }
         catch
         {
             ICommObjectService.Abort();
         }
     }
 }
 /// <summary>
 /// 加载授权文件并显示授权信息
 /// </summary>
 private void loadAuthorizeInfos()
 {
     if (File.Exists(authorized_keys_filePath))
     {
         authorizes = AuthorizeVerify.FunctionAuthorizeInfo.AnalyzeAuthorize(authorized_keys_filePath);
         DataBinding();
     }
 }
 /// <summary>
 /// 保存服务授权文件到本地(Host服务根目录)
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool SaveFunctionAuthorize(FunctionAuthorizeInfo model)
 {
     IWCFService.ISeatManageService seatService = new WcfServiceForSeatManage.SeatManageDateService();
     try
     {
         return(seatService.SaveFunctionAuthorize(model));
     }
     catch (Exception ex)
     {
         SeatManageComm.WriteLog.Write("保存授权文件失败:" + ex.Message);
         throw new Exception("保存授权文件失败:" + ex.Message);
     }
 }
 private void btn_Save_Click(object sender, EventArgs e)
 {
     if (authorizes == null)
     {
         authorizes = new FunctionAuthorizeInfo();
     }
     if (string.IsNullOrEmpty(txt_SchoolNum.Text))
     {
         MessageBox.Show("学校编号不能为空!");
         return;
     }
     authorizes.SchoolNum      = txt_SchoolNum.Text;
     authorizes.SystemFunction = new List <string>();
     if (cb_Bespeak_AppointTime.Checked)
     {
         authorizes.SystemFunction.Add("Bespeak_AppointTime");
     }
     if (cb_Bespeak_NowDay.Checked)
     {
         authorizes.SystemFunction.Add("Bespeak_NowDay");
     }
     if (cb_Client_SeachBespeak.Checked)
     {
         authorizes.SystemFunction.Add("Client_SeachBespeak");
     }
     if (cb_Client_SeachBlasklist.Checked)
     {
         authorizes.SystemFunction.Add("Client_SeachBlasklist");
     }
     if (cb_Client_SeachViolation.Checked)
     {
         authorizes.SystemFunction.Add("Client_SeachViolation");
     }
     if (cb_Client_ShowLastSeat.Checked)
     {
         authorizes.SystemFunction.Add("Client_ShowLastSeat");
     }
     if (cb_Client_ShowReaderInfo.Checked)
     {
         authorizes.SystemFunction.Add("Client_ShowReaderInfo");
     }
     if (cb_Client_ShowReaderMeg.Checked)
     {
         authorizes.SystemFunction.Add("Client_ShowReaderMeg");
     }
     if (cb_LimitTime_SpanMode.Checked)
     {
         authorizes.SystemFunction.Add("LimitTime_SpanMode");
     }
     if (cb_Media_MediaPlayer.Checked)
     {
         authorizes.SystemFunction.Add("Media_MediaPlayer");
     }
     if (cb_Media_PopAd.Checked)
     {
         authorizes.SystemFunction.Add("Media_PopAd");
     }
     if (cb_Media_SchoolNotice.Checked)
     {
         authorizes.SystemFunction.Add("Media_SchoolNotice");
     }
     if (cb_Media_TitleAd.Checked)
     {
         authorizes.SystemFunction.Add("Media_TitleAd");
     }
     if (cb_MoveClient_AdminManage.Checked)
     {
         authorizes.SystemFunction.Add("MoveClient_AdminManage");
     }
     if (cb_MoveClient_ContinueTime.Checked)
     {
         authorizes.SystemFunction.Add("MoveClient_ContinueTime");
     }
     if (cb_MoveClient_QRcodeDecode.Checked)
     {
         authorizes.SystemFunction.Add("MoveClient_QRcodeDecode");
     }
     if (cb_24HModel.Checked)
     {
         authorizes.SystemFunction.Add("RoomOC_24HModel");
     }
     if (cb_MoveClient_SeatSelect.Checked)
     {
         authorizes.SystemFunction.Add("MoveClient_SeatSelect");
     }
     if (cb_MoveClient_SeatWait.Checked)
     {
         authorizes.SystemFunction.Add("MoveClient_SeatWait");
     }
     if (cb_SendMsg.Checked)
     {
         authorizes.SystemFunction.Add("SendMsg");
     }
     if (DialogResult.OK == MessageBox.Show("确定保存授权信息吗?", "消息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information))
     {
         try
         {
             using (System.IO.StreamWriter file = new System.IO.StreamWriter(authorized_keys_filePath, false, Encoding.ASCII))
             {
                 string strJson    = SeatManage.SeatManageComm.JSONSerializer.Serialize(authorizes);
                 string ciphertext = SeatManage.SeatManageComm.AESAlgorithm.AESEncrypt(strJson);
                 file.WriteLine(ciphertext);
                 file.Flush();
             }
             MessageBox.Show("保存成功");
             System.Diagnostics.Process.Start("Explorer.exe", sPath);
         }
         catch (Exception ex)
         {
             MessageBox.Show("保存失败");
         }
     }
 }