Esempio n. 1
0
        public void SetStoreStatus(int erpStoreId, String token, StoreStatus status)
        {
            var postDict = new SortedDictionary <string, string>();

            postDict["appAuthToken"] = token;
            postDict["charset"]      = "utf-8";
            postDict["timestamp"]    = (Helper.ConvertDateTimeInt(DateTime.Now)).ToString();
            postDict["sign"]         = MeituanHelper.Sign(postDict, this.Config.SignKey);
            var url     = status == StoreStatus.Opened ? "http://api.open.cater.meituan.com/waimai/poi/open" : "http://api.open.cater.meituan.com/waimai/poi/close";
            var result  = Helper.PostQueryString(url, postDict, 8000);
            var jsonObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result);

            Newtonsoft.Json.Linq.JToken errobj;
            if (jsonObj.TryGetValue("error", StringComparison.CurrentCultureIgnoreCase, out errobj))
            {
                throw new Exception(errobj.Value <string>("message"));
            }
            if (!string.Equals(jsonObj.Value <string>("data"), "ok", StringComparison.CurrentCultureIgnoreCase))
            {
                throw new Exception("发生错误");
            }
        }
Esempio n. 2
0
        public override bool StoreMessage(string topic, Message message, OperationContext context)
        {
            Topic topicInstance = _topicManager.GetTopic(topic);
            bool  stored        = false;

            if (topicInstance != null)
            {
                StoreStatus status = _cacheStore.HasSpace(message, 0, true);

                _cacheStore.CheckIfCacheNearEviction();

                if (status == StoreStatus.HasSpace || status == StoreStatus.NearEviction)
                {
                    stored = topicInstance.StoreMessage(message, context);
                }

                if (_context.PerfStatsColl != null)
                {
                    _context.PerfStatsColl.SetCacheSize(Size);
                }

                if (status != StoreStatus.HasSpace)
                {
                    Evict();
                }

                if (status == StoreStatus.HasNotEnoughSpace)
                {
                    throw new OperationFailedException("The cache is full and not enough items could be evicted.");
                }
            }
            else
            {
                throw new OperationFailedException(string.Format("Topic '{0}' does not exists.", topic));
            }

            return(stored);
        }
Esempio n. 3
0
        /// <summary>
        /// Provides implementation of Insert method of the ICacheStorage interface. Insert
        /// the key value pair to the store.
        /// </summary>
        /// <param name="key">key</param>
        /// <param name="item">object</param>
        /// <returns>returns the result of operation.</returns>
        public override StoreInsResult Insert(object key, IStorageEntry item, Boolean allowExtendedSize)
        {
            try
            {
                MmfObjectPtr  info    = (MmfObjectPtr)_itemDict[key];
                IStorageEntry oldItem = null;

                if (info == null)
                {
                    StoreAddResult res = Add(key, item, allowExtendedSize);
                    switch (res)
                    {
                    case StoreAddResult.NotEnoughSpace: return(StoreInsResult.NotEnoughSpace);

                    case StoreAddResult.Failure: return(StoreInsResult.Failure);
                    }
                    return(StoreInsResult.Success);
                }

                oldItem = (IStorageEntry)Get(key);

                StoreStatus status = HasSpace(oldItem as ISizable, (ISizable)item, Common.MemoryUtil.GetStringSize(key), allowExtendedSize);

                if (status == StoreStatus.HasNotEnoughSpace)
                {
                    return(StoreInsResult.NotEnoughSpace);
                }

                byte[] buffer = StoreItem.ToBinary(key, item, CacheContext);
                lock (_itemDict.SyncRoot)
                {
                    MmfObjectPtr newInfo = _internalStore.Insert(info, buffer);
                    if (newInfo == null)
                    {
                        return(StoreInsResult.NotEnoughSpace);
                    }
                    else
                    {
                        if (newInfo.Arena != info.Arena)
                        {
                            _itemDict[key] = newInfo;
                            _internalStore.Remove(info);
                        }

                        base.Inserted(oldItem, item, Common.MemoryUtil.GetStringSize(key));
                    }
                    if (status == StoreStatus.NearEviction)
                    {
                        return(oldItem != null ? StoreInsResult.SuccessOverwriteNearEviction : StoreInsResult.SuccessNearEviction);
                    }
                    return(newInfo != null ? StoreInsResult.SuccessOverwrite : StoreInsResult.Success);
                }
            }
            catch (OutOfMemoryException e)
            {
                Trace.error("MmfStorageProvider.Insert()", e.ToString());
                return(StoreInsResult.NotEnoughSpace);
            }
            catch (Exception e)
            {
                Trace.error("MmfStorageProvider.Insert()", e.ToString());
                return(StoreInsResult.Failure);
            }
        }
 partial void DeleteStoreStatus(StoreStatus instance);
 partial void UpdateStoreStatus(StoreStatus instance);
 partial void InsertStoreStatus(StoreStatus instance);
Esempio n. 7
0
 /// <summary>
 /// 更新店铺状态
 /// </summary>
 /// <param name="status"></param>
 public void UpdateStatus(StoreStatus status)
 {
     ApplyEvent(new StoreStatusUpdatedEvent(status));
 }
Esempio n. 8
0
 private void Handle(StoreStatusUpdatedEvent evnt)
 {
     _status = evnt.Status;
 }
 public StoreStatusUpdatedEvent(StoreStatus status)
 {
     Status = status;
 }
Esempio n. 10
0
 public async Task <bool> Create(StoreStatus StoreStatus)
 {
     return(StoreStatus.IsValidated);
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoreHeader" /> class.
 /// </summary>
 /// <param name="Name">Name (required).</param>
 /// <param name="Url">Url (required).</param>
 /// <param name="CountryIsoCodeAlpha3">CountryIsoCodeAlpha3 (required).</param>
 /// <param name="Sectors">Sectors (required).</param>
 /// <param name="StoreId">StoreId (required).</param>
 /// <param name="UserRole">UserRole (required).</param>
 /// <param name="Status">Status (required).</param>
 /// <param name="OwnerUserId">The user id of the owner of the store (required).</param>
 /// <param name="ShareCount">The share count related to this store (required).</param>
 /// <param name="CreationUtcDate">The creation date of the store (required).</param>
 /// <param name="Links">Links.</param>
 public StoreHeader(StoreName Name = default(StoreName), StoreUrl Url = default(StoreUrl), StoreCountryIsoCodeAlpha3 CountryIsoCodeAlpha3 = default(StoreCountryIsoCodeAlpha3), StoreSectors Sectors = default(StoreSectors), BeezUPCommonStoreId StoreId = default(BeezUPCommonStoreId), StoreUserRole UserRole = default(StoreUserRole), StoreStatus Status = default(StoreStatus), string OwnerUserId = default(string), int?ShareCount = default(int?), DateTime?CreationUtcDate = default(DateTime?), StoreHeaderLinks Links = default(StoreHeaderLinks))
 {
     // to ensure "Name" is required (not null)
     if (Name == null)
     {
         throw new InvalidDataException("Name is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.Name = Name;
     }
     // to ensure "Url" is required (not null)
     if (Url == null)
     {
         throw new InvalidDataException("Url is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.Url = Url;
     }
     // to ensure "CountryIsoCodeAlpha3" is required (not null)
     if (CountryIsoCodeAlpha3 == null)
     {
         throw new InvalidDataException("CountryIsoCodeAlpha3 is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.CountryIsoCodeAlpha3 = CountryIsoCodeAlpha3;
     }
     // to ensure "Sectors" is required (not null)
     if (Sectors == null)
     {
         throw new InvalidDataException("Sectors is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.Sectors = Sectors;
     }
     // to ensure "StoreId" is required (not null)
     if (StoreId == null)
     {
         throw new InvalidDataException("StoreId is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.StoreId = StoreId;
     }
     // to ensure "UserRole" is required (not null)
     if (UserRole == null)
     {
         throw new InvalidDataException("UserRole is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.UserRole = UserRole;
     }
     // to ensure "Status" is required (not null)
     if (Status == null)
     {
         throw new InvalidDataException("Status is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.Status = Status;
     }
     // to ensure "OwnerUserId" is required (not null)
     if (OwnerUserId == null)
     {
         throw new InvalidDataException("OwnerUserId is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.OwnerUserId = OwnerUserId;
     }
     // to ensure "ShareCount" is required (not null)
     if (ShareCount == null)
     {
         throw new InvalidDataException("ShareCount is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.ShareCount = ShareCount;
     }
     // to ensure "CreationUtcDate" is required (not null)
     if (CreationUtcDate == null)
     {
         throw new InvalidDataException("CreationUtcDate is a required property for StoreHeader and cannot be null");
     }
     else
     {
         this.CreationUtcDate = CreationUtcDate;
     }
     this.Links = Links;
 }
Esempio n. 12
0
 public StoreHours(DayofWeek weekDay, StoreStatus sStatus)
 {
     this._weekDay = weekDay;
     this._sStatus = sStatus;
 }
Esempio n. 13
0
        public HistoryBar GetHistory(string symbol, DateTime dateTime)
        {
            HistoryBar historyBar = new HistoryBar();

            if (!IsConnected)
            {
                if (!Connect())
                {
                    return(historyBar);
                }
            }

            if (string.IsNullOrEmpty(StorageFolderName))
            {
                return(historyBar);
            }

            List <string> symbolNames = GetSymbols();

            if (symbolNames == null || symbolNames.Count == 0)
            {
                _logger.Debug("QuotesHistoryConnector.GetHistory(): Failed to get symbols.");
                return(historyBar);
            }

            try
            {
                if (_historyStore == null)
                {
                    string   assemblyFileName = GetType().Assembly.Location;
                    FileInfo fileInfo         = new FileInfo(assemblyFileName);

                    int historySourceVersion = _historySource.GetHistoryVersion();
                    _historyStore = new NtfsHistoryStore(Path.Combine(fileInfo.DirectoryName, "DCQuotesStorage", StorageFolderName + "_v" + historySourceVersion), new NullMonitoringService());
                    StoreStatus storeStatus = _historyStore.OpenOrCreate(historySourceVersion, false);

                    if (storeStatus != StoreStatus.Ok)
                    {
                        _logger.Debug("QuotesHistoryConnector.GetHistory(): Failed to open or create quotes storage. Store status: {0}", storeStatus);
                        return(historyBar);
                    }
                }

                if (_historyManager == null)
                {
                    Dictionary <Periodicity, TimeInterval> periodicityMap = new Dictionary <Periodicity, TimeInterval>();
                    periodicityMap.Add(new Periodicity(TimeInterval.Second), TimeInterval.Hour);
                    periodicityMap.Add(new Periodicity(TimeInterval.Second, 10), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Minute), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Minute, 5), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Minute, 15), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Minute, 30), TimeInterval.Day);
                    periodicityMap.Add(new Periodicity(TimeInterval.Hour), TimeInterval.Month);
                    periodicityMap.Add(new Periodicity(TimeInterval.Hour, 4), TimeInterval.Month);
                    periodicityMap.Add(new Periodicity(TimeInterval.Day), TimeInterval.Year);
                    periodicityMap.Add(new Periodicity(TimeInterval.Week), TimeInterval.Year);
                    periodicityMap.Add(new Periodicity(TimeInterval.Month), TimeInterval.Year);

                    _historyManager = HistoryManager.Create(_historyStore, new SortedSet <string>(symbolNames),
                                                            periodicityMap, true,
                                                            Cache.ClientInstance("CacheInstance"), true, true, new NullMonitoringService(), null);
                }

                if (!_historyManager.BarsAreSynchronized(_historySource, symbol, new Periodicity(TimeInterval.Minute),
                                                         TickTrader.Common.Business.FxPriceType.Bid,
                                                         new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0),
                                                         new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour + 1, 0, 0), true))
                {
                    _historyManager.SynchronizeBars(_historySource, symbol, new Periodicity(TimeInterval.Minute),
                                                    TickTrader.Common.Business.FxPriceType.Bid,
                                                    new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, 0, 0),
                                                    new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour + 1, 0, 0), true,
                                                    delegate(int completed, int total, DateTime start, TimeSpan length) { });
                }

                MarketHistoryItemsReport <HistoryBar> report = _historyManager.QueryBarHistory(dateTime, 1, symbol,
                                                                                               new Periodicity(TimeInterval.Minute).ToString(), TickTrader.Common.Business.FxPriceType.Bid);

                if (report.Items.Count > 0)
                {
                    historyBar = report.Items[0];
                }
                else
                {
                    _logger.Debug("QuotesHistoryConnector.GetHistory(): Failed to query bar history (empry collection returned).");
                }
            }
            catch (Exception ex)
            {
                _logger.Debug(ex, "QuotesHistoryConnector.GetHistory(): Failed to query bar history (exception): {0}", ex.Message);
            }

            return(historyBar);
        }
Esempio n. 14
0
 public UpdateStoreStautsCommand(StoreStatus status)
 {
     Status = status;
 }
Esempio n. 15
0
        public static StoreModel GetTestStore(
            string connectionString,
            string countryName,
            string storeStatusName,
            int andromedaSiteId,
            string customerSiteId,
            string externalSiteId,
            string externalSiteName,
            string clientSiteName,
            DateTime lastFTPUploadDateTime,
            string name,
            string telephone,
            string timezone,
            Address address)
        {
            Country     country     = null;
            StoreStatus storeStatus = null;

            using (AndroAdminDataAccess.EntityFramework.AndroAdminEntities entitiesContext = new AndroAdminDataAccess.EntityFramework.AndroAdminEntities())
            {
                entitiesContext.Database.Connection.ConnectionString = connectionString;

                // Get a country for our test store
                var countryQuery = from s in entitiesContext.Countries
                                   where s.CountryName == countryName
                                   select s;

                AndroAdminDataAccess.EntityFramework.Country countryEntity = countryQuery.FirstOrDefault();

                // Does the country exist?
                Assert.IsNotNull(countryEntity, "Unknown country name");

                country = new Country()
                {
                    Id                = countryEntity.Id,
                    CountryName       = countryEntity.CountryName,
                    ISO3166_1_alpha_2 = countryEntity.ISO3166_1_alpha_2,
                    ISO3166_1_numeric = countryEntity.ISO3166_1_numeric
                };

                // Get a store status for our test store
                var storeStatusQuery = from s in entitiesContext.StoreStatus
                                       where s.Status == storeStatusName
                                       select s;

                AndroAdminDataAccess.EntityFramework.StoreStatu storeStatusEntity = storeStatusQuery.FirstOrDefault();

                // Does the store status exist?
                Assert.IsNotNull(storeStatusEntity, "Unknown store status");

                storeStatus = new StoreStatus()
                {
                    Id          = storeStatusEntity.Id,
                    Description = storeStatusEntity.Description,
                    Status      = storeStatusEntity.Status,
                };
            }

            // We need to set the address country
            address.Country = country;

            // Create a new store
            StoreModel storeModel = new StoreModel()
            {
                Store = new Store()
                {
                    AndromedaSiteId       = andromedaSiteId,
                    Address               = address,
                    CustomerSiteId        = customerSiteId,
                    CustomerSiteName      = clientSiteName,
                    ExternalSiteId        = externalSiteId,
                    ExternalSiteName      = externalSiteName,
                    LastFTPUploadDateTime = lastFTPUploadDateTime,
                    Name        = name,
                    StoreStatus = storeStatus,
                    Telephone   = telephone,
                    TimeZone    = timezone
                },
                Selected = true
            };

            return(storeModel);
        }