Beispiel #1
0
        public void UpdateTable(string tableName, string data)
        {
            List <PurchaseOrders> list = JsonConvert.DeserializeObject <List <PurchaseOrders> >(data);

            foreach (PurchaseOrders item in list)
            {
                PurchaseOrdersBLL.Save(item);
            }
            ;
            //Common.UpdateTableVersion("CloudTrade.dbo.PurchaseOrders");
        }
Beispiel #2
0
        public List <PurchaseOrders> GetList(TableObject table)
        {
            string CacheEnable = ConfigurationManager.AppSettings["CacheEnable"];
            string key         = CacheUtility.GetKey(table);
            object obj         = CacheUtility.Get(key);

            if (obj != null)
            {
                return((List <PurchaseOrders>)obj);
            }
            string sqlStr = "select * from PurchaseOrders where CompanyID=@BranchID and SchoolID= @SchoolID and LastModified>@LastModified";

            List <SqlParameter> pms = new List <SqlParameter>();

            pms.Add(new SqlParameter("BranchID", table.BranchID));
            pms.Add(new SqlParameter("SchoolID", table.SchoolID));
            pms.Add(new SqlParameter("LastModified", table.LastModified));
            if (!string.IsNullOrEmpty(table.StartDate))
            {
                sqlStr += " and [LastModifiedDate]>@StartDate";
                pms.Add(new SqlParameter("StartDate", table.StartDate));
            }
            if (!string.IsNullOrEmpty(table.EndDate))
            {
                sqlStr += " and [LastModifiedDate]<@EndDate";
                pms.Add(new SqlParameter("EndDate", table.EndDate));
            }
            List <PurchaseOrders> list = PurchaseOrdersBLL.Search(sqlStr, pms.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);
        }