Example #1
0
 public string GetJson(int pageindex, int pagesize, string filterJson, string sort = "FID",
                       string order = "asc", string platformid = "")
 {
     _platformid = platformid;
     return(base.JsonDataForEasyUIdataGrid(TableConvention.Resolve(typeof(PlatFormModel)), pageindex, pagesize, filterJson,
                                           sort, order));
 }
Example #2
0
        public static int Insert(string connectionString, Access_sRecords_Model o, string s)
        {
            //SQLiteConnection cn = new SQLiteConnection(connectionString);
            //SQLiteCommand cmd = cn.CreateCommand();
            //cmd.CommandText = commandText;
            //AttachParameters(cmd, commandText, paramList);
            //if (cn.State == ConnectionState.Closed)
            //    cn.Open();
            //int result = cmd.ExecuteNonQuery();
            //cmd.Dispose();
            //cn.Close();



            using (SQLiteConnection cn = new SQLiteConnection(connectionString))
                using (SQLiteCommand cmd = cn.CreateCommand())
                {
                    cmd.CommandType = CommandType.Text;

                    cmd.CommandText = "INSERT  INTO " + TableConvention.Resolve(o) + " (DatabaseName,"
                                      .InjectFrom(new FieldsBy().IgnoreFields("keyid"), o) + ") values(@DatabaseName,"
                                      .InjectFrom(new FieldsBy().IgnoreFields("keyid").SetFormat("@{0}"), o)
                                      + ")";
                    cmd.Parameters.AddWithValue("@DatabaseName", s);

                    cmd.InjectFrom(new SetParamsValues_SQLite().IgnoreFields("keyid"), o);

                    cn.Open();
                    return(Convert.ToInt32(cmd.ExecuteNonQuery()));
                }
        }
Example #3
0
        public static IEnumerable <Access_sRecords_Model> GetWhere(string where)
        {
            using (var conn = new OleDbConnection(connectionString))
            {
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.Text;
                    string xxxx = TableConvention.Resolve(typeof(Access_sRecords_Model));

                    cmd.CommandText = "select * from " + xxxx + " where " + where;


                    //cmd.CommandText = "select * from " + xxxx + " where "
                    //    .InjectFrom(new FieldsBy()
                    //    .SetFormat("{0}=@{0}")
                    //    .SetNullFormat("{0} is null")
                    //    .SetGlue("and"),
                    //    where);
                    //cmd.InjectFrom<SetParamsValues>(where);
                    conn.Open();

                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            var o = new Access_sRecords_Model();
                            o.InjectFrom <ReaderInjection>(dr);
                            yield return(o);
                        }
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// 添加更新操作日志
        /// </summary>
        /// <param name="oldObj">旧实体对象</param>
        /// <param name="newObj">新实体对象</param>
        /// <returns></returns>
        public int UpdateLog(T oldObj, T newObj)
        {
            return(1);

            Type objTye = typeof(T);

            PropertyInfo property = objTye.GetProperty("FID");

            LogModel log = new LogModel();

            log.BusinessName  = GetBusingessName();
            log.OperationIp   = PublicMethod.GetClientIP();
            log.OperationTime = DateTime.Now;
            log.OperationType = (int)OperationType.Update;
            log.PrimaryKey    = property.GetValue(newObj, null).ToString();
            log.TableName     = TableConvention.Resolve(newObj);
            log.UserId        = SysVisitor.Instance.UserId;
            log.SqlText       = "";


            //添加日志详细信息
            StringBuilder sb = new StringBuilder();

            var sqlTemp =
                "insert into Sys_LogDetails (FID, logid,fieldName,fieldtext,oldvalue,newvalue,remark) values('{0}','{1}','{2}','{3}','{4}','{5}','')";

            string logId = LogDal.Instance.Insert(log);

            if (logId != "")
            {
                var propertyList = objTye.GetInfos();
                foreach (PropertyInfo p in propertyList)
                {
                    object oldVal = p.GetValue(oldObj, null);
                    object newVal = p.GetValue(newObj, null);

                    if (!string.Equals(p.Name, "FID", StringComparison.CurrentCultureIgnoreCase) &&
                        p.GetCustomAttributes(true).OfType <DbFieldAttribute>().Count(dbFieldAttribute => !dbFieldAttribute.IsDbField) == 0 &&
                        !ignoredFields.Contains(p.Name, StringComparer.InvariantCultureIgnoreCase))
                    {
                        if (!IsEqual(p.PropertyType, oldVal, newVal))
                        {
                            sb.AppendFormat(sqlTemp, Guid.NewGuid().ToString(), logId, p.Name, GetFieldText(p), oldVal, newVal, "");
                            sb.AppendLine();
                        }
                    }
                }

                if (sb.Length > 0)
                {
                    return(DbUtils.ExecuteNonQuery(sb.ToString(), null));
                }
                return(LogDal.Instance.Delete(logId));
            }
            return(0);
        }
Example #5
0
 public string GetJson(int pageindex, int pagesize, string userid, string sort = "FID",
                       string order = "asc")
 {
     string where = "1=1";
     if (!string.IsNullOrEmpty(userid))
     {
         where += string.Format(" and FUSERID='{0}'", userid);
     }
     return(base.JsonDataForEasyUIdataGrid(where, TableConvention.Resolve(typeof(TB_USERBRANDModel)), pageindex, pagesize, "",
                                           sort, order));
 }
Example #6
0
        /// <summary>
        /// 添加操作日志
        /// </summary>
        /// <param name="t">实体类</param>
        /// <returns></returns>
        public int AddLog(T t, string busingessName = "")
        {
            return(0);

            Type         objTye   = typeof(T);
            PropertyInfo property = objTye.GetProperty("FID");

            LogModel log = new LogModel();

            log.BusinessName  = busingessName ?? GetBusingessName();
            log.OperationIp   = PublicMethod.GetClientIP();
            log.OperationTime = DateTime.Now;
            log.OperationType = (int)OperationType.Add;
            if (property != null)
            {
                log.PrimaryKey = property.GetValue(t, null).ToString();
            }
            log.TableName = TableConvention.Resolve(t);
            log.UserId    = SysVisitor.Instance.UserId;
            log.SqlText   = "";


            string logId = LogDal.Instance.Insert(log);

            if (logId != "")
            {
                //添加日志详细信息
                StringBuilder sb = new StringBuilder();

                var sqlTemp =
                    "insert into Sys_LogDetails (fid, logid,fieldName,fieldtext,oldvalue,newvalue,remark) values('{0}','{1}','{2}','{3}','{4}','{5}','');";
                foreach (PropertyInfo pi in objTye.GetProperties())
                {
                    if (!string.Equals(pi.Name, "FID", StringComparison.CurrentCultureIgnoreCase) &&
                        pi.GetCustomAttributes(true).OfType <DbFieldAttribute>().Count(dbFieldAttribute => !dbFieldAttribute.IsDbField) == 0 &&
                        !ignoredFields.Contains(pi.Name, StringComparer.InvariantCultureIgnoreCase))
                    {
                        sb.AppendFormat(sqlTemp, Guid.NewGuid().ToString(), logId, pi.Name, GetFieldText(pi), "", pi.GetValue(t, null));
                        sb.AppendLine();
                    }
                }

                if (sb.Length > 0)
                {
                    return(DbUtils.ExecuteNonQuery(sb.ToString(), null));
                }
            }
            return(0);
        }
        public int CountIsUseByPOLICYID(string POLICYID)
        {
            string sql = string.Format(@"SELECT (
		                        SELECT COUNT(*)
		                        FROM ICPRPOLICY
		                        WHERE ICPRPOLICY.FPOLICYID IN (SELECT FID
			                        FROM {1}
			                        WHERE {1}.FPOLICYID = '{0}' )
		                        ) + (
		                        SELECT COUNT(*)
		                        FROM ICPOPOLICY
		                        WHERE ICPOPOLICY.FPOLICYID IN (SELECT FID
			                        FROM ICPricePolicyEntry
			                        WHERE ICPricePolicyEntry.FPOLICYID = '{0}' )
		                        )
                        FROM dual", POLICYID, TableConvention.Resolve(typeof(ICPRICEPOLICYENTRYMODEL)));

            return(DbUtils.CountBySQL(sql));
        }
Example #8
0
        internal static IEnumerable <Sqlite_sRecords_Model> GetWhere(string connectionString, string commandText = "")
        {
            using (SQLiteConnection cn = new SQLiteConnection(connectionString))
            {
                using (SQLiteCommand cmd = new SQLiteCommand(commandText, cn))
                {
                    cmd.CommandType = CommandType.Text;
                    string xxxx = TableConvention.Resolve(typeof(Sqlite_sRecords_Model));
                    if (commandText == "")
                    {
                        cmd.CommandText = "select * from " + xxxx + " where State = 'N' ";
                    }
                    else
                    {
                        cmd.CommandText = "select * from " + xxxx + " where State = 'N' AND  DatabaseName = '" + commandText + "'";
                    }


                    //cmd.CommandText = "select * from " + xxxx + " where "
                    //    .InjectFrom(new FieldsBy()
                    //    .SetFormat("{0}=@{0}")
                    //    .SetNullFormat("{0} is null")
                    //    .SetGlue("and"),
                    //    where);
                    //cmd.InjectFrom<SetParamsValues>(where);
                    cn.Open();

                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            var o = new Sqlite_sRecords_Model();
                            o.InjectFrom <ReaderInjection>(dr);
                            yield return(o);
                        }
                    }
                }
            }
        }
Example #9
0
 public string GetJson(int pageindex, int pagesize, string filterJson, string sort = "keyid",
                       string order = "asc")
 {
     return(base.JsonDataForEasyUIdataGrid(TableConvention.Resolve(typeof(DemoArticleModel)), pageindex, pagesize, filterJson,
                                           sort, order));
 }
 public string GetJson(int pageindex, int pagesize, string filterJson, string sort = "FID",
                       string order = "asc")
 {
     return(base.JsonDataForEasyUIdataGrid(TableConvention.Resolve(typeof(TB_REVIEWTEAMModel)), pageindex, pagesize, filterJson,
                                           sort, order));
 }
Example #11
0
 public string GetJson(int pageindex, int pagesize, string filterJson, string sort = "FID",
                       string order = "asc")
 {
     return(JsonDataForEasyUIdataGrid(TableConvention.Resolve(typeof(ICSTOCKBILLMODEL)), pageindex, pagesize, filterJson,
                                      sort, order));
 }
 public string GetJson(string where, int pageindex, int pagesize, string filterJson, string sort = "FID",
                       string order = "asc")
 {
     return(base.JsonDataForEasyUIdataGrid(where, TableConvention.Resolve(typeof(V_CLIENTACCOUNTModel)), pageindex, pagesize, filterJson,
                                           sort, order));
 }