示例#1
0
        private HashSet <int> UploadChannelData(List <OxigenIIAdvertising.AppData.Channel> channels)
        {
            MasterDataMarshallerStreamerClient streamerClient = null;
            MemoryStream ms = null;
            AppDataFileStreamParameterMessage message = null;
            HashSet <int> channelIDs = new HashSet <int>();

            try
            {
                streamerClient = new MasterDataMarshallerStreamerClient();

                foreach (OxigenIIAdvertising.AppData.Channel channel in channels)
                {
                    try
                    {
                        ms = Serializer.SerializeWithEncryption(channel, _cryptPassword);

                        message                  = new AppDataFileStreamParameterMessage();
                        message.Stream           = ms;
                        message.SystemPassPhrase = _systemPassPhrase;
                        message.Checksum         = ChecksumCalculator.GetChecksum(ms);
                        message.ChannelID        = channel.ChannelID;
                        message.DataFileType     = DataFileType.ChannelData;

                        streamerClient.SetAppDataFiles(message);

                        channelIDs.Add(channel.ChannelID);
                    }
                    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(channelIDs);
        }
示例#2
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);
        }