Ejemplo n.º 1
0
        private int IsPartialMessage(string MID, string Length)
        {
            // Function to check and return if any partially received MIDs are saved
            // Returns 0 if none or if current file size >= Length or an error,
            // otherwise the length of data already received.
            var intBytesReceived = default(int);

            byte[] bytFiledata;
            try
            {
                var dataStore = new MessageStore(DatabaseFactory.Get());
                bytFiledata = dataStore.GetTemporaryInboundMessage(MID);
                if (bytFiledata.Length > 0)
                {
                    // Assume any partial will be a multiple of 250 real bytes as the last block of < 250 bytes
                    // would indicate a completed file...
                    if (bytFiledata.Length > 255)
                    {
                        intBytesReceived = bytFiledata.Length - (bytFiledata[1] + 2 + 2 * (bytFiledata.Length / 250));
                        if (intBytesReceived < 250 | intBytesReceived % 250 != 0)
                        {
                            // Problem with partial...
                            _log.Error("IsPartialMessage: Computed Bytes received is not modulo 250, Partial MID: " + MID + " Purged!");
                            dataStore.DeleteTemporaryInboundMessage(MID);
                            intBytesReceived = 0;
                        }
                        else if (intBytesReceived >= Convert.ToInt32(Length))
                        {
                            _log.Error("IsPartialMessage: Partial Length exceeded proposed length, Partial MID: " + MID + " Purged!");
                            dataStore.DeleteTemporaryInboundMessage(MID);
                            intBytesReceived = 0;
                        }
                    }
                    else
                    {
                        _log.Error("IsPartialMessage: Partial Files size < 255, Partial MID: " + MID + " Purged!");
                        dataStore.DeleteTemporaryInboundMessage(MID);
                    }
                }

                return(intBytesReceived);
            }
            catch (Exception e)
            {
                var dataStore = new MessageStore(DatabaseFactory.Get());
                dataStore.DeleteTemporaryInboundMessage(MID);
                _log.Error("[IsPartialMessage] " + e.Message);
                return(0);
            }
        } // IsPartialMessage
Ejemplo n.º 2
0
        } // WritePartialToFile

        public void PurgeCurrentPartial()
        {
            // Called to purge the partial if the message was received completly or protocol failure
            bytData = new byte[0];
            try
            {
                var messageStore = new MessageStore(DatabaseFactory.Get());
                messageStore.DeleteTemporaryInboundMessage(strMID);
            }
            catch
            {
            }
        } // PurgeCurrentPartial
Ejemplo n.º 3
0
 public void StartNewPartial(string MID)
 {
     strMID  = MID;
     bytData = new byte[0];
     try
     {
         var messageStore = new MessageStore(DatabaseFactory.Get());
         messageStore.DeleteTemporaryInboundMessage(MID);
     }
     catch (Exception ex)
     {
         _log.Error("[PartialSession.StartNewPartial] " + ex.Message);
     }
 } // StartNewFile