Esempio n. 1
0
        public List <OrderItems> GetList(TableObject table)
        {
            string CustomerLink = ConfigurationManager.AppSettings["CustomerLink"];
            string CacheEnable  = ConfigurationManager.AppSettings["CacheEnable"];
            string key          = CacheUtility.GetKey(table);
            object obj          = CacheUtility.Get(key);

            if (obj != null)
            {
                return((List <OrderItems>)obj);
            }
            string sqlStr = "";
            string sqlAdd = "";

            if (table.IsValid == 1)
            {
                sqlAdd = " AND (TotalCourseAmount>0 OR CommonCourseAmount>0 OR SpecialCourseAmount>0) ";
            }
            sqlStr = @"select * from OrderItems where LastModified>@LastModified 
and OrderID in(select OrderID from OrderStatistics where CustomerID
in(
select CustomerID  FROM " + CustomerLink + @"[CloudCustomer].[dbo].[CustomerSearch] ss where ss.XDSchoolID=@SchoolID " + sqlAdd + "))";
            //string sqlStr = "select * from OrderItems where LastModified>@LastModified";
            List <DbParameter> paras        = new List <DbParameter>();
            string             providerName = ConfigurationManager.ConnectionStrings["CloudTrade"].ProviderName;

            switch (providerName)
            {
            case "MySql.Data.MySqlClient":
                paras.Add(new MySqlParameter("BranchID", table.BranchID));
                paras.Add(new MySqlParameter("SchoolID", table.SchoolID));
                paras.Add(new MySqlParameter("LastModified", table.LastModifiedDate));
                break;

            default:
                paras.Add(new SqlParameter("BranchID", table.BranchID));
                paras.Add(new SqlParameter("SchoolID", table.SchoolID));
                paras.Add(new SqlParameter("LastModified", table.LastModified));
                break;
            }

            List <OrderItems> list = OrderItemsBLL.Search(sqlStr, paras.ToArray());

            if (list.Count > 0)
            {
                byte[] b = new byte[8];
                if (CacheUtility.GetCollectionKey(table.LastModified) == CacheUtility.GetCollectionKey(b))
                {
                    CacheUtility.Insert(key, list);
                }
                else
                {
                    if (CacheEnable == "true")
                    {
                        CacheUtility.Insert(key, list);
                    }
                }
            }
            return(list);
        }
Esempio n. 2
0
        public void UpdateTable(string tableName, string data)
        {
            List <OrderItems> list = JsonConvert.DeserializeObject <List <OrderItems> >(data);

            foreach (OrderItems item in list)
            {
                OrderItemsBLL.Save(item);
            }
            ;
            //Common.UpdateTableVersion("CloudTrade.dbo.OrderItems");
        }