コード例 #1
0
        /// <summary>
        /// Imports the content of a connections file and adds them to the current collection
        /// </summary>
        public void Import(ImportExportData data)
        {
            try
            {
                string content = null;
                if (data.Encrypt)
                {
                    content = EncDec.Decrypt(data.FileName, true);
                }
                else
                {
                    content = File.ReadAllText(data.FileName);
                }
                SqlConnectionInfosCollection imported = SqlConnectionInfosCollection.Deserialize(content, false);
                if (imported.Count > 0)
                {
                    foreach (SqlConnectionInfo item in imported)
                    {
                        SqlConnections.Add(item);
                    }
                }

                IsChanged = true;
            }
            catch (Exception ex)
            {
                EventLogger.SendMsg(ex);
                throw;
            }
        }
コード例 #2
0
 /// <summary>
 /// Exports the content of the collection in a file selected by the user
 /// </summary>
 public void Export(ImportExportData data)
 {
     try
     {
         if (!data.Encrypt)
         {
             this.SqlConnections.Serialize(data.FileName);
         }
         else
         {
             EncDec.Encrypt(this.mSqlConnections.Serialize(), data.FileName);
         }
     }
     catch (Exception ex)
     {
         EventLogger.SendMsg(ex);
         throw;
     }
 }