Ejemplo n.º 1
0
        public static IObjectProxy getProxy(Model mode, object id, SqlCon con, Context.ICurrentContextFactory conFac)
        {
            if (id == null)
            {
                return(null);
            }

            var ob = MemoryCache.StoreDbCache.GetDbMemoryCache(con, mode, id, conFac);

            if (ob == null)
            {
                var proxy = new SqlDataProxy(mode, conFac, LoadType.Null);
                MemoryCache.StoreDbCache.UpdateOrAddDbMemoryCache(con, mode, id, proxy);
                return(proxy);
            }

            return(ob);
        }
Ejemplo n.º 2
0
        public static IObjectProxy LoadSqlDataQuery(Soway.Model.View.View view,
                                                    System.Data.DataRow row, SqlCon con, Context.ICurrentContextFactory conFac)
        {
            IObjectProxy proxy = new SqlDataProxy(view.Model, conFac, LoadType.Null, con);

            foreach (var viewItem in view.Items)
            {
                if (viewItem.Property.PropertyType == PropertyType.RadomDECS)
                {
                    proxy [viewItem.Property] = EncryptionClass.GetDecrptyString(
                        viewItem.Property, row, string.Format("{0}_", proxy.Model.DataTableName));
                }
                else
                if (viewItem.Property.PropertyType != PropertyType.BusinessObject)
                {
                    if (string.IsNullOrEmpty(viewItem.Property.DBName) == false)
                    {
                        proxy[viewItem.Property] = row[string.Format("{0}_{1}", proxy.Model.DataTableName, viewItem.Property.DBName)];
                    }
                }
                else
                {
                    var propertyProxy = new SqlDataProxy(viewItem.Property.Model, conFac, LoadType.Null, con);


                    if (viewItem.Property.IsMultiMap == false)
                    {
                        if (viewItem.Property.Model.ShowProperty != null
                            &&
                            row[string.Format("{0}_{1}", viewItem.Property.Name, viewItem.Property.Model.ShowProperty.DBName)]
                            != DBNull.Value)
                        {
                            if (viewItem.Property.Model.IdProperty != null)
                            {
                                propertyProxy[viewItem.Property.Model.IdProperty] = row[string.Format("{0}_{1}", viewItem.Property.Name, viewItem.Property.Model.IdProperty.DBName)];
                            }
                            if (viewItem.Property.Model.ShowProperty != null)
                            {
                                propertyProxy[viewItem.Property.Model.ShowProperty] = row[string.Format("{0}_{1}", viewItem.Property.Name, viewItem.Property.Model.ShowProperty.DBName)];
                            }
                        }
                        else
                        {
                            propertyProxy = null;
                        }
                    }
                    else
                    {
                        foreach (var map in viewItem.Property.DBMaps)
                        {
                            propertyProxy[viewItem.Property.Model.Properties.First(p => p.Name == map.PropertyName || p.PropertyName == map.PropertyName)] = row[string.Format("{0}_{1}",
                                                                                                                                                                               viewItem.Property.Name,
                                                                                                                                                                               map.PropertyName)];
                        }
                    }

                    proxy[viewItem.Property] = propertyProxy;
                }
            }
            if (proxy.Model.AutoSysId == true)
            {
                proxy.ID = row[string.Format("{0}_{1}", proxy.Model.DataTableName, "SYSID")];
            }
            else
            {
                proxy.ID = row[string.Format("{0}_{1}", proxy.Model.DataTableName, proxy.Model.IdProperty.DBName)];
            }
            return(proxy);
        }
Ejemplo n.º 3
0
 public dbContext(SqlCon con, Context.ICurrentContextFactory conFac)
 {
     sqlCon = con;
     ConFac = conFac;
 }
Ejemplo n.º 4
0
 public ModelBindingList(Property property, IObjectProxy owner, Context.ICurrentContextFactory conFac)
 {
     this.Property = property;
     this.Owner    = owner;
     this.ConFac   = conFac;
 }
Ejemplo n.º 5
0
 //public SqlCon SqlCon;
 public SqlServerModuleInstaller(Context.ICurrentContextFactory conFac)
 {
     this.ConFac = conFac;
 }
Ejemplo n.º 6
0
 public SqlDataProxy(Model Model, Context.ICurrentContextFactory conFac, LoadType isLoad = LoadType.Null, SqlCon con = null) : base(Model, conFac, isLoad)
 {
     this.Con = con;
 }
Ejemplo n.º 7
0
 public QueryFactory(SqlCon con, Context.ICurrentContextFactory conFac)
 {
     this.Con     = con;
     this.ConFac  = conFac;
     relationView = new View.AutoViewFactory(this.Con, this.ConFac).CreateDefaultListView(relatoinModel);
 }
Ejemplo n.º 8
0
 public ObjectProxy(Model model, Context.ICurrentContextFactory conFac, LoadType isLoad = LoadType.Null) : base(model, conFac, isLoad)
 {
 }
Ejemplo n.º 9
0
 public ListViewQueryContext(SqlCon con, Context.ICurrentContextFactory conFac)
 {
     this.Con    = con;
     this.ConFac = conFac;
 }
Ejemplo n.º 10
0
        public static IObjectProxy GetDbMemoryCache(SqlCon con, Model Model, object id, Context.ICurrentContextFactory confac)
        {
            var modellist =
                GetCachedList(con.ToString(), Model.Name, DbCachedList);

            if (modellist.ContainsKey(id))
            {
                var ob = modellist[id];
                ob.LastUsedTime = DateTime.Now;
                ob.UsedCount++;
                return(ob.CachedOb);
            }
            else
            {
                var memitem = new CacheItem();
                memitem.Key      = id;
                memitem.CachedOb = new SqlDataProxy(Model, confac, LoadType.Null, con)
                {
                    ID = id
                };
                modellist.TryAdd(id, memitem);
                return(memitem.CachedOb);
            }
        }
Ejemplo n.º 11
0
 public ItemQueryContext(Soway.Model.View.View listView, QueryContext query, long current, SqlCon con, Context.ICurrentContextFactory conFac)
 {
     this.ListView     = listView;
     this.QueryContext = query;
     this.CurrentIndex = current;
     this.Con          = con;
     this.ConFac       = conFac;
     Query();
 }
Ejemplo n.º 12
0
 public GetValueExpression(Context.ICurrentContextFactory confac)
 {
     this.ContextFac = confac;
 }
Ejemplo n.º 13
0
 public ObjectContext(Soway.Model.SqlCon sqlCon, Context.ICurrentContextFactory conFac)
 {
     Model       = new Soway.Model.AssemblyModelFactory(typeof(T).Assembly).GetModel(typeof(T));
     this.ConFac = conFac;
     this.SqlCon = sqlCon;
 }
Ejemplo n.º 14
0
 public AppFac(SqlCon sqlCon, Context.ICurrentContextFactory conFac)
 {
     this.SqlCon = sqlCon;
     this.ConFac = ConFac;
 }
Ejemplo n.º 15
0
        public static void   LoadSqlData(IObjectProxy proxy, System.Data.DataRow row, SqlCon con, Context.ICurrentContextFactory conFac)
        {
            if (proxy != null && proxy.Model.ModelType != ModelType.Enum)
            {
                foreach (var property in proxy.Model.Properties.Where(p => p.IsArray == false &&
                                                                      (string.IsNullOrEmpty(p.DBName) == false || p.IsMultiMap == true)))
                {
                    dynamic propertyOb = null;
                    if (property.PropertyType == PropertyType.RadomDECS)
                    {
                        propertyOb = EncryptionClass.GetDecrptyString(property, row);
                    }
                    else
                    if (property.PropertyType != PropertyType.BusinessObject)
                    {
                        if (String.IsNullOrEmpty((property.DBName ?? "").Trim()) == false &&
                            row.Table.Columns.Contains(property.DBName) == true &&
                            row[property.DBName] != DBNull.Value)
                        {
                            propertyOb = row[property.DBName];
                        }
                        else
                        {
                            propertyOb = GetDefaultValue(property);
                        }
                    }
                    else
                    {
                        IObjectProxy tempProxy = null;/// new SqlDataProxy(property.Model,conFac, LoadType.Null,con);
                        if (property.IsMultiMap == false)
                        {
                            if (String.IsNullOrEmpty(property.DBName) == false && row[property.DBName] != DBNull.Value)
                            {
                                tempProxy = getProxy(property.Model, row[property.DBName], con, conFac);
                            }
                            else
                            {
                                tempProxy = null;
                            }
                        }
                        else
                        {
                            var modelKeyProperty = property.Model.IdProperty;
                            if (modelKeyProperty != null)
                            {
                                var itemKeyProperrty = property.DBMaps.FirstOrDefault(p => p.PropertyName == modelKeyProperty.PropertyName);
                                if (itemKeyProperrty != null)
                                {
                                    var rowOb = row[itemKeyProperrty.DBColName];
                                    if (rowOb != DBNull.Value)
                                    {
                                        tempProxy = getProxy(property.Model, rowOb, con, conFac);

                                        tempProxy.IsLoad = LoadType.Null;
                                    }
                                }
                            }

                            bool IsSet = false;
                            foreach (var map in property.DBMaps)
                            {
                                var rowOb = row[map.DBColName];
                                if (rowOb != DBNull.Value)
                                {
                                    tempProxy[tempProxy.Model.Properties.First(p => p.Name == map.PropertyName ||
                                                                               p.PropertyName == map.PropertyName)] = rowOb;

                                    IsSet = true;
                                }
                            }
                            if (IsSet == false)
                            {
                                tempProxy = null;
                            }
                            else
                            {
                                tempProxy.IsLoad = LoadType.Partial;
                            }
                        }
                        propertyOb = tempProxy;
                    }


                    proxy[property] = propertyOb;
                    proxy.UpdateToNew(property);
                }
            }

            if (proxy.ID == null || (proxy.ID is long && System.Convert.ToInt64(proxy.ID) == 0))
            {
                if (proxy.Model.AutoSysId == false && proxy.Model.IdProperty != null)
                {
                    proxy.ID = proxy[proxy.Model.IdProperty];
                }
                else
                {
                    proxy.ID = row["SysId"];
                }
            }



            MemoryCache.StoreDbCache.UpdateOrAddDbMemoryCache(con, proxy.Model, proxy.ID, proxy);
            // System.Diagnostics.Trace.WriteLine( "Id:" + proxy.ID);
        }
Ejemplo n.º 16
0
 public SqlServerModelFactory(Soway.Model.SqlCon con, Context.ICurrentContextFactory conFac)
 {
     this.Con    = con;
     this.ConFac = conFac;
 }
Ejemplo n.º 17
0
 public AutoViewFactory(SqlCon con, Context.ICurrentContextFactory conFac)
 {
     this.Con    = con;
     this.ConFac = ConFac;
 }
Ejemplo n.º 18
0
 public ModelHelper(Context.ICurrentContextFactory conFac)
 {
     this.ConFac = conFac;
 }