Пример #1
0
        public CacheOrder(OrderInfo order, NoteInfo[] notesToAdd, PhotoInfo[] photosToAdd, CacheStatus status)
        {
            this.order = order;

            this.newNotes = new List <NoteInfo>();
            if (notesToAdd != null)
            {
                // reassign the IDs to linearlize them in ascending order
                foreach (NoteInfo note in notesToAdd)
                {
                    note.ID = nextNewNoteIndex;
                    this.newNotes.Add(note);
                    nextNewNoteIndex++;
                }
            }

            this.newPhotos = new List <PhotoInfo>();
            if (photosToAdd != null)
            {
                // reassign the IDs to linearlize them in ascending order
                foreach (PhotoInfo photo in photosToAdd)
                {
                    photo.ID = nextNewPhotoIndex;
                    this.newPhotos.Add(photo);
                    nextNewPhotoIndex++;
                }
            }

            this.status = status;
        }
Пример #2
0
 public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
 {
     _info  = reader.ReadObject() as string;
     Status = (CacheStatus)reader.ReadInt32();
     IsCoordinatorInternal = reader.ReadBoolean();
     configID = reader.ReadDouble();
 }
Пример #3
0
 public Boolean delete(string id)
 {
     if (MessageBox.Show("削除しますか", "削除", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try
         {
             CacheStatus sts = User.ADBK.DeleteId(adbksrc.conn, id);
             if (sts.IsOK)
             {
                 return(true);
             }
             else
             {
                 Exception uerr = new Exception(sts.Message);
                 throw uerr;
             }
         }
         catch (Exception err)
         {
             MessageBox.Show("削除エラー" + err.Message);
             return(false);
         }
     }
     return(false);
 }
 public void UpdateCache <TDbEntity>(List <TDbEntity> entities)
 {
     try
     {
         CacheEntity type        = CacheEntityMap.GetEntityTypeForDBEntity <TDbEntity>();
         CacheStatus cacheStatus = Uow.CacheStatusesRepository.GetCacheStatus(type);
         cacheStatus.Status      = CacheEntryStatus.UpdateInProgress;
         cacheStatus.LastUpdated = DateTime.UtcNow;
         // try to get DB lock;
         if (Uow.CacheStatusesRepository.TryUpdate(cacheStatus))
         {
             ICachedEntitiesRepository <TDbEntity> entityRepository = Uow.GetRepository <ICachedEntitiesRepository <TDbEntity> >();
             Task task = entityRepository.UpdateCacheAsync(entities);
             task.ContinueWith(task1 =>
             {
                 using (IOptionsPlayUow uow = ObjectFactory.GetInstance <IOptionsPlayUow>())
                 {
                     cacheStatus             = uow.CacheStatusesRepository.GetCacheStatus(type);
                     cacheStatus.Status      = CacheEntryStatus.Active;
                     cacheStatus.LastUpdated = DateTime.UtcNow;
                     uow.CacheStatusesRepository.Update(cacheStatus);
                     uow.Commit();
                 }
             });
         }
     }
     catch (Exception ex)
     {
         Logging.Logger.Debug("thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + ", UpdateCache Exception is:" + ex.StackTrace.ToString() + ", class is DatabaseCacheService");
     }
 }
Пример #5
0
        public CacheStatus Set(string key, string value, UInt32 flags, UInt32 expiry, UInt64 cas, out UInt64 newCas)
        {
            uint        tableSlot = ((uint)key.GetHashCode()) % Configuration.CacheTableSize;
            CacheStatus status    = CacheStatus.NoError;

            newCas = 0;

            lock (this.cacheTable[tableSlot])
            {
                CacheRecord record = null;

                if (!this.cacheTable[tableSlot].TryGetValue(key, out record))
                {
                    record = new CacheRecord {
                        Key = key
                    };
                    this.cacheTable[tableSlot] [key] = record;
                }

                if (cas == 0 || cas == record.CAS)
                {
                    record.Value  = value;
                    record.Flags  = flags;
                    record.Expiry = expiry;
                    record.CAS++;
                }
                else
                {
                    status = CacheStatus.CasDosentMatch;
                }
            }

            return(status);
        }
Пример #6
0
 public void AddNewNote(NoteInfo note)
 {
     // fix up the note ID so that it is the last one in the list
     note.ID = nextNewNoteIndex;
     newNotes.Add(note);
     nextNewNoteIndex++;
     this.status = CacheStatus.Dirty;
 }
        public override void Up()
        {
            SqlExecute.ExecuteNonQuery("DELETE FROM [dbo].[__MigrationHistory] WHERE [MigrationId] = N'201411270918013_AddCacheStatus'");

            CacheStatus securitiesInfoCacheEntry  = new CacheStatus(CacheEntity.SecurityInformation);
            CacheStatus optionBasicInfoCacheEntry = new CacheStatus(CacheEntity.OptionBasicInformation);

            SqlExecute.InsertAndGetInt32Identity("CacheStatuses", securitiesInfoCacheEntry);
            SqlExecute.InsertAndGetInt32Identity("CacheStatuses", optionBasicInfoCacheEntry);
        }
Пример #8
0
        public ResponseBuilder WithStatusHeader(CacheStatus status)
        {
            _instance._builderActions.Add(delegate(HttpResponseMessage response)
            {
                EnsureCacheControlHeaders(response);
                response.Headers.AddClientCacheStatusHeader(status);
            });

            return(_instance);
        }
Пример #9
0
 public void UpdateNewNote(int id, string newText)
 {
     foreach (NoteInfo note in this.newNotes)
     {
         if (note.ID == id)
         {
             note.Text   = newText;
             this.status = CacheStatus.Dirty;
             return;
         }
     }
 }
 //-----------------------------------------------------------------//
 //
 private void LocalStatistics(int page, CacheStatus status)
 {
     Console.ForegroundColor = ConsoleColor.Gray;
     Console.Write("[r] Procurando a página ");
     Console.ForegroundColor = ConsoleColor.DarkYellow;
     Console.Write("{0} ", page);
     Console.ForegroundColor = ConsoleColor.Gray;
     Console.Write("na cache... ");
     Console.ForegroundColor = (status == CacheStatus.Hit) ? ConsoleColor.DarkGreen : ConsoleColor.DarkRed;
     Console.Write("{0}", (status == CacheStatus.Hit) ? "-HIT-\n" : "-MISS-\n");
     Console.ForegroundColor = ConsoleColor.Gray;
     Console.Write("{0}", (status == CacheStatus.Hit) ? "    Conteúdo da cache:               " : "[w] Conteúdo da cache após inserção: ");
 }
Пример #11
0
        public void DeleteNewNote(int id)
        {
            List <NoteInfo> notesNotDeleted = new List <NoteInfo>();

            foreach (NoteInfo newNote in this.newNotes)
            {
                if (newNote.ID != id)
                {
                    notesNotDeleted.Add(newNote);
                }
            }
            this.newNotes = notesNotDeleted;
            this.status   = CacheStatus.Dirty;
        }
Пример #12
0
        private static string GetHeaderStringValue(CacheStatus status)
        {
            switch (status)
            {
            case CacheStatus.Hit: return(StatusHit);

            case CacheStatus.Miss: return(StatusMiss);

            case CacheStatus.Stale: return(StatusStale);

            case CacheStatus.Revalidated: return(StatusRevalidated);

            default: throw new ArgumentOutOfRangeException(nameof(status), $"{status} is not recognized as a valid value");
            }
        }
Пример #13
0
        /// <summary>
        /// Handle a get request. Lookup cache and return response
        /// </summary>
        /// <param name="getRequest">GET request</param>
        /// <param name="connection">TcpConnection</param>
        private void HandleGet(GetRequest getRequest, TcpConnection connection)
        {
            String value = String.Empty;
            uint   flags = 0;

            CacheStatus    status         = this.cache.Get(getRequest.Key, out value, out flags);
            ResponseStatus responseStatus = ResponseStatus.NoError;

            switch (status)
            {
            case CacheStatus.KeyDoesNotExist:
                responseStatus = ResponseStatus.KeyNotFound;
                break;
            }

            GetResponse getResponse = new GetResponse(responseStatus);

            if (getRequest.Header.OpCode == CommandOpCode.GetK ||
                getRequest.Header.OpCode == CommandOpCode.GetKQ)
            {
                getResponse.Key = getRequest.Key;
            }

            getResponse.Value               = value;
            getResponse.Header.Extras       = new CommandExtras(4);
            getResponse.Header.Extras.Flags = flags;
            getResponse.Header.Opaque       = getRequest.Header.Opaque;

            byte[] responsePacket = getResponse.Serialize();

            if (getRequest.Header.OpCode == CommandOpCode.GetQ ||
                getRequest.Header.OpCode == CommandOpCode.GetKQ)
            {
                Trace.TraceInformation("Queuing Get request");
                this.queuedResponses.Enqueue(responsePacket);
            }
            else
            {
                Trace.TraceInformation("Flushing request queue");
                while (this.queuedResponses.Count != 0)
                {
                    byte[] queuedPacket = this.queuedResponses.Dequeue();
                    connection.SendResponse(queuedPacket, 0, queuedPacket.Length);
                }

                connection.SendResponse(responsePacket, 0, responsePacket.Length);
            }
        }
Пример #14
0
        /// <summary>
        /// Handle a set request. Modify the record for the given key
        /// </summary>
        /// <param name="setRequest">SET request</param>
        /// <param name="connection">Tcp Connection</param>
        private void HandleSet(SetRequest setRequest, TcpConnection connection)
        {
            UInt32 flags  = (setRequest.Header.Extras != null) ? setRequest.Header.Extras.Flags : 0;
            UInt32 expiry = (setRequest.Header.Extras != null) ? setRequest.Header.Extras.Expiry : 0;
            UInt64 newCas = 0;

            CacheStatus status = this.cache.Set(setRequest.Key,
                                                setRequest.Value,
                                                flags,
                                                expiry,
                                                setRequest.Header.CAS,
                                                out newCas);

            ResponseStatus responseStatus = ResponseStatus.NoError;

            switch (status)
            {
            case CacheStatus.CasDosentMatch:
                responseStatus = ResponseStatus.InvalidArguments;
                break;
            }

            SetResponse setResponse = new SetResponse(responseStatus);

            setRequest.Header.CAS     = newCas;
            setResponse.Header.Opaque = setRequest.Header.Opaque;

            byte[] responsePacket = setResponse.Serialize();

            if (setRequest.Header.OpCode == CommandOpCode.SetQ)
            {
                Trace.TraceInformation("Queuing set request");
                this.queuedResponses.Enqueue(responsePacket);
            }
            else
            {
                Trace.TraceInformation("Flushing request queue");
                while (this.queuedResponses.Count != 0)
                {
                    byte[] queuedPacket = this.queuedResponses.Dequeue();
                    connection.SendResponse(queuedPacket, 0, queuedPacket.Length);
                }

                connection.SendResponse(responsePacket, 0, responsePacket.Length);
            }
        }
Пример #15
0
        static void Main(string[] args)
        {
            CacheConnection CacheConnect = new CacheConnection();

            CacheConnect.ConnectionString = "Server = 192.168.1.10; "
                                            + "Port = 5641; " + "Namespace = COMPANY2; "
                                            + "Password = SYS; " + "User ID = _SYSTEM;";
            CacheConnect.Open();

            var startTime = DateTime.Now;

            CacheConnect.DynamicMode = true;
            CacheMethodSignature mtdSignature = CacheConnect.GetMtdSignature();

            mtdSignature.Clear();
            mtdSignature.Add(375399, false); //id
            mtdSignature.Add(0, false);      //exclusive lock
            mtdSignature.Add(0, false);      //immediate timeout
            mtdSignature.SetReturnType(CacheConnect, ClientTypeId.tStatus);
            CacheObject.RunClassMethod(CacheConnect, "User.Customer", "%LockId", mtdSignature);
            CacheStatus status = (CacheStatus)((CacheStatusReturnValue)(mtdSignature.ReturnValue)).Value;

            if (status.IsOK)
            {
                Console.WriteLine("Lock acquired");

                Console.ReadLine();

                mtdSignature.Clear();
                mtdSignature.Add(1, false); //id
                mtdSignature.SetReturnType(CacheConnect, ClientTypeId.tStatus);
                CacheObject.RunClassMethod(CacheConnect, "Sample.Person", "%UnlockId", mtdSignature);
                Console.WriteLine("Unlocked");
            }
            else
            {
                Console.WriteLine("Already Locked");
            }
            var endTime = DateTime.Now;
            var diff    = endTime.Subtract(startTime);
            var res     = String.Format("{0} milliseconds", diff.TotalMilliseconds);

            Console.WriteLine($"Time Spend on lock checking: {res}");
            CacheConnect.Close();
        }
Пример #16
0
        public void DeleteNewPhoto(int id)
        {
            // we deliberately orphan the cached file because it may not be in the cache folder anyway.  Also,
            // the entire folder will be cleared when the order is deleted.

            List <PhotoInfo> photosNotDeleted = new List <PhotoInfo>();

            foreach (PhotoInfo newPhoto in this.newPhotos)
            {
                if (newPhoto.ID != id)
                {
                    photosNotDeleted.Add(newPhoto);
                }
            }
            this.newPhotos = photosNotDeleted;

            this.status = CacheStatus.Dirty;
        }
Пример #17
0
        public void AddNewPhoto(string title, string cachedPhotoFullPath, int userID, string userName)
        {
            // write info object that refers to image
            PhotoInfo photo = new PhotoInfo();

            photo.FilePath        = cachedPhotoFullPath;
            photo.Title           = title;
            photo.DateTimeEntered = DateTime.Now;
            photo.EnteredByUserID = userID;
            photo.EnteredByUser   = userName;

            // fix up the photo ID so that it is the last one in the list
            photo.ID = nextNewPhotoIndex;

            newPhotos.Add(photo);
            nextNewPhotoIndex++;

            this.status = CacheStatus.Dirty;
        }
Пример #18
0
        public void save(string id)
        {
            User.ADBK adbk;
            try
            {
                if (newflag == true)
                {
                    adbk = new User.ADBK(adbksrc.conn);
                }
                else
                {
                    adbk = User.ADBK.OpenId(adbksrc.conn, id);
                }

                adbk.ACITY   = City;
                adbk.APHHOME = HomePhone;
                adbk.ANAME   = Name;
                adbk.ASTREET = Street;
                adbk.APHWORK = WorkPhone;
                adbk.AZIP    = ZipCode;
                adbk.ABTHDAY = CacheDate.Parse(dob.ToString());
                CacheStatus sts = adbk.Save();

                if (sts.IsOK)
                {
                    if (newflag == true)
                    {
                        updatedatamodel(adbk);
                    }
                }
                else
                {
                    Exception uerr = new Exception(sts.Message);
                    throw uerr;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("保存エラー " + err.Message);
            }
        }
Пример #19
0
        static CacheObject Lock(CacheConnection conn, string tableName, int id)
        {
            try
            {
                //ADD CACHE OBJECT LOCKING HERE
                conn.DynamicMode = true;                                    //needed for proxy objects dynamic binding
                CacheMethodSignature mtdSignature = conn.GetMtdSignature(); //used to pass attributed and return values from methods

                mtdSignature.Clear();
                mtdSignature.Add(id, false); //Id = 1, false means dont pass by reference
                mtdSignature.Add(0, false);  //exclusive lock
                mtdSignature.Add(0, false);  //immediate timeout
                mtdSignature.SetReturnType(conn, ClientTypeId.tStatus);
                CacheObject.RunClassMethod(conn, $"User.{tableName}", "%LockId", mtdSignature);
                CacheStatus status = (CacheStatus)((CacheStatusReturnValue)(mtdSignature.ReturnValue)).Value;

                if (status.IsOK)
                {
                    Console.WriteLine("Lock acquired");

                    Console.ReadLine();

                    //mtdSignature.Clear();
                    //mtdSignature.Add(id, false); //id
                    //mtdSignature.SetReturnType(conn, ClientTypeId.tStatus);
                    //CacheObject.RunClassMethod(conn, "Sample.Person", "%UnlockId", mtdSignature);
                    //Console.WriteLine("Unlocked");
                }
                else
                {
                    Console.WriteLine("Already Locked");
                }

                return((CacheObject)((CacheObjReturnValue)(mtdSignature.ReturnValue)).Value);
            }
            catch (Exception ee)
            {
                throw new Exception($"Error in DbConn.Lock(tableName, id)", ee);
            }
        }
Пример #20
0
        public List <CacheStatus> GetCacheStatus()
        {
            var result = new List <CacheStatus>();

            foreach (var channel in Client.Guilds.SelectMany(o => o.TextChannels))
            {
                var messageCache = MessageCache.GetFromChannel(channel.Id);

                var item = new CacheStatus(channel)
                {
                    InternalCacheCount = channel.CachedMessages.Count,
                    MessageCacheCount  = messageCache.Count(),
                };

                if (item.InternalCacheCount > 0 || item.MessageCacheCount > 0)
                {
                    result.Add(item);
                }
            }

            return(result);
        }
Пример #21
0
        public void Add(string key, object value)
        {
            if (value == null)
                return;

            //var config = CacheConfiguration.Instance.CacheConfigurations.FirstOrDefault(a => TypeUtils.GetFormattedName(a.Name).Equals(_cacheName));
            var config = _cacheConfiguration.Instance.CacheConfigurations.FirstOrDefault(a => TypeUtils.GetFormattedName(a.Name).Equals(_cacheName));

            if (config != null)
            {
                _policy.AbsoluteExpiration = DateTime.Now.AddMilliseconds(config.DefaultTimeOut);
            }
            if (_policy.AbsoluteExpiration <= DateTimeOffset.Now)
                return;
            CacheUtility.EnsureCacheKey(ref key);
            var cacheItem = new CacheItem(key, _binarySerializer.Serialize(value));

            DataCache.Add(cacheItem, _policy);

            var d = new CacheStatus(key, DateTime.Now, _policy.AbsoluteExpiration);
            CacheStatus.AddOrUpdate(key, d, (k, j) => { return d; });
        }
Пример #22
0
        //public static IQueryable<OptionBasicInformation> Get(out DBCacheStatus status)
        //{
        //    if (LastUpdated.Value.Add(TimeSpan.FromMinutes(60)) <= DateTime.UtcNow)
        //    {
        //        status = DBCacheStatus.Ok;
        //    }
        //    else
        //    {
        //        status = DBCacheStatus.Expired;
        //    }
        //    return OptionBasicInformationCache;
        //}

        public IQueryable <TEntity> Get <TEntity>(out DBCacheStatus status)
        {
            CacheEntity type        = CacheEntityMap.GetEntityTypeForDBEntity <TEntity>();
            CacheStatus cacheStatus = Uow.CacheStatusesRepository.GetCacheStatus(type);

            if (cacheStatus.Status == CacheEntryStatus.Empty || cacheStatus.Status == CacheEntryStatus.UpdateInProgress)
            {
                status = DBCacheStatus.Empty;
                return(null);
            }

            TimeSpan expiration = GetExpirationForEntity(type);
            ICachedEntitiesRepository <TEntity> entityRepository = Uow.GetRepository <ICachedEntitiesRepository <TEntity> >();

            if (!cacheStatus.LastUpdated.HasValue || cacheStatus.LastUpdated.Value.Add(expiration) <= DateTime.UtcNow)
            {
                status = DBCacheStatus.Expired;
                return(entityRepository.GetAll());
            }
            if (type == CacheEntity.OptionBasicInformation)
            {
                if (OptionBasicInformationCache == null)
                {
                    var repository = (IList <OptionBasicInformationCache>)entityRepository.GetAll().ToList();
                    OptionBasicInformationCache = (List <OptionBasicInformationCache>)repository;
                }
            }
            else
            {
                if (SecurityInformationCache == null)
                {
                    var repository = (IList <SecurityInformationCache>)entityRepository.GetAll().ToList();
                    SecurityInformationCache = (List <SecurityInformationCache>)entityRepository.GetAll();
                }
            }
            status = DBCacheStatus.Ok;
            return(entityRepository.GetAll());
        }
Пример #23
0
        /// <summary>
        /// Sets an item in the artwork cache.
        /// </summary>
        /// <param name="artGuid">The ArtContainerGuid at the start of the cache operation. If it is different from the current ArtContainerGuid, the cache will be ignored.</param>
        /// <param name="status">The status of the cache operation.</param>
        /// <param name="trackID">The item's ID.</param>
        /// <param name="path">The path to the image, if status is CacheStatus.Cached.</param>
        /// <returns>Whether the cache was successful.</returns>
        internal static bool SetArtworkCacheItem(Guid artGuid, CacheStatus status, uint trackID, Uri path)
        {
            if (artGuid == ArtContainerGuid)
            {
                switch (status)
                {
                case CacheStatus.Cached:
                    _local.CreateContainer(ArtContainerGuid.ToString(), Windows.Storage.ApplicationDataCreateDisposition.Always).Values[trackID.ToString()] = path.ToString();
                    break;

                case CacheStatus.CannotCache:
                    _local.CreateContainer(ArtContainerGuid.ToString(), Windows.Storage.ApplicationDataCreateDisposition.Always).Values[trackID.ToString()] = string.Empty;
                    break;

                case CacheStatus.Uncached:
                    break;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public IQueryable <TDbEntity> Get <TDbEntity>(out DBCacheStatus status)
        {
            CacheEntity type        = CacheEntityMap.GetEntityTypeForDBEntity <TDbEntity>();
            CacheStatus cacheStatus = Uow.CacheStatusesRepository.GetCacheStatus(type);

            ICachedEntitiesRepository <TDbEntity> entityRepository = Uow.GetRepository <ICachedEntitiesRepository <TDbEntity> >();

            if (cacheStatus.Status == CacheEntryStatus.Empty || cacheStatus.Status == CacheEntryStatus.UpdateInProgress)
            {
                status = DBCacheStatus.Empty;
                return(null);
            }

            TimeSpan expiration = GetExpirationForEntity(type);

            if (!cacheStatus.LastUpdated.HasValue || cacheStatus.LastUpdated.Value.Add(expiration) <= DateTime.UtcNow)
            {
                status = DBCacheStatus.Expired;
                return(entityRepository.GetAll());
            }

            status = DBCacheStatus.Ok;
            return(entityRepository.GetAll());
        }
Пример #25
0
        public CacheStatus Get(string key, out string value, out UInt32 flags)
        {
            uint        tableSlot = ((uint)key.GetHashCode()) % Configuration.CacheTableSize;
            CacheStatus status    = CacheStatus.NoError;

            lock (this.cacheTable[tableSlot])
            {
                CacheRecord record = null;

                if (this.cacheTable[tableSlot].TryGetValue(key, out record))
                {
                    value = record.Value;
                    flags = record.Flags;
                }
                else
                {
                    status = CacheStatus.KeyDoesNotExist;
                    value  = String.Empty;
                    flags  = 0;
                }
            }

            return(status);
        }
Пример #26
0
        public static CacheOrder ParseXml(string xml)
        {
            try
            {
                // parse the XML into a document
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(xml);
                XmlElement orderElement = doc.GetElementsByTagName(orderTag)[0] as XmlElement;

                // create the pieces from XML elements
                OrderInfo order = new OrderInfo();
                order.ParseOrderDetailsXml(orderElement);

                XmlElement existingNotesElement = orderElement.GetElementsByTagName(existingNotesTag)[0] as XmlElement;
                order.Notes = NoteInfo.ParseNotes(existingNotesElement);

                XmlElement newNotesElement = orderElement.GetElementsByTagName(newNotesTag)[0] as XmlElement;
                NoteInfo[] newNotes        = NoteInfo.ParseNotes(newNotesElement);

                XmlElement existingPhotosElement = orderElement.GetElementsByTagName(existingPhotosTag)[0] as XmlElement;
                order.Photos = PhotoInfo.ParsePhotos(existingPhotosElement);

                XmlElement  newPhotosElement = orderElement.GetElementsByTagName(newPhotosTag)[0] as XmlElement;
                PhotoInfo[] newPhotos        = PhotoInfo.ParsePhotos(newPhotosElement);

                XmlElement  statusElement = orderElement.GetElementsByTagName(statusTag)[0] as XmlElement;
                CacheStatus status        = (CacheStatus)Enum.Parse(typeof(CacheStatus), statusElement.InnerText);

                // create the cache order object from the pieces
                return(new CacheOrder(order, newNotes, newPhotos, status));
            }
            catch
            {
                return(null);
            }
        }
Пример #27
0
 private void RaiseDownloadEvent(CacheStatus status, int totalFiles, int file)
 {
     OnDownloadUpdate(this, new SynoReportCacheDownloadEventArgs(status, totalFiles, file));
 }
Пример #28
0
 private void RaiseDownloadEvent(CacheStatus status, string message)
 {
     OnDownloadUpdate(this, new SynoReportCacheDownloadEventArgs(status, message));
 }
Пример #29
0
 private void RaiseDownloadEvent(CacheStatus status)
 {
     OnDownloadUpdate(this, new SynoReportCacheDownloadEventArgs(status));
 }
Пример #30
0
 public StatusInfo(CacheStatus status, string info)
 {
     Status = status;
     _info  = info;
 }
Пример #31
0
 public StatusInfo(CacheStatus status)
     : this(status, "")
 { }
Пример #32
0
 public StatusInfo(CacheStatus status, string info)
 {
     Status = status;
     _info = info;
 }
Пример #33
0
 public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
 {
     _info = reader.ReadObject() as string;
     Status = (CacheStatus)reader.ReadInt32();
     IsCoordinatorInternal = reader.ReadBoolean();
     configID = reader.ReadDouble();
 }
Пример #34
0
 /// <summary>
 /// Executes a command with the given parameter string and returns a string return
 /// </summary>
 /// <param name="command">command name string</param>
 /// <param name="param">parameter string</param>
 /// <param name="playlist">now playing playlist, may be null</param>
 /// <param name="result">string</param>
 /// <returns></returns>
 public OpResult Execute(String command, string param, NowPlayingList playlist, MediaItem currentItem)
 {
     command = command.ToLower();
     if (m_commands.ContainsKey(command))
     {
         try
         {
             if (command.Equals("music-cache-status"))
             {
                 OpResult opResult = new OpResult();
                 CacheStatus status = new CacheStatus(this.isCacheBuilding);
                 opResult.StatusCode = OpStatusCode.Json;
                 opResult.ContentText = JsonConvert.SerializeObject(status, Newtonsoft.Json.Formatting.Indented);
                 return opResult;
             }
             else if (m_commands[command] is MusicICommand)
             {
                 //Make sure cache is not being modified before executing any of the music-* commands
                 lock (cacheLock)
                 {
                     return ((MusicICommand)m_commands[command]).Execute(param, playlist, currentItem);
                 }
             }
             else
             {
                 return m_commands[command].Execute(param);
             }
         }
         catch (Exception ex)
         {
             OpResult opResult = new OpResult();
             opResult.StatusCode = OpStatusCode.Exception;
             opResult.StatusText = ex.Message;
             opResult.AppendFormat(ex.Message);
             return opResult;
         }
     }
     else
     {
         return new OpResult(OpStatusCode.BadRequest);
     }
 }