예제 #1
0
 private void initKey()
 {
     try
     {
         /**
          * 获取秘钥
          * 没有秘钥则产生一对秘钥,并用非明文方式保存秘钥
          * */
         String strKey = FileReadWrite.Read();
         if (String.IsNullOrEmpty(strKey))
         {
             Key    = AesCryptoHelper.CreateKeyAndIv();
             strKey = SerializationHelper.Serialization(Key);
             strKey = AesCryptoHelper.Encrypt(strKey, keyEncryptorKey);
             FileReadWrite.Write(strKey);
         }
         else
         {
             strKey = AesCryptoHelper.Decrypt(strKey, keyEncryptorKey);
             Key    = SerializationHelper.Deserialization(strKey);
         }
     }
     catch (Exception ex)
     {
         var entity = LogEntityFactory.Create(String.Format("秘钥初始化失败:{0}", ex.ToString()),
                                              LogTypeFacotry.CreateExceptionLogType(),
                                              LogLevelFactory.CreateGravenessLogLevel());
         log.SaveLog(entity);
         throw new Exception("秘钥初始化失败,秘钥文件被破坏!");
     }
 }
예제 #2
0
        private void lvPlugin_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (lvPlugin.SelectedItems.Count > 0)
            {
                try
                {
                    IPlugin plugin = this.lvPlugin.SelectedItems[0].Tag as IPlugin;
                    plugin.StartUp();
                }
                catch (Exception ex)
                {
                    var entity = LogEntityFactory.Create(String.Format("启动工具失败:{0}", ex.ToString()),
                                                         LogTypeFacotry.CreateExceptionLogType(),
                                                         LogLevelFactory.CreateGravenessLogLevel());
                    log.SaveLog(entity);

                    MessageBox.Show(ex.ToString(), "启动工具失败");
                }
            }
        }