コード例 #1
0
ファイル: UserInfo.xaml.cs プロジェクト: tgckpg/wenku10
        private void SetTemplate()
        {
            RCache = new RuntimeCache();

            RCache.POST(
                Shared.ShRequest.Server
                , Shared.ShRequest.MyProfile()
                , ( e, id ) =>
                {
                    try
                    {
                        JsonObject JDef = JsonStatus.Parse( e.ResponseString );
                        JsonObject JData = JDef.GetNamedObject( "data" );
                        var j = Dispatcher.RunIdleAsync( ( x ) => SetProfileData( JData ) );
                    }
                    catch ( Exception ex )
                    {
                        ShowErrorMessage( ex.Message );
                    }
                    MarkIdle();
                }
                , ( a, b, ex ) =>
                {
                    ShowErrorMessage( ex.Message );
                    MarkIdle();
                }
                , false
            );
        }
コード例 #2
0
        /// <summary>
        /// Gets an entity by the passed in Id
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The entity retrieved
        /// </returns>
        public TEntity Get(Guid key)
        {
            if (IsCachedRepository)
            {
                var fromCache = TryGetFromCache(key);
                if (fromCache.Success)
                {
                    return(fromCache.Result);
                }
            }

            var entity = PerformGet(key);

            if (entity != null)
            {
                RuntimeCache.GetCacheItem(GetCacheKey(key), () => entity);
            }

            if (entity != null)
            {
                entity.ResetDirtyProperties();
            }

            return(entity);
        }
コード例 #3
0
        /// <summary>
        /// Quotes all available ship methods
        /// </summary>
        /// <param name="tryGetCached">
        /// If set true the strategy will try to get a quote from cache
        /// </param>
        /// <returns>
        /// A collection of <see cref="IShipmentRateQuote"/>
        /// </returns>
        public override IEnumerable <IShipmentRateQuote> GetShipmentRateQuotes(bool tryGetCached = true)
        {
            var quotes = new List <IShipmentRateQuote>();

            foreach (var gwShipMethod in ShippingGatewayMethods)
            {
                var rateQuote = tryGetCached ? TryGetCachedShipmentRateQuote(Shipment, gwShipMethod) : default(ShipmentRateQuote);

                if (rateQuote == null)
                {
                    // REFACTOR-v3 this would only need happen if an attempt was to get cached, then not, then cached again
                    // without any changes.
                    RuntimeCache.ClearCacheItem(GetShipmentRateQuoteCacheKey(Shipment, gwShipMethod));

                    //// http://issues.merchello.com/youtrack/issue/M-458
                    //// Clones the shipment so that with each iteration so that we can have the same shipment
                    //// with different ship methods
                    //// REFACTOR-v3 clone should be inherent on ICloneableEntity
                    var attempt = gwShipMethod.QuoteShipment(Shipment.Clone());
                    if (attempt.Success)
                    {
                        rateQuote = attempt.Result;

                        RuntimeCache.GetCacheItem(GetShipmentRateQuoteCacheKey(Shipment, gwShipMethod), () => rateQuote, TimeSpan.FromMinutes(5));
                    }
                }

                if (rateQuote != null)
                {
                    quotes.Add(rateQuote);
                }
            }

            return(quotes);
        }
コード例 #4
0
        /// <summary>
        /// Gets the details of an existing subscription.
        /// </summary>
        /// <param name="subscriptionId">
        /// The subscription id.
        /// </param>
        /// <returns>
        /// The <see cref="Subscription"/>.
        /// </returns>
        public Subscription GetSubscription(string subscriptionId)
        {
            var cacheKey = MakeSubscriptionCacheKey(subscriptionId);

            if (Exists(subscriptionId))
            {
                var subscription = (Subscription)RuntimeCache.GetCacheItem(cacheKey);

                if (subscription != null)
                {
                    return(subscription);
                }

                var attempt = TryGetApiResult(() => BraintreeGateway.Subscription.Find(subscriptionId));

                if (!attempt.Success)
                {
                    return(null);
                }

                subscription = attempt.Result;
                return((Subscription)RuntimeCache.GetCacheItem(cacheKey, () => subscription));
            }

            return(null);
        }
コード例 #5
0
        /// <summary>
        /// Add the item to the runtime cache
        /// </summary>
        /// <param name="memberInfo">The member info type containing the data.</param>
        /// <param name="userInfo">The user info type containing the data.</param>
        internal static void AddUserToCache(MemberInfo memberInfo, UserInfo userInfo)
        {
            IHandler handler      = new LogHandler(ApplicationName, EventNamespace);
            double   cacheTimeOut = (double)handler.BaseHandlerConfigurationReader.MembershipCacheTimeOut;

            RuntimeCache.Add(memberInfo.UniqueHashcode, userInfo, cacheTimeOut);
        }
コード例 #6
0
        /// <summary>
        /// Updates an existing subscription
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Attempt"/>.
        /// </returns>
        public Attempt <Subscription> Update(SubscriptionRequest request)
        {
            Updating.RaiseEvent(new SaveEventArgs <SubscriptionRequest>(request), this);

            var attempt = TryGetApiResult(() => BraintreeGateway.Subscription.Update(request.Id, request));

            if (!attempt.Success)
            {
                return(Attempt <Subscription> .Fail(attempt.Exception));
            }

            var result = attempt.Result;

            if (result.IsSuccess())
            {
                Updated.RaiseEvent(new SaveEventArgs <Subscription>(result.Target), this);

                var cacheKey = MakeSubscriptionCacheKey(request.Id);
                RuntimeCache.ClearCacheItem(cacheKey);

                return(Attempt <Subscription> .Succeed(result.Target));
            }

            var error = new BraintreeApiException(result.Errors, result.Message);

            LogHelper.Error <BraintreeSubscriptionApiService>("Failed to create a subscription", error);

            return(Attempt <Subscription> .Fail(error));
        }
コード例 #7
0
        /// <summary>
        /// Gets <see cref="IEntityFilterGroup"/> by it's key.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="IEntityFilterGroup"/>.
        /// </returns>
        /// <remarks>
        /// TODO this is pretty brittle since it assumes the collection will be intended to be used as the special filter group.
        /// However, it merely builds a filter group using whatever collection and it's children - so Service should definitely
        /// have this as an internal method until we can refactor
        /// </remarks>
        public IEntityFilterGroup GetEntityFilterGroup(Guid key)
        {
            var cacheKey = Cache.CacheKeys.GetEntityCacheKey <IEntityFilterGroup>(key);
            var cached   = (IEntityFilterGroup)RuntimeCache.GetCacheItem(cacheKey);

            if (cached != null)
            {
                return(cached);
            }

            var collection = Get(key);

            if (collection == null)
            {
                return(null);
            }
            var query = Querying.Query <IEntityCollection> .Builder.Where(x => x.ParentKey == key);

            var children = GetByQuery(query);

            var filterGroup = new EntityFilterGroup(collection);

            foreach (var child in children)
            {
                filterGroup.Filters.Add(child);
            }

            return((IEntityFilterGroup)RuntimeCache.GetCacheItem(cacheKey, () => filterGroup));
        }
コード例 #8
0
        /// <summary>
        /// Gets a <see cref="PaymentMethod"/>.
        /// </summary>
        /// <param name="token">
        /// The token.
        /// </param>
        /// <returns>
        /// The <see cref="PaymentMethod"/>.
        /// </returns>
        public PaymentMethod GetPaymentMethod(string token)
        {
            var cacheKey = MakePaymentMethodCacheKey(token);

            if (Exists(token))
            {
                var paymentMethod = (PaymentMethod)RuntimeCache.GetCacheItem(cacheKey);

                if (paymentMethod != null)
                {
                    return(paymentMethod);
                }

                // this following should never happen as the Exists should cache it but its a good fallback
                var attempt = TryGetApiResult(() => BraintreeGateway.PaymentMethod.Find(token));

                if (attempt.Success)
                {
                    RuntimeCache.GetCacheItem(cacheKey, () => attempt.Result);
                }

                return(attempt.Success ? attempt.Result : null);
            }

            return(null);
        }
コード例 #9
0
 public void InsertCacheItem <T>(string cacheKey,
                                 CacheItemPriority priority,
                                 TimeSpan timeout,
                                 Func <T> getCacheItem)
 {
     RuntimeCache.InsertCacheItem <T>(cacheKey, getCacheItem, timeout, priority: priority);
 }
コード例 #10
0
        public IEnumerable <IContent> GetByPublishedVersion(IQuery <IContent> query)
        {
            // we WANT to return contents in top-down order, ie parents should come before children
            // ideal would be pure xml "document order" which can be achieved with:
            // ORDER BY substring(path, 1, len(path) - charindex(',', reverse(path))), sortOrder
            // but that's probably an overkill - sorting by level,sortOrder should be enough

            var sqlClause  = GetBaseQuery(false);
            var translator = new SqlTranslator <IContent>(sqlClause, query);
            var sql        = translator.Translate()
                             .Where <DocumentDto>(x => x.Published)
                             .OrderBy <NodeDto>(x => x.Level, SqlSyntax)
                             .OrderBy <NodeDto>(x => x.SortOrder, SqlSyntax);

            //NOTE: This doesn't allow properties to be part of the query
            var dtos = Database.Fetch <DocumentDto, ContentVersionDto, ContentDto, NodeDto, DocumentPublishedReadOnlyDto>(sql);

            foreach (var dto in dtos)
            {
                //Check in the cache first. If it exists there AND it is published
                // then we can use that entity. Otherwise if it is not published (which can be the case
                // because we only store the 'latest' entries in the cache which might not be the published
                // version)
                var fromCache = RuntimeCache.GetCacheItem <IContent>(GetCacheIdKey <IContent>(dto.NodeId));
                //var fromCache = TryGetFromCache(dto.NodeId);
                if (fromCache != null && fromCache.Published)
                {
                    yield return(fromCache);
                }
                else
                {
                    yield return(CreateContentFromDto(dto, dto.VersionId, sql));
                }
            }
        }
コード例 #11
0
        private void SetTemplate()
        {
            InitAppBar();

            RCache = new RuntimeCache();

            RCache.POST(
                Shared.ShRequest.Server
                , Shared.ShRequest.MyProfile()
                , (e, id) =>
            {
                try
                {
                    JsonObject JDef  = JsonStatus.Parse(e.ResponseString);
                    JsonObject JData = JDef.GetNamedObject("data");
                    var j            = Dispatcher.RunIdleAsync((x) => SetProfileData(JData));
                }
                catch (Exception ex)
                {
                    ShowErrorMessage(ex.Message);
                }
                MarkIdle();
            }
                , (a, b, ex) =>
            {
                ShowErrorMessage(ex.Message);
                MarkIdle();
            }
                , false
                );
        }
コード例 #12
0
ファイル: ScriptUpload.xaml.cs プロジェクト: MewX/wenku10
        public async Task <string> ReserveId(string AccessToken)
        {
            TaskCompletionSource <string> TCS = new TaskCompletionSource <string>();

            RuntimeCache RCache = new RuntimeCache();

            RCache.POST(
                Shared.ShRequest.Server
                , Shared.ShRequest.ReserveId(AccessToken)
                , (e, QueryId) =>
            {
                try
                {
                    JsonObject JDef = JsonStatus.Parse(e.ResponseString);
                    string Id       = JDef.GetNamedString("data");
                    TCS.SetResult(Id);
                }
                catch (Exception ex)
                {
                    Logger.Log(ID, ex.Message, LogType.WARNING);
                    TCS.TrySetResult(null);
                }
            }
                , (cache, Id, ex) =>
            {
                Logger.Log(ID, ex.Message, LogType.WARNING);
                TCS.TrySetResult(null);
            }
                , false
                );

            return(await TCS.Task);
        }
コード例 #13
0
        /// <summary>
        /// Quotes all available shipmethods
        /// </summary>
        /// <returns>A collection of <see cref="IShipmentRateQuote"/></returns>
        public override IEnumerable <IShipmentRateQuote> GetShipmentRateQuotes()
        {
            var quotes = new List <IShipmentRateQuote>();

            foreach (var gwShipMethod in ShippingGatewayMethods)
            {
                var rateQuote = TryGetCachedShipmentRateQuote(Shipment, gwShipMethod);

                if (rateQuote == null)
                {
                    var attempt = gwShipMethod.QuoteShipment(Shipment);
                    if (attempt.Success)
                    {
                        rateQuote = attempt.Result;

                        RuntimeCache.GetCacheItem(GetShipmentRateQuoteCacheKey(Shipment, gwShipMethod), () => rateQuote);
                    }
                }
                if (rateQuote != null)
                {
                    quotes.Add(rateQuote);
                }
            }

            return(quotes);
        }
コード例 #14
0
        /// <summary>
        /// The persist updated item.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistUpdatedItem(IProductVariant entity)
        {
            if (!MandateProductVariantRules(entity))
            {
                return;
            }

            Mandate.ParameterCondition(!SkuExists(entity.Sku, entity.Key), "Entity cannot be updated.  The sku already exists.");

            ((Entity)entity).UpdatingEntity();
            ((ProductVariant)entity).VersionKey = Guid.NewGuid();

            var factory = new ProductVariantFactory(
                pa => ((ProductVariant)entity).ProductAttributes,
                ci => ((ProductVariant)entity).CatalogInventoryCollection,
                dc => ((ProductVariant)entity).DetachedContents);

            var dto = factory.BuildDto(entity);

            // update the variant
            Database.Update(dto);

            SaveCatalogInventory(entity);

            SaveDetachedContents(entity);

            entity.ResetDirtyProperties();

            RuntimeCache.ClearCacheItem(Cache.CacheKeys.GetEntityCacheKey <IProduct>(entity.ProductKey));
        }
コード例 #15
0
        /// <summary>
        /// Creates a Braintree <see cref="Customer"/> from a Merchello <see cref="ICustomer"/>
        /// </summary>
        /// <param name="customer">
        /// The customer.
        /// </param>
        /// <param name="paymentMethodNonce">
        /// The "nonce-from-the-client"
        /// </param>
        /// <param name="billingAddress">
        /// The billing address
        /// </param>
        /// <param name="shippingAddress">
        /// The shipping Address.
        /// </param>
        /// <returns>
        /// The <see cref="Attempt{Customer}"/>.
        /// </returns>
        public Attempt <Customer> Create(ICustomer customer, string paymentMethodNonce = "", IAddress billingAddress = null, IAddress shippingAddress = null)
        {
            if (Exists(customer))
            {
                return(Attempt.Succeed(GetBraintreeCustomer(customer)));
            }

            var request = RequestFactory.CreateCustomerRequest(customer, paymentMethodNonce, billingAddress);

            Creating.RaiseEvent(new Core.Events.NewEventArgs <CustomerRequest>(request), this);

            // attempt the API call
            var attempt = TryGetApiResult(() => BraintreeGateway.Customer.Create(request));

            if (!attempt.Success)
            {
                return(Attempt <Customer> .Fail(attempt.Exception));
            }

            var result = attempt.Result;

            if (result.IsSuccess())
            {
                Created.RaiseEvent(new Core.Events.NewEventArgs <Customer>(result.Target), this);

                return(Attempt.Succeed((Customer)RuntimeCache.GetCacheItem(MakeCustomerCacheKey(customer), () => result.Target)));
            }

            var error = new BraintreeApiException(result.Errors);

            LogHelper.Error <BraintreeCustomerApiService>("Braintree API Customer Create return a failure", error);

            return(Attempt <Customer> .Fail(error));
        }
コード例 #16
0
        /// <summary>
        /// Updates a payment method
        /// </summary>
        /// <param name="token">The payment method token</param>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="Attempt"/>.
        /// </returns>
        public Attempt <PaymentMethod> Update(string token, PaymentMethodRequest request)
        {
            Mandate.ParameterNotNull(request, "request");

            Updating.RaiseEvent(new SaveEventArgs <PaymentMethodRequest>(request), this);

            var attempt = TryGetApiResult(() => BraintreeGateway.PaymentMethod.Update(token, request));

            if (!attempt.Success)
            {
                return(Attempt <PaymentMethod> .Fail(attempt.Exception));
            }

            var result = attempt.Result;

            if (result.IsSuccess())
            {
                var cacheKey = MakePaymentMethodCacheKey(token);

                RuntimeCache.ClearCacheItem(cacheKey);

                Updated.RaiseEvent(new SaveEventArgs <PaymentMethod>(result.Target), this);

                return(Attempt <PaymentMethod> .Succeed((PaymentMethod)RuntimeCache.GetCacheItem(cacheKey, () => result.Target)));
            }

            var error = new BraintreeApiException(result.Errors, result.Message);

            LogHelper.Error <BraintreePaymentMethodApiService>("Failed to update payment method", error);

            return(Attempt <PaymentMethod> .Fail(error));
        }
コード例 #17
0
ファイル: HSLoader.cs プロジェクト: MewX/wenku10
 public HSLoader(string Id, SharersRequest.SHTarget Target, Func <SharersRequest.SHTarget, int, uint, string[], PostData> PostArgs)
 {
     RCache        = new RuntimeCache();
     this.Id       = Id;
     this.Target   = Target;
     this.PostArgs = PostArgs;
 }
コード例 #18
0
        /// <summary>
        /// Quotes all available ship methods
        /// </summary>
        /// <param name="tryGetCached">
        /// If set true the strategy will try to get a quote from cache
        /// </param>
        /// <returns>
        /// A collection of <see cref="IShipmentRateQuote"/>
        /// </returns>
        public override IEnumerable <IShipmentRateQuote> GetShipmentRateQuotes(bool tryGetCached = true)
        {
            var quotes = new List <IShipmentRateQuote>();

            foreach (var gwShipMethod in ShippingGatewayMethods)
            {
                var rateQuote = tryGetCached ? TryGetCachedShipmentRateQuote(Shipment, gwShipMethod) : default(ShipmentRateQuote);

                if (rateQuote == null)
                {
                    RuntimeCache.ClearCacheItem(GetShipmentRateQuoteCacheKey(Shipment, gwShipMethod));

                    //// http://issues.merchello.com/youtrack/issue/M-458
                    //// Clones the shipment so that with each iteration so that we can have the same shipment
                    //// with different ship methods
                    var attempt = gwShipMethod.QuoteShipment(Shipment.Clone());
                    if (attempt.Success)
                    {
                        rateQuote = attempt.Result;

                        RuntimeCache.GetCacheItem(GetShipmentRateQuoteCacheKey(Shipment, gwShipMethod), () => rateQuote);
                    }
                }

                if (rateQuote != null)
                {
                    quotes.Add(rateQuote);
                }
            }

            return(quotes);
        }
コード例 #19
0
ファイル: Register.xaml.cs プロジェクト: MewX/wenku10
        private void DetectInputLogin()
        {
            string Name    = Account.Text.Trim();
            string Passwd  = Password.Password;
            string PasswdV = PasswordV.Password;
            string Email   = EmailInput.Text.Trim();

            if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Passwd) || string.IsNullOrEmpty(PasswdV) || string.IsNullOrEmpty(Email))
            {
                if (string.IsNullOrEmpty(Name))
                {
                    Account.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(Passwd))
                {
                    Password.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(PasswdV))
                {
                    PasswordV.Focus(FocusState.Keyboard);
                }
                else if (string.IsNullOrEmpty(Email))
                {
                    EmailInput.Focus(FocusState.Keyboard);
                }
            }
            else if (Passwd != PasswdV)
            {
                StringResources stx = StringResources.Load("Error");
                ServerMessage.Text = stx.Str("PasswordMismatch");
                Password.Focus(FocusState.Keyboard);
            }
            else
            {
                ServerMessage.Text = "";

                IsPrimaryButtonEnabled
                              = IsSecondaryButtonEnabled
                              = Account.IsEnabled
                              = Password.IsEnabled
                              = PasswordV.IsEnabled
                              = EmailInput.IsEnabled
                              = false
                    ;

                this.Focus(FocusState.Pointer);

                IndicateLoad();

                RuntimeCache RCache = new RuntimeCache()
                {
                    EN_UI_Thead = true
                };
                RCache.POST(
                    Shared.ShRequest.Server
                    , Shared.ShRequest.Register(Name, Passwd, Email)
                    , RequestComplete, RequestFailed, false);
            }
        }
コード例 #20
0
        protected override void PersistDeletedItem(ILanguage entity)
        {
            base.PersistDeletedItem(entity);

            //Clear the cache entries that exist by key/iso
            RuntimeCache.ClearCacheItem(GetCacheIdKey <ILanguage>(entity.IsoCode));
            RuntimeCache.ClearCacheItem(GetCacheIdKey <ILanguage>(entity.CultureName));
        }
コード例 #21
0
 /// <summary>
 /// Removes products from cache.
 /// </summary>
 /// <param name="productKeys">
 /// The product keys of products that need to be removed from cache.
 /// </param>
 private void RemoveProductsFromRuntimeCache(IEnumerable <Guid> productKeys)
 {
     // clear the cache for other products affected
     foreach (var key in productKeys)
     {
         RuntimeCache.ClearCacheItem(Cache.CacheKeys.GetEntityCacheKey <IProduct>(key));
     }
 }
コード例 #22
0
        /// <summary>
        /// The persist deleted item.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistDeletedItem(IEntityCollection entity)
        {
            base.PersistDeletedItem(entity);

            if (entity.ParentKey != null)
            {
                RuntimeCache.ClearCacheItem(Cache.CacheKeys.GetEntityCacheKey <IEntityFilterGroup>(entity.ParentKey.Value));
            }
        }
コード例 #23
0
        public async Task Load()
        {
            RuntimeCache wCache = new RuntimeCache();

            TaskCompletionSource <int> TCS = new TaskCompletionSource <int>();

            List <Announcements> News = new List <Announcements>();
            int i = 0;

            wCache.GET(
                new Uri(BULLETIN + BULLETIN_CH)
                , (DRequestCompletedEventArgs e, string id) =>
            {
                News.Add(new Announcements(e.ResponseString));
                if (++i == 2)
                {
                    TCS.SetResult(i);
                }
            }
                , (string id, string url, Exception ex) =>
            {
                PushItem();
                if (++i == 2)
                {
                    TCS.SetResult(i);
                }
            }
                , false);

            wCache.GET(
                new Uri(BULLETIN + BULLETIN_ALL)
                , (DRequestCompletedEventArgs e, string id) =>
            {
                News.Add(new Announcements(e.ResponseString));
                if (++i == 2)
                {
                    TCS.SetResult(i);
                }
            }
                , (string id, string url, Exception ex) =>
            {
                PushItem();
                if (++i == 2)
                {
                    TCS.SetResult(i);
                }
            }
                , false);


            await TCS.Task;

            foreach (Announcements A in News)
            {
                PushItem(A);
            }
        }
コード例 #24
0
        /// <summary>
        /// The try get from cache.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="Attempt"/>.
        /// </returns>
        protected Attempt <TEntity> TryGetFromCache(Guid key)
        {
            var cacheKey = GetCacheKey(key);

            var retEntity = RuntimeCache.GetCacheItem(cacheKey);

            return(retEntity != null ?
                   Attempt <TEntity> .Succeed((TEntity)retEntity) :
                   Attempt <TEntity> .Fail());
        }
コード例 #25
0
        /// <summary>
        /// The persist deleted item.
        /// </summary>
        /// <param name="entity">
        /// The entity to be deleted
        /// </param>
        protected override void PersistDeletedItem(ICustomerAddress entity)
        {
            var deletes = GetDeleteClauses();

            foreach (var delete in deletes)
            {
                Database.Execute(delete, new { Key = entity.Key });
            }

            RuntimeCache.ClearCacheItem(Cache.CacheKeys.GetEntityCacheKey <ICustomer>(entity.CustomerKey));
        }
コード例 #26
0
        /// <summary>
        /// The persist deleted item.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistDeletedItem(IProductVariant entity)
        {
            var deletes = GetDeleteClauses();

            foreach (var delete in deletes)
            {
                Database.Execute(delete, new { entity.Key });
            }

            RuntimeCache.ClearCacheItem(Cache.CacheKeys.GetEntityCacheKey <IProduct>(entity.ProductKey));
        }
コード例 #27
0
        protected override void PersistDeletedItem(IDictionaryItem entity)
        {
            RecursiveDelete(entity.Key);

            Database.Delete <LanguageTextDto>("WHERE UniqueId = @Id", new { Id = entity.Key });
            Database.Delete <DictionaryDto>("WHERE id = @Id", new { Id = entity.Key });

            //Clear the cache entries that exist by uniqueid/item key
            RuntimeCache.ClearCacheItem(GetCacheIdKey <IDictionaryItem>(entity.ItemKey));
            RuntimeCache.ClearCacheItem(GetCacheIdKey <IDictionaryItem>(entity.Key));
        }
コード例 #28
0
        /// <summary>
        /// Get the current user data from the cache.
        /// </summary>
        /// <returns>The user information for the cuurent session.</returns>
        public static UserInfo GetUserInfo()
        {
            if (UserOnlineController.CurrentUser == null)
            {
                throw new Exception("No current session data has been set.");
            }

            UserInfo userInfo = ((UserInfo)RuntimeCache.Get(UserOnlineController.CurrentUser.UniqueHashcode));

            return(userInfo);
        }
コード例 #29
0
        public SharersHub()
        {
            SearchSet = new Observables <HubScriptItem, HubScriptItem>();

            RCache = new RuntimeCache();

            MessageBus.Subscribe(this, MessageBus_OnDelivery);

            SearchSet.LoadStart += (s, e) => { Searching = true; };
            SearchSet.LoadEnd   += (s, e) => { Searching = false; };
        }
コード例 #30
0
        /// <summary>
        /// Deletes a persisted warehouse catalog
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistDeletedItem(IWarehouseCatalog entity)
        {
            var deletes = GetDeleteClauses();

            foreach (var delete in deletes)
            {
                Database.Execute(delete, new { entity.Key });
            }

            RuntimeCache.ClearCacheItem(Cache.CacheKeys.GetEntityCacheKey <IWarehouse>(entity.WarehouseKey));
        }
コード例 #31
0
        /// <summary>
        /// Persists an updated warehouse catalog.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistUpdatedItem(IWarehouseCatalog entity)
        {
            ((Entity)entity).AddingEntity();

            var factory = new WarehouseCatalogFactory();
            var dto     = factory.BuildDto(entity);

            Database.Update(dto);
            entity.ResetDirtyProperties();

            RuntimeCache.ClearCacheItem(Cache.CacheKeys.GetEntityCacheKey <IWarehouse>(entity.WarehouseKey));
        }
コード例 #32
0
 public static NHExt.Runtime.Cache.AbstractCache<string, object> GetRuntimeCache()
 {
     lock (locker)
     {
         AbstractCache<string, object> cache = AbstractCache<string, object>.GetInstance("NHExt.Runtime.Cache.RuntimeCache");
         if (cache == null)
         {
             cache = new RuntimeCache();
         }
         return cache;
     }
 }
コード例 #33
0
ファイル: PlaceRequest.xaml.cs プロジェクト: tgckpg/wenku10
        private async void SetTemplate()
        {
            MarkLoading();

            RCache = new RuntimeCache();
            RemarksInput.PlaceholderText = RemarksPlaceholder;
            RSA = await RSAManager.CreateAsync();
            RSA.PropertyChanged += RSA_PropertyChanged;
            Keys.DataContext = RSA;
            PreSelectKey();

            Keys.IsEnabled = true;
            MarkIdle();
        }
コード例 #34
0
ファイル: SharersHub.cs プロジェクト: tgckpg/wenku10
        public SharersHub()
        {
            Activities = new ObservableCollection<Activity>();
            SearchSet = new Observables<HubScriptItem, HubScriptItem>();

            RCache = new RuntimeCache();
            Grants = new SHGrant[ 0 ];
            Member = X.Singleton<IMember>( XProto.SHMember );
            Member.OnStatusChanged += Member_OnStatusChanged;

            MessageBus.OnDelivery += MessageBus_OnDelivery;

            SearchSet.LoadStart += ( s, e ) => { Searching = true; };
            SearchSet.LoadEnd += ( s, e ) => { Searching = false; };

            UpdateLLText();
        }
コード例 #35
0
ファイル: LocalTextScope.cs プロジェクト: tgckpg/wenku10
        public void LoadUrl( LocalModeTxtList.DownloadBookContext Context )
        {
            RuntimeCache rCache = new RuntimeCache();
            Logger.Log( ID, Context.Id, LogType.DEBUG );
            Logger.Log( ID, Context.Title, LogType.DEBUG );

            Worker.UIInvoke( () =>
            {
                StringResources stx = new StringResources( "AdvDM" );
                Loading = stx.Text( "Active" );
            } );

            rCache.GET( Context.Url, ( e, url ) =>
            {
                Loading = null;
                SaveTemp( e, Context );
            }
            , ( id, url, ex ) =>
            {
                Logger.Log( ID, "Cannot download: " + id, LogType.WARNING );
                Logger.Log( ID, ex.Message, LogType.WARNING );

            }, false );
        }
コード例 #36
0
 public void SetUp()
 {
     _cachePathBuilder = MockRepository.GenerateMock<ICacheFilePathBuilder>();
     _cache = new RuntimeCache();
 }
コード例 #37
0
ファイル: ChangePassword.xaml.cs プロジェクト: tgckpg/wenku10
        private void DetectInputLogin()
        {
            string CurrPasswd = CurrentPassword.Password;
            string NewPasswd = Password.Password;
            string PasswdV = PasswordV.Password;

            if ( string.IsNullOrEmpty( CurrPasswd ) || string.IsNullOrEmpty( NewPasswd ) || string.IsNullOrEmpty( PasswdV ) )
            {
                if ( string.IsNullOrEmpty( CurrPasswd ) )
                {
                    CurrentPassword.Focus( FocusState.Keyboard );
                }
                else if ( string.IsNullOrEmpty( NewPasswd ) )
                {
                    Password.Focus( FocusState.Keyboard );
                }
                else if( string.IsNullOrEmpty( PasswdV ) )
                {
                    PasswordV.Focus( FocusState.Keyboard );
                }
            }
            else if( NewPasswd != PasswdV )
            {
                StringResources stx = new StringResources( "Error" );
                ServerMessage.Text = stx.Str( "PasswordMismatch" );
                Password.Focus( FocusState.Keyboard );
            }
            else
            {
                ServerMessage.Text = "";

                IsPrimaryButtonEnabled
                    = IsSecondaryButtonEnabled
                    = CurrentPassword.IsEnabled
                    = Password.IsEnabled
                    = PasswordV.IsEnabled
                    = false
                    ;

                this.Focus( FocusState.Pointer );

                IndicateLoad();

                RuntimeCache RCache = new RuntimeCache() { EN_UI_Thead = true };
                RCache.POST(
                    Shared.ShRequest.Server
                    , Shared.ShRequest.ChangePassword( CurrPasswd, NewPasswd )
                    , RequestComplete, RequestFailed, false );
            }
        }
コード例 #38
0
ファイル: ScriptUpload.xaml.cs プロジェクト: tgckpg/wenku10
        public async Task<string> ReserveId( string AccessToken )
        {
            TaskCompletionSource<string> TCS = new TaskCompletionSource<string>();

            RuntimeCache RCache = new RuntimeCache();
            RCache.POST(
                Shared.ShRequest.Server
                , Shared.ShRequest.ReserveId( AccessToken )
                , ( e, QueryId ) =>
                {
                    try
                    {
                        JsonObject JDef = JsonStatus.Parse( e.ResponseString );
                        string Id = JDef.GetNamedString( "data" );
                        TCS.SetResult( Id );
                    }
                    catch( Exception ex )
                    {
                        Logger.Log( ID, ex.Message, LogType.WARNING );
                        TCS.TrySetResult( null );
                    }
                }
                , ( cache, Id, ex ) =>
                {
                    Logger.Log( ID, ex.Message, LogType.WARNING );
                    TCS.TrySetResult( null );
                }
                , false
            );

            return await TCS.Task;
        }
コード例 #39
0
ファイル: Register.xaml.cs プロジェクト: tgckpg/wenku10
        private void DetectInputLogin()
        {
            string Name = Account.Text.Trim();
            string Passwd = Password.Password;
            string PasswdV = PasswordV.Password;
            string Email = EmailInput.Text.Trim();

            if ( string.IsNullOrEmpty( Name ) || string.IsNullOrEmpty( Passwd ) || string.IsNullOrEmpty( PasswdV ) || string.IsNullOrEmpty( Email ) )
            {
                if ( string.IsNullOrEmpty( Name ) )
                {
                    Account.Focus( FocusState.Keyboard );
                }
                else if ( string.IsNullOrEmpty( Passwd ) )
                {
                    Password.Focus( FocusState.Keyboard );
                }
                else if( string.IsNullOrEmpty( PasswdV ) )
                {
                    PasswordV.Focus( FocusState.Keyboard );
                }
                else if( string.IsNullOrEmpty( Email ) )
                {
                    EmailInput.Focus( FocusState.Keyboard );
                }
            }
            else if( Passwd != PasswdV )
            {
                StringResources stx = new StringResources( "Error" );
                ServerMessage.Text = stx.Str( "PasswordMismatch" );
                Password.Focus( FocusState.Keyboard );
            }
            else
            {
                ServerMessage.Text = "";

                IsPrimaryButtonEnabled
                    = IsSecondaryButtonEnabled
                    = Account.IsEnabled
                    = Password.IsEnabled
                    = PasswordV.IsEnabled
                    = EmailInput.IsEnabled
                    = false
                    ;

                this.Focus( FocusState.Pointer );

                IndicateLoad();

                RuntimeCache RCache = new RuntimeCache() { EN_UI_Thead = true };
                RCache.POST(
                    Shared.ShRequest.Server
                    , Shared.ShRequest.Register( Name, Passwd, Email )
                    , RequestComplete, RequestFailed, false );
            }
        }