예제 #1
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;
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
 public IHashObjectList GetDetail(int id)
 {
     using (DbHelper db = AppUtils.CreateDbHelper())
     {
         db.AddParameter("bid", id);
         return(db.Select("select * from billdetail where bid=@bid"));
     }
 }
예제 #4
0
파일: PlugList.cs 프로젝트: ljbbean/project
 public object GetItems()
 {
     using (DbHelper db = AppUtils.CreateDbHelper())
     {
         string sql = "select pid as id, picon as img, pname as name, pdes as des, pvideo as video, pview as view, pversion as version, pdownpath, ppics, DATE_FORMAT(pupdatedate,'%Y-%m-%d %H:%i:%s') as pupdatedate, DATE_FORMAT(pcreatedate,'%Y-%m-%d') as pcreatedate, plabel as label from plugs";
         return(db.ExecuteSQL(sql));
     }
 }
예제 #5
0
        /// <summary>
        /// 获取订单数量
        /// </summary>
        private IHashObjectList GetBillAmount(string startDate, string endDate)
        {
            using (DbHelper db = AppUtils.CreateDbHelper())
            {
                db.AddParameter("startDate", startDate);
                db.AddParameter("endDate", endDate);
                UserInfo info = (UserInfo)Session["user"];
                db.AddParameter("user", info.User);

                return(db.Select(@"
                    SELECT COUNT(1) AS amount,sourceTitle,DATE_FORMAT(createdate, '%Y-%m-%d') AS paydate FROM bill b
                     JOIN billdetail bd ON b.id = bd.bid 
                    where `user`=@user and createdate BETWEEN @startDate and @endDate GROUP BY sourceTitle ,DATE_FORMAT(createdate, '%Y-%m-%d')"));
            }
        }
예제 #6
0
파일: Default.cs 프로젝트: ljbbean/project
 private bool WebLogin(string token, string user)
 {
     using (DbHelper db = AppUtils.CreateDbHelper())
     {
         string sql = "select count(1) as count from  logintoken where `user`=@user and `token`=@token";
         db.AddParameter("token", token);
         db.AddParameter("user", user);
         if (db.SelectSingleRow(sql).GetValue <int>("count") > 0)
         {
             UserInfo data = new UserInfo();
             data.User       = user;
             data.LoginDate  = DateTime.Now;
             Session["user"] = data;
             return(true);
         }
     }
     return(false);
 }
예제 #7
0
        private string GetStartDate(string user)
        {
            using (DbHelper db = AppUtils.CreateDbHelper())
            {
                db.AddParameter("uid", GetId(db, user));

                var list = db.Select("SELECT MAX(DATE) as ndate FROM bill WHERE billfrom IS NOT NULL AND uid = @uid ORDER BY DATE DESC");
                if (list == null || list.Count == 0)
                {
                    return(MilliTimeStamp(DateTime.Now.AddDays(-2)).ToString());
                }

                DateTime dateTime = list[0].GetValue <DateTime>("ndate");
                if (dateTime == new DateTime())
                {
                    return(MilliTimeStamp(DateTime.Now.AddDays(-2)).ToString());
                }
                dateTime = dateTime.AddDays(-2);//往后推2天
                return(MilliTimeStamp(dateTime).ToString());
            }
        }
예제 #8
0
        public void SavePlugData(Plug plug)
        {
            HashObject hash       = new HashObject();
            long       fileLength = 0;

            //数据搬移
            plug.PDownpath = MoveFile(plug.PDownpath, out fileLength);
            plug.PTotal    = fileLength;
            plug.PVideo    = MoveFile(plug.PVideo, out fileLength);
            plug.PIcon     = MoveFile(plug.PIcon, out fileLength);
            plug.PPic1     = MoveFile(plug.PPic1, out fileLength);
            plug.PPic2     = MoveFile(plug.PPic2, out fileLength);
            plug.PPic3     = MoveFile(plug.PPic3, out fileLength);
            hash.Add("pdownpath", plug.PDownpath);
            hash.Add("pvideo", plug.PVideo);
            hash.Add("picon", plug.PIcon);
            hash.Add("ppics", plug.PPics);
            hash.Add("pcreatedate", DateTime.Now);

            //数据保存
            using (DbHelper db = AppUtils.CreateDbHelper())
            {
                try
                {
                    db.BeginTransaction();

                    List <string> needToDeleteFiles = DeleteOldData(plug, db, hash);
                    if (plug.PTotal == 0)
                    {
                        plug.PTotal = hash.GetValue <int>("ptotal", 0);
                    }
                    string sql = "insert into plugs (pid,pname,pversion,pkind,plabel,picon,pdes,pvideo,pvideoweb,pcost,plevel,pdownpath,pdownpathweb,ptotal,pext,ppics,pcreatedate,pupdatedate,pshowway,pstorename,pwindowname) values(@pid,@pname,@pversion,@pkind,@plabel,@picon,@pdes,@pvideo,@pvideoweb,@pcost,@plevel,@pdownpath,@pdownpathweb,@ptotal,@pext,@ppics,@pcreatedate,@pupdatedate,@pshowway,@pstorename,@pwindowname)";
                    db.AddParameter("pid", plug.PId);
                    db.AddParameter("pname", plug.PName);
                    db.AddParameter("pversion", plug.PVersion);
                    db.AddParameter("pkind", plug.PKind);
                    db.AddParameter("plabel", plug.PLabel);
                    db.AddParameter("picon", hash.GetValue <string>("picon"));
                    db.AddParameter("pdes", plug.PDes);
                    db.AddParameter("pvideo", hash.GetValue <string>("pvideo"));
                    db.AddParameter("pcost", plug.PCost);
                    db.AddParameter("plevel", plug.PLevel);
                    db.AddParameter("pdownpath", hash.GetValue <string>("pdownpath"));
                    db.AddParameter("ptotal", plug.PTotal);
                    db.AddParameter("pext", plug.PExt);
                    db.AddParameter("ppics", hash.GetValue <string>("ppics"));
                    db.AddParameter("pcreatedate", hash.GetValue <DateTime>("pcreatedate"));
                    db.AddParameter("pupdatedate", plug.PUpdatedate);
                    db.AddParameter("pshowway", plug.PShowway);
                    db.AddParameter("pstorename", plug.PStorename);
                    db.AddParameter("pwindowname", plug.PWindowname);
                    db.AddParameter("pvideoweb", GetWebUri());
                    db.AddParameter("pdownpathweb", GetWebUri());
                    db.ExecuteScalerSQL(sql);
                    foreach (string file in needToDeleteFiles)
                    {
                        File.Delete(file);
                    }
                    db.CommitTransaction();
                }
                catch (Exception e)
                {
                    if (db.HasBegunTransaction)
                    {
                        db.RollbackTransaction();
                    }
                    throw e;
                }
            }
        }