Ejemplo n.º 1
0
        protected virtual void PreLoadExecute(IDictionary <string, IStorageContext> storageContexts)
        {
            foreach (KeyValuePair <string, IStorageContext> context in storageContexts)
            {
                IStorageContext storageContext = context.Value;
                string          sConnection    = StorageParser.BuildConnectionString(storageContext.Storage);
                storageContext.Connection =
                    storageContext.Storage.Pooling
                        ?
                    DbConnectionPoolManager.GetConnection(storageContext.StorageName, sConnection)
                        :
                    DatabaseFactory.GetDbConnection(storageContext.Storage.DatabaseStyle, sConnection);

                try
                {
                    if (ConnectionState.Open != storageContext.Connection.State)
                    {
                        storageContext.Connection.Open();
                    }
                }
                catch (Exception exc)
                {
                    IStorageAttribute storageAttr = (IStorageAttribute)StorageCache.Get(storageContext.StorageName);
                    storageAttr.IsHealth = false;
                    UnhealthyStorage.Add(storageAttr.Name);
                    if (null != Logger)
                    {
                        Logger.WarnFormat("Storage:{0} can not open.Set the health is false and it not used until the health set true.", storageAttr.Name);
                    }
                    IConnectionNotify notify = AlbianServiceRouter.GetService <IConnectionNotify>();
                    if (null != notify)
                    {
                        Logger.Info("send message when open database is error.");
                        string msg = string.Format("Server:{0},Database:{1},Exception Message:{2}.", storageContext.Storage.Server, storageContext.Storage.Database, exc.Message);
                        notify.SendMessage(msg);
                    }
                    throw exc;
                }
                if (storageContext.Storage.Transactional)
                {
                    storageContext.Transaction =
                        storageContext.Connection.BeginTransaction(IsolationLevel.ReadUncommitted);
                }
                foreach (IFakeCommandAttribute fc in storageContext.FakeCommand)
                {
                    IDbCommand cmd = storageContext.Connection.CreateCommand();
                    cmd.CommandText = fc.CommandText;
                    cmd.CommandType = CommandType.Text;
                    if (storageContext.Storage.Transactional)
                    {
                        cmd.Transaction = storageContext.Transaction;
                    }
                    foreach (DbParameter para in fc.Paras)
                    {
                        cmd.Parameters.Add(para);
                    }
                    storageContext.Command.Add(cmd);
                }
            }
        }
Ejemplo n.º 2
0
        protected void btnModify_Click(object sender, EventArgs e)
        {
            IBizOffer bizoffer = AlbianServiceRouter.GetService <IBizofferOperation>().LoadBizOffer(txtId.Text);

            bizoffer.Creator        = txtSellerId.Text;
            bizoffer.Description    = txtDesc.Text;
            bizoffer.Discount       = null;
            bizoffer.IsDiscount     = null;
            bizoffer.LastModifier   = txtSellerId.Text;
            bizoffer.LastModifyTime = DateTime.Now;
            bizoffer.LastPrice      = decimal.Parse(txtPrice.Text);
            bizoffer.Name           = txtName.Text;
            bizoffer.Price          = decimal.Parse(txtPrice.Text);
            bizoffer.SellerId       = txtSellerId.Text;
            bizoffer.SellerName     = txtSellerName.Text;
            bizoffer.State          = BizofferState.Create;
            if (AlbianServiceRouter.GetService <IBizofferOperation>().Modify(bizoffer))
            {
                txtId.Text = bizoffer.Id;
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Save",
                                                       "<script language=\"javascript\" type=\"text/javascript\">alert(\"Modify Success!\");</script>");
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Save",
                                                       "<script language=\"javascript\" type=\"text/javascript\">alert(\"Modify Fail!\");</script>");
            }
        }
Ejemplo n.º 3
0
        public static IList <T> GetCachingObjects <T>(string routingName, int top, IFilterCondition[] where,
                                                      IOrderByCondition[] orderby)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return(null);
            }
            string         cachedKey     = Utils.GetCacheKey <T>(routingName, top, where, orderby);
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return(null);
            }
            object oTarget = cachedService.Get(cachedKey);

            if (null == oTarget)
            {
                return(null);
            }
            return((IList <T>)oTarget);
        }
Ejemplo n.º 4
0
        public static IList <T> GetCachingObjects <T>(IDbCommand cmd)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return(null);
            }
            string         cachedKey     = Utils.GetCacheKey <T>(cmd);
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return(null);
            }
            object oTarget = cachedService.Get(cachedKey);

            if (null == oTarget)
            {
                return(null);
            }
            return((IList <T>)oTarget);
        }
Ejemplo n.º 5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            IBizOffer bizoffer = AlbianObjectFactory.CreateInstance <BizOffer>();

            bizoffer.Id             = AlbianObjectFactory.CreateId("BOFF");
            bizoffer.CreateTime     = DateTime.Now;
            bizoffer.Creator        = txtSellerId.Text;
            bizoffer.Description    = txtDesc.Text;
            bizoffer.Discount       = null;
            bizoffer.IsDiscount     = null;
            bizoffer.LastModifier   = txtSellerId.Text;
            bizoffer.LastModifyTime = DateTime.Now;
            bizoffer.LastPrice      = decimal.Parse(txtPrice.Text);
            bizoffer.Name           = txtName.Text;
            bizoffer.Price          = decimal.Parse(txtPrice.Text);
            bizoffer.SellerId       = txtSellerId.Text;
            bizoffer.SellerName     = txtSellerName.Text;
            bizoffer.State          = BizofferState.Create;
            if (AlbianServiceRouter.GetService <IBizofferOperation>().Create(bizoffer))
            {
                txtId.Text = bizoffer.Id;
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Save",
                                                       "<script language=\"javascript\" type=\"text/javascript\">alert(\"Create Success!\");</script>");
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Save",
                                                       "<script language=\"javascript\" type=\"text/javascript\">alert(\"Create Fail!\");</script>");
            }
            sw.Stop();
            Response.Write(sw.ElapsedMilliseconds);
        }
Ejemplo n.º 6
0
        public static T GetCachingObject <T>(string routingName, IFilterCondition[] where)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return(null);
            }
            string cachedKey = null != where && 1 == where.Length && "id" == where[0].PropertyName.ToLower()
                                   ? Utils.GetCacheKey <T>(where[0].Value.ToString(), AssemblyManager.GetFullTypeName <T>()) //find by pk id
                                   : Utils.GetCacheKey <T>(routingName, 0, where, null);

            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return(null);
            }
            object oTarget = cachedService.Get(cachedKey);

            if (null == oTarget)
            {
                return(null);
            }
            return((T)oTarget);
        }
Ejemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         IList <BizOffer> bizoffers = AlbianServiceRouter.GetService <IBizofferOperation>().FindBizoffer();
         gv.DataSource = bizoffers;
         gv.DataBind();
     }
 }
Ejemplo n.º 8
0
        protected void btnFind_Click(object sender, EventArgs e)
        {
            IBizOffer bizoffer = AlbianServiceRouter.GetService <IBizofferOperation>().FindBizOffer(txtId.Text);

            txtDesc.Text       = bizoffer.Description;
            txtId.Text         = bizoffer.Id;
            txtName.Text       = bizoffer.Name;
            txtPrice.Text      = bizoffer.Price.ToString();
            txtSellerId.Text   = bizoffer.SellerId;
            txtSellerName.Text = bizoffer.SellerName;
        }
Ejemplo n.º 9
0
        public bool Create(IUser user)
        {
            IUserDao dao = AlbianServiceRouter.ObjectGenerator <UserDao, IUserDao>();
            ILogInfo log = AlbianObjectFactory.CreateInstance <LogInfo>();

            log.Content    = string.Format("创建用户,用户id为:{0}", user.Id);
            log.CreateTime = DateTime.Now;
            log.Creator    = user.Id;
            log.Id         = AlbianObjectFactory.CreateId("Log");
            log.Style      = InfoStyle.Registr;
            IList <IAlbianObject> infos = new List <IAlbianObject> {
                user, log
            };

            return(dao.Create(infos));
        }
Ejemplo n.º 10
0
        public virtual bool Modify(IBizOffer bizoffer)
        {
            ILogInfo log = AlbianObjectFactory.CreateInstance <LogInfo>();

            log.Content    = string.Format("修改发布单,发布单id为:{0}", bizoffer.Id);
            log.CreateTime = DateTime.Now;
            log.Creator    = bizoffer.Id;
            log.Id         = AlbianObjectFactory.CreateId("Log");
            log.Style      = InfoStyle.Publish;

            IList <IAlbianObject> list = new List <IAlbianObject> {
                bizoffer, log
            };
            IBizofferDao dao = AlbianServiceRouter.ObjectGenerator <BizofferDao, IBizofferDao>();

            return(dao.Modify(list));
        }
Ejemplo n.º 11
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            IUser user = AlbianObjectFactory.CreateInstance <User>();

            user.Id             = AlbianObjectFactory.CreateId("User");
            user.CreateTime     = DateTime.Now;
            user.Creator        = user.Id;
            user.LastModifier   = user.Id;
            user.LastMofidyTime = DateTime.Now;
            user.Mail           = txtMail.Text;
            user.Mobile         = txtMobile.Text;
            user.Nickname       = txtNickName.Text;
            user.Password       = txtPassword.Text;
            user.RegistrDate    = DateTime.Now;
            user.UserName       = txtUserName.Text;
            bool isSuccess = AlbianServiceRouter.GetService <IUserOperation>().Create(user);

            txtID.Text = user.Id;
        }
Ejemplo n.º 12
0
        public static void CachingObjects <T>(IDbCommand cmd, IList <T> target)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return;
            }
            string         cachedKey     = Utils.GetCacheKey <T>(cmd);
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return;
            }
            cachedService.InsertOrUpdate(cachedKey, target, cache.LifeTime);
        }
Ejemplo n.º 13
0
        public static void CachingObject <T>(T target)
            where T : class, IAlbianObject
        {
            ICacheAttribute cacheAttr = GetCacheAttribute(target);

            if (null == cacheAttr || !cacheAttr.Enable)
            {
                return;
            }
            string         cachedKey     = Utils.GetCacheKey <T>(target.Id, AssemblyManager.GetFullTypeName(target));
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return;
            }
            cachedService.InsertOrUpdate(cachedKey, target, cacheAttr.LifeTime);
        }
Ejemplo n.º 14
0
        public bool Modify(string id, string nickName)
        {
            IUserDao dao  = AlbianServiceRouter.ObjectGenerator <UserDao, IUserDao>();
            IUser    user = dao.Load(id);

            user.Nickname       = nickName;
            user.LastMofidyTime = DateTime.Now;
            user.LastModifier   = id;

            ILogInfo log = AlbianObjectFactory.CreateInstance <LogInfo>();

            log.Content    = string.Format("修改用户,用户id为:{0}", user.Id);
            log.CreateTime = DateTime.Now;
            log.Creator    = user.Id;
            log.Id         = AlbianObjectFactory.CreateId("Log");
            log.Style      = InfoStyle.Modify;
            IList <IAlbianObject> infos = new List <IAlbianObject> {
                user, log
            };

            return(dao.Modify(infos));
        }
Ejemplo n.º 15
0
        public static void CachingObjects <T>(string routingName, int top, IFilterCondition[] where,
                                              IOrderByCondition[] orderby, IList <T> target)
            where T : class, IAlbianObject
        {
            ICacheAttribute cache = GetCacheAttribute <T>();

            if (null == cache || !cache.Enable)
            {
                return;
            }
            string         cachedKey     = Utils.GetCacheKey <T>(routingName, top, where, orderby);
            IExpiredCached cachedService = AlbianServiceRouter.GetService <IExpiredCached>();

            if (null == cachedService)
            {
                if (null != Logger)
                {
                    Logger.Warn("No expired cached service.");
                }
                return;
            }
            cachedService.InsertOrUpdate(cachedKey, target, cache.LifeTime);
        }
Ejemplo n.º 16
0
        public virtual IBizOffer LoadBizOffer(string id)
        {
            IBizofferDao dao = AlbianServiceRouter.ObjectGenerator <BizofferDao, IBizofferDao>();

            return(dao.Load("IdRouting", id));
        }
Ejemplo n.º 17
0
        public IList <BizOffer> FindBizoffer()
        {
            IBizofferDao dao = AlbianServiceRouter.ObjectGenerator <BizofferDao, IBizofferDao>();

            return(dao.FindBizoffer());
        }
Ejemplo n.º 18
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     bool isSuccess = AlbianServiceRouter.GetService <IUserOperation>().Modify(txtID.Text, txtNickName.Text);
 }