Revit内置了一些命令,直接调用Revit操作方式。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Security.Cryptography;
using System.IO;
namespace Solution.Common
{
    public class CommonHelper
    {
        #region md5加密
        public static string GetMd5(string str)
        {
            MD5 md5 = MD5.Create();
            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(str);
            byte[] md5Buffer = md5.ComputeHash(buffer);
            StringBuilder sb = new StringBuilder();

            foreach (byte b in md5Buffer)
            {
                sb.Append(b.ToString("x2"));
            }
            return sb.ToString();
        }

        #endregion


        #region Des对称加密

        /// <summary>
        /// 加密
        /// </summary>
        /// <param name="strText">待加密的字符串</param>
        /// <param name="strEncrKey">密钥</param>
        /// <returns></returns>
        public static string DesEncrypt(string strText, string strEncrKey)
        {
            try
            {
                byte[] byKey = null;
                byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };

                byKey = Encoding.UTF8.GetBytes(strEncrKey.Substring(0, 8));
                DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                byte[] inputByteArray = Encoding.UTF8.GetBytes(strText);
                MemoryStream ms = new MemoryStream();
                CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);

                cs.Write(inputByteArray, 0, inputByteArray.Length);
                cs.FlushFinalBlock();
                return Convert.ToBase64String(ms.ToArray());
            }
            catch (Exception ex)
            {
                return "";
            }
        }

        /// <summary>
        /// 解密
        /// </summary>
        /// <param name="strText">待解密的字符串</param>
        /// <param name="sDecrKey">密钥</param>
        /// <returns></returns>
        public static string DesDecrypt(string strText, string sDecrKey)
        {
            try
            {
                byte[] byKey = null;
                byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
                byte[] inputByteArray = new Byte[strText.Length];

                byKey = Encoding.UTF8.GetBytes(sDecrKey.Substring(0, 8));
                DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                inputByteArray = Convert.FromBase64String(strText);
                MemoryStream ms = new MemoryStream();
                CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
                cs.Write(inputByteArray, 0, inputByteArray.Length);
                cs.FlushFinalBlock();
                Encoding encoding = new UTF8Encoding();
                return encoding.GetString(ms.ToArray());
            }
            catch
            {
                return null;
            }
        }



        #endregion


        #region base64加密解密 
        //使用场景:url、 二进制图片传输、加密cookie
        //加密
        public static string Base64Encrypt(string str)
        {
            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(str);
            return Convert.ToBase64String(buffer);
        }

        //解密
        public static string Base64Decrypt(string str)
        {
            byte[] decbuffer = Convert.FromBase64String(str);
            return System.Text.Encoding.UTF8.GetString(decbuffer);
        }

        #endregion


    }
}

rails框架默认有三个模式development(开发),production(上线),test(测试)

可以去API文档查询PostableCommand枚举,还是很多的。

 

Development

 config.cache_classes =
false 每次请求都会重新加载,修改代码之后可以直接使用。

 config.consider_all_requests_local =
true 在本地测试的时候可以显示所有的错误。

 config.action_controller.perform_caching =
false 

 config.action_mailer.raise_delivery_errors =
false 如果寄信失败,是否要丢出例外。建议可以改成 true。

 config.active_support.deprecation =
:log 随着 Rails
版本的升级,如果有方法会在之后的版本中移除,deprecation
会提示你如何因应。这里的 :log 表示会记录到 log 档案中。

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注