Esempio n. 1
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>");
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
                }
            }
        }
Esempio n. 5
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);
        }
Esempio 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);
        }
Esempio 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();
     }
 }
Esempio 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;
        }
Esempio n. 9
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;
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     bool isSuccess = AlbianServiceRouter.GetService <IUserOperation>().Modify(txtID.Text, txtNickName.Text);
 }