Ejemplo n.º 1
0
 public BaseSQLMaker(IHashObject qryParams, string sql)
 {
     conStr = "";
     originSQL = sql;
     this.sqlFilePath = "";
     ini(null, qryParams);
 }
Ejemplo n.º 2
0
 public void DoSave(object[] data)
 {
     using (DbHelper db = AppUtils.CreateDbHelper())
     {
         try
         {
             db.BeginTransaction();
             Test001.Login.User user = ((Test001.Login.User)Session["user"]);
             db.AddParameter("userid", user.Id);
             db.ExecuteScalerSQL("delete from btypeconfig where userid=@userid");
             for (int i = 0; i < data.Length; i++)
             {
                 IHashObject item = (IHashObject)data[i];
                 db.AddParameter("size", item["size"]);
                 db.AddParameter("color", item["color"]);
                 db.AddParameter("price", item["price"]);
                 db.AddParameter("userid", user.Id);
                 db.ExecuteIntSQL("insert into btypeconfig values(@size, @color, @price, @userid)");
             }
             db.CommitTransaction();
         }
         catch (Exception e)
         {
             if (db.HasBegunTransaction)
             {
                 db.RollbackTransaction();
             }
             throw e;
         }
     }
 }
Ejemplo n.º 3
0
 public void Save(IHashObject data)
 {
     using (DbHelper db = AppUtils.CreateDbHelper())
     {
         IHashObject section = db.SelectFirstRow(string.Format("select id, paytotal from backsection where month='{0}-1'", data["tmonth"]));
         if (section == null)
         {
             throw new Exception(string.Format("{0}月不存在回款金额", data["tmonth"]));
         }
         data["datetime"] = DateTime.Now;
         data["id"]       = Cuid.NewCuid();
         data["uid"]      = ((Login.User)Session["user"]).Id;
         data.Remove("tmonth");
         section["paytotal"] = section.GetValue <decimal>("paytotal") + data.GetValue <decimal>("total");
         try
         {
             db.BeginTransaction();
             db.Insert("backsectionDetail", data);
             db.Update("backsection", "id", section);//更新金额
             db.CommitTransaction();
         }
         catch (Exception e)
         {
             if (db.HasBegunTransaction)
             {
                 db.RollbackTransaction();
             }
         }
     }
 }
Ejemplo n.º 4
0
        public string UserLogin(int width, int height, string name, string pwd)
        {
            Session[Settings.ClientWidthContextName]  = width;
            Session[Settings.ClientHeightContextName] = height;
            using (DbHelper db = AppUtils.CreateDbHelper())
            {
                db.AddParameter("name", name);
                try
                {
                    IHashObject list = db.SelectSingleRow("select id,password,passwordsalt, power from user where name=@name");

                    if (Utils.ValidatePasswordHashed(list.GetValue <string>("password"), list.GetValue <string>("passwordsalt"), pwd))
                    {
                        User user = new User()
                        {
                            Name = name, Id = list.GetValue <int>("id"), Power = list.GetValue <int>("power")
                        };
                        Session["user"] = user;
                    }
                    else
                    {
                        throw new Exception("用户名或密码错误,请重试");
                    }
                }
                catch (Exception e)
                {
                    throw new Exception("用户名或密码错误,请重试");
                }
            }
            return("");
        }
Ejemplo n.º 5
0
 public PageDataStrMaker(IHashObject qryParams, SQLHelper helper, string conString, int pageIndex, int pageCount, string sort)
     : base(qryParams, helper, conString)
 {
     this.index = pageIndex;
     this.count = pageCount;
     this.sortInfo = sort;
 }
Ejemplo n.º 6
0
        public override void Initialize()
        {
            base.Initialize();
            Login.User user = (Login.User)Session["user"];
            Context["grid"] = new list(new Login.User()
            {
                Id = user.Id, Power = user.Power, Name = user.Name
            });
            DateTime time = DateTime.Now;

            Context["startDate"]   = new DateTime(time.Year, time.Month, 1);
            Context["backSection"] = user.Power == 99;
            using (DbHelper db = AppUtils.CreateDbHelper())
            {
                IHashObject data = db.SelectFirstRow("select sum(total) as total, sum(paytotal) as paytotal, max(month) as month from backsection");
                if (data == null)
                {
                    data = new HashObject();
                }
                Context["total"]      = data.GetValue <decimal>("total");
                Context["paytotal"]   = data.GetValue <decimal>("paytotal");
                Context["nopaytotal"] = data.GetValue <decimal>("total") - data.GetValue <decimal>("paytotal");
                Context["month"]      = data.GetValue <DateTime>("month").ToString("yyyy-MM");
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///  List集合参数运算符 Or
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="ListSource">集合来源处理的数据</param>
        /// <returns></returns>
        public List <T> GetListByOrParam(IHashObject parameter, List <T> ListSource)
        {
            List <T>     reList   = new List <T>();
            List <T>     tempList = ListSource;
            bool         IsAdd    = false;
            Type         type     = null;
            PropertyInfo property = null;

            if (parameter != null && parameter.Count > 0)
            {
                foreach (T item in tempList)
                {
                    IsAdd = false;
                    type  = item.GetType();
                    foreach (KeyValuePair <string, object> data in parameter)
                    {
                        property = type.GetProperty(data.Key);
                        if (property != null && property.GetValue(item, null) != null && property.GetValue(item, null).ToString().Trim().Equals(data.Value.ToString().Trim()))
                        {
                            IsAdd = true;
                            break;
                        }
                    }
                    if (IsAdd)
                    {
                        reList.Add(item);
                    }
                }
            }
            else
            {
                reList = tempList;
            }
            return(reList);
        }
Ejemplo n.º 8
0
 public void DoSave(IHashObject data)
 {
     using (DbHelper db = AppUtils.CreateDbHelper())
     {
         try
         {
             int id = Guid.NewGuid().GetHashCode();
             db.BeginTransaction();
             object[] list = data.GetValue <object[]>("grid");
             for (int i = 0; i < list.Length; i++)
             {
                 IHashObject item = (IHashObject)list[i];
                 item["id"]  = Guid.NewGuid().GetHashCode();
                 item["bid"] = id;
                 db.Insert("billdetail", item);
             }
             data.Remove("grid");
             data["id"] = id;
             db.Insert("bill", data);
             db.CommitTransaction();
         }
         catch (Exception e)
         {
             if (db.HasBegunTransaction)
             {
                 db.RollbackTransaction();
             }
             throw e;
         }
     }
 }
Ejemplo n.º 9
0
        public override void Initialize()
        {
            base.Initialize();
            string id = Request.QueryString["id"];

            if (string.IsNullOrEmpty(id))
            {
                Context["data"] = null;
                return;
            }
            using (DbHelper db = AppUtils.CreateDbHelper())
            {
                db.AddParameter("pid", id);
                IHashObject data  = db.SelectSingleRow("select picon,pid as id,pname,pversion,pkind,plabel,pshowway,pwindowname,pdes,ppics,pid,pdownpath,pvideo from plugs where pid=@pid");
                string      ppics = data.GetValue <string>("ppics");
                string[]    array = ppics.Split(',');
                data["ppic1"] = array.Length > 0 ? array[0] : "";
                data["ppic2"] = array.Length > 1 ? array[1] : "";
                data["ppic3"] = array.Length > 2 ? array[2] : "";
                string[] labels = data.GetValue <string>("plabel", ",,").Split(',');
                data["plabel1"] = labels.Length > 0 ? labels[0] : "";
                data["plabel2"] = labels.Length > 1 ? labels[1] : "";
                data["plabel3"] = labels.Length > 2 ? labels[2] : "";

                Context["data"] = data;
            }
        }
Ejemplo n.º 10
0
 public static void addHashObject(IHashObject obj, string key, object value)
 {
     if (obj.Keys.Contains(key))
         obj[key] = value;
     else
         obj.Add(key, value);
 }
Ejemplo n.º 11
0
 public static string getHashObject(IHashObject obj, string key, string sDefault="")
 {
     if (obj.ContainsKey(key))
         return obj[key].ToString();
     else
         return sDefault;
 }
Ejemplo n.º 12
0
 public async Task <int> ExecuteNonQueryAsync(string sql, IHashObject param)
 {
     using (var cmd = GetCommand(sql, true, param))
     {
         return(await cmd.ExecuteNonQueryAsync());
     }
 }
Ejemplo n.º 13
0
        public object GetDownData(string token)
        {
            //UserInfo info = (UserInfo)Session["user"];
            JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();

            using (DbHelper db = AppUtils.CreateDbHelper())
            {
                string sql = "select `condition`, user from downtoken where  `token`=@token";
                db.AddParameter("token", token);
                IHashObject data = db.SelectSingleRow(sql);//只用一次
                db.AddParameter("token", token);
                db.AddParameter("ntoken", Guid.NewGuid());
                db.ExecuteIntSQL("update downtoken set `token`=@ntoken where token=@token");
                string user = data.GetValue <string>("user");
                //if (!info.User.Equals(user))
                //{
                //    throw new Exception("非法请求");
                //}
                HashObject condition = serializer.Deserialize <HashObject>(data.GetValue <string>("condition"));

                string     dataSql = WebMain.BillList.list.GetBillSql(db, user, (SearchArea)Enum.Parse(typeof(SearchArea), condition.GetValue <string>("area")));
                HashObject rt      = new HashObject();
                rt.Add("data", db.Select(dataSql));
                rt.Add("captions", new string[] { "订单日期", "姓名", "联系电话", "淘宝账号", "联系地址", "发货信息", "订单状态", "订单回款" });
                rt.Add("fields", new string[] { "date", "cname", "ctel", "taobaocode", "caddress", "sender", "process", "ltotal" });
                return(rt);
            }
        }
Ejemplo n.º 14
0
 public void Save(IHashObject data)
 {
     using (DbHelper db = AppUtils.CreateDbHelper())
     {
         data["id"]   = Guid.NewGuid().GetHashCode();
         data["date"] = DateTime.Now;
         db.Insert("affiliatedbill", data);
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="ProcedureName">存储过程名称</param>
        /// <param name="outputParam">输入参数</param>
        /// <param name="InputParam">输出参数</param>
        /// <returns></returns>
        public DataTable ExecProcedure(string ProcedureName, IHashObject InputParam, IHashObject outputParam)
        {
            DataTable dt = null;

            using (DbHelper db = new DbHelper(DbControl.GetDbConnStringBasic(DbHandleBehaviorDefine.SELECT, 0)))
            {
                dt = db.ExecuteProcedureAndOutputParameter(ProcedureName, out outputParam, InputParam);
            }
            return(dt);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 执行存储过程 操作 返回受影响的函数
        /// </summary>
        /// <param name="ProcedureName">存储过程名称</param>
        /// <param name="outputParam">输入参数</param>
        /// <returns></returns>
        public int ExecuteNonQueryProcedure(string ProcedureName, IHashObject InputParam)
        {
            int result = -1;

            using (DbHelper db = new DbHelper(DbControl.GetDbConnStringBasic(DbHandleBehaviorDefine.UPDATE, 0)))
            {
                result = db.ExecuteNonQueryProcedure(ProcedureName, InputParam);
            }
            return(result);
        }
Ejemplo n.º 17
0
 public static BSqlMaker getMaker(string conString, string filePath, string classPath, IHashObject queryParams)
 {
     DbHelper db = new DbHelper(conString, true);
     Assembly assembly = Assembly.Load("BSQLMaker");
     object[] param = { db, queryParams, conString, filePath };
     Type itype = assembly.GetType(classPath);
     object obj = Activator.CreateInstance(itype, param);
     BSqlMaker maker = (BSqlMaker)obj;
     maker.SQLFilePath = filePath;
     return maker;
 }
Ejemplo n.º 18
0
        public static string getValueIgnoreCase(IHashObject obj, string key, string sDefault = "")
        {
            if (obj.ContainsKey(key))
                return obj[key].ToString();

            foreach (KeyValuePair<string, object> pair in obj)
            {
                if (pair.Key.ToUpper() == key.ToUpper())
                    return pair.Value.ToString();
            }
            return sDefault;
        }
Ejemplo n.º 19
0
        public virtual async Task <IHashObject> SingRowAsync(string sql, IHashObject parms)
        {
            var cmd = GetCommand(sql, false, parms);

            using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.SingleRow))
            {
                if (await reader.ReadAsync())
                {
                    return(ReaderTohashObj(reader));
                }
                return(null);
            }
        }
Ejemplo n.º 20
0
        public virtual async Task <IHashObjectList> ListAsync(string sql, IHashObject parms)
        {
            IHashObjectList list = new HashObjectList();
            var             cmd  = GetCommand(sql, false, parms);

            using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.SingleRow))
            {
                while (await reader.ReadAsync())
                {
                    list.Add(ReaderTohashObj(reader));
                }
            }
            return(list);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 开户添加数据
        /// </summary>
        /// <param name="parameter">参数</param>
        /// <param name="parameter">执行类型</param>
        public int uporinAccount(IHashObject parameter, int type)
        {
            int result = 0;

            using (DbHelper db = new DbHelper(DbControl.GetDbConnStringBasic(DbHandleBehaviorDefine.WRITE, 0)))
            {
                try
                {
                    db.BeginTransaction();
                    if (type == 0)
                    {
                        db.ExecuteNonQuerySQL(parameter["User_Company"].ToString());
                        db.ExecuteNonQuerySQL(parameter["User_Employees"].ToString());
                        db.ExecuteNonQuerySQL(parameter["User_Permissions"].ToString());
                    }
                    if (type == 1)
                    {
                        db.ExecuteNonQuerySQL(parameter["User_Company"].ToString());
                        db.ExecuteNonQuerySQL(parameter["User_Employees"].ToString());
                        db.ExecuteNonQuerySQL(parameter["User_Permissions"].ToString());
                        db.ExecuteNonQuerySQL(parameter["Bd_Base_Parameters"].ToString());
                    }
                    //db.ExecuteNonQuerySQL(parameter["Bd_Base_Parameters"].ToString());
                    db.CommitTransaction();
                    //if (type == 0)
                    //{
                    //    bool acbUser1 = new ControlBase.BaseData<User_Company>().RefreshCache();
                    //    bool acbUser2 = new ControlBase.BaseData<User_Employees>().RefreshCache();
                    //    bool acbUser3 = new ControlBase.BaseData<User_Permissions>().RefreshCache();
                    //}
                    //if (type == 1)
                    //{
                    //    bool acbUser1 = new ControlBase.BaseData<User_Company>().RefreshCache();
                    //    bool acbUser2 = new ControlBase.BaseData<User_Employees>().RefreshCache();
                    //    bool acbUser3 = new ControlBase.BaseData<User_Permissions>().RefreshCache();
                    //    bool acbUser4 = new ControlBase.BaseData<Bd_Base_Parameters>().RefreshCache();
                    //}



                    result = 1;
                }
                catch (Exception)
                {
                    db.RollbackTransaction();
                }
            }
            return(result);
        }
Ejemplo n.º 22
0
        //public static int UpdateById(IHashObject parameter)
        //{
        //    using (DbHelper db = new DbHelper(DbControl.GetDbConnStringBasic(DbHandleBehaviorDefine.UPDATE, 0)))
        //    {
        //        int count = db.Update("Log_Error", "id", parameter);
        //        return count;
        //    }
        //}

        //public int DeleteById(long id)
        //{
        //    using (DbHelper db = new DbHelper(DbControl.GetDbConnStringBasic(DbHandleBehaviorDefine.DELETE, 0)))
        //    {
        //        int count = db.Delete("Log_Error", "id", id);
        //        return count;
        //    }
        //}
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static int Insert(IHashObject parameter)
        {
            using (DbHelper db = new DbHelper(DbControl.GetDbConnStringBasic(DbHandleBehaviorDefine.WRITE, 0)))
            {
                int count = db.Insert("Log_Error", parameter);
                if (count > 0)
                {
                    return(count);
                }
                else
                {
                    return(0);
                }
            }
        }
Ejemplo n.º 23
0
 protected override void innerIni(DbHelper dbHelper, IHashObject qryParams)
 {
     try
     {
         if (qryParams == null)
         {
             setTestParams();
         }
         setInnerParams();
         registFuncMakers();
     } catch (Exception e)
     {
         throw new Exception("BSqlMaker->innerIni: " + e.Message);
     }
 }
Ejemplo n.º 24
0
 /**
  * 从baseSql抽取系统参数及用户参数
  * 用户参数:{ParamName}
  * 系统参数:{-ParamName-}
  **/
 public void getAllParams(string baseSql, out List<string> userParams, out List<string> sysParams, out IHashObject defaultValue)
 {
     userParams = new List<string>();
     sysParams = new List<string>();
     defaultValue = new HashObject();
     string s = baseSql;
     string[] ss = s.Split('}');
     string[] arry = new string[ss.Length - 1];
     string param = "", value = "";
     int index = -1;
     for (int i = 0; i < ss.Length - 1; i++)
     {
         if (ss[i].IndexOf("{-") > 0)
         {
             arry[i] = ss[i].Substring(ss[i].IndexOf("{-") + 2, ss[i].Length - ss[i].IndexOf("{-")-3);
             param = arry[i];
             index = arry[i].IndexOf("=");
             if (index >= 0)
             {
                 value = param.Substring(index+1);
                 param = param.Substring(0, index);
                 defaultValue.Add(param, value);
             }
             else
             {
                 if (!sysParams.Contains(param))
                     sysParams.Add(arry[i]);
             }
         }
         else
         {
             arry[i] = ss[i].Substring(ss[i].IndexOf("{") + 1, ss[i].Length - ss[i].IndexOf("{")-1);
             param = arry[i];
             index = arry[i].IndexOf("=");
             if (index >= 0)
             {
                 value = param.Substring(index+1);
                 param = param.Substring(0, index);
                 defaultValue.Add(param, value);
             }
             else
             {
                 if (!userParams.Contains(param))
                     userParams.Add(arry[i]);
             }
         }
     }
 }
Ejemplo n.º 25
0
        private static List <string> DeleteOldData(Plug plug, DbHelper db, HashObject hash)
        {
            List <string> rtlist = new List <string>();

            if (plug.PId == 0)
            {
                plug.PId = Cuid.NewCuid();
                return(rtlist);
            }
            db.AddParameter("pid", plug.PId);
            IHashObject item = db.SelectSingleRow("select pdownpath,pvideo,picon,ppics,pcreatedate,ptotal from plugs where pid=@pid");

            foreach (string key in item.Keys)
            {
                string path = item.GetValue <string>(key);
                if (string.IsNullOrEmpty(path))
                {
                    continue;
                }
                if (key == "ppics")
                {
                    foreach (string item1 in path.Split(','))
                    {
                        if (string.IsNullOrEmpty(item1) || item1.StartsWith(saveFileFolder))
                        {
                            continue;
                        }
                        rtlist.Add(string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, item1));
                    }
                }
                else
                {
                    if (hash.GetValue <string>(key) == item.GetValue <string>(key))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(hash.GetValue <string>(key)))
                    {
                        hash[key] = item[key];
                    }
                    rtlist.Add(string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, item[key]));
                }
            }
            hash["pcreatedate"] = item["pcreatedate"];
            hash["ptotal"]      = item["ptotal"];
            db.Delete("plugs", "pid", plug.PId);
            return(rtlist);
        }
Ejemplo n.º 26
0
        public void Save(IHashObject data)
        {
            using (DbHelper db = AppUtils.CreateDbHelper())
            {
                data["datetime"] = DateTime.Now;
                data["id"]       = Cuid.NewCuid();
                data["uid"]      = ((Login.User)Session["user"]).Id;

                IHashObject section = db.SelectFirstRow(string.Format("select id from backsectionDetail where month='{0}'", data["month"]));
                if (section != null)
                {
                    throw new Exception(string.Format("{0}月已设置回款金额,如需继续,请联系管理员", data["month"]));
                }
                db.Insert("backsection", data);
            }
        }
Ejemplo n.º 27
0
        private IHashObject GetBill(IHashObject data, int id)
        {
            IHashObject item = new HashObject();

            item["id"]           = id;
            item["date"]         = data["date"];
            item["taobaocode"]   = data["taobaocode"];
            item["cname"]        = data["cname"];
            item["ctel"]         = data["ctel"];
            item["caddress"]     = data["caddress"];
            item["carea"]        = data["carea"];
            item["csendway"]     = data["csendway"];
            item["cremark"]      = data["cremark"];
            item["btotal"]       = data["btotal"];
            item["ltotal"]       = data["ltotal"];
            item["preferential"] = data["preferential"];
            return(item);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 对指定参数进行更新
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public bool Update(IHashObject parameter)
        {
            bool result = false;

            using (DbHelper db = new DbHelper(DbControl.GetDbConnStringBasic(DbHandleBehaviorDefine.UPDATE, 0)))
            {
                int count = db.Update(typeof(T).Name, this.m_PrimaryFiledKey, parameter);
                if (count > 0)
                {
                    /*
                     *  //更新缓存
                     *  string id = parameter.GetValue<object>(this.m_PrimaryFiledKey).ToString();
                     *  T m_model = GetNotCacheById(id);
                     *  IMemcacheAgent cachePool = MemcacheControl.GetBasicMemcachePool(0);
                     *  List<T> list = new List<T>();
                     *  T[] modelArray = cachePool.GetValFromCache<T[]>(m_CachePix + typeof(T).Name.ToLower(), 0);
                     *  if (m_model != null)
                     *  {
                     *      if (modelArray != null && modelArray.Length > 0)
                     *      {
                     *          list = modelArray.ToList<T>();
                     *          for (int i = 0; i < list.Count; i++)
                     *          {
                     *              if (list[i].GetType().GetProperty(this.m_PrimaryFiledKey).GetValue(list[i], null).ToString().Trim() == id.Trim())
                     *              {
                     *                  //移除
                     *                  list.Remove(list[i]);
                     *                  break;
                     *              }
                     *          }
                     *      }
                     *      //添加
                     *      list.Add(m_model);
                     *      result = cachePool.SetValToCache<T[]>(m_CachePix + typeof(T).Name.ToLower(), 0, list.ToArray());
                     *  }
                     *  //刷新缓存
                     *  //result = RefreshCache();
                     * */
                    result = true;
                }
                return(result);
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        ///  添加数据库 并且添加到缓存
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Insert(T model)
        {
            IHashObject  parameter = ModelToHashObject(model);
            bool         InsertSuc = Insert(parameter);
            string       id        = parameter.GetValue <string>(this.m_PrimaryFiledKey);
            PropertyInfo PI        = model.GetType().GetProperty(this.m_PrimaryFiledKey);
            object       obj       = null;

            if (PI.PropertyType.FullName == "System.Guid")
            {
                obj = Guid.Parse(id);
            }
            else
            {
                obj = Convert.ChangeType(id, PI.PropertyType);
            }
            PI.SetValue(model, obj, null);
            return(InsertSuc);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 调用某个泛型指定方法名的方法
        /// </summary>
        /// <param name="tableName">泛型中T即表名也是Model中的类型名</param>
        /// <param name="MothedName">BaseData中的方法名</param>
        /// <param name="Params">输出参数 从里面返回数据 指定参数类型 key为参数索引从1开始 value为引用类型 out ref</param>
        /// <param name="Params">调用方法的参数</param>
        /// <returns></returns>
        public object CallMethod(string tableName, string MethodName, IHashObject OutParams, params object[] InputParams)
        {
            object reObj = null;
            //构造泛型类
            Type            Type_tableName = baseType.MakeGenericType(Type.GetType("PbProject.Model." + tableName + ",Model"));
            ConstructorInfo Contruct       = Type_tableName.GetConstructor(new Type[0]);
            //实例化
            object instance = Contruct.Invoke(new object[] { });

            if (InputParams.Length > 0)
            {
                List <Type> lstType = new List <Type>();
                Type        t       = null;
                for (int i = 0; i < InputParams.Length; i++)
                {
                    t = InputParams[i].GetType();
                    if (OutParams != null && OutParams.Keys.Count > 0 && OutParams.Keys.Contains((i + 1).ToString()))
                    {
                        lstType.Add(t.MakeByRefType());
                    }
                    else
                    {
                        lstType.Add(t);
                    }
                }
                //调用方法
                reObj = Type_tableName.GetMethod(MethodName, lstType.ToArray()).Invoke(instance, InputParams);

                for (int i = 0; i < InputParams.Length; i++)
                {
                    if (OutParams != null && OutParams.Keys.Count > 0 && OutParams.Keys.Contains((i + 1).ToString()))
                    {
                        OutParams[(i + 1).ToString()] = InputParams[i];
                    }
                }
            }
            else
            {
                reObj = Type_tableName.GetMethod(MethodName).Invoke(instance, InputParams);
            }
            return(reObj);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// 添加数据库 并且添加到缓存
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public bool Insert(IHashObject parameter)
        {
            bool result = false;
            int  count  = 0;

            using (DbHelper db = new DbHelper(DbControl.GetDbConnStringBasic(DbHandleBehaviorDefine.WRITE, 0)))
            {
                parameter[this.m_PrimaryFiledKey] = Guid.NewGuid().ToString();
                try
                {
                    count = db.Insert(typeof(T).Name, parameter);
                }
                catch (Exception)
                {
                }
                if (count > 0)
                {
                    result = true;

                    /*
                     *  string id = parameter.GetValue<string>(this.m_PrimaryFiledKey);
                     *  T m_model = GetNotCacheById(id);
                     *  //添加成功 添加到缓存中
                     *  IMemcacheAgent cachePool = MemcacheControl.GetBasicMemcachePool(0);
                     *  if (m_model != null)
                     *  {
                     *      List<T> list = new List<T>();
                     *      T[] modelArray = cachePool.GetValFromCache<T[]>(m_CachePix + typeof(T).Name.ToLower(), 0);
                     *      if (modelArray != null && modelArray.Length > 0)
                     *      {
                     *          list.AddRange(modelArray);
                     *      }
                     *      list.Add(m_model);
                     *      result = cachePool.SetValToCache<T[]>(m_CachePix + typeof(T).Name.ToLower(), 0, list.ToArray());
                     *  }
                     *  //刷新缓存
                     *  //result = RefreshCache();
                     * */
                }
            }
            return(result);
        }
Ejemplo n.º 32
0
        private bool GetDetails(string logistics)
        {
            string         url        = string.Format("http://www.kuaidi100.com/query?type={2}&postid={0}&id=1&valicode=&temp={1}", Request.QueryString["code"], Request.QueryString["r"], logistics);
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);

            webRequest.Method    = "get";
            webRequest.Accept    = "text/html, application/xhtml+xml, */*";
            webRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/7.0)";
            WebResponse response = webRequest.GetResponse();

            using (Stream stream = response.GetResponseStream())
            {
                string sHtml = new StreamReader(stream, System.Text.Encoding.UTF8).ReadToEnd();
                JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();
                IHashObject          list       = serializer.Deserialize <IHashObject>(sHtml);
                //对写入数据的RequestStream对象进行异步请求
                Context["grid"] = list.GetValue <object[]>("data");
                return(sHtml.IndexOf("参数异常") < 0);
            }
        }
Ejemplo n.º 33
0
        private IHashObject GetDetail(IHashObject data, int id)
        {
            IHashObject detail = new HashObject();

            detail["id"]           = Guid.NewGuid().GetHashCode();
            detail["bid"]          = id;
            detail["size"]         = data["size"];
            detail["code"]         = data["code"];
            detail["area"]         = data["carea"];
            detail["address"]      = data["caddress"];
            detail["color"]        = data["color"];
            detail["amount"]       = data["amount"];
            detail["btotal"]       = data["btotal"];
            detail["ltotal"]       = data["ltotal"];
            detail["total"]        = data["total"];
            detail["preferential"] = data["preferential"];
            detail["sendway"]      = data["csendway"];
            detail["remark"]       = data["cremark"];
            return(detail);
        }
Ejemplo n.º 34
0
        private long GetId(DbHelper db, string user)
        {
            user = user.ToLower();
            if (user == "ljbbean")
            {
                db.AddParameter("name", "ljb");
            }
            else if (user == "annychenzy")
            {
                db.AddParameter("name", "cy");
            }
            else
            {
                return(-1);
            }


            IHashObject hash = db.SelectFirstRow("select id from `user` where name =@name");

            return(hash == null ? -1 : hash.GetValue <long>("id"));
        }
Ejemplo n.º 35
0
        /// <summary>
        /// 导入政策
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public bool ImportPolicy(IHashObject parameter)
        {
            bool rs = false;

            using (DbHelper db = new DbHelper(DbControl.GetDbConnStringBasic(DbHandleBehaviorDefine.WRITE, 0)))
            {
                try
                {
                    db.BeginTransaction();
                    for (int i = 0; i < parameter.Count; i++)
                    {
                        db.ExecuteNonQuerySQL(parameter[i.ToString()].ToString());
                    }
                    db.CommitTransaction();
                    rs = true;
                }
                catch (Exception)
                {
                    db.RollbackTransaction();
                }
            }
            return(rs);
        }
Ejemplo n.º 36
0
 public void DoSave(IHashObject data)
 {
     using (DbHelper db = AppUtils.CreateDbHelper())
     {
         try
         {
             db.BeginTransaction();
             int id = Guid.NewGuid().GetHashCode();
             if (data.ContainsKey("id"))
             {
                 id = data.GetValue <int>("id");
                 IHashObject detail = GetDetail(data, id);
                 detail.Remove("id");
                 db.Update("billdetail", "bid", detail);
                 IHashObject item = GetBill(data, id);
                 db.Update("bill", "id", item);
             }
             else
             {
                 IHashObject detail = GetDetail(data, id);
                 db.Insert("billdetail", detail);
                 IHashObject item = GetBill(data, id);
                 item["uid"] = ((Test001.Login.User)Session["user"]).Id;
                 db.Insert("bill", item);
             }
             db.CommitTransaction();
         }
         catch (Exception e)
         {
             if (db.HasBegunTransaction)
             {
                 db.RollbackTransaction();
             }
             throw e;
         }
     }
 }
Ejemplo n.º 37
0
 public BParamsPresetSql(DbHelper dbHelper, IHashObject qryParams, string conString, string sqlPath)
     : base(dbHelper, qryParams, conString, sqlPath)
 {
 }
Ejemplo n.º 38
0
 public void setSQL(string baseSql, IHashObject queryParams)
 {
     sql = baseSql;
     extractParamFromBaseSQL(queryParams);
     intlSetSql(sql);
 }
Ejemplo n.º 39
0
 private void extractParamFromBaseSQL(IHashObject queryParams)
 {
     try
     {
         string[] ss = sql.Split('}');
         string[] arry = new string[ss.Length - 1];
         string key, value;
         int index = 0;
         for (int i = 0; i < ss.Length - 1; i++)
         {
             if (ss[i].IndexOf("{-") > 0) continue;
             arry[i] = ss[i].Substring(ss[i].IndexOf("{"), ss[i].Length - ss[i].IndexOf("{")) + "}";
             index = arry[i].IndexOf("=");
             if (index <= 0) continue;
             key = arry[i].Substring(1, index - 1).Trim();
             value = arry[i].Substring(index + 1, arry[i].Length - index - 2);
             if (!queryParams.ContainsKey(key))
             {
                 queryParams.Add(key.Trim(), value);
             }
             sql = sql.Replace(arry[i], "");
         }
     }
     catch (Exception e)
     {
         throw new Exception("SQLHelper抽取参数时出错:" + e.Message);
     }
 }
Ejemplo n.º 40
0
        public static DataTable SpliteContentToDataTable(string user, List <CatchDataTemplate> list)
        {
            DataTable            table      = MessageTable();
            JavaScriptSerializer serializer = JavaScriptSerializer.CreateInstance();

            string[] keys =
            {
                "mainOrder/payInfo/actualFee/value",
                "mainOrder/buyer/nick",
                "mainOrder/id",
                "mainOrder/orderInfo/lines",
                "mainOrder/subOrders",
                "buyMessage",                    //买家备注
                "operationsGuide"                //卖家备注
            };
            foreach (CatchDataTemplate template in list)
            {
                var    hashObject = new HashObject();
                string content    = template.DetailContent;
                try
                {
                    hashObject = serializer.Deserialize <HashObject>(content);
                }
                catch (Exception t)
                {
                    continue;
                }

                DataRow    row = table.NewRow();
                HashObject addressAndLogistics = GeAddressAndLogisticsInfo(hashObject);
                foreach (string key in addressAndLogistics.Keys)
                {
                    row[key] = addressAndLogistics[key];
                }
                var newHash = hashObject.GetHashValue(keys);
                row["订单ID"] = newHash.GetDataEx <string>("id");
                row["旺旺名称"] = newHash.GetDataEx <string>("nick");
                row["买家留言"] = newHash.GetDataEx <string>("buyMessage");

                row["卖家留言"] = GetSaleMessage(GetKeyObject(newHash, "operationsGuide"));
                ArrayList       linesList     = newHash.GetDataEx <ArrayList>("lines");
                IHashObjectList orderInfoList = GetOrderInfoList(serializer, linesList);
                if (orderInfoList.Count > 1 || orderInfoList.Count == 0)
                {
                    throw new Exception("订单信息存在多个时间,请重新核实");
                }
                IHashObject tempOrderInfoList = orderInfoList[0];
                row["支付宝交易号"] = tempOrderInfoList.GetValue <string>("支付宝交易号:", "");
                row["创建时间"]   = tempOrderInfoList.GetValue <string>("创建时间:", null);
                row["付款时间"]   = tempOrderInfoList.GetValue <string>("付款时间:", null);
                var sendDate = tempOrderInfoList.GetValue <string>("发货时间:", null);
                row["发货时间"] = sendDate;
                if (sendDate != null)
                {
                    row["发货状态"]       = "已发货";
                    row["发货状态status"] = "1";
                }

                var successDate = tempOrderInfoList.GetValue <string>("成交时间:", null);
                if (successDate != null)
                {
                    row["发货状态"]       = "已收货";
                    row["发货状态status"] = "2";
                }
                row["成交时间"] = successDate;

                //后期单据退款(各种原因的退款)
                if ("交易关闭".Equals(template.Status))
                {
                    row["支付金额"]       = 0;
                    row["发货状态"]       = "已关闭";
                    row["发货状态status"] = "9";
                }
                else
                {
                    row["支付金额"] = newHash.GetDataEx <string>("value"); //支付总金额
                    newHash.GetDataEx <string>("value");               //支付总金额
                }

                ArrayList        subOrders = newHash.GetDataEx <ArrayList>("subOrders");
                List <GoodsInfo> gList     = GetSubOrderSkuList(subOrders);
                decimal          all       = 0;
                foreach (GoodsInfo info in gList)
                {
                    all += info.PriceInfo;
                }
                row["拍下总金额"] = all;
                row["货物信息"]  = serializer.Serialize(gList);
                row["所属用户"]  = user;
                table.Rows.Add(row);
            }

            return(table);
        }
Ejemplo n.º 41
0
 public virtual void setTestParams()
 {
     if (helper == null) helper = new SQLHelper();
     if (queryParams == null)
     {
         queryParams = new HashObject();
         string sql = getBaseSQL();
         helper.setSQL(getBaseSQL(), queryParams);
     }
     else
         helper.setSQL(getBaseSQL(), queryParams);
 }
Ejemplo n.º 42
0
 public CommonSQLMaker(IHashObject qryParams, string sql)
     : base(qryParams, sql)
 {
     this.textSql = sql;
 }
Ejemplo n.º 43
0
 //=============================================
 private void ini()
 {
     rPagerSql.Text = "";
     rSumSql.Text = "";
     rRecordCountSql.Text = "";
     rCommonSql.Text = "";
     _userParams = null;
     _sysParams = null;
     _defaultValue = null;
 }
Ejemplo n.º 44
0
 protected void addParam(IHashObject qryParams, string key, object value)
 {
     if (qryParams.ContainsKey(key))
         qryParams[key] = value;
     else
         qryParams.Add(key, value);
 }
Ejemplo n.º 45
0
 public BSqlMaker(DbHelper dbHelper, IHashObject qryParams, string conString, string filePath)
     : base(dbHelper, qryParams, conString, filePath)
 {
 }
Ejemplo n.º 46
0
 public void getBaseSqlInfo(out string baseSQl, out List<string> userParams, out List<string> sysParams, out IHashObject defaultValue)
 {
     baseSQl = getBaseSQL();
     if (helper == null) helper = new SQLHelper();
     helper.getAllParams(baseSQl, out userParams, out sysParams, out defaultValue);
 }
Ejemplo n.º 47
0
        public override void Initialize()
        {
            base.Initialize();

            using (DbHelper db = AppUtils.CreateDbHelper())
            {
                Test001.Login.User user = ((Test001.Login.User)Session["user"]);
                db.AddParameter("userid", user.Id);
                IHashObjectList userList = db.Select("select color, size, price from btypeconfig where userid=@userid");

                List <string> color = new List <string>();
                List <string> size  = new List <string>();
                foreach (IHashObject hash in userList)
                {
                    if (!color.Contains(hash.GetValue <string>("color")))
                    {
                        color.Add(hash.GetValue <string>("color"));
                    }
                    if (!size.Contains(hash.GetValue <string>("size")))
                    {
                        size.Add(hash.GetValue <string>("size"));
                    }
                }
                Context["size"]      = size;
                Context["color"]     = color;
                Context["sizecolor"] = userList;

                if (this.Request.QueryString["id"] == null)
                {
                    IHashObject data = new HashObject();
                    data["date"]      = DateTime.Now;
                    data["amount"]    = 1;
                    data["size"]      = size.Count > 0 ? size[0] : "";
                    data["color"]     = color.Count > 0 ? color[0] : "";
                    data["csendway"]  = "送货到小区";
                    data["dobtotal"]  = user.Power == 99 ? 1 : 0;
                    data["sizecolor"] = userList;
                    decimal total = userList.Count > 0 ? userList[0].GetValue <decimal>("price") : 0;
                    if (user.Power == 99)
                    {
                        data["btotal"] = 0;
                    }
                    else
                    {
                        data["btotal"] = (total * (decimal)0.05);
                    }
                    data["total"]     = total;
                    Context["bill"]   = data;
                    Context["enable"] = true;
                    return;
                }

                string id = Request.QueryString["id"].ToString();
                db.AddParameter("id", id);
                IHashObject bill = db.SelectSingleRow(@"select id,DATE_FORMAT(date, '%Y-%m-%d') as date,taobaocode,cname,ctel,caddress,carea,csendway,cremark,btotal,ltotal,preferential, status from bill where id=@id");
                db.AddParameter("id", id);
                //todo 一个单对多个商品时会报错
                IHashObject billDetial = db.SelectSingleRow("select * from billdetail where bid=@id");
                foreach (string key in billDetial.Keys)
                {
                    if (key.ToLower() == "id")
                    {
                        continue;
                    }
                    bill[key] = billDetial[key];
                }
                bill["dobtotal"]  = user.Power == 99 ? 1 : 0;
                bill["sizecolor"] = userList;
                Context["bill"]   = bill;
                Context["enable"] = true;// bill.GetValue<int>("status") < 1;
            }
        }
Ejemplo n.º 48
0
        public void ini(DbHelper dbHelper, IHashObject qryParams)
        {
            try
            {
                this.funcMakers = new List<FunctionStrMaker>();
                this.wrappers = new List<FunctionStrMaker>();
                this.db = dbHelper;
                this.queryParams = qryParams;
                executeSql = new ExecuteSQL();
                helper = new SQLHelper();

                innerIni(dbHelper, qryParams);

            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
        }
Ejemplo n.º 49
0
 public PageSumMaker(IHashObject qryParams, SQLHelper helper, string conString)
     : base(qryParams, helper, conString)
 {
 }
Ejemplo n.º 50
0
 protected abstract void innerIni(DbHelper dbHelper, IHashObject qryParams);
Ejemplo n.º 51
0
 public BPagerSqlMaker(DbHelper dbHelper, IHashObject qryParams, string conString, string sqlPath)
     : base(dbHelper, qryParams, conString, sqlPath)
 {
 }
Ejemplo n.º 52
0
 public FunctionStrMaker(IHashObject qryParams, SQLHelper sqlHelper, string conString)
 {
     this.conStr = conString;
     this.helper = sqlHelper;
     QueryParams = qryParams;
 }
Ejemplo n.º 53
0
        private BSqlMaker getSQL(Boolean bPagerMaker, IHashObject queryParams)
        {
            if (queryParams == null) queryParams = new HashObject();
            BSqlMaker maker = BMakerHelper.getMaker(conString, filePath, className, queryParams);
            try
            {
                if (bPagerMaker)
                {
                    rSumSql.Text = ((BPagerSqlMaker)maker).getSumDataSQL();
                    rRecordCountSql.Text = ((BPagerSqlMaker)maker).getRecordCountSQL();
                    rPagerSql.Text = ((BPagerSqlMaker)maker).getPageDataSQL(0, 20, true);

                }
                else
                {
                    rCommonSql.Text = maker.getSQL();
                }
            }
            catch (Exception error)
            {
                addErrList("getSQL出错:" + error.Message);
            }
            return maker;
        }
Ejemplo n.º 54
0
 public RecordCountMaker(IHashObject qryParams, SQLHelper helper, string conString)
     : base(qryParams, helper, conString)
 {
 }
Ejemplo n.º 55
0
 public RightsSQLMaker(IHashObject qryParams, SQLHelper helper, string conString)
     : base(qryParams, helper, conString)
 {
 }
Ejemplo n.º 56
0
 public BaseSQLMaker(DbHelper dbHelper, IHashObject qryParams, string conString, string filePath)
 {
     conStr = conString;
     this.sqlFilePath = filePath;
     ini(dbHelper, qryParams);
 }