예제 #1
0
        static List <AutoObject> DataReaderToAutoObject(SqlDataReader reader)
        {
            List <AutoObject> lst = new List <AutoObject>();

            while (reader.Read())
            {
                List <AutoItem> items = new List <AutoItem>();
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    AutoItem p = new AutoItem();
                    p.CSharpType = reader.GetFieldType(i).FullName;
                    p.Name       = reader.GetName(i); //p.SqlType = Lambda.Framework.BMIConvert.GetSqlTypeFromStringType(reader.GetDataTypeName(i));
                    //p.SqlType = reader.GetDataTypeName(i);
                    var value = reader.GetValue(i);
                    p.Value = value;
                    if (p.Value == DBNull.Value)
                    {
                        p.Value = null;
                    }
                    items.Add(p);
                }
                AutoObject d = new AutoObject();
                d.Items = items;
                lst.Add(d);
            }
            reader.Close();
            return(lst);
        }
예제 #2
0
        //public static List<T> CreateListBus<T>(List<AutoObject> items) where T : Bus
        //{
        //    List<T> listBus = new List<T>();
        //    for (int i = 0; i < items.Count; i++)
        //    {
        //        T x = (T)Activator.CreateInstance(typeof(T), items[i]);
        //        x.MakeUnchange();
        //        listBus.Add(x);
        //    }
        //    return listBus;
        //}
        //public static List<AutoObject> CreateListAuto<T>(List<T> listBus) where T : Bus
        //{
        //    var listAuto = new List<AutoObject>();
        //    for (int i = 0; i < listBus.Count; i++)
        //    {
        //        listAuto.Add(listBus[i].DataToAutoObject());
        //    }
        //    return listAuto;
        //}
        //public static List<T> GetListWithState<T>(List<T> listBus, RowState state) where T : Bus
        //{
        //    var result = new List<T>();
        //    for (int i = 0; i < listBus.Count; i++)
        //        if ((listBus[i].State & state) == listBus[i].State)
        //            result.Add(listBus[i]);
        //    return result;
        //}
        //static List<AutoObject> CreateListAutoParams<T>(params List<T>[] arraylistBus) where T : Bus
        //{
        //    var result = new List<AutoObject>();
        //    for (int i = 0; i < arraylistBus.Length; i++)
        //    {
        //        //result.AddRange(CreateListAuto(GetListWithState(arraylistBus[i],RowState.Insert | RowState.Update | RowState.Delete)));
        //        var tmp = BusinessAction.GetBusinessObjectWithState(arraylistBus[i], RowState.Insert | RowState.Update | RowState.Delete);
        //        result.AddRange(BusinessAction.ToAutoObject(tmp));
        //    }
        //    return result;
        //}
        #region Get
        public List <T> Get <T>(AutoObject item, bool?isCache = null, long?MinuteToCache = null) where T : Bus
        {
            //return CreateListBus<T>(GetInvoke(item,isCache,MinuteToCache));
            var result = GetInvoke(item, isCache, MinuteToCache);

            return(BusinessAction.ToBusinessObject <T>(result));
        }
예제 #3
0
 private static AutoItem FindVersion(AutoObject dataItem)
 {
     if (dataItem == null)
     {
         return(null);
     }
     for (int i = 0; i < dataItem.Items.Count; i++)
     {
         if (dataItem.Items[i].SqlType == SqlDbType.Timestamp)
         {
             return(dataItem.Items[i]);
         }
     }
     return(null);
 }
예제 #4
0
 public static string ExecuteQueryToTableXML(string ConnectionStringName, AutoObject item)
 {
     using (SqlConnection con = GetConnection(ConnectionStringName))
     {
         con.Open();
         List <SqlParameter> Sqlparam = item.Items.ToSqlParameter();
         var reader = ExecuteReader(item.SpName, Sqlparam, con);
         var table  = new DataTable(item.SpName);
         table.Load(reader);
         reader.Close();
         con.Close();
         using (StringWriter sw = new StringWriter())
         {
             table.WriteXml(sw, XmlWriteMode.WriteSchema);
             return(sw.ToString());
         }
     }
 }
예제 #5
0
        protected virtual List <AutoObject> GetInvoke(AutoObject item, bool?isCache = null, long?MinuteToCache = null)
        {
            var     p       = Proxy;
            Request request = new Request();

            request.DataItem = item;
            PreRequest(request, isCache, MinuteToCache);
            var response = p.GetData(request);

            if (response.Acknowledge == AcknowledgeType.Failure)
            {
                throw new Exception(response.Message);
            }
            if (request.RequestId != response.CorrelationId)
            {
                throw new Exception(string.Format("ReservationId:{0}", response.ReservationId));
            }
            return(response.DataItems);
        }
예제 #6
0
        public static List <AutoObject> ExecuteQuery(string ConnectionStringName, AutoObject item, bool Caching = false, long MinuteToCache = 60)
        {
            List <AutoObject> data;

            string key = AutoMemCached.MakeKey(ConnectionStringName, item);

            if (Caching == true)
            {
                data = AutoMemCached.Get(key);
                if (data != null && data.Count > 0)
                {
                    return(data);
                }
            }
            //Get data from database
            data = ExecuteQuery(ConnectionStringName, item.SpName, item.Items);
            AutoMemCached.Add(key, data, DateTimeOffset.Now.AddMinutes(MinuteToCache));
            return(data);
        }
예제 #7
0
 public static string MakeKey(string ConnectionStringName, AutoObject item)
 {
     return(MakeKey(ConnectionStringName, item.SpName, item.Items));
 }
예제 #8
0
 public ServiceItem(AutoObject value)
 {
     OnCreating();
     DataFromAutoObject(value);
     OnCreated();
 }
예제 #9
0
 public DataTable GetDataTable(AutoObject item, bool?isCache = null, long?MinuteToCache = null)
 {
     return(DataTableFromAutoObject(GetInvoke(item), item.SpName));
 }
예제 #10
0
        public int SetAutoObject(AutoObject item, string KeyService = null)
        {
            var response = SetInvoke(item, KeyService);

            return(response.RowsAffected);
        }
예제 #11
0
 protected Response SetInvoke(AutoObject item, string KeyService = null)
 {
     return(SetInvoke(new List <AutoObject> {
         item
     }, KeyService));
 }
예제 #12
0
 public List <AutoObject> GetAutoObject(AutoObject item, bool?isCache = null, long?MinuteToCache = null)
 {
     return(GetInvoke(item, isCache, MinuteToCache));
 }
예제 #13
0
 public BanggiaModel(AutoObject value)
 {
     OnCreating();
     DataFromAutoObject(value);
     OnCreated();
 }
 public ChitietHoadonModel(AutoObject value)
 {
     OnCreating();
     DataFromAutoObject(value);
     OnCreated();
 }
예제 #15
0
 public _UserModel(AutoObject value)
 {
     OnCreating();
     DataFromAutoObject(value);
     OnCreated();
 }
예제 #16
0
 public NhomHanghoaModel(AutoObject value)
 {
     OnCreating();
     DataFromAutoObject(value);
     OnCreated();
 }