Exemplo n.º 1
0
        private HashSet <int> UploadAssets(List <SimpleFileInfo> assets)
        {
            MasterDataMarshallerStreamerClient streamerClient = null;
            MemoryStream ms = null;
            AssetFileStreamParameterMessage message = null;
            HashSet <int> assetIDs = new HashSet <int>();

            try
            {
                streamerClient = new MasterDataMarshallerStreamerClient();

                foreach (SimpleFileInfo asset in assets)
                {
                    try
                    {
                        ms = EncryptAssetFile(_slidePath + asset.FileNameWithPath, _cryptPassword);

                        message                  = new AssetFileStreamParameterMessage();
                        message.Stream           = ms;
                        message.SystemPassPhrase = _systemPassPhrase;
                        message.Checksum         = ChecksumCalculator.GetChecksum(ms);
                        message.Filename         = asset.FilenameNoPath;

                        streamerClient.SetAssetFile(message);

                        assetIDs.Add(asset.FileID);
                    }
                    catch (Exception ex)
                    {
                        LogException(_eventLog, ex.ToString());
                    }
                    finally
                    {
                        if (ms != null)
                        {
                            ms.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogException(_eventLog, ex.ToString());
            }
            finally
            {
                if (streamerClient != null)
                {
                    streamerClient.Dispose();
                }
            }

            return(assetIDs);
        }
Exemplo n.º 2
0
        public void SetAssetFile(AssetFileStreamParameterMessage assetFileParameterStreamMessage)
        {
            if (assetFileParameterStreamMessage.SystemPassPhrase != _systemPassPhrase)
            {
                return;
            }

            string assetDir = _assetPath + assetFileParameterStreamMessage.Filename.Substring(assetFileParameterStreamMessage.Filename.LastIndexOf("_") + 1, 1).ToUpper();

            if (!Directory.Exists(assetDir))
            {
                Directory.CreateDirectory(assetDir);
            }

            string assetFullPath = assetDir + "\\" + assetFileParameterStreamMessage.Filename;

            SaveFileIfDifferent(assetFileParameterStreamMessage, assetFullPath);
        }
 public void SetAssetFile(AssetFileStreamParameterMessage assetFileParameterMessage)
 {
     Channel.SetAssetFile(assetFileParameterMessage);
 }