private void ReadMediaXmlCallback(IAsyncResult ar)
 {
     try
     {
         int nReadWriteBytes;
         m_oGetMediaXml.m_eError = m_oGetMediaXml.m_oStorage.ReadFileEnd(ar, out nReadWriteBytes);
         if (ErrorTypes.NoError == m_oGetMediaXml.m_eError || ErrorTypes.StorageFileNoFound == m_oGetMediaXml.m_eError)
         {
             MemoryStream oMemoryStream = m_oGetMediaXml.m_oMemoryStream;
             if (nReadWriteBytes > 0)
             {
                 string sXml = Encoding.UTF8.GetString(oMemoryStream.GetBuffer(), 0, (int)oMemoryStream.Position);
                 using (XmlTextReader reader = new XmlTextReader(new StringReader(sXml)))
                 {
                     while (reader.Read())
                     {
                         if ("image" == reader.Name)
                         {
                             string sHash     = null;
                             string sFilename = null;
                             while (reader.MoveToNextAttribute())
                             {
                                 if ("md5" == reader.Name)
                                 {
                                     sHash = reader.Value;
                                 }
                                 else if ("filename" == reader.Name)
                                 {
                                     sFilename = reader.Value;
                                 }
                             }
                             if (null != sHash && null != sFilename)
                             {
                                 m_oGetMediaXml.m_aMediaXmlMapHash[sHash]         = sFilename;
                                 m_oGetMediaXml.m_aMediaXmlMapFilename[sFilename] = sHash;
                             }
                         }
                     }
                 }
             }
         }
         m_oGetMediaXml.FireCallback();
     }
     catch
     {
         m_oGetMediaXml.DisposeAndCallback();
     }
 }
예제 #2
0
        public void GetOrCreateBegin(string sKey, TaskResultData oDataToAdd, AsyncCallback fCallback, object oParam)
        {
            m_oGetOrCreate           = new TransportClass(fCallback, oParam);
            m_oGetOrCreate.m_oTast   = oDataToAdd;
            m_oGetOrCreate.m_bCreate = true;
            try
            {
                m_oGetOrCreate.m_oSqlCon = GetDbConnection();
                m_oGetOrCreate.m_oSqlCon.Open();

                if (Constants.mc_sPostgreProvider == Utils.GetDbConnectionProviderName(m_sConnectionString))
                {
                    IDbCommand oInsCommand = m_oGetOrCreate.m_oSqlCon.CreateCommand();
                    oInsCommand.CommandText           = GetINSERTString(m_oGetOrCreate.m_oTast);
                    m_oGetOrCreate.m_oCommand         = oInsCommand;
                    m_oGetOrCreate.m_delegateNonQuery = new ExecuteNonQuery(oInsCommand.ExecuteNonQuery);
                    m_oGetOrCreate.m_delegateNonQuery.BeginInvoke(GetOrCreateCallback, null);
                }
                else
                {
                    IDbCommand oSelCommand = m_oGetOrCreate.m_oSqlCon.CreateCommand();
                    oSelCommand.CommandText           = GetUPSERTString(m_oGetOrCreate.m_oTast);
                    m_oGetOrCreate.m_oCommand         = oSelCommand;
                    m_oGetOrCreate.m_delegateNonQuery = new ExecuteNonQuery(oSelCommand.ExecuteNonQuery);
                    m_oGetOrCreate.m_delegateNonQuery.BeginInvoke(GetOrCreateCallback2, null);
                }
            }
            catch
            {
                m_oGetOrCreate.DisposeAndCallback();
            }
        }
예제 #3
0
        public void GetTaskBegin(AsyncCallback fCallback, object oParam)
        {
            m_GetTask = new TransportClass(fCallback, oParam);
            try
            {
                DateTime oDateTimeNow = DateTime.UtcNow;
                DateTime oDateTimeNowMinusConvertTime = oDateTimeNow.AddSeconds(-1 * m_dMaxConvertTimeInSeconds);
                string   strDateTimeNow = oDateTimeNow.ToString(Constants.mc_sDateTimeFormat);
                string   strDateTimeNowMinusConvertTime = oDateTimeNowMinusConvertTime.ToString(Constants.mc_sDateTimeFormat);

                string strSelectSQL = GetSelectString();

                m_GetTask.m_oSqlCon = GetDbConnection();
                m_GetTask.m_oSqlCon.Open();
                IDbCommand oSelCommand = m_GetTask.m_oSqlCon.CreateCommand();
                oSelCommand.CommandText    = strSelectSQL;
                m_GetTask.m_oCommand       = oSelCommand;
                m_GetTask.m_delegateReader = new ExecuteReader(oSelCommand.ExecuteReader);
                m_GetTask.m_delegateReader.BeginInvoke(GetTaskCallback, null);
            }
            catch
            {
                m_GetTask.DisposeAndCallback();
            }
        }
예제 #4
0
        public void WriteFileBegin(string strPath, System.IO.Stream oStream, AsyncCallback fCallback, object oParam)
        {
            m_oWriteFile = new TransportClass(fCallback, ErrorTypes.StorageWrite, oParam);
            try
            {
                string   strFilepath = GetFilePath(strPath);
                FileInfo oFileInfo   = new FileInfo(strFilepath);
                if (false == oFileInfo.Directory.Exists)
                {
                    oFileInfo.Directory.Create();
                }
                int nStreamLength = (int)oStream.Length;

                if (0 == nStreamLength)
                {
                    nStreamLength = 1;
                }
                FileStream oFileStreamOutput = new FileStream(strFilepath, FileMode.Create, FileAccess.Write, FileShare.Write, nStreamLength, true);
                byte[]     aBuffer           = new byte[oStream.Length];

                m_oWriteFile.m_oInput         = oStream;
                m_oWriteFile.m_aBuffer        = aBuffer;
                m_oWriteFile.m_oOutput        = oFileStreamOutput;
                m_oWriteFile.m_bDisposeOutput = true;
                m_oWriteFile.m_oInput.BeginRead(aBuffer, 0, aBuffer.Length, EndCallbackRead, m_oWriteFile);
            }
            catch
            {
                m_oWriteFile.DisposeAndCallback();
            }
        }
예제 #5
0
 public void RemovePathBegin(string strPath, AsyncCallback fCallback, object oParam)
 {
     m_oRemovePath = new TransportClass(fCallback, ErrorTypes.StorageRemoveDir, oParam);
     try
     {
         string strDirpath = GetFilePath(strPath);
         if (Directory.Exists(strDirpath))
         {
             m_oRemovePath.m_delegateDirectoryDelete = Directory.Delete;
             m_oRemovePath.m_delegateDirectoryDelete.BeginInvoke(strDirpath, true, m_oRemovePath.m_fCallback, m_oRemovePath.m_oParam);
         }
         else if (File.Exists(strDirpath))
         {
             m_oRemovePath.m_delegateFileDelete = File.Delete;
             m_oRemovePath.m_delegateFileDelete.BeginInvoke(strDirpath, m_oRemovePath.m_fCallback, m_oRemovePath.m_oParam);
         }
         else
         {
             m_oRemovePath.FireCallback();
         }
     }
     catch
     {
         m_oRemovePath.DisposeAndCallback();
     }
 }
예제 #6
0
        private void EndCallbackGetListObjects(IAsyncResult ar)
        {
            TransportClass oObject = null;

            try
            {
                oObject = ar.AsyncState as TransportClass;
                oObject.m_oListObjectsResponse = oObject.m_oS3Client.EndListObjects(ar);

                if (oObject.m_oListObjectsResponse.S3Objects.Count > 0)
                {
                    Amazon.S3.Model.DeleteObjectsRequest oDeleteObjectsRequest = new Amazon.S3.Model.DeleteObjectsRequest();
                    oDeleteObjectsRequest.WithBucketName(m_strBucketName);

                    foreach (Amazon.S3.Model.S3Object oS3Obj in oObject.m_oListObjectsResponse.S3Objects)
                    {
                        oDeleteObjectsRequest.AddKey(oS3Obj.Key);
                    }

                    oObject.m_oS3Client.BeginDeleteObjects(oDeleteObjectsRequest, m_oRemoveDirectory.m_fCallback, m_oRemoveDirectory.m_oParam);
                }
                else
                {
                    oObject.FireCallback();
                }
            }
            catch
            {
                m_oRemoveDirectory.m_eError = ErrorTypes.StorageRemoveDir;
                m_oRemoveDirectory.DisposeAndCallback();
            }
        }
예제 #7
0
        public void ReadFileBegin(string strPath, System.IO.Stream oStream, AsyncCallback fCallback, object oParam)
        {
            m_oReadFile = new TransportClass(fCallback, ErrorTypes.StorageRead, oParam);
            try
            {
                string   strFilepath = GetFilePath(strPath);
                FileInfo oFileInfo   = new FileInfo(strFilepath);
                if (oFileInfo.Exists)
                {
                    FileStream oFileStreamInput = new FileStream(strFilepath, FileMode.Open, FileAccess.Read, FileShare.Read, (int)oFileInfo.Length, true);
                    byte[]     aBuffer          = new byte[oFileStreamInput.Length];
                    m_oReadFile.m_oInput        = oFileStreamInput;
                    m_oReadFile.m_aBuffer       = aBuffer;
                    m_oReadFile.m_oOutput       = oStream;
                    m_oReadFile.m_bDisposeInput = true;

                    m_oReadFile.m_oInput.BeginRead(aBuffer, 0, aBuffer.Length, EndCallbackRead, m_oReadFile);
                }
                else
                {
                    m_oReadFile.m_eError = ErrorTypes.StorageFileNoFound;
                    m_oReadFile.FireCallback();
                }
            }
            catch
            {
                m_oReadFile.DisposeAndCallback();
            }
        }
예제 #8
0
        private void EndCallbackReadStream(IAsyncResult ar)
        {
            TransportClass oObject = null;

            try
            {
                oObject = ar.AsyncState as TransportClass;
                oObject.m_nReadWriteBytes = oObject.m_oGetObjectResponse.ResponseStream.EndRead(ar);

                if (oObject.m_nReadWriteBytes > 0)
                {
                    oObject.m_nTotalReadWriteBytes += oObject.m_nReadWriteBytes;
                    oObject.m_oStreamOutput.BeginWrite(oObject.m_aBuffer, 0, oObject.m_nReadWriteBytes, EndCallbackWriteStream, oObject);
                }
                else
                {
                    oObject.FireCallback();
                }
            }
            catch
            {
                if (null != oObject)
                {
                    oObject.DisposeAndCallback();
                }
            }
        }
        private void GetOrCreateCallback(IAsyncResult ar)
        {
            try
            {
                TaskResultData oTaskResult = null;
                m_oGetOrCreate.m_delegateGet.EndInvoke(out oTaskResult, ar);
                m_oGetOrCreate.m_delegateGet = null;

                if (oTaskResult != null)
                {
                    m_oGetOrCreate.m_bCreate = false;
                    m_oGetOrCreate.m_oTast   = oTaskResult;
                    m_oGetOrCreate.FireCallback();
                }
                else
                {
                    m_oGetOrCreate.m_bReadFromDB = true;
                    m_oTaskResultDB.GetOrCreateBegin(m_oGetOrCreate.m_sKey, m_oGetOrCreate.m_oTast, m_oGetOrCreate.m_fCallback, m_oGetOrCreate.m_oParam);
                }
            }
            catch
            {
                m_oGetOrCreate.DisposeAndCallback();
            }
        }
예제 #10
0
 private void GetOrCreateCallback(IAsyncResult ar)
 {
     try
     {
         bool bEmptyRead = false;
         using (IDataReader oReader = m_oGetOrCreate.m_delegateReader.EndInvoke(ar))
         {
             if (true == oReader.Read())
             {
                 m_oGetOrCreate.m_oTast = new TaskResultData();
                 TaskResultFromReader(m_oGetOrCreate.m_oTast, oReader);
             }
             else
             {
                 bEmptyRead = true;
             }
         }
         if (null != m_oGetOrCreate.m_oCommand)
         {
             m_oGetOrCreate.m_oCommand.Dispose();
             m_oGetOrCreate.m_oCommand = null;
         }
         if (bEmptyRead)
         {
             IDbCommand oSelCommand = m_oGetOrCreate.m_oSqlCon.CreateCommand();
             oSelCommand.CommandText           = GetINSERTString(m_oGetOrCreate.m_oTast);
             m_oGetOrCreate.m_oCommand         = oSelCommand;
             m_oGetOrCreate.m_delegateNonQuery = new ExecuteNonQuery(oSelCommand.ExecuteNonQuery);
             m_oGetOrCreate.m_delegateNonQuery.BeginInvoke(GetOrCreateCallback2, null);
         }
         else
         {
             m_oGetOrCreate.m_bCreate        = false;
             m_oGetOrCreate.m_delegateReader = null;
             m_oGetOrCreate.FireCallback();
         }
     }
     catch
     {
         m_oGetOrCreate.DisposeAndCallback();
     }
 }
예제 #11
0
 private void GetOrCreateCallback(IAsyncResult ar)
 {
     try
     {
         bool bExist = false;
         try
         {
             m_oGetOrCreate.m_delegateNonQuery.EndInvoke(ar);
         }
         catch
         {
             bExist = true;
         }
         if (bExist)
         {
             m_oGetOrCreate.m_bCreate = false;
             if (null != m_oGetOrCreate.m_oCommand)
             {
                 m_oGetOrCreate.m_oCommand.Dispose();
                 m_oGetOrCreate.m_oCommand = null;
             }
             IDbCommand             oSelCommand = m_oGetOrCreate.m_oSqlCon.CreateCommand();
             TaskResultDataToUpdate oToUpdate   = new TaskResultDataToUpdate();
             oToUpdate.oLastOpenDate         = DateTime.UtcNow;
             oSelCommand.CommandText         = GetUPDATEString(m_oGetOrCreate.m_oTast.sKey, oToUpdate) + GetSELECTString(m_oGetOrCreate.m_oTast.sKey);
             m_oGetOrCreate.m_oCommand       = oSelCommand;
             m_oGetOrCreate.m_delegateReader = new ExecuteReader(oSelCommand.ExecuteReader);
             m_oGetOrCreate.m_delegateReader.BeginInvoke(m_oGetOrCreate.m_fCallback, m_oGetOrCreate.m_oParam);
         }
         else
         {
             m_oGetOrCreate.m_bCreate        = true;
             m_oGetOrCreate.m_delegateReader = null;
             m_oGetOrCreate.FireCallback();
         }
     }
     catch
     {
         m_oGetOrCreate.DisposeAndCallback();
     }
 }
 public void RemoveTaskBegin(object key, AsyncCallback fCallback, object oParam)
 {
     m_oRemoveTask = new TransportClass(fCallback, oParam);
     try
     {
         m_oRemoveTask.m_delegateRemover = RemoveTask;
         m_oRemoveTask.m_delegateRemover.BeginInvoke(key, fCallback, oParam);
     }
     catch
     {
         m_oRemoveTask.DisposeAndCallback();
     }
 }
 public void GetTaskBegin(AsyncCallback fCallback, object oParam)
 {
     m_oGetTask = new TransportClass(fCallback, oParam);
     try
     {
         m_oGetTask.m_delegateGetter = GetTask;
         m_oGetTask.m_delegateGetter.BeginInvoke(m_oGetTask.m_fCallback, m_oGetTask.m_oParam);
     }
     catch
     {
         m_oGetTask.DisposeAndCallback();
     }
 }
예제 #14
0
        private void EndCallbackRead(IAsyncResult ar)
        {
            TransportClass oTransportClass = ar.AsyncState as TransportClass;

            try
            {
                oTransportClass.m_oInput.EndRead(ar);
                oTransportClass.m_oOutput.BeginWrite(oTransportClass.m_aBuffer, 0, (int)oTransportClass.m_aBuffer.Length, oTransportClass.m_fCallback, oTransportClass.m_oParam);
            }
            catch
            {
                oTransportClass.DisposeAndCallback();
            }
        }
 public void AddTaskBegin(TaskQueueData oTask, Priority oPriority, AsyncCallback fCallback, object oParam)
 {
     m_oAddTask = new TransportClass(fCallback, oParam);
     try
     {
         m_oAddTask.m_delegateAdder = AddTask;
         m_oAddTask.m_delegateAdder.BeginInvoke(oTask, oPriority, m_oAddTask.m_fCallback, m_oAddTask.m_oParam);
     }
     catch
     {
         m_oAddTask.DisposeAndCallback();
     }
     return;
 }
 public void GetBegin(string sKey, AsyncCallback fCallback, object oParam)
 {
     m_oGet = new TransportClass(fCallback, oParam);
     try
     {
         m_oGet.m_sKey        = sKey;
         m_oGet.m_delegateGet = new DelegateGet(GetFromMC);
         m_oGet.m_delegateGet.BeginInvoke(sKey, out m_oGet.m_oTast, GetCallback, null);
     }
     catch
     {
         m_oGet.DisposeAndCallback();
     }
 }
예제 #17
0
 public void WriteMediaXmlBegin(string sPath, Dictionary <string, string> aMediaXmlMapHash, AsyncCallback fAsyncCallback, object oParam)
 {
     m_oWriteMediaXml = new TransportClass(fAsyncCallback, oParam);
     try
     {
         byte[]       aBuffer = GetMediaXmlBytes(aMediaXmlMapHash);
         MemoryStream ms      = new MemoryStream(aBuffer);
         m_oWriteMediaXml.m_oStorage = new Storage();
         m_oWriteMediaXml.m_oStorage.WriteFileBegin(sPath, ms, fAsyncCallback, oParam);
     }
     catch
     {
         m_oWriteMediaXml.DisposeAndCallback();
     }
 }
 public void GetOrCreateBegin(string sKey, TaskResultData oDataToAdd, AsyncCallback fCallback, object oParam)
 {
     m_oGetOrCreate           = new TransportClass(fCallback, oParam);
     m_oGetOrCreate.m_oTast   = oDataToAdd;
     m_oGetOrCreate.m_bCreate = true;
     m_oGetOrCreate.m_sKey    = sKey;
     try
     {
         TaskResultData oTast = null;
         m_oGetOrCreate.m_delegateGet = new DelegateGet(GetFromMC);
         m_oGetOrCreate.m_delegateGet.BeginInvoke(sKey, out oTast, GetOrCreateCallback, null);
     }
     catch
     {
         m_oGetOrCreate.DisposeAndCallback();
     }
 }
예제 #19
0
        private void GetTaskCallback(IAsyncResult ar)
        {
            try
            {
                uint     ncq_id          = 0;
                DateTime oTaskUpdateTime = DateTime.UtcNow;
                bool     bIsExist        = false;
                using (IDataReader oReader = m_GetTask.m_delegateReader.EndInvoke(ar))
                {
                    if (true == oReader.Read())
                    {
                        ncq_id          = Convert.ToUInt32(oReader["cq_id"]);
                        oTaskUpdateTime = Convert.ToDateTime(oReader["cq_update_time"]);

                        m_GetTask.m_oTaskQueueData            = TaskQueueData.DeserializeFromXml(Convert.ToString(oReader["cq_data"]));
                        m_GetTask.m_oTaskQueueData.m_oDataKey = ncq_id;

                        bIsExist = true;
                    }
                }
                if (null != m_GetTask.m_oCommand)
                {
                    m_GetTask.m_oCommand.Dispose();
                    m_GetTask.m_oCommand = null;
                }
                m_GetTask.Close();
                if (bIsExist)
                {
                    IDbCommand oUpdateCommand = m_GetTask.m_oSqlCon.CreateCommand();
                    oUpdateCommand.CommandText   = GetUpdateString(ncq_id, oTaskUpdateTime);
                    m_GetTask.m_oCommand         = oUpdateCommand;
                    m_GetTask.m_delegateNonQuery = new ExecuteNonQuery(oUpdateCommand.ExecuteNonQuery);
                    m_GetTask.m_delegateNonQuery.BeginInvoke(m_GetTask.m_fCallback, m_GetTask.m_oParam);
                }
                else
                {
                    m_GetTask.m_delegateNonQuery = null;
                    m_GetTask.FireCallback();
                }
            }
            catch (Exception e)
            {
                _log.Error("Exception cathed in GetTaskCallback:", e);
                m_GetTask.DisposeAndCallback();
            }
        }
예제 #20
0
        private void EndCallbackWriteStream(IAsyncResult ar)
        {
            TransportClass oObject = null;

            try
            {
                oObject = ar.AsyncState as TransportClass;
                oObject.m_oStreamOutput.EndWrite(ar);
                oObject.m_oGetObjectResponse.ResponseStream.BeginRead(oObject.m_aBuffer, 0, oObject.m_aBuffer.Length, EndCallbackReadStream, oObject);
            }
            catch
            {
                if (null != oObject)
                {
                    oObject.DisposeAndCallback();
                }
            }
        }
예제 #21
0
        public void GetTreeNodeBegin(string strPath, AsyncCallback cb, object oParam)
        {
            try
            {
                m_oGetTreeNode             = new TransportClass(cb, oParam);
                m_oGetTreeNode.m_oS3Client = Amazon.AWSClientFactory.CreateAmazonS3Client(m_oRegion);
                m_oGetTreeNode.m_strPrefix = GetDirPath(strPath);
                Amazon.S3.Model.ListObjectsRequest oRequest = new Amazon.S3.Model.ListObjectsRequest();
                oRequest.WithBucketName(m_strBucketName).WithPrefix(m_oGetTreeNode.m_strPrefix);

                m_oGetTreeNode.m_oS3Client.BeginListObjects(oRequest, m_oGetTreeNode.m_fCallback, m_oGetTreeNode.m_oParam);
            }
            catch
            {
                m_oGetTreeNode.m_eError = ErrorTypes.StorageGetInfo;
                m_oGetTreeNode.DisposeAndCallback();
            }
        }
예제 #22
0
        private void EndCallbackGetObject(IAsyncResult ar)
        {
            TransportClass oObject = null;

            try
            {
                oObject = ar.AsyncState as TransportClass;
                oObject.m_oGetObjectResponse = oObject.m_oS3Client.EndGetObject(ar);
                oObject.m_aBuffer            = new byte[Math.Min(oObject.m_oGetObjectResponse.ContentLength, c_nMaxReadBufferSize)];
                oObject.m_oGetObjectResponse.ResponseStream.BeginRead(oObject.m_aBuffer, 0, oObject.m_aBuffer.Length, EndCallbackReadStream, oObject);
            }
            catch
            {
                if (null != oObject)
                {
                    oObject.DisposeAndCallback();
                }
            }
        }
예제 #23
0
        public void RemovePathBegin(string strPath, AsyncCallback cb, object oParam)
        {
            try
            {
                m_oRemoveDirectory             = new TransportClass(cb, oParam);
                m_oRemoveDirectory.m_oS3Client = Amazon.AWSClientFactory.CreateAmazonS3Client(m_oRegion);

                string strDirKey = GetDirPath(strPath);
                Amazon.S3.Model.ListObjectsRequest oListObjectsRequest = new Amazon.S3.Model.ListObjectsRequest()
                                                                         .WithBucketName(m_strBucketName).WithPrefix(strDirKey);

                m_oRemoveDirectory.m_oS3Client.BeginListObjects(oListObjectsRequest, EndCallbackGetListObjects, m_oRemoveDirectory);
            }
            catch
            {
                m_oRemoveDirectory.m_eError = ErrorTypes.StorageRemoveDir;
                m_oRemoveDirectory.DisposeAndCallback();
            }
        }
예제 #24
0
        public void ReadFileBegin(string strPath, System.IO.Stream oStream, AsyncCallback cb, object oParam)
        {
            try
            {
                m_oReadFile             = new TransportClass(cb, oParam);
                m_oReadFile.m_oS3Client = Amazon.AWSClientFactory.CreateAmazonS3Client(m_oRegion);

                string strFileKey = GetFilePath(strPath);
                Amazon.S3.Model.GetObjectRequest oRequest = new Amazon.S3.Model.GetObjectRequest()
                                                            .WithBucketName(m_strBucketName).WithKey(strFileKey);

                m_oReadFile.m_oStreamOutput = oStream;
                m_oReadFile.m_oS3Client.BeginGetObject(oRequest, EndCallbackGetObject, m_oReadFile);
            }
            catch
            {
                m_oReadFile.m_eError = ErrorTypes.StorageRead;
                m_oReadFile.DisposeAndCallback();
            }
        }
예제 #25
0
 public void GetOrCreateBegin(string sKey, TaskResultData oDataToAdd, AsyncCallback fCallback, object oParam)
 {
     m_oGetOrCreate           = new TransportClass(fCallback, oParam);
     m_oGetOrCreate.m_oTast   = oDataToAdd;
     m_oGetOrCreate.m_bCreate = true;
     try
     {
         m_oGetOrCreate.m_oSqlCon = GetDbConnection();
         m_oGetOrCreate.m_oSqlCon.Open();
         IDbCommand oSelCommand = m_oGetOrCreate.m_oSqlCon.CreateCommand();
         oSelCommand.CommandText         = GetSELECTString(sKey);
         m_oGetOrCreate.m_oCommand       = oSelCommand;
         m_oGetOrCreate.m_delegateReader = new ExecuteReader(oSelCommand.ExecuteReader);
         m_oGetOrCreate.m_delegateReader.BeginInvoke(GetOrCreateCallback, null);
     }
     catch
     {
         m_oGetOrCreate.DisposeAndCallback();
     }
 }
예제 #26
0
        public void GetTaskBegin(AsyncCallback fCallback, object oParam)
        {
            m_GetTask = new TransportClass(fCallback, oParam);
            try
            {
                string strSelectSQL = GetSelectString();

                m_GetTask.m_oSqlCon = GetDbConnection();
                m_GetTask.m_oSqlCon.Open();
                IDbCommand oSelCommand = m_GetTask.m_oSqlCon.CreateCommand();
                oSelCommand.CommandText    = strSelectSQL;
                m_GetTask.m_oCommand       = oSelCommand;
                m_GetTask.m_delegateReader = new ExecuteReader(oSelCommand.ExecuteReader);
                m_GetTask.m_delegateReader.BeginInvoke(GetTaskCallback, null);
            }
            catch (Exception e)
            {
                _log.Error("Exception cathed in GetTaskBegin:", e);
                m_GetTask.DisposeAndCallback();
            }
        }
예제 #27
0
        public void WriteFileBegin(string strPath, System.IO.Stream oStream, AsyncCallback cb, object oParam)
        {
            try
            {
                m_oWriteFile = new TransportClass(cb, oParam);
                m_oWriteFile.m_nReadWriteBytes = (int)oStream.Length;
                m_oWriteFile.m_oS3Client       = Amazon.AWSClientFactory.CreateAmazonS3Client(m_oRegion);

                string strFileKey = GetFilePath(strPath);
                Amazon.S3.Model.PutObjectRequest oRequest = new Amazon.S3.Model.PutObjectRequest()
                                                            .WithBucketName(m_strBucketName).WithKey(strFileKey);
                oRequest.WithInputStream(oStream);

                m_oWriteFile.m_oS3Client.BeginPutObject(oRequest, m_oWriteFile.m_fCallback, m_oWriteFile.m_oParam);
            }
            catch
            {
                m_oWriteFile.m_eError = ErrorTypes.StorageWrite;
                m_oWriteFile.DisposeAndCallback();
            }
        }
예제 #28
0
 public void AddRandomKeyBegin(string sKey, TaskResultData oTastToAdd, AsyncCallback fCallback, object oParam)
 {
     m_oAddRandomKey         = new TransportClass(fCallback, oParam);
     m_oAddRandomKey.m_oTast = oTastToAdd.Clone();
     try
     {
         m_oAddRandomKey.m_oSqlCon = GetDbConnection();
         m_oAddRandomKey.m_oSqlCon.Open();
         string sNewKey = sKey + "_" + m_oRandom.Next(mc_nRandomMaxNumber);
         m_oAddRandomKey.m_oTast.sKey = sNewKey;
         IDbCommand oSelCommand = m_oAddRandomKey.m_oSqlCon.CreateCommand();
         m_oAddRandomKey.m_oCommand         = oSelCommand;
         oSelCommand.CommandText            = GetINSERTString(m_oAddRandomKey.m_oTast);
         m_oAddRandomKey.m_delegateNonQuery = new ExecuteNonQuery(oSelCommand.ExecuteNonQuery);
         m_oAddRandomKey.m_delegateNonQuery.BeginInvoke(AddRandomKeyCallback, null);
     }
     catch
     {
         m_oAddRandomKey.DisposeAndCallback();
     }
 }
예제 #29
0
 private void AddRandomKeyCallback(IAsyncResult ar)
 {
     try
     {
         bool bExist = false;
         try
         {
             m_oAddRandomKey.m_delegateNonQuery.EndInvoke(ar);
             if (null != m_oAddRandomKey.m_oCommand)
             {
                 m_oAddRandomKey.m_oCommand.Dispose();
                 m_oAddRandomKey.m_oCommand = null;
             }
         }
         catch
         {
             bExist = true;
         }
         if (bExist)
         {
             string sNewKey = m_oAddRandomKey.m_oTast.sKey + "_" + m_oRandom.Next(mc_nRandomMaxNumber);
             m_oAddRandomKey.m_oTast.sKey = sNewKey;
             IDbCommand oSelCommand = m_oAddRandomKey.m_oSqlCon.CreateCommand();
             m_oAddRandomKey.m_oCommand         = oSelCommand;
             oSelCommand.CommandText            = GetINSERTString(m_oAddRandomKey.m_oTast);
             m_oAddRandomKey.m_delegateNonQuery = new ExecuteNonQuery(oSelCommand.ExecuteNonQuery);
             m_oAddRandomKey.m_delegateNonQuery.BeginInvoke(AddRandomKeyCallback, null);
         }
         else
         {
             m_oAddRandomKey.Close();
             m_oAddRandomKey.FireCallback();
         }
     }
     catch
     {
         m_oAddRandomKey.DisposeAndCallback();
     }
 }
 public void WriteMediaXmlBegin(string sPath, Dictionary <string, string> aMediaXmlMapHash, AsyncCallback fAsyncCallback, object oParam)
 {
     m_oWriteMediaXml = new TransportClass(fAsyncCallback, oParam);
     try
     {
         StringBuilder sb = new StringBuilder();
         sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
         sb.Append("<images>");
         foreach (KeyValuePair <string, string> kvp in aMediaXmlMapHash)
         {
             sb.AppendFormat("<image md5=\"{0}\" filename=\"{1}\"/>", kvp.Key, kvp.Value);
         }
         sb.Append("</images>");
         byte[]       aBuffer = Encoding.UTF8.GetBytes(sb.ToString());
         MemoryStream ms      = new MemoryStream(aBuffer);
         m_oWriteMediaXml.m_oStorage = new Storage();
         m_oWriteMediaXml.m_oStorage.WriteFileBegin(sPath, ms, fAsyncCallback, oParam);
     }
     catch
     {
         m_oWriteMediaXml.DisposeAndCallback();
     }
 }
예제 #31
0
        public void GetTreeNodeBegin(string strPath, AsyncCallback cb, object oParam)
        {
            try
            {
                m_oGetTreeNode = new TransportClass(cb, oParam);
                m_oGetTreeNode.m_oS3Client = Amazon.AWSClientFactory.CreateAmazonS3Client(m_oRegion);
                m_oGetTreeNode.m_strPrefix = GetDirPath(strPath);
                Amazon.S3.Model.ListObjectsRequest oRequest = new Amazon.S3.Model.ListObjectsRequest();
                oRequest.WithBucketName(m_strBucketName).WithPrefix(m_oGetTreeNode.m_strPrefix);

                m_oGetTreeNode.m_oS3Client.BeginListObjects(oRequest, m_oGetTreeNode.m_fCallback, m_oGetTreeNode.m_oParam);
            }
            catch
            {
                m_oGetTreeNode.m_eError = ErrorTypes.StorageGetInfo;
                m_oGetTreeNode.DisposeAndCallback();
            }
        }
예제 #32
0
        public void WriteFileBegin(string strPath, System.IO.Stream oStream, AsyncCallback fCallback, object oParam)
        {
            m_oWriteFile = new TransportClass(fCallback, ErrorTypes.StorageWrite, oParam);
            try
            {
                string strFilepath = GetFilePath(strPath);
                FileInfo oFileInfo = new FileInfo(strFilepath);
                if (false == oFileInfo.Directory.Exists)
                    oFileInfo.Directory.Create();
                int nStreamLength = (int)oStream.Length;

                if(0 == nStreamLength)
                    nStreamLength = 1;
                FileStream oFileStreamOutput = new FileStream(strFilepath, FileMode.Create, FileAccess.Write, FileShare.Write, nStreamLength, true);
                byte[] aBuffer = new byte[oStream.Length];

                m_oWriteFile.m_oInput = oStream;
                m_oWriteFile.m_aBuffer = aBuffer;
                m_oWriteFile.m_oOutput = oFileStreamOutput;
                m_oWriteFile.m_bDisposeOutput = true;
                m_oWriteFile.m_oInput.BeginRead(aBuffer, 0, aBuffer.Length, EndCallbackRead, m_oWriteFile);
            }
            catch
            {
                m_oWriteFile.DisposeAndCallback();
            }
        }
예제 #33
0
 public void RemovePathBegin(string strPath, AsyncCallback fCallback, object oParam)
 {
     m_oRemovePath = new TransportClass(fCallback, ErrorTypes.StorageRemoveDir, oParam);
     try
     {
         string strDirpath = GetFilePath(strPath);
         if (Directory.Exists(strDirpath))
         {
             m_oRemovePath.m_delegateDirectoryDelete = Directory.Delete;
             m_oRemovePath.m_delegateDirectoryDelete.BeginInvoke(strDirpath, true, m_oRemovePath.m_fCallback, m_oRemovePath.m_oParam);
         }
         else if (File.Exists(strDirpath))
         {
             m_oRemovePath.m_delegateFileDelete = File.Delete;
             m_oRemovePath.m_delegateFileDelete.BeginInvoke(strDirpath, m_oRemovePath.m_fCallback, m_oRemovePath.m_oParam);
         }
         else
         {
             m_oRemovePath.FireCallback();
         }
     }
     catch
     {
         m_oRemovePath.DisposeAndCallback();
     }
 }
예제 #34
0
        public void GetTaskBegin(AsyncCallback fCallback, object oParam)
        {
            m_GetTask = new TransportClass(fCallback, oParam);
            try
            {
                
                string strSelectSQL = GetSelectString();

                m_GetTask.m_oSqlCon = GetDbConnection();
                m_GetTask.m_oSqlCon.Open();
                IDbCommand oSelCommand = m_GetTask.m_oSqlCon.CreateCommand();
                oSelCommand.CommandText = strSelectSQL;
                m_GetTask.m_oCommand = oSelCommand;
                m_GetTask.m_delegateReader = new ExecuteReader(oSelCommand.ExecuteReader);
                m_GetTask.m_delegateReader.BeginInvoke(GetTaskCallback, null);
            }
            catch(Exception e)
            {
                _log.Error("Exception cathed in GetTaskBegin:", e);
                m_GetTask.DisposeAndCallback();
            }
        }
예제 #35
0
        public void GetOrCreateBegin(string sKey, TaskResultData oDataToAdd, AsyncCallback fCallback, object oParam)
        {
            m_oGetOrCreate = new TransportClass(fCallback, oParam);
            m_oGetOrCreate.m_oTast = oDataToAdd;
            m_oGetOrCreate.m_bCreate = true;
            try
            {
                m_oGetOrCreate.m_oSqlCon = GetDbConnection();
                m_oGetOrCreate.m_oSqlCon.Open();

                if (Constants.mc_sPostgreProvider == Utils.GetDbConnectionProviderName(m_sConnectionString))
                {
                    IDbCommand oInsCommand = m_oGetOrCreate.m_oSqlCon.CreateCommand();
                    oInsCommand.CommandText = GetINSERTString(m_oGetOrCreate.m_oTast);
                    m_oGetOrCreate.m_oCommand = oInsCommand;
                    m_oGetOrCreate.m_delegateNonQuery = new ExecuteNonQuery(oInsCommand.ExecuteNonQuery);
                    m_oGetOrCreate.m_delegateNonQuery.BeginInvoke(GetOrCreateCallback, null);
                }
                else
                {

                    IDbCommand oSelCommand = m_oGetOrCreate.m_oSqlCon.CreateCommand();
                    oSelCommand.CommandText = GetUPSERTString(m_oGetOrCreate.m_oTast);
                    m_oGetOrCreate.m_oCommand = oSelCommand;
                    m_oGetOrCreate.m_delegateNonQuery = new ExecuteNonQuery(oSelCommand.ExecuteNonQuery);
                    m_oGetOrCreate.m_delegateNonQuery.BeginInvoke(GetOrCreateCallback2, null);
                }
            }
            catch
            {
                m_oGetOrCreate.DisposeAndCallback();
            }
        }
예제 #36
0
 public void WriteMediaXmlBegin(string sPath, Dictionary<string, string> aMediaXmlMapHash, AsyncCallback fAsyncCallback, object oParam)
 {
     m_oWriteMediaXml = new TransportClass(fAsyncCallback, oParam);
     try
     {
         
         byte[] aBuffer = GetMediaXmlBytes(aMediaXmlMapHash);
         MemoryStream ms = new MemoryStream(aBuffer);
         m_oWriteMediaXml.m_oStorage = new Storage();
         m_oWriteMediaXml.m_oStorage.WriteFileBegin(sPath, ms, fAsyncCallback, oParam);
     }
     catch
     {
         m_oWriteMediaXml.DisposeAndCallback();
     }
 }
예제 #37
0
 public void GetOrCreateBegin(string sKey, TaskResultData oDataToAdd, AsyncCallback fCallback, object oParam)
 {
     m_oGetOrCreate = new TransportClass(fCallback, oParam);
     m_oGetOrCreate.m_oTast = oDataToAdd;
     m_oGetOrCreate.m_bCreate = true;
     m_oGetOrCreate.m_sKey = sKey;
     try
     {
         TaskResultData oTast = null;
         m_oGetOrCreate.m_delegateGet = new DelegateGet(GetFromMC);
         m_oGetOrCreate.m_delegateGet.BeginInvoke(sKey, out oTast, GetOrCreateCallback, null);
     }
     catch
     {
         m_oGetOrCreate.DisposeAndCallback();
     }
 }
예제 #38
0
 public void GetBegin(string sKey, AsyncCallback fCallback, object oParam)
 {
     m_oGet = new TransportClass(fCallback, oParam);
     try
     {
         m_oGet.m_sKey = sKey;
         m_oGet.m_delegateGet = new DelegateGet(GetFromMC);
         m_oGet.m_delegateGet.BeginInvoke(sKey, out m_oGet.m_oTast, GetCallback, null);
     }
     catch 
     {
         m_oGet.DisposeAndCallback();
     }
 }
예제 #39
0
        public void ReadFileBegin(string strPath, System.IO.Stream oStream, AsyncCallback cb, object oParam)
        {
            try
            {
                m_oReadFile = new TransportClass(cb, oParam);
                m_oReadFile.m_oS3Client = Amazon.AWSClientFactory.CreateAmazonS3Client(m_oRegion);

                string strFileKey = GetFilePath(strPath);
                Amazon.S3.Model.GetObjectRequest oRequest = new Amazon.S3.Model.GetObjectRequest()
                      .WithBucketName(m_strBucketName).WithKey(strFileKey);

                m_oReadFile.m_oStreamOutput = oStream;
                m_oReadFile.m_oS3Client.BeginGetObject(oRequest, EndCallbackGetObject, m_oReadFile);
            }
            catch
            {
                m_oReadFile.m_eError = ErrorTypes.StorageRead;
                m_oReadFile.DisposeAndCallback();
            }
        }
예제 #40
0
        public void WriteFileBegin(string strPath, System.IO.Stream oStream, AsyncCallback cb, object oParam)
        {
            try
            {
                m_oWriteFile = new TransportClass(cb, oParam);
                m_oWriteFile.m_nReadWriteBytes = (int)oStream.Length;
                m_oWriteFile.m_oS3Client = Amazon.AWSClientFactory.CreateAmazonS3Client(m_oRegion);

                string strFileKey = GetFilePath(strPath);
                Amazon.S3.Model.PutObjectRequest oRequest = new Amazon.S3.Model.PutObjectRequest()
                    .WithBucketName(m_strBucketName).WithKey(strFileKey);
                oRequest.WithInputStream(oStream);

                m_oWriteFile.m_oS3Client.BeginPutObject(oRequest, m_oWriteFile.m_fCallback, m_oWriteFile.m_oParam);
            }
            catch
            {
                m_oWriteFile.m_eError = ErrorTypes.StorageWrite;
                m_oWriteFile.DisposeAndCallback();
            }
        }
        public void WriteMediaXmlBegin(string sPath, Dictionary<string, string> aMediaXmlMapHash, AsyncCallback fAsyncCallback, object oParam)
        {
            m_oWriteMediaXml = new TransportClass(fAsyncCallback, oParam);
            try
            {

                StringBuilder sb = new StringBuilder();
                sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                sb.Append("<images>");
                foreach (KeyValuePair<string, string> kvp in aMediaXmlMapHash)
                    sb.AppendFormat("<image md5=\"{0}\" filename=\"{1}\"/>", kvp.Key, kvp.Value);
                sb.Append("</images>");
                byte[] aBuffer = Encoding.UTF8.GetBytes(sb.ToString());
                MemoryStream ms = new MemoryStream(aBuffer);
                m_oWriteMediaXml.m_oStorage = new Storage();
                m_oWriteMediaXml.m_oStorage.WriteFileBegin(sPath, ms, fAsyncCallback, oParam);
            }
            catch
            {
                m_oWriteMediaXml.DisposeAndCallback();
            }
        }
 public void AddTaskBegin(TaskQueueData oTask, Priority oPriority, AsyncCallback fCallback, object oParam)
 {
     m_oAddTask = new TransportClass(fCallback, oParam);
     try
     {
         m_oAddTask.m_delegateAdder = AddTask;
         m_oAddTask.m_delegateAdder.BeginInvoke(oTask, oPriority, m_oAddTask.m_fCallback, m_oAddTask.m_oParam);
     }
     catch
     {
         m_oAddTask.DisposeAndCallback();
     }
     return;
 }
        public void GetTaskBegin(AsyncCallback fCallback, object oParam)
        {
            m_GetTask = new TransportClass(fCallback, oParam);
            try
            {
                DateTime oDateTimeNow = DateTime.UtcNow;
                DateTime oDateTimeNowMinusConvertTime = oDateTimeNow.AddSeconds(-1 * m_dMaxConvertTimeInSeconds);
                string strDateTimeNow = oDateTimeNow.ToString(Constants.mc_sDateTimeFormat);
                string strDateTimeNowMinusConvertTime = oDateTimeNowMinusConvertTime.ToString(Constants.mc_sDateTimeFormat);

                string strSelectSQL = GetSelectString();

                m_GetTask.m_oSqlCon = GetDbConnection();
                m_GetTask.m_oSqlCon.Open();
                IDbCommand oSelCommand = m_GetTask.m_oSqlCon.CreateCommand();
                oSelCommand.CommandText = strSelectSQL;
                m_GetTask.m_oCommand = oSelCommand;
                m_GetTask.m_delegateReader = new ExecuteReader(oSelCommand.ExecuteReader);
                m_GetTask.m_delegateReader.BeginInvoke(GetTaskCallback, null);
            }
            catch
            {
                m_GetTask.DisposeAndCallback();
            }
        }
 public void RemoveTaskBegin(object key, AsyncCallback fCallback, object oParam)
 {
     m_oRemoveTask = new TransportClass(fCallback, oParam);
     try
     {
         m_oRemoveTask.m_delegateRemover = RemoveTask;
         m_oRemoveTask.m_delegateRemover.BeginInvoke(key, fCallback, oParam);
     }
     catch
     {
         m_oRemoveTask.DisposeAndCallback();
     }
 }
 public void GetTaskBegin(AsyncCallback fCallback, object oParam)
 {
     m_oGetTask = new TransportClass(fCallback, oParam);
     try
     {
         m_oGetTask.m_delegateGetter = GetTask;
         m_oGetTask.m_delegateGetter.BeginInvoke(m_oGetTask.m_fCallback, m_oGetTask.m_oParam);
     }
     catch
     {
         m_oGetTask.DisposeAndCallback();
     }
 }
예제 #46
0
        public void RemovePathBegin(string strPath, AsyncCallback cb, object oParam)
        {
            try
            {
                m_oRemoveDirectory = new TransportClass(cb, oParam);
                m_oRemoveDirectory.m_oS3Client = Amazon.AWSClientFactory.CreateAmazonS3Client(m_oRegion);

                string strDirKey = GetDirPath(strPath);
                Amazon.S3.Model.ListObjectsRequest oListObjectsRequest = new Amazon.S3.Model.ListObjectsRequest()
                    .WithBucketName(m_strBucketName).WithPrefix(strDirKey);

                m_oRemoveDirectory.m_oS3Client.BeginListObjects(oListObjectsRequest, EndCallbackGetListObjects, m_oRemoveDirectory);
            }
            catch
            {
                m_oRemoveDirectory.m_eError = ErrorTypes.StorageRemoveDir;
                m_oRemoveDirectory.DisposeAndCallback();
            }
        }
예제 #47
0
 public void AddRandomKeyBegin(string sKey, TaskResultData oTastToAdd, AsyncCallback fCallback, object oParam)
 {
     m_oAddRandomKey = new TransportClass(fCallback, oParam);
     m_oAddRandomKey.m_oTast = oTastToAdd.Clone();
     try
     {
         m_oAddRandomKey.m_oSqlCon = GetDbConnection();
         m_oAddRandomKey.m_oSqlCon.Open();
         string sNewKey = sKey + "_" + m_oRandom.Next(mc_nRandomMaxNumber);
         m_oAddRandomKey.m_oTast.sKey = sNewKey;
         IDbCommand oSelCommand = m_oAddRandomKey.m_oSqlCon.CreateCommand();
         m_oAddRandomKey.m_oCommand = oSelCommand;
         oSelCommand.CommandText = GetINSERTString(m_oAddRandomKey.m_oTast);
         m_oAddRandomKey.m_delegateNonQuery = new ExecuteNonQuery(oSelCommand.ExecuteNonQuery);
         m_oAddRandomKey.m_delegateNonQuery.BeginInvoke(AddRandomKeyCallback, null);
     }
     catch
     {
         m_oAddRandomKey.DisposeAndCallback();
     }
 }
예제 #48
0
        public void ReadFileBegin(string strPath, System.IO.Stream oStream, AsyncCallback fCallback, object oParam)
        {
            m_oReadFile = new TransportClass(fCallback, ErrorTypes.StorageRead ,oParam);
            try
            {
                string strFilepath = GetFilePath(strPath);
                FileInfo oFileInfo = new FileInfo(strFilepath);
                if (oFileInfo.Exists)
                {
                    FileStream oFileStreamInput = new FileStream(strFilepath, FileMode.Open, FileAccess.Read, FileShare.Read, (int)oFileInfo.Length, true);
                    byte[] aBuffer = new byte[oFileStreamInput.Length];
                    m_oReadFile.m_oInput = oFileStreamInput;
                    m_oReadFile.m_aBuffer = aBuffer;
                    m_oReadFile.m_oOutput = oStream;
                    m_oReadFile.m_bDisposeInput = true;

                    m_oReadFile.m_oInput.BeginRead(aBuffer, 0, aBuffer.Length, EndCallbackRead, m_oReadFile);
                }
                else
                {
                    m_oReadFile.m_eError = ErrorTypes.StorageFileNoFound;
                    m_oReadFile.FireCallback();
                }
            }
            catch
            {
                m_oReadFile.DisposeAndCallback();
            }
        }
예제 #49
0
 public void GetOrCreateBegin(string sKey, TaskResultData oDataToAdd, AsyncCallback fCallback, object oParam)
 {
     m_oGetOrCreate = new TransportClass(fCallback, oParam);
     m_oGetOrCreate.m_oTast = oDataToAdd;
     m_oGetOrCreate.m_bCreate = true;
     try
     {
         m_oGetOrCreate.m_oSqlCon = GetDbConnection();
         m_oGetOrCreate.m_oSqlCon.Open();
         IDbCommand oSelCommand = m_oGetOrCreate.m_oSqlCon.CreateCommand();
         oSelCommand.CommandText = GetSELECTString(sKey);
         m_oGetOrCreate.m_oCommand = oSelCommand;
         m_oGetOrCreate.m_delegateReader = new ExecuteReader(oSelCommand.ExecuteReader);
         m_oGetOrCreate.m_delegateReader.BeginInvoke(GetOrCreateCallback, null);
     }
     catch
     {
         m_oGetOrCreate.DisposeAndCallback();
     }
 }