コード例 #1
0
        private dynamic GetRefObjectClss(Type t, IReadContext r)
        {
            var     pis = t.GetProperties();
            dynamic nm  = t.Assembly.CreateInstance(t.FullName);

            for (int i = 0; i < pis.Length; i++)
            {
                var    pi      = pis[i];
                string colName = pi.Name;
                switch (pi.PropertyType.FullName)
                {
                case "System.String":
                    pi.SetValue(nm, Read(r, colName), null);
                    break;

                case "System.Int16":
                    pi.SetValue(nm, Convert.ToInt16(Read(r, colName)), null);
                    break;

                case "System.Int32":
                    pi.SetValue(nm, Conv.ToInt(Read(r, colName)), null);
                    break;

                case "System.Int64":
                    pi.SetValue(nm, Convert.ToInt64(Read(r, colName)), null);
                    break;

                case "System.Decimal":
                    pi.SetValue(nm, Conv.ToDecimal(Read(r, colName)), null);
                    break;

                case "System.Double":
                    pi.SetValue(nm, Convert.ToDouble(Read(r, colName)), null);
                    break;

                case "System.Float":
                    pi.SetValue(nm, Convert.ToSingle(Read(r, colName)), null);
                    break;

                //case "System.Guid":
                //    if (row[colName] != DBNull.Value) pi.SetValue(r, (Guid)row[colName], null);
                //    break;
                case "System.DateTime":
                    pi.SetValue(nm, Conv.ToDateTime(Read(r, colName)), null);
                    break;

                case "System.Char":
                    pi.SetValue(nm, Conv.ToChar(Read(r, colName)), null);
                    break;
                    //case "System.Boolean":
                    //    if (row[colName] != DBNull.Value) pi.SetValue(r, (bool)row[colName], null);
                    //    break;
                    //case "System.Byte":
                    //    if (row[colName] != DBNull.Value) pi.SetValue(r, (byte)row[colName], null);
                    //    break;
                }
            }

            return(nm);
        }
コード例 #2
0
        public static void Upadte()
        {
            try
            {
                {
                    //更新中间件
                    IBLL.IUpdate bll = new BLL.UpdateBLL();
                    bll.AutoUpdate();
                }
                {
                    //更新数据库
                    IBLL.ISys bll     = new BLL.Sys();
                    int       ser_ver = Conv.ToInt(bll.Read("ser_ver").Split('_')[1]);
                    int       ver     = Conv.ToInt(Appsetting.versions.Split('_')[1]);
                    if (ser_ver < ver)
                    {
                        //需要更新
                        Type         t     = soft_update.GetType();
                        MethodInfo[] infos = t.GetMethods();
                        foreach (MethodInfo info in infos)
                        {
                            if (info.Name.IndexOf("_") > -1)
                            {
                                int time = Conv.ToInt(info.Name.Split('_')[1]);

                                if (time > ser_ver)
                                {
                                    info.Invoke(soft_update, null);
                                }
                            }
                        }
                    }
                    else if (ser_ver > ver)
                    {
                        //需要更新程序
                        Log.writeLog("中间件版本过低,请更新");
                    }
                }
            }
            catch (Exception ex)
            {
                Log.writeLog("更新失败" + Environment.NewLine + ex.ToString());
            }
        }
コード例 #3
0
        public T GetObject <T>(string key)
        {
            var t   = typeof(T);
            var pis = t.GetProperties();
            T   nm  = (T)Activator.CreateInstance(t);

            for (int i = 0; i < pis.Length; i++)
            {
                var    pi      = pis[i];
                string colName = pi.Name;

                switch (pi.PropertyType.FullName)
                {
                case "System.String":
                    pi.SetValue(nm, Read(key, colName), null);
                    break;

                case "System.Int16":
                    pi.SetValue(nm, Convert.ToInt16(Read(key, colName)), null);
                    break;

                case "System.Int32":
                    pi.SetValue(nm, Conv.ToInt(Read(key, colName)), null);
                    break;

                case "System.Int64":
                    pi.SetValue(nm, Convert.ToInt64(Read(key, colName)), null);
                    break;

                case "System.Decimal":
                    pi.SetValue(nm, Conv.ToDecimal(Read(key, colName)), null);
                    break;

                case "System.Double":
                    pi.SetValue(nm, Convert.ToDouble(Read(key, colName)), null);
                    break;

                case "System.Float":
                    pi.SetValue(nm, Convert.ToSingle(Read(key, colName)), null);
                    break;

                //case "System.Guid":
                //    if (row[colName] != DBNull.Value) pi.SetValue(r, (Guid)row[colName], null);
                //    break;
                case "System.DateTime":
                    pi.SetValue(nm, Conv.ToDateTime(Read(key, colName)), null);
                    break;

                case "System.Char":
                    pi.SetValue(nm, Conv.ToChar(Read(key, colName)), null);
                    break;
                    //case "System.Boolean":
                    //    if (row[colName] != DBNull.Value) pi.SetValue(r, (bool)row[colName], null);
                    //    break;
                    //case "System.Byte":
                    //    if (row[colName] != DBNull.Value) pi.SetValue(r, (byte)row[colName], null);
                    //    break;
                }
            }

            return(nm);
        }