/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public void PushOne(SynchDataModel param)
        {
            var agent = AgentBusiness.GetByAppKey(HttpContext.Current.Request.Headers["AppKey"]);

            agent.LastRequestTime = DateTime.Now;
            var syncData = new SynchData()
            {
                SourceId = param.SourceId,
                Data     = BsonDocument.Parse(param.Data.ToString()),
            };

            Add(syncData);
            AgentBusiness.Update(agent);
            SynchLogBusiness.Add(new SynchLog()
            {
                AgentId        = agent.Id.ToString(),
                CollectionName = HttpContext.Current.Request.Headers["CollectionName"],
                MinId          = syncData.Id.ToString(),
                MaxId          = syncData.Id.ToString(),
                Result         = "",
                TotalCount     = 1,
                Type           = SynchLogTypeEnum.Add,
                Ip             = HttpHelper.IP,
                Token          = HttpContext.Current.Request.Headers["Token"]
            });
        }
Example #2
0
        /// <summary>
        ///    Reads the contents of the current instance determining
        ///    the size of the dsf data, the area the tagging is in,
        ///    and optionally reading in the tags and media properties.
        /// </summary>
        /// <param name="read_tags">
        ///    If <see langword="true" />, any tags found will be read
        ///    into the current instance.
        /// </param>
        /// <param name="style">
        ///    A <see cref="ReadStyle"/> value specifying how the media
        ///    data is to be read into the current instance.
        /// </param>
        /// <param name="dsf_size">
        ///    A <see cref="uint"/> value reference to be filled with
        ///    the size of the RIFF data as read from the file.
        /// </param>
        /// <param name="tag_start">
        ///    A <see cref="long" /> value reference to be filled with
        ///    the absolute seek position at which the tagging data
        ///    starts.
        /// </param>
        /// <param name="tag_end">
        ///    A <see cref="long" /> value reference to be filled with
        ///    the absolute seek position at which the tagging data
        ///    ends.
        /// </param>
        /// <exception cref="CorruptFileException">
        ///    The file does not begin with <see cref="FileIdentifier"
        ///    />.
        /// </exception>
        private void Read(bool read_tags, ReadStyle style,
                          out uint dsf_size, out long tag_start,
                          out long tag_end)
        {
            Seek(0);
            if (ReadBlock(4) != FileIdentifier)
            {
                throw new CorruptFileException(
                          "File does not begin with DSF identifier");
            }

            Seek(12);
            dsf_size = ReadBlock(8).ToUInt(false);

            tag_start = (long)ReadBlock(8).ToULong(false);
            tag_end   = -1;

            // Get the properties of the file
            if (header_block == null &&
                style != ReadStyle.None)
            {
                long fmt_chunk_pos = Find(FormatIdentifier, 0);

                if (fmt_chunk_pos == -1)
                {
                    throw new CorruptFileException(
                              "No Format chunk available in DSF file.");
                }

                Seek(fmt_chunk_pos);
                header_block = ReadBlock((int)StreamHeader.Size);

                StreamHeader header = new StreamHeader(header_block, dsf_size);
                properties = new Properties(TimeSpan.Zero, header);
            }

            // Now position to the ID3 chunk, which we read before
            if (tag_start > 0)
            {
                Seek(tag_start);
                if (ReadBlock(3) == ID3Identifier)
                {
                    if (read_tags && tag == null)
                    {
                        tag = new Id3v2.Tag(this, tag_start, style);
                    }

                    // Get the length of the tag out of the ID3 chunk
                    Seek(tag_start + 6);
                    uint tag_size = SynchData.ToUInt(ReadBlock(4)) + 10;

                    InvariantStartPosition = tag_start;
                    tag_end = InvariantEndPosition = tag_start + tag_size;
                }
            }
        }
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity"></param>
 public void UpdateBySourceId(SynchData entity)
 {
     SynchDataProvider.UpdateBySourceId(entity);
 }
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="entity"></param>
 public void Add(SynchData entity)
 {
     SynchDataProvider.Add(entity);
 }
Example #5
0
    /// <summary>
    /// Création des entités créées, destruction des entités détruites,
    /// et synchronisation des autres.
    /// </summary>
    /// <param name="stateUpdate"></param>
    public void OnStateUpdate(BloodAndBileEngine.Networking.Messaging.NetworkMessages.StateUpdateMessage stateUpdate)
    {
        // Synchronisation
        // Chaque EntitySynchronizationDataObject a un identifiant d'entité à synchroniser, il suffit donc
        // d'appliquer la synchronisation à l'entité en question.
        BloodAndBileEngine.EntitySynchronizationDataObject[] synchObject = (BloodAndBileEngine.EntitySynchronizationDataObject[])(stateUpdate.GetStateUpdateInfo("EntitySynchronization")[0].Information);
        if (synchObject == null || synchObject.Length == 0)
        {
            BloodAndBileEngine.Debugger.Log("ERREUR : pas de EntitySynchronizationDataObject !", UnityEngine.Color.red);
        }
        foreach (BloodAndBileEngine.EntitySynchronizationDataObject SynchData in synchObject)
        {
            BloodAndBileEngine.Entity entity = BloodAndBileEngine.EntitiesManager.GetEntityFromID(SynchData.GetEntityID());
            BloodAndBileEngine.EntitySynchroniserComponent synchComponent = (BloodAndBileEngine.EntitySynchroniserComponent)entity.GetComponent(typeof(BloodAndBileEngine.EntitySynchroniserComponent));
            if (synchComponent != null)
            {
                synchComponent.GetSynchronizationData().SetSynchInfoFromSynchObject(SynchData);

                synchComponent.OnSynch();
            }
        }
    }