// 管理通道 public int ManageChannel( string strAction, string strStyle, ChannelInfo[] requests, out ChannelInfo[] results, out string strError) { strError = ""; results = null; if (strAction == "close") { int nCount = 0; foreach(ChannelInfo info in requests) { if (string.IsNullOrEmpty(info.SessionID) == false) { bool bRet = this.SessionTable.CloseSessionBySessionID(info.SessionID); if (bRet == true) nCount++; } if (string.IsNullOrEmpty(info.ClientIP) == false) { nCount += this.SessionTable.CloseSessionByClientIP(info.ClientIP); } } return nCount; } return 0; }
public ChannelEditMessage(IChannelInfo channel) : this() { if (channel == null) throw new ArgumentNullException ("channel"); this.channel = new ChannelInfo (channel); }
public LobbyChannelProvider() { this.lobby = new ChannelInfo (1) { Name = "Lobby", Description = String.Empty, ReadOnly = true }; DefaultChannel = this.lobby; }
public ChannelInfo AddChannel(int id, string name) { if (channels.ContainsKey(id)) { return channels[id]; } ChannelInfo ci = new ChannelInfo(); ci.id = id; ci.name = name; channels.Add(id, ci); return ci; }
public void CtorCopy() { var channel = new ChannelInfo (1) { ParentChannelId = 2, Name = "Name", Description = "Description", ReadOnly = false, UserLimit = 2 }; var channel2 = new ChannelInfo (channel); AssertChanelsAreEqual (channel, channel2); }
public void PlayClip(SMusicState pState) { if(currentState != pState) { Debug.Log("GameMusic: " + pState); AudioClip _requestedClip = GetClipForState(pState); if(mCurrentChannel != null) { Stop (mCurrentChannel, false); } mCurrentChannel = Play(_requestedClip, true); currentState = pState; } }
public void CreateChannel() { ChannelInfo c = new ChannelInfo { Name = "Name", Description = "Description", ParentChannelId = 1 }; manager.Create (c); var msg = server.DequeueAndAssertMessage<ChannelEditMessage> (); Assert.AreEqual (c.Name, msg.Channel.Name); Assert.AreEqual (c.Description, msg.Channel.Description); Assert.AreEqual (c.ParentChannelId, msg.Channel.ParentChannelId); }
/// <summary> /// Adds channel information to packet. /// </summary> /// <param name="packet"></param> /// <param name="channel"></param> /// <param name="type"></param> public static void AddChannelInfo(this Packet packet, ChannelInfo channel, ServerInfoType type) { packet.PutString(channel.Name); packet.PutInt((int)channel.State); packet.PutInt((int)channel.Events); packet.PutInt(0); // 1 for Housing? Hidden? packet.PutShort(channel.Stress); // Channels need more information if (type == ServerInfoType.Internal) { packet.PutString(channel.Host); packet.PutInt(channel.Port); packet.PutInt(channel.Users); } }
/// <summary> /// Parse a parameter from FreeSWITCH /// </summary> /// <param name="name">Parameter name as defined by FS</param> /// <param name="value">Parameter value</param> /// <returns> /// true if parsed sucessfully; otherwise false. /// </returns> public override bool ParseParameter(string name, string value) { switch (name) { case "unique-id": Id = new UniqueId(value); break; case "answer-state": AnswerState = value; break; case "call-direction": CallDirection = Enumm.Parse<ChannelDirection>(value); break; case "channel-call-state": CallState = Enumm.Parse<CallState>(value); break; case "presence-call-direction": PresenceCallDirection = Enumm.Parse<ChannelDirection>(value); break; case "channel-hit-dialplan": HasHitDialplan = value == "true"; break; case "proto": Protocol = value; break; default: if (name.StartsWith("variable_")) { Variables.Add(name.Remove(0, 10), value); return true; } if (name.Length > 8 && name.Substring(0, 8) == "channel-") { if (ChannelInfo == null) ChannelInfo = new ChannelInfo(); return ChannelInfo.Parse(name, value); } return base.ParseParameter(name, value); } return true; }
public void PrintPokemon(SniperInfo sniperInfo, ChannelInfo channelInfo) { Application.Current.Dispatcher.BeginInvoke((Action) delegate { var info = new SniperInfoModel { Info = sniperInfo, Icon = new BitmapImage( new Uri( $"pack://application:,,,/PogoLocationFeeder.GUI;component/Assets/icons/{(int) sniperInfo.Id}.png", UriKind.Absolute)), Server = channelInfo.server, Channel = channelInfo.channel }; info.Icon.Freeze(); InsertToList(info); RemoveListExtras(); }); }
public ChannelInfo ToChannelInfo(string channelId) { var channelInfo = new ChannelInfo(); if (channelId != null) { foreach (var channel in Settings) { if (string.Compare(channelId, channel.id) == 0) { channelInfo.server = channel.Server; channelInfo.channel = channel.Name; channelInfo.isValid = true; return channelInfo; } } } channelInfo.server = "Unknown"; channelInfo.channel = "Unknown"; return channelInfo; }
// 列出指定的通道信息 // parameters: // strUserName 用户名。如果为空,表示列出全部用户名 // return: // -1 出错 // 其他 用户总数(不是本批的个数) public int ListChannels( string strQuery, string strStyle, int nStart, int nCount, out ChannelInfo[] infos, out string strError) { strError = ""; infos = null; Hashtable table = StringUtil.ParseParameters(strQuery); List<ChannelInfo> list = null; int nRet = this.SessionTable.ListChannels( (string)table["ip"], (string)table["username"], strStyle, out list, out strError); if (nRet == -1) return -1; // 计算出本次要返回的数量 if (nCount == -1) nCount = Math.Max(0, list.Count - nStart); nCount = Math.Min(100, nCount); // 限制每批最多100个 // 复制出本次需要的局部 List<ChannelInfo> parts = new List<ChannelInfo>(); for (int i = nStart; i < Math.Min(nStart + nCount, list.Count); i++) // { parts.Add(list[i]); } infos = new ChannelInfo[parts.Count]; parts.CopyTo(infos); return list.Count; // 返回总量 }
public static void PopulateChannels(ClientChannelManager manager, IConnection server) { ChannelInfo c1 = new ChannelInfo (1) { Name = "Channel 1", Description = "Description 1" }; ChannelInfo sc1 = new ChannelInfo (2) { Name = "SubChannel 1", Description = "Description 2", ParentChannelId = c1.ChannelId }; ChannelInfo c2 = new ChannelInfo (3) { Name = "Channel 2", Description = "Description 3" }; manager.OnChannelListReceivedMessage (new MessageEventArgs<ChannelListMessage> (server, new ChannelListMessage (new[] { c1, sc1, c2 }, sc1))); Assert.AreEqual (3, manager.Count ()); Assert.AreEqual (1, manager.Count (c => c.ChannelId == c1.ChannelId && c.Name == c1.Name && c.Description == c1.Description && c.ParentChannelId == c1.ParentChannelId)); Assert.AreEqual (1, manager.Count (c => c.ChannelId == sc1.ChannelId && c.Name == sc1.Name && c.Description == sc1.Description && c.ParentChannelId == sc1.ParentChannelId)); Assert.AreEqual (1, manager.Count (c => c.ChannelId == c2.ChannelId && c.Name == c2.Name && c.Description == c2.Description && c.ParentChannelId == c2.ParentChannelId)); }
public static AddMessageDelegate SetHandler(int channel, NetworkMessageDelegate handler, MyReceiveQueue.Mode mode = MyReceiveQueue.Mode.Synchronized, Func<TimeSpan> timestampProvider = null) { ChannelInfo info; if (m_channels.TryGetValue(channel, out info)) { if (info.Queue.ReadMode == mode) { info.Handler = handler; return info.Queue.AddMessage; } else { info.Queue.Dispose(); } } info = new ChannelInfo(); info.Handler = handler; info.Queue = new MyReceiveQueue(channel, mode, mode == MyReceiveQueue.Mode.Synchronized ? 1 : 50, timestampProvider); m_channels[channel] = info; return info.Queue.AddMessage; }
public static int GetCount(SiteInfo siteInfo, ChannelInfo channelInfo, int adminId, bool isAllContents = false) { var ccIds = GetChannelContentIdList(siteInfo, channelInfo, adminId, isAllContents); return(ccIds.Count()); }
static ChannelInfo[] CreateChannels() { var channels = new ChannelInfo[5]; for (int i = 0; i < channels.Length; i++) { channels[i] = new ChannelInfo(); } return channels; }
void ExecuteCmd(ChannelInfo channel) { ushort value; short offset; ChannelInfo current_channel; ChannelInfo dest_channel; current_channel = channel; if (channel.d.next_cmd == 0) { CheckStopped(); return; } int script_ptr = channel.d.next_cmd; for (;;) { byte opcode = _current_data[script_ptr++]; if (opcode >= 0xf8) { switch (opcode) { case 0xf8: // set hull curve Debug.WriteLine("channels[{0}]: hull curve {1}", Array.IndexOf(_channels, channel), _current_data[script_ptr]); channel.d.hull_curve = hull_offsets[_current_data[script_ptr] / 2]; script_ptr++; break; case 0xf9: // set freqmod curve Debug.WriteLine("channels[{0}]: freqmod curve {1}", Array.IndexOf(_channels, channel), _current_data[script_ptr]); channel.d.freqmod_table = freqmod_offsets[_current_data[script_ptr] / 4]; channel.d.freqmod_modulo = freqmod_lengths[_current_data[script_ptr] / 4]; script_ptr++; break; case 0xfd: // clear other channel value = (ushort)(BitConverter.ToUInt16(_current_data, script_ptr) / 48); Debug.WriteLine("clear channel {0}", value); script_ptr += 2; // In Indy3, when traveling to Venice a command is // issued to clear channel 4. So we introduce a 4th // channel, which is never used. All OOB accesses are // mapped to this channel. // // The original game had room for 8 channels, but only // channels 0-3 are read, changes to other channels // had no effect. if (value >= _channels.Length) value = 4; channel = _channels[value]; channel.d = new channel_data(); break; case 0xfa: // clear current channel if (opcode == 0xfa) Debug.WriteLine("Clear channel"); channel.d = new channel_data(); break; case 0xfb: // ret from subroutine Debug.WriteLine("ret from sub"); script_ptr = _retaddr; break; case 0xfc: // call subroutine offset = BitConverter.ToInt16(_current_data, script_ptr); Debug.WriteLine("subroutine {0}", offset); script_ptr += 2; _retaddr = script_ptr; script_ptr = offset; break; case 0xfe: // loop music opcode = _current_data[script_ptr++]; offset = BitConverter.ToInt16(_current_data, script_ptr); script_ptr += 2; Debug.WriteLine("loop if {0} to {1}", opcode, offset); if (0 == channel[opcode / 2] || --channel[opcode / 2] != 0) script_ptr += offset; break; case 0xff: // set parameter opcode = _current_data[script_ptr++]; value = BitConverter.ToUInt16(_current_data, script_ptr); channel[opcode / 2] = value; Debug.WriteLine("channels[{0}]: set param {1} = {2}", Array.IndexOf(_channels, channel), opcode, value); script_ptr += 2; if (opcode == 14) { /* tempo var */ _ticks_per_music_timer = 125; } if (opcode == 0) goto end; break; } } else { // opcode < 0xf8 for (;;) { short note, octave; int is_last_note; dest_channel = _channels[(opcode >> 5) & 3]; if (0 == (opcode & 0x80)) { int tempo = channel.d.tempo; if (0 == tempo) tempo = 1; channel.d.time_left = (ushort)(tempo * note_lengths[opcode & 0x1f]); note = _current_data[script_ptr++]; is_last_note = note & 0x80; note &= 0x7f; if (note == 0x7f) { Debug.WriteLine("channels[{0}]: pause {1}", Array.IndexOf(_channels, channel), channel.d.time_left); goto end; } } else { channel.d.time_left = (ushort)(((opcode & 7) << 8) | _current_data[script_ptr++]); if ((opcode & 0x10) != 0) { Debug.WriteLine("channels[{0}]: pause {1}", Array.IndexOf(_channels, channel), channel.d.time_left); goto end; } is_last_note = 0; note = (short)(_current_data[script_ptr++] & 0x7f); } Debug.WriteLine("channels[{0}]: @{1:X4} note: {2:D3}+{3:D2} len: {4:D2} hull: {5} mod: {6}/{7}/{8} {9}", Array.IndexOf(_channels, dest_channel), _current_data != null ? script_ptr - 2 : 0, note, (short)dest_channel.d.transpose, channel.d.time_left, dest_channel.d.hull_curve, dest_channel.d.freqmod_table, dest_channel.d.freqmod_incr, dest_channel.d.freqmod_multiplier, is_last_note != 0 ? "last" : ""); ushort myfreq; dest_channel.d.time_left = channel.d.time_left; dest_channel.d.note_length = (ushort)(channel.d.time_left - dest_channel.d.inter_note_pause); note += (short)(dest_channel.d.transpose); while (note < 0) note += 12; octave = (short)(note / 12); note = (short)(note % 12); dest_channel.d.hull_offset = 0; dest_channel.d.hull_counter = 1; if (_pcjr && Equals(dest_channel, _channels[3])) { dest_channel.d.hull_curve = (ushort)(196 + note * 12); myfreq = (ushort)(384 - 64 * octave); } else { myfreq = (ushort)(_freqs_table[note] >> octave); } dest_channel.d.freq = dest_channel.d.base_freq = myfreq; if (is_last_note != 0) goto end; opcode = _current_data[script_ptr++]; } } } end: channel = current_channel; if (channel.d.time_left != 0) { channel.d.next_cmd = (ushort)script_ptr; return; } channel.d.next_cmd = 0; CheckStopped(); }
protected override async Task <ILiveStream> GetChannelStream(TunerHostInfo info, ChannelInfo channelInfo, string streamId, List <ILiveStream> currentLiveStreams, CancellationToken cancellationToken) { var profile = streamId.Split('_')[0]; Logger.LogInformation("GetChannelStream: channel id: {0}. stream id: {1} profile: {2}", channelInfo.Id, streamId, profile); var hdhrId = GetHdHrIdFromChannelId(channelInfo.Id); var hdhomerunChannel = channelInfo as HdHomerunChannelInfo; var modelInfo = await GetModelInfo(info, false, cancellationToken).ConfigureAwait(false); if (!modelInfo.SupportsTranscoding) { profile = "native"; } var mediaSource = GetMediaSource(info, hdhrId, channelInfo, profile); if (hdhomerunChannel != null && hdhomerunChannel.IsLegacyTuner) { return(new HdHomerunUdpStream(mediaSource, info, streamId, new LegacyHdHomerunChannelCommands(hdhomerunChannel.Path), modelInfo.TunerCount, FileSystem, _httpClient, Logger, Config.ApplicationPaths, _appHost, _socketFactory, _networkManager)); } var enableHttpStream = true; if (enableHttpStream) { mediaSource.Protocol = MediaProtocol.Http; var httpUrl = channelInfo.Path; // If raw was used, the tuner doesn't support params if (!string.IsNullOrWhiteSpace(profile) && !string.Equals(profile, "native", StringComparison.OrdinalIgnoreCase)) { httpUrl += "?transcode=" + profile; } mediaSource.Path = httpUrl; return(new SharedHttpStream(mediaSource, info, streamId, FileSystem, _httpClient, Logger, Config.ApplicationPaths, _appHost)); } return(new HdHomerunUdpStream(mediaSource, info, streamId, new HdHomerunChannelCommands(hdhomerunChannel.Number, profile), modelInfo.TunerCount, FileSystem, _httpClient, Logger, Config.ApplicationPaths, _appHost, _socketFactory, _networkManager)); }
public Mesh(AssetPreloadData MeshPD) { //Stream = new EndianStream(File.OpenRead(sourceFile.filePath), sourceFile.endianType); //Stream.endian = sourceFile.endianType; var version = MeshPD.sourceFile.version; a_Stream = MeshPD.sourceFile.a_Stream; a_Stream.Position = MeshPD.Offset; bool m_Use16BitIndices = true; //3.5.0 and newer always uses 16bit indices uint m_MeshCompression = 0; if (MeshPD.sourceFile.platform == -2) { uint m_ObjectHideFlags = a_Stream.ReadUInt32(); PPtr m_PrefabParentObject = MeshPD.sourceFile.ReadPPtr(); PPtr m_PrefabInternal = MeshPD.sourceFile.ReadPPtr(); } m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) { m_Use16BitIndices = a_Stream.ReadBoolean(); a_Stream.Position += 3; } #region Index Buffer for 2.5.1 and earlier if (version[0] == 2 && version[1] <= 5) { int m_IndexBuffer_size = a_Stream.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = a_Stream.ReadUInt16(); } a_Stream.AlignStream(4); } else { m_IndexBuffer = new uint[m_IndexBuffer_size / 4]; for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = a_Stream.ReadUInt32(); } } } #endregion int m_SubMeshes_size = a_Stream.ReadInt32(); for (int s = 0; s < m_SubMeshes_size; s++) { m_SubMeshes.Add(new SubMesh()); m_SubMeshes[s].firstByte = a_Stream.ReadUInt32(); m_SubMeshes[s].indexCount = a_Stream.ReadUInt32(); //what is this in case of triangle strips? m_SubMeshes[s].topology = a_Stream.ReadInt32(); //isTriStrip if (version[0] < 4) { m_SubMeshes[s].triangleCount = a_Stream.ReadUInt32(); } if (version[0] >= 3) { m_SubMeshes[s].firstVertex = a_Stream.ReadUInt32(); m_SubMeshes[s].vertexCount = a_Stream.ReadUInt32(); a_Stream.Position += 24; //Axis-Aligned Bounding Box } } #region m_Shapes for 4.1.0 and later, excluding 4.1.0 alpha if (version [0] >= 5 || (version[0] == 4 && (version[1] > 1 || (version[1] == 1 && MeshPD.sourceFile.buildType[0] != "a")))) { if (version[0] == 4 && version[1] <= 2) //4.1.0f4 - 4.2.2f1 { int m_Shapes_size = a_Stream.ReadInt32(); if (m_Shapes_size > 0) { bool stop = true; } for (int s = 0; s < m_Shapes_size; s++) //untested { string shape_name = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); a_Stream.Position += 36; //uint firstVertex, vertexCount; Vector3f aabbMinDelta, aabbMaxDelta; bool hasNormals, hasTangents } int m_ShapeVertices_size = a_Stream.ReadInt32(); a_Stream.Position += m_ShapeVertices_size * 40; //vertex positions, normals, tangents & uint index } else //4.3.0 and later { int m_ShapeVertices_size = a_Stream.ReadInt32(); a_Stream.Position += m_ShapeVertices_size * 40; //vertex positions, normals, tangents & uint index int shapes_size = a_Stream.ReadInt32(); a_Stream.Position += shapes_size * 12; //uint firstVertex, vertexCount; bool hasNormals, hasTangents int channels_size = a_Stream.ReadInt32(); for (int c = 0; c < channels_size; c++) { string channel_name = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); a_Stream.Position += 12; //uint nameHash; int frameIndex, frameCount } int fullWeights_size = a_Stream.ReadInt32(); a_Stream.Position += fullWeights_size * 4; //floats int m_BindPose_size = a_Stream.ReadInt32(); a_Stream.Position += m_BindPose_size * 16 * 4; //matrix 4x4 int m_BoneNameHashes_size = a_Stream.ReadInt32(); a_Stream.Position += m_BoneNameHashes_size * 4; //uints uint m_RootBoneNameHash = a_Stream.ReadUInt32(); } } #endregion #region Index Buffer for 2.6.0 and later if (version[0] >= 3 || (version[0] == 2 && version[1] >= 6)) { m_MeshCompression = a_Stream.ReadByte(); if (version[0] >= 4) { if (version[0] < 5) { uint m_StreamCompression = a_Stream.ReadByte(); } bool m_IsReadable = a_Stream.ReadBoolean(); bool m_KeepVertices = a_Stream.ReadBoolean(); bool m_KeepIndices = a_Stream.ReadBoolean(); } a_Stream.AlignStream(4); int m_IndexBuffer_size = a_Stream.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = a_Stream.ReadUInt16(); } a_Stream.AlignStream(4); } else { m_IndexBuffer = new uint[m_IndexBuffer_size / 4]; for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = a_Stream.ReadUInt32(); } //align?? } } #endregion #region Vertex Buffer for 3.4.2 and earlier if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) { m_VertexCount = a_Stream.ReadUInt32(); m_Vertices = new float[m_VertexCount * 3]; for (int v = 0; v < m_VertexCount * 3; v++) { m_Vertices[v] = a_Stream.ReadSingle(); } int m_Skin_size = a_Stream.ReadInt32(); a_Stream.Position += m_Skin_size * 32; //4x float weights & 4x int boneIndices int m_BindPose_size = a_Stream.ReadInt32(); a_Stream.Position += m_BindPose_size * 16 * 4; //matrix 4x4 int m_UV1_size = a_Stream.ReadInt32(); m_UV1 = new float[m_UV1_size * 2]; for (int v = 0; v < m_UV1_size * 2; v++) { m_UV1[v] = a_Stream.ReadSingle(); } int m_UV2_size = a_Stream.ReadInt32(); m_UV2 = new float[m_UV2_size * 2]; for (int v = 0; v < m_UV2_size * 2; v++) { m_UV2[v] = a_Stream.ReadSingle(); } if (version[0] == 2 && version[1] <= 5) { int m_TangentSpace_size = a_Stream.ReadInt32(); m_Normals = new float[m_TangentSpace_size * 3]; for (int v = 0; v < m_TangentSpace_size; v++) { m_Normals[v * 3] = a_Stream.ReadSingle(); m_Normals[v * 3 + 1] = a_Stream.ReadSingle(); m_Normals[v * 3 + 2] = a_Stream.ReadSingle(); a_Stream.Position += 16; //Vector3f tangent & float handedness } } else //2.6.0 and later { int m_Tangents_size = a_Stream.ReadInt32(); a_Stream.Position += m_Tangents_size * 16; //Vector4f int m_Normals_size = a_Stream.ReadInt32(); m_Normals = new float[m_Normals_size * 3]; for (int v = 0; v < m_Normals_size * 3; v++) { m_Normals[v] = a_Stream.ReadSingle(); } } } #endregion #region Vertex Buffer for 3.5.0 and later else { #region read vertex stream int m_Skin_size = a_Stream.ReadInt32(); a_Stream.Position += m_Skin_size * 32; //4x float weights & 4x int boneIndices if (version[0] <= 3 || (version[0] == 4 && version[1] <= 2)) { int m_BindPose_size = a_Stream.ReadInt32(); a_Stream.Position += m_BindPose_size * 16 * 4; //matrix 4x4 } int m_CurrentChannels = a_Stream.ReadInt32();//defined as uint in Unity m_VertexCount = a_Stream.ReadUInt32(); #region 3.5.0 - 3.5.7 if (version[0] < 4) { if (m_MeshCompression != 0 && version[2] == 0) //special case not just on platform 9 { a_Stream.Position += 12; } else { m_Streams = new StreamInfo[4]; for (int s = 0; s < 4; s++) { m_Streams[s] = new StreamInfo(); m_Streams[s].channelMask = new BitArray(new int[1] { a_Stream.ReadInt32() }); m_Streams[s].offset = a_Stream.ReadInt32(); m_Streams[s].stride = a_Stream.ReadInt32(); m_Streams[s].align = a_Stream.ReadUInt32(); } } } #endregion #region 4.0.0 and later else { int singleStreamStride = 0;//used tor unity 5 m_Channels = new ChannelInfo[a_Stream.ReadInt32()]; for (int c = 0; c < m_Channels.Length; c++) { m_Channels[c] = new ChannelInfo(); m_Channels[c].stream = a_Stream.ReadByte(); m_Channels[c].offset = a_Stream.ReadByte(); m_Channels[c].format = a_Stream.ReadByte(); m_Channels[c].dimension = a_Stream.ReadByte(); //calculate stride for Unity 5 singleStreamStride += m_Channels[c].dimension * (m_Channels[c].format % 2 == 0 ? 4 : 2);//fingers crossed! } if (version[0] < 5) { m_Streams = new StreamInfo[a_Stream.ReadInt32()]; for (int s = 0; s < m_Streams.Length; s++) { m_Streams[s] = new StreamInfo(); m_Streams[s].channelMask = new BitArray(new int[1] { a_Stream.ReadInt32() }); m_Streams[s].offset = a_Stream.ReadInt32(); m_Streams[s].stride = a_Stream.ReadByte(); m_Streams[s].dividerOp = a_Stream.ReadByte(); m_Streams[s].frequency = a_Stream.ReadUInt16(); } } else //it's just easier to create my own stream here { m_Streams = new StreamInfo[1]; m_Streams[0] = new StreamInfo(); m_Streams[0].channelMask = new BitArray(new int[1] { m_CurrentChannels }); m_Streams[0].offset = 0; m_Streams[0].stride = singleStreamStride; } } #endregion //actual Vertex Buffer byte[] m_DataSize = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_DataSize, 0, m_DataSize.Length); #endregion #region compute FvF byte valueBufferSize = 0; byte[] valueBuffer; float[] dstArray; if (m_Channels != null) { //it is better to loop channels instead of streams //because channels are likely to be sorted by vertex property #region 4.0.0 and later foreach (var m_Channel in m_Channels) { if (m_Channel.dimension > 0) { var m_Stream = m_Streams[m_Channel.stream]; for (int b = 0; b < 6; b++) { if (m_Stream.channelMask.Get(b)) { switch (m_Channel.format) { case 0: //32bit valueBufferSize = 4; break; case 1: //16bit valueBufferSize = 2; break; case 2: //8bit valueBufferSize = 1; m_Channel.dimension = 4;//these are actually groups of 4 components break; } valueBuffer = new byte[valueBufferSize]; dstArray = new float[m_VertexCount * m_Channel.dimension]; for (int v = 0; v < m_VertexCount; v++) { for (int d = 0; d < m_Channel.dimension; d++) { int m_DataSizeOffset = m_Stream.offset + m_Channel.offset + m_Stream.stride * v + valueBufferSize * d; Buffer.BlockCopy(m_DataSize, m_DataSizeOffset, valueBuffer, 0, valueBufferSize); dstArray[v * m_Channel.dimension + d] = bytesToFloat(valueBuffer); } } switch (b) { case 0://1 m_Vertices = dstArray; break; case 1://2 m_Normals = dstArray; break; case 2://4 m_Colors = dstArray; break; case 3://8 m_UV1 = dstArray; break; case 4://16 m_UV2 = dstArray; break; case 5://32 m_Tangents = dstArray; break; } m_Stream.channelMask.Set(b, false); //is this needed? valueBuffer = null; dstArray = null; break; //go to next channel } } } } } #endregion #region 3.5.0 - 3.5.7 else if (m_Streams != null) { foreach (var m_Stream in m_Streams) { //a stream may have multiple vertex components but without channels there are no offsets, so I assume all vertex properties are in order //Unity 3.5.x only uses floats, and that's probably why channels were introduced in Unity 4 ChannelInfo m_Channel = new ChannelInfo();//create my own channel so I can use the same methods m_Channel.offset = 0; for (int b = 0; b < 6; b++) { if (m_Stream.channelMask.Get(b)) { switch (b) { case 0: case 1: valueBufferSize = 4; m_Channel.dimension = 3; break; case 2: valueBufferSize = 1; m_Channel.dimension = 4; break; case 3: case 4: valueBufferSize = 4; m_Channel.dimension = 2; break; case 5: valueBufferSize = 4; m_Channel.dimension = 4; break; } valueBuffer = new byte[valueBufferSize]; dstArray = new float[m_VertexCount * m_Channel.dimension]; for (int v = 0; v < m_VertexCount; v++) { for (int d = 0; d < m_Channel.dimension; d++) { int m_DataSizeOffset = m_Stream.offset + m_Channel.offset + m_Stream.stride * v + valueBufferSize * d; Buffer.BlockCopy(m_DataSize, m_DataSizeOffset, valueBuffer, 0, valueBufferSize); dstArray[v * m_Channel.dimension + d] = bytesToFloat(valueBuffer); } } switch (b) { case 0: m_Vertices = dstArray; break; case 1: m_Normals = dstArray; break; case 2: m_Colors = dstArray; break; case 3: m_UV1 = dstArray; break; case 4: m_UV2 = dstArray; break; case 5: m_Tangents = dstArray; break; } m_Channel.offset += (byte)(m_Channel.dimension * valueBufferSize); //strides larger than 255 are unlikely m_Stream.channelMask.Set(b, false); //is this needed? valueBuffer = null; dstArray = null; } } } } #endregion #endregion } #endregion #region Compressed Mesh data for 2.6.0 and later - 160 bytes if (version[0] >= 3 || (version[0] == 2 && version[1] >= 6)) { //remember there can be combinations of packed and regular vertex properties PackedBitVector m_Vertices_Packed = new PackedBitVector(); m_Vertices_Packed.m_NumItems = a_Stream.ReadUInt32(); m_Vertices_Packed.m_Range = a_Stream.ReadSingle(); m_Vertices_Packed.m_Start = a_Stream.ReadSingle(); m_Vertices_Packed.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_Vertices_Packed.m_Data, 0, m_Vertices_Packed.m_Data.Length); a_Stream.AlignStream(4); m_Vertices_Packed.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment if (m_Vertices_Packed.m_NumItems > 0) { m_VertexCount = m_Vertices_Packed.m_NumItems / 3; uint[] m_Vertices_Unpacked = UnpackBitVector(m_Vertices_Packed); int bitmax = 0;//used to convert int value to float for (int b = 0; b < m_Vertices_Packed.m_BitSize; b++) { bitmax |= (1 << b); } m_Vertices = new float[m_Vertices_Packed.m_NumItems]; for (int v = 0; v < m_Vertices_Packed.m_NumItems; v++) { m_Vertices[v] = (float)m_Vertices_Unpacked[v] / bitmax * m_Vertices_Packed.m_Range + m_Vertices_Packed.m_Start; } } PackedBitVector m_UV_Packed = new PackedBitVector(); //contains both channels m_UV_Packed.m_NumItems = a_Stream.ReadUInt32(); m_UV_Packed.m_Range = a_Stream.ReadSingle(); m_UV_Packed.m_Start = a_Stream.ReadSingle(); m_UV_Packed.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_UV_Packed.m_Data, 0, m_UV_Packed.m_Data.Length); m_UV_Packed.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment if (m_UV_Packed.m_NumItems > 0) { uint[] m_UV_Unpacked = UnpackBitVector(m_UV_Packed); int bitmax = 0; for (int b = 0; b < m_Vertices_Packed.m_BitSize; b++) { bitmax |= (1 << b); } m_UV1 = new float[m_VertexCount * 2]; for (int v = 0; v < m_VertexCount * 2; v++) { m_UV1[v] = (float)m_UV_Unpacked[v] / bitmax * m_UV_Packed.m_Range + m_UV_Packed.m_Start; } if (m_UV_Packed.m_NumItems == m_VertexCount * 4) { m_UV2 = new float[m_VertexCount * 2]; for (uint v = 0; v < m_VertexCount * 2; v++) { m_UV2[v] = (float)m_UV_Unpacked[v + m_VertexCount * 2] / bitmax * m_UV_Packed.m_Range + m_UV_Packed.m_Start; } } } if (version[0] < 5) { PackedBitVector m_BindPoses_Packed = new PackedBitVector(); m_BindPoses_Packed.m_NumItems = a_Stream.ReadUInt32(); m_BindPoses_Packed.m_Range = a_Stream.ReadSingle(); m_BindPoses_Packed.m_Start = a_Stream.ReadSingle(); m_BindPoses_Packed.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_BindPoses_Packed.m_Data, 0, m_BindPoses_Packed.m_Data.Length); a_Stream.AlignStream(4); m_BindPoses_Packed.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment } PackedBitVector m_Normals_Packed = new PackedBitVector(); m_Normals_Packed.m_NumItems = a_Stream.ReadUInt32(); m_Normals_Packed.m_Range = a_Stream.ReadSingle(); m_Normals_Packed.m_Start = a_Stream.ReadSingle(); m_Normals_Packed.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_Normals_Packed.m_Data, 0, m_Normals_Packed.m_Data.Length); a_Stream.AlignStream(4); m_Normals_Packed.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment PackedBitVector m_Tangents_Packed = new PackedBitVector(); m_Tangents_Packed.m_NumItems = a_Stream.ReadUInt32(); m_Tangents_Packed.m_Range = a_Stream.ReadSingle(); m_Tangents_Packed.m_Start = a_Stream.ReadSingle(); m_Tangents_Packed.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_Tangents_Packed.m_Data, 0, m_Tangents_Packed.m_Data.Length); a_Stream.AlignStream(4); m_Tangents_Packed.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment PackedBitVector m_Weights_Packed = new PackedBitVector(); m_Weights_Packed.m_NumItems = a_Stream.ReadUInt32(); m_Weights_Packed.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_Weights_Packed.m_Data, 0, m_Weights_Packed.m_Data.Length); a_Stream.AlignStream(4); m_Weights_Packed.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment PackedBitVector m_NormalSigns_packed = new PackedBitVector(); m_NormalSigns_packed.m_NumItems = a_Stream.ReadUInt32(); m_NormalSigns_packed.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_NormalSigns_packed.m_Data, 0, m_NormalSigns_packed.m_Data.Length); a_Stream.AlignStream(4); m_NormalSigns_packed.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment if (m_Normals_Packed.m_NumItems > 0) { uint[] m_Normals_Unpacked = UnpackBitVector(m_Normals_Packed); uint[] m_NormalSigns = UnpackBitVector(m_NormalSigns_packed); int bitmax = 0; for (int b = 0; b < m_Normals_Packed.m_BitSize; b++) { bitmax |= (1 << b); } m_Normals = new float[m_Normals_Packed.m_NumItems / 2 * 3]; for (int v = 0; v < m_Normals_Packed.m_NumItems / 2; v++) { m_Normals[v * 3] = (float)((double)m_Normals_Unpacked[v * 2] / bitmax) * m_Normals_Packed.m_Range + m_Normals_Packed.m_Start; m_Normals[v * 3 + 1] = (float)((double)m_Normals_Unpacked[v * 2 + 1] / bitmax) * m_Normals_Packed.m_Range + m_Normals_Packed.m_Start; m_Normals[v * 3 + 2] = (float)Math.Sqrt(1 - m_Normals[v * 3] * m_Normals[v * 3] - m_Normals[v * 3 + 1] * m_Normals[v * 3 + 1]); if (m_NormalSigns[v] == 0) { m_Normals[v * 3 + 2] *= -1; } } } PackedBitVector m_TangentSigns = new PackedBitVector(); m_TangentSigns.m_NumItems = a_Stream.ReadUInt32(); m_TangentSigns.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_TangentSigns.m_Data, 0, m_TangentSigns.m_Data.Length); a_Stream.AlignStream(4); m_TangentSigns.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment if (version[0] >= 5) { PackedBitVector m_FloatColors = new PackedBitVector(); m_FloatColors.m_NumItems = a_Stream.ReadUInt32(); m_FloatColors.m_Range = a_Stream.ReadSingle(); m_FloatColors.m_Start = a_Stream.ReadSingle(); m_FloatColors.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_FloatColors.m_Data, 0, m_FloatColors.m_Data.Length); a_Stream.AlignStream(4); m_FloatColors.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment if (m_FloatColors.m_NumItems > 0) { uint[] m_FloatColors_Unpacked = UnpackBitVector(m_FloatColors); int bitmax = 0; for (int b = 0; b < m_Vertices_Packed.m_BitSize; b++) { bitmax |= (1 << b); } m_Colors = new float[m_FloatColors.m_NumItems]; for (int v = 0; v < m_FloatColors.m_NumItems; v++) { m_Colors[v] = (float)m_FloatColors_Unpacked[v] / bitmax * m_FloatColors.m_Range + m_FloatColors.m_Start; } } } PackedBitVector m_BoneIndices = new PackedBitVector(); m_BoneIndices.m_NumItems = a_Stream.ReadUInt32(); m_BoneIndices.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_BoneIndices.m_Data, 0, m_BoneIndices.m_Data.Length); a_Stream.AlignStream(4); m_BoneIndices.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment PackedBitVector m_Triangles = new PackedBitVector(); m_Triangles.m_NumItems = a_Stream.ReadUInt32(); m_Triangles.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_Triangles.m_Data, 0, m_Triangles.m_Data.Length); a_Stream.AlignStream(4); m_Triangles.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment if (m_Triangles.m_NumItems > 0) { m_IndexBuffer = UnpackBitVector(m_Triangles); } } #endregion #region Colors & Collision triangles for 3.4.2 and earlier if (version[0] <= 2 || (version[0] == 3 && version[1] <= 4)) // { a_Stream.Position += 24; //Axis-Aligned Bounding Box int m_Colors_size = a_Stream.ReadInt32(); m_Colors = new float[m_Colors_size * 4]; for (int v = 0; v < m_Colors_size * 4; v++) { m_Colors[v] = (float)(a_Stream.ReadByte()) / 0xFF; } int m_CollisionTriangles_size = a_Stream.ReadInt32(); a_Stream.Position += m_CollisionTriangles_size * 4; //UInt32 indices int m_CollisionVertexCount = a_Stream.ReadInt32(); } #endregion #region Compressed colors & Local AABB for 3.5.0 to 4.x.x else //vertex colors are either in streams or packed bits { if (version[0] < 5) { PackedBitVector m_Colors_Packed = new PackedBitVector(); m_Colors_Packed.m_NumItems = a_Stream.ReadUInt32(); m_Colors_Packed.m_Data = new byte[a_Stream.ReadInt32()]; a_Stream.Read(m_Colors_Packed.m_Data, 0, m_Colors_Packed.m_Data.Length); a_Stream.AlignStream(4); m_Colors_Packed.m_BitSize = a_Stream.ReadByte(); a_Stream.Position += 3; //4 byte alignment if (m_Colors_Packed.m_NumItems > 0) { if (m_Colors_Packed.m_BitSize == 32) { //4 x 8bit color channels m_Colors = new float[m_Colors_Packed.m_Data.Length]; for (int v = 0; v < m_Colors_Packed.m_Data.Length; v++) { m_Colors[v] = (float)m_Colors_Packed.m_Data[v] / 0xFF; } } else //not tested { uint[] m_Colors_Unpacked = UnpackBitVector(m_Colors_Packed); int bitmax = 0;//used to convert int value to float for (int b = 0; b < m_Colors_Packed.m_BitSize; b++) { bitmax |= (1 << b); } m_Colors = new float[m_Colors_Packed.m_NumItems]; for (int v = 0; v < m_Colors_Packed.m_NumItems; v++) { m_Colors[v] = (float)m_Colors_Unpacked[v] / bitmax; } } } } a_Stream.Position += 24; //Axis-Aligned Bounding Box } #endregion int m_MeshUsageFlags = a_Stream.ReadInt32(); if (version[0] >= 5) { //int m_BakedConvexCollisionMesh = a_Stream.ReadInt32(); //a_Stream.Position += m_BakedConvexCollisionMesh; //int m_BakedTriangleCollisionMesh = a_Stream.ReadInt32(); //a_Stream.Position += m_BakedConvexCollisionMesh; } #region Build face indices for (int s = 0; s < m_SubMeshes_size; s++) { uint firstIndex = m_SubMeshes[s].firstByte / 2; if (!m_Use16BitIndices) { firstIndex /= 2; } if (m_SubMeshes[s].topology == 0) { for (int i = 0; i < m_SubMeshes[s].indexCount / 3; i++) { m_Indices.Add(m_IndexBuffer[firstIndex + i * 3]); m_Indices.Add(m_IndexBuffer[firstIndex + i * 3 + 1]); m_Indices.Add(m_IndexBuffer[firstIndex + i * 3 + 2]); m_materialIDs.Add(s); } } else { for (int i = 0; i < m_SubMeshes[s].indexCount - 2; i++) { uint fa = m_IndexBuffer[firstIndex + i]; uint fb = m_IndexBuffer[firstIndex + i + 1]; uint fc = m_IndexBuffer[firstIndex + i + 2]; if ((fa!=fb) && (fa!=fc) && (fc!=fb)) { m_Indices.Add(fa); if ((i % 2) == 0) { m_Indices.Add(fb); m_Indices.Add(fc); } else { m_Indices.Add(fc); m_Indices.Add(fb); } m_materialIDs.Add(s); } } } } #endregion }
/// <summary> /// Play the specified audio clip. /// </summary> /// <param name="clip">audio clip.</param> /// <param name="loop">If set to <c>true</c> loops the audio clip.</param> /// <returns>A ChannelInfo instance to stop playback or access the channel. </returns> public virtual ChannelInfo Play(AudioClip clip, bool loop) { var channel = GetFreeChannel(); channel.Clip = clip; channel.Loops = loop; channel.FadeDuration = FadeDuration; channel.Play(); ChannelInfo ci = new ChannelInfo(); ci.Channel = channel; return ci; }
/// <summary> /// Sends the PMT to the CI module /// </summary> /// <param name="subChannel">The sub channel.</param> /// <param name="channel">channel on which we are tuned</param> /// <param name="PMT">byte array containing the PMT</param> /// <param name="pmtLength">length of the pmt array</param> /// <param name="audioPid">pid of the current audio stream</param> /// <returns></returns> public bool SendPMT(int subChannel, DVBBaseChannel channel, byte[] PMT, int pmtLength, int audioPid, bool isPmtChange) { try { if (!_useCam) { return(true); } if (channel.FreeToAir) { return(true); //no need to descramble this one... } AddSubChannel(subChannel, channel); ConditionalAccessContext context = _mapSubChannels[subChannel]; context.CamType = _CamType; context.Channel = channel; if (_CamType == CamType.Astoncrypt2) { int newLength; context.PMT = PatchPMT_AstonCrypt2(PMT, pmtLength, out newLength); context.PMTLength = newLength; } else { context.PMT = PMT; context.PMTLength = pmtLength; } context.AudioPid = audioPid; context.ServiceId = channel.ServiceId; if (_turbosight != null) { return(_turbosight.SendPmt(ListManagementType.Only, CommandIdType.Descrambling, context.PMT, context.PMTLength)); } if (_winTvCiModule != null) { int hr = _winTvCiModule.SendPMT(PMT, pmtLength); if (hr != 0) { Log.Log.Info("Conditional Access: sendPMT to WinTVCI failed"); return(false); } Log.Log.Info("Conditional Access: sendPMT to WinTVCI succeeded"); return(true); } if (_knc != null) { ChannelInfo info = new ChannelInfo(); info.DecodePmt(PMT); int caPmtLen; byte[] caPmt = info.caPMT.CaPmtStruct(out caPmtLen); return(_knc.SendPMT(caPmt, caPmtLen)); } if (_DigitalDevices != null) { if (isPmtChange) { _DigitalDevices.SendServiceIdToCam(0); } return(_DigitalDevices.SendServiceIdToCam(channel.ServiceId)); } if (_digitalEveryWhere != null) { return(_digitalEveryWhere.SendPMTToFireDTV(_mapSubChannels)); } if (_technoTrend != null) { return(_technoTrend.DescrambleMultiple(_mapSubChannels)); // return _technoTrend.SendPMT(PMT, pmtLength); } if (_twinhan != null) { ChannelInfo info = new ChannelInfo(); info.DecodePmt(PMT); int caPmtLen; byte[] caPmt = info.caPMT.CaPmtStruct(out caPmtLen); return(_twinhan.SendPMT(caPmt, caPmtLen)); } } catch (Exception ex) { Log.Log.Write(ex); } return(true); }
protected virtual Task OnTeamsChannelRenamedAsync(ChannelInfo channelInfo, TeamInfo teamInfo, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { return(Task.CompletedTask); }
protected override async Task <ILiveStream> GetChannelStream(TunerHostInfo info, ChannelInfo channelInfo, string streamId, List <ILiveStream> currentLiveStreams, CancellationToken cancellationToken) { var tunerCount = info.TunerCount; if (tunerCount > 0) { var tunerHostId = info.Id; var liveStreams = currentLiveStreams.Where(i => string.Equals(i.TunerHostId, tunerHostId, StringComparison.OrdinalIgnoreCase)).ToList(); if (liveStreams.Count >= tunerCount) { throw new LiveTvConflictException("M3U simultaneous stream limit has been reached."); } } var sources = await GetChannelStreamMediaSources(info, channelInfo, cancellationToken).ConfigureAwait(false); var mediaSource = sources.First(); if (mediaSource.Protocol == MediaProtocol.Http && !mediaSource.RequiresLooping) { var extension = Path.GetExtension(mediaSource.Path) ?? string.Empty; if (!_disallowedSharedStreamExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase)) { return(new SharedHttpStream(mediaSource, info, streamId, FileSystem, _httpClient, Logger, Config.ApplicationPaths, _appHost)); } } return(new LiveStream(mediaSource, info, FileSystem, Logger, Config.ApplicationPaths)); }
protected virtual MediaSourceInfo CreateMediaSourceInfo(TunerHostInfo info, ChannelInfo channel) { var path = channel.Path; var supportsDirectPlay = !info.EnableStreamLooping && info.TunerCount == 0; var supportsDirectStream = !info.EnableStreamLooping; var protocol = _mediaSourceManager.GetPathProtocol(path); Uri uri; var isRemote = true; if (Uri.TryCreate(path, UriKind.Absolute, out uri)) { isRemote = !_networkManager.IsInLocalNetwork(uri.Host); } var httpHeaders = new Dictionary <string, string>(); if (protocol == MediaProtocol.Http) { // Use user-defined user-agent. If there isn't one, make it look like a browser. httpHeaders["User-Agent"] = string.IsNullOrWhiteSpace(info.UserAgent) ? "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.85 Safari/537.36" : info.UserAgent; } var mediaSource = new MediaSourceInfo { Path = path, Protocol = protocol, MediaStreams = new List <MediaStream> { new MediaStream { Type = MediaStreamType.Video, // Set the index to -1 because we don't know the exact index of the video stream within the container Index = -1, IsInterlaced = true }, new MediaStream { Type = MediaStreamType.Audio, // Set the index to -1 because we don't know the exact index of the audio stream within the container Index = -1 } }, RequiresOpening = true, RequiresClosing = true, RequiresLooping = info.EnableStreamLooping, ReadAtNativeFramerate = false, Id = channel.Path.GetMD5().ToString("N"), IsInfiniteStream = true, IsRemote = isRemote, IgnoreDts = true, SupportsDirectPlay = supportsDirectPlay, SupportsDirectStream = supportsDirectStream, RequiredHttpHeaders = httpHeaders }; mediaSource.InferTotalBitrate(); return(mediaSource); }
protected override Task <List <MediaSourceInfo> > GetChannelStreamMediaSources(TunerHostInfo info, ChannelInfo channelInfo, CancellationToken cancellationToken) { return(Task.FromResult(new List <MediaSourceInfo> { CreateMediaSourceInfo(info, channelInfo) })); }
private async Task MessageReceived(SocketMessage message) { try { var senderUser = ((global::Discord.WebSocket.SocketGuildUser)message.Author); string sender = senderUser.Nickname; sender = sender == null ? message.Author.Username : sender; CommandMessage command = new CommandMessage(message.Content); var klaas = await message.Channel.GetUserAsync(command.Mention); if (klaas == null || (klaas.Username.ToLower() != DiscordClient.CurrentUser.Username.ToLower())) { return; } switch (command.Command) { case "test": { await message.Channel.SendMessageAsync("test"); break; } case "help": { await message.Channel.SendMessageAsync(@"Jooo malse makker, \n" + "Ik ben er om je te helpen!\n" + "Gebruik '@richard dab' voor een mooie dab.\n " + "Gebruik '@richard kokhals' voor een kokhals.\n " + "Gebruik '@richard meme' voor een leuke meme.\n" + "Gebruik '@richard weer' voor het weer!"); break; } case "connect": { var channelId = message.Channel.Id; var guildId = senderUser.Guild.Id; ChannelInfo channel = new ChannelInfo() { ChannelId = channelId, GuildId = guildId }; config.connectedChannels.Add(channel); botsConfig.Save(); await message.Channel.SendMessageAsync("Channel toegevoegd."); break; } case "message": { if (senderUser.Id != config.AdminId) { await SendMessageToChannels(command.ReadString(true)); } break; } case "meme": case "dab": case "vinger": case "kokhals": { var memeType = MemeTypeHelper.FromString(command.Command); var file = GetMeme(memeType); if (!string.IsNullOrEmpty(file)) { Task.Run(async() => await message.Channel.SendFileAsync(file)); } else { await sendDebugMessage($"image error {command} not found??"); } break; } case "weer": { var weatherMessage = await message.Channel.SendMessageAsync(":robot:"); await weatherMessage.ModifyAsync(x => { x.Content = ""; x.Embed = GetWeather(); }); break; } case "broadcastweer": { if (senderUser.Id != config.AdminId) { var weer = GetWeather(); await SendMessageToChannels(":robot:", weer); } break; } } } catch (Exception e) { await sendDebugMessage(e.ToString()); } }
public TypingStatusUpdateNotification(object sender, ChannelInfo channel) : base(sender) { Channel = channel; }
void IStreamCallbacks.LoginCallback(ErrorCode result, ChannelInfo channelInfo) { if (Error.Succeeded(result)) { m_ChannelInfo = channelInfo; SetBroadcastState(BroadcastState.LoggedIn); m_LoggedIn = true; } else { SetBroadcastState(BroadcastState.Initialized); m_LoggedIn = false; string err = Error.GetString(result); ReportError(string.Format("LoginCallback got failure: {0}", err)); } try { if (LoginAttemptComplete != null) { this.LoginAttemptComplete(result); } } catch (Exception x) { ReportError(x.ToString()); } }
private void CleanUpSound(ref FMOD.Sound fmodSound) { this.State = PlayerState.Stop; this.CurrentMediaFile = null; if (this.channelInfo != null && this.channelInfo.Channel != null) { this.channelInfo.File.State = PlayerState.Stop; this.channelInfo.Channel.setCallback(null); this.channelInfo.Channel = null; this.channelInfo.File = null; this.channelInfo = null; } if (fmodSound != null) { var result = fmodSound.release(); result.ERRCHECK(); fmodSound = null; } this.timer.Stop(); this.currentPositionMs = 0; this.OnPropertyChanged("CurrentPositionMs"); this.LengthMs = 0; }
protected abstract Task <List <MediaSourceInfo> > GetChannelStreamMediaSources(TunerHostInfo tuner, ChannelInfo channel, CancellationToken cancellationToken);
public override bool ParseParameter(string name, string value) { var res = ChannelState.ParseParameter(name, value); switch (name) { case "status": Status = value; break; case "rpid": Rpid = value; break; case "login": Login = value; break; case "event_type": PresenceEventType = value; break; case "resub": ReSubscribe = value == "true"; break; case "alt_event_type": AlternativeEventType = value; break; case "event_count": EventCount = int.Parse(value); break; case "channel-state": State = ChannelStateParser.Parse(value); break; case "presence-calling-file": CallingFile = value; break; case "presence-calling-function": CallingFunction = value; break; case "presence-calling-line": CallingLineNumber = int.Parse(value); break; default: if (name.Length > 8 && name.Substring(0, 8) == "channel-") { if (ChannelInfo == null) ChannelInfo = new ChannelInfo(); return ChannelInfo.Parse(name, value); } if (name.Length > 7 && name.Substring(0, 7) == "caller-") { if (Caller == null) Caller = new PartyInfo(); return Caller.Parse(name.Substring(7), value); } return base.ParseParameter(name, value) || res; } return true; }
protected abstract Task <ILiveStream> GetChannelStream(TunerHostInfo tuner, ChannelInfo channel, string streamId, List <ILiveStream> currentLiveStreams, CancellationToken cancellationToken);
public override void ReadPayload(ISerializationContext context, IValueReader reader) { this.channel = new ChannelInfo (context, reader); Delete = reader.ReadBool (); MakeDefault = reader.ReadBool(); }
public Task <IEnumerable <ChannelInfo> > BuildChannelInfos(CancellationToken cancellationToken) { return(Task.Factory.StartNew <IEnumerable <ChannelInfo> >(() => { lock (_data) { List <ChannelInfo> result = new List <ChannelInfo>(); foreach (KeyValuePair <int, HTSMessage> entry in _data) { if (cancellationToken.IsCancellationRequested) { _logger.LogInformation("[TVHclient] ChannelDataHelper.buildChannelInfos, call canceled - returning part list."); return result; } HTSMessage m = entry.Value; try { ChannelInfo ci = new ChannelInfo(); ci.Id = "" + entry.Key; ci.ImagePath = ""; if (m.containsField("channelIcon")) { string channelIcon = m.getString("channelIcon"); Uri uriResult; bool uriCheckResult = Uri.TryCreate(channelIcon, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp; if (uriCheckResult) { ci.ImageUrl = channelIcon; } else { ci.HasImage = true; if (!_piconData.ContainsKey(ci.Id)) { _piconData.Add(ci.Id, channelIcon); } } } if (m.containsField("channelName")) { string name = m.getString("channelName"); if (string.IsNullOrEmpty(name)) { continue; } ci.Name = m.getString("channelName"); } if (m.containsField("channelNumber")) { int channelNumber = m.getInt("channelNumber"); ci.Number = "" + channelNumber; if (m.containsField("channelNumberMinor")) { int channelNumberMinor = m.getInt("channelNumberMinor"); ci.Number = ci.Number + "." + channelNumberMinor; } } Boolean serviceFound = false; if (m.containsField("services")) { IList tunerInfoList = m.getList("services"); if (tunerInfoList != null && tunerInfoList.Count > 0) { HTSMessage firstServiceInList = (HTSMessage)tunerInfoList[0]; if (firstServiceInList.containsField("type")) { string type = firstServiceInList.getString("type").ToLower(); switch (type) { case "radio": ci.ChannelType = ChannelType.Radio; serviceFound = true; break; case "sdtv": case "hdtv": case "fhdtv": case "uhdtv": ci.ChannelType = ChannelType.TV; serviceFound = true; break; case "other": switch (_channelType4Other.ToLower()) { case "tv": _logger.LogInformation("[TVHclient] ChannelDataHelper: map service tag 'Other' to 'TV'."); ci.ChannelType = ChannelType.TV; serviceFound = true; break; case "radio": _logger.LogInformation("[TVHclient] ChannelDataHelper: map service tag 'Other' to 'Radio'."); ci.ChannelType = ChannelType.Radio; serviceFound = true; break; default: _logger.LogInformation("[TVHclient] ChannelDataHelper: don't map service tag 'Other' - will be ignored."); break; } break; default: _logger.LogInformation("[TVHclient] ChannelDataHelper: unkown service tag '{tag}' - will be ignored.", type); break; } } } } if (!serviceFound) { _logger.LogInformation("[TVHclient] ChannelDataHelper: unable to detect service-type (tvheadend tag!!!) from service list: {m}", m.ToString()); continue; } _logger.LogInformation("[TVHclient] ChannelDataHelper: Adding channel: {m}", m.ToString()); result.Add(ci); } catch (Exception ex) { _logger.LogError(ex, "[TVHclient] ChannelDataHelper.BuildChannelInfos caught exception. HTSmessage: {m}", m); } } return result; } })); }
/// <summary> /// チャンネル詳細を更新 /// </summary> private void UpdateChannelDetail(ChannelInfo info) { string chName = getChannelName(info); statusBar.ChannelDetail = String.Format("{0} {1}{2} {3}", chName, (string.IsNullOrEmpty(info.Genre) ? "" : string.Format("[{0}] ", info.Genre)), info.Desc, info.Comment); }
protected override VodChannelListInfo AnalysisData(System.Xml.XmlReader reader) { var result = new VodChannelListInfo(); result.Channels = new List <ChannelInfo>(); while (reader.Read()) { if (reader.IsStartElement("count")) { reader.Read(); result.ChannelCount = int.Parse(reader.Value); } if (reader.IsStartElement("page_count")) { reader.Read(); result.PageCount = int.Parse(reader.Value); } if (reader.NodeType == XmlNodeType.Element && reader.Name == "v") { //LogManager.Ins.Log("v begin"); int vid = 0; string title = ""; string playLink = ""; int typeID = 0; string imgUrl = ""; string catalogTags = ""; string directorTags = ""; string actTags = ""; string yearTags = ""; string areaTags = ""; int state = 0; string note = ""; double mark = 0; int bitrate = 0; int resolutionWidth = 0; int resolutionHeight = 0; bool isHD = false; bool isRecommend = false; bool isNew = false; bool is3D = false; double duration = 0; string resolution = ""; string content = ""; string slotUrl = ""; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { string node_name = reader.Name; reader.Read(); switch (node_name) { case "vid": vid = int.Parse(reader.Value); break; case "type": typeID = int.Parse(reader.Value); break; case "playlink": playLink = reader.Value; break; case "title": title = reader.Value; break; case "catalog": catalogTags = reader.Value; break; case "director": directorTags = reader.Value; break; case "act": actTags = reader.Value; break; case "year": yearTags = reader.Value; break; case "area": areaTags = reader.Value; break; case "imgurl": imgUrl = reader.Value; break; case "state": try { state = int.Parse(reader.Value); } catch (Exception) { state = 1; } break; case "note": note = reader.Value; break; case "mark": mark = double.Parse(reader.Value); break; case "bitrate": bitrate = int.Parse(reader.Value); break; case "resolution": resolution = reader.Value; string[] widthHeight = resolution.Split('|'); if (widthHeight.Length > 0) { resolutionWidth = int.Parse(widthHeight[0]); resolutionHeight = int.Parse(widthHeight[1]); } break; case "flag": string[] flags = reader.Value.Split('|'); foreach (string flag in flags) { //h表示高清,r表示推荐,n表示最新更新,b表示蓝光, d表示3d switch (flag) { case "h": isHD = true; break; case "r": isRecommend = true; break; case "n": isNew = true; break; case "d": is3D = true; break; default: break; } } break; case "duration": duration = double.Parse(reader.Value); break; case "content": content = reader.Value; break; case "sloturl": slotUrl = reader.Value; break; default: break; } } // end if if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "v") { ChannelInfo channelInfo = new ChannelInfo(vid, title, playLink, typeID, imgUrl, catalogTags, directorTags, actTags, yearTags, areaTags, state, note, mark, bitrate, resolutionWidth, resolutionHeight, isHD, isRecommend, isNew, is3D, duration, content, slotUrl); if (string.IsNullOrEmpty(channelInfo.ImgUrl)) { channelInfo.ImgUrl = channelInfo.SlotUrl; } result.Channels.Add(channelInfo); break; } // end if } //end while } // end if } // end while return(result); }
void NextFreqs(ChannelInfo channel) { channel.d.volume += channel.d.volume_delta; channel.d.base_freq += channel.d.freq_delta; channel.d.freqmod_offset += channel.d.freqmod_incr; if (channel.d.freqmod_modulo > 0) { channel.d.freqmod_offset %= channel.d.freqmod_modulo; } // if (channel.d.freqmod_offset > channel.d.freqmod_modulo) // channel.d.freqmod_offset -= channel.d.freqmod_modulo; channel.d.freq = (ushort)( freqmod_table[channel.d.freqmod_table + (channel.d.freqmod_offset >> 4)] * channel.d.freqmod_multiplier / 256 + channel.d.base_freq); Debug.WriteLine("Freq: {0}/{1}, {2}/{3}/{4}*{5} {6}", channel.d.base_freq, (short)channel.d.freq_delta, channel.d.freqmod_table, channel.d.freqmod_offset, channel.d.freqmod_incr, channel.d.freqmod_multiplier, channel.d.freq); if (channel.d.note_length != 0 && --channel.d.note_length == 0) { channel.d.hull_offset = 16; channel.d.hull_counter = 1; } if (--channel.d.time_left == 0) { ExecuteCmd(channel); } if (channel.d.hull_counter != 0 && --channel.d.hull_counter == 0) { for (;;) { var hull_ptr = channel.d.hull_curve + channel.d.hull_offset / 2; if (hulls[hull_ptr + 1] == -1) { channel.d.volume = (ushort)hulls[hull_ptr]; if (hulls[hull_ptr] == 0) channel.d.volume_delta = 0; channel.d.hull_offset += 4; } else { channel.d.volume_delta = (ushort)hulls[hull_ptr]; channel.d.hull_counter = (ushort)hulls[hull_ptr + 1]; channel.d.hull_offset += 4; break; } } } }
void PutSDK(string filePath, SDKInfo info, ChannelInfo channelInfo) { SDKConfig config = EditorData.TotalSDKInfo.GetSDKConfig(info.sdkName); //添加Jar OutPut("添加Jar " + info.sdkName); PutJar(filePath, info); //手动移除无法编译通过的字段 RemoveErrordManifest(filePath); //自动编译类 if (config.useCustomJavaClass) { OutPut("自动编译 "); compileTool.Compile(config, channelInfo, filePath); } //拷贝资源文件 OutPut("拷贝资源文件 " + info.sdkName); CopyFile(filePath, info, channelInfo); //添加标签头 for (int i = 0; i < config.XmlHeadList.Count; i++) { OutPut("添加XMLHead " + info.sdkName + " " + config.XmlHeadList[i].key); AddXMLHead(filePath, config.XmlHeadList[i], info, channelInfo); } //添加Application头 for (int i = 0; i < config.ApplicationHeadList.Count; i++) { OutPut("添加ApplicationHead " + info.sdkName + " " + config.ApplicationHeadList[i].Key); AddApplicationHead(filePath, config.ApplicationHeadList[i], info, channelInfo); } //添加Activity for (int i = 0; i < config.ActivityInfoList.Count; i++) { OutPut("添加Activity " + info.sdkName + " " + config.ActivityInfoList[i].name); AddActivity(filePath, config.ActivityInfoList[i], info, channelInfo); } //添加MainActivityProperty for (int i = 0; i < config.mainActivityPropertyList.Count; i++) { OutPut("添加mainActivityProperty " + info.sdkName + " " + config.mainActivityPropertyList[i].key); AddMainActivityProperty(filePath, config.mainActivityPropertyList[i], info, channelInfo); } //添加Service for (int i = 0; i < config.serviceInfoList.Count; i++) { OutPut("添加Service " + info.sdkName + " " + config.serviceInfoList[i].name); AddService(filePath, config.serviceInfoList[i], channelInfo, info); } //添加Provider for (int i = 0; i < config.providerInfoList.Count; i++) { OutPut("添加Provider " + info.sdkName + " " + config.providerInfoList[i].name); AddProvider(filePath, config.providerInfoList[i], channelInfo, info); } //添加Meta字段 for (int i = 0; i < config.metaInfoList.Count; i++) { OutPut("添加Meta " + info.sdkName + " " + config.metaInfoList[i].key); AddMeta(filePath, config.metaInfoList[i], channelInfo, info); } //添加Uses字段 for (int i = 0; i < config.usesList.Count; i++) { OutPut("添加Uses " + info.sdkName + " " + config.usesList[i].key); AddUses(filePath, config.usesList[i], channelInfo, info); } //修改ApplicationName if (!string.IsNullOrEmpty(config.ApplicationName)) { OutPut("修改ApplicationName " + config.ApplicationName); ChangeApplicationName(filePath, config.ApplicationName); } //添加配置文件 OutPut("添加配置文件 " + info.sdkName); SaveSDKConfigFile(filePath, info); }
void IStreamCallbacks.LoginCallback(ErrorCode result, ChannelInfo channelInfo) { }
protected override async Task OnTeamsChannelDeletedAsync(ChannelInfo channelInfo, TeamInfo teamInfo, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { var heroCard = new HeroCard(text: $"{channelInfo.Name} is the Channel deleted"); await turnContext.SendActivityAsync(MessageFactory.Attachment(heroCard.ToAttachment()), cancellationToken); }
public void UpdateChannelFailed() { ChannelInfo c1 = new ChannelInfo (1) { Name = "Channel 1", Description = "Description 1" }; ChannelInfo sc1 = new ChannelInfo (2) { Name = "SubChannel 1", Description = "Description 2", ParentChannelId = c1.ChannelId }; ChannelInfo c2 = new ChannelInfo (3) { Name = "Channel 2", Description = "Description 3" }; manager.OnChannelListReceivedMessage (new MessageEventArgs<ChannelListMessage> (this.server, new ChannelListMessage (new[] { c1, sc1, c2 }, sc1))); ChannelInfo updated = new ChannelInfo (1, c1) { Name = "Updated 1", Description = "U Description 1" }; manager.OnChannelEditResultMessage (new ChannelEditResultMessage (updated, ChannelEditResult.FailedUnknown)); Assert.AreEqual (3, manager.Count ()); Assert.AreEqual (0, manager.Count (c => c.ChannelId == c1.ChannelId && c.Name == updated.Name && c.Description == updated.Description)); Assert.AreEqual (1, manager.Count (c => c.ChannelId == c1.ChannelId && c.Name == c1.Name && c.Description == c1.Description)); }
private MediaSourceInfo GetMediaSource(TunerHostInfo info, string channelId, ChannelInfo channelInfo, string profile) { int? width = null; int? height = null; bool isInterlaced = true; string videoCodec = null; string audioCodec = null; int?videoBitrate = null; int?audioBitrate = null; if (string.Equals(profile, "mobile", StringComparison.OrdinalIgnoreCase)) { width = 1280; height = 720; isInterlaced = false; videoCodec = "h264"; videoBitrate = 2000000; } else if (string.Equals(profile, "heavy", StringComparison.OrdinalIgnoreCase)) { width = 1920; height = 1080; isInterlaced = false; videoCodec = "h264"; videoBitrate = 15000000; } else if (string.Equals(profile, "internet540", StringComparison.OrdinalIgnoreCase)) { width = 960; height = 546; isInterlaced = false; videoCodec = "h264"; videoBitrate = 2500000; } else if (string.Equals(profile, "internet480", StringComparison.OrdinalIgnoreCase)) { width = 848; height = 480; isInterlaced = false; videoCodec = "h264"; videoBitrate = 2000000; } else if (string.Equals(profile, "internet360", StringComparison.OrdinalIgnoreCase)) { width = 640; height = 360; isInterlaced = false; videoCodec = "h264"; videoBitrate = 1500000; } else if (string.Equals(profile, "internet240", StringComparison.OrdinalIgnoreCase)) { width = 432; height = 240; isInterlaced = false; videoCodec = "h264"; videoBitrate = 1000000; } if (channelInfo != null) { if (string.IsNullOrWhiteSpace(videoCodec)) { videoCodec = channelInfo.VideoCodec; } audioCodec = channelInfo.AudioCodec; if (!videoBitrate.HasValue) { videoBitrate = (channelInfo.IsHD ?? true) ? 15000000 : 2000000; } audioBitrate = (channelInfo.IsHD ?? true) ? 448000 : 192000; } // normalize if (string.Equals(videoCodec, "mpeg2", StringComparison.OrdinalIgnoreCase)) { videoCodec = "mpeg2video"; } string nal = null; if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase)) { nal = "0"; } var url = GetApiUrl(info, false); var id = profile; if (string.IsNullOrWhiteSpace(id)) { id = "native"; } id += "_" + channelId.GetMD5().ToString("N") + "_" + url.GetMD5().ToString("N"); var mediaSource = new MediaSourceInfo { Path = url, Protocol = MediaProtocol.Udp, MediaStreams = new List <MediaStream> { new MediaStream { Type = MediaStreamType.Video, // Set the index to -1 because we don't know the exact index of the video stream within the container Index = -1, IsInterlaced = isInterlaced, Codec = videoCodec, Width = width, Height = height, BitRate = videoBitrate, NalLengthSize = nal }, new MediaStream { Type = MediaStreamType.Audio, // Set the index to -1 because we don't know the exact index of the audio stream within the container Index = -1, Codec = audioCodec, BitRate = audioBitrate } }, RequiresOpening = true, RequiresClosing = true, BufferMs = 0, Container = "ts", Id = id, SupportsDirectPlay = false, SupportsDirectStream = true, SupportsTranscoding = true, IsInfiniteStream = true, IgnoreDts = true, //SupportsProbing = false, //AnalyzeDurationMs = 2000000 //IgnoreIndex = true, //ReadAtNativeFramerate = true }; mediaSource.InferTotalBitrate(); return(mediaSource); }
//------------------------------------------------------------- // イベントの初期化 //------------------------------------------------------------- private void InitEvent() { // スレッドビューワを開く openViewerToolStripButton.Click += (sender, e) => shortcut.ExecCommand(Commands.OpenPeerstViewer); // 最小化ボタン minToolStripButton.Click += (sender, e) => shortcut.RaiseEvent(ShortcutEvents.MinButtonClick); // 最大化ボタン maxToolStripButton.Click += (sender, e) => shortcut.RaiseEvent(ShortcutEvents.MaxButtonClick); // 閉じるボタン closeToolStripButton.Click += (sender, e) => shortcut.RaiseEvent(ShortcutEvents.CloseButtonClick); // 音量クリック statusBar.VolumeClick += (sender, e) => shortcut.RaiseEvent(ShortcutEvents.Mute); // ダブルクリック pecaPlayer.DoubleClickEvent += (sender, e) => shortcut.RaiseEvent(ShortcutEvents.DoubleClick); // マウスホイール MouseWheel += (sender, e) => { if ((Control.MouseButtons & MouseButtons.Right) == MouseButtons.Right) { // 右クリックマウスホイール if (e.Delta > 0) { shortcut.RaiseEvent(ShortcutEvents.RightClickWheelUp); } else if (e.Delta < 0) { shortcut.RaiseEvent(ShortcutEvents.RightClickWheelDown); } } else { // マウスホイール if (e.Delta > 0) { shortcut.RaiseEvent(ShortcutEvents.WheelUp); } else if (e.Delta < 0) { shortcut.RaiseEvent(ShortcutEvents.WheelDown); } } }; // チャンネル情報更新 bool isFirst = true; pecaPlayer.ChannelInfoChange += (sender, e) => { ChannelInfo info = pecaPlayer.ChannelInfo; // TODO 文字が空の場合は、スペースを空けない UpdateChannelDetail(info); // タイトル設定 string chName = getChannelName(info); Win32API.SetWindowText(Handle, String.Format("{0} - PeerstPlayer", chName)); // 初回のみの設定 if (isFirst) { // コンタクトURL設定 // TODO コンタクトURLが変更されたら、通知後にURL変更 // コンタクトURLが空の場合、引数からコンタクトURLを取得する if (string.IsNullOrEmpty(info.Url)) { var commandLine = Environment.GetCommandLineArgs(); if (Environment.GetCommandLineArgs().Length > 4) { var url = commandLine[4]; statusBar.SelectThreadUrl = url; } else { // コンタクトURLが空の場合 statusBar.SelectThreadUrl = String.Empty; } } else { statusBar.SelectThreadUrl = info.Url; } isFirst = false; } }; // ステータスバーのサイズ変更 statusBar.HeightChanged += (sender, e) => { // 最大化時はサイズ変更しない if (WindowState == FormWindowState.Maximized) { return; } // Formサイズ変更 if (FrameInvisible) { Size = new Size(pecaPlayer.Width, pecaPlayer.Height + statusBar.Height); } else { ClientSize = new Size(ClientSize.Width, (pecaPlayer.Height + statusBar.Height)); } }; // ステータスバーのクリックイベント statusBar.ChannelDetailClick += (sender, e) => { if (e.Button == MouseButtons.Left) { shortcut.RaiseEvent(ShortcutEvents.StatusbarLeftClick); } else if (e.Button == MouseButtons.Right) { shortcut.RaiseEvent(ShortcutEvents.StatusbarRightClick); } }; // サイズ変更 SizeChanged += (sender, e) => { if ((ClientSize.Width) == 0 || (ClientSize.Height == 0)) { return; } // 幅 pecaPlayer.Width = ClientSize.Width; statusBar.Width = ClientSize.Width; // 高さ pecaPlayer.Height = ClientSize.Height - statusBar.Height; statusBar.Top = pecaPlayer.Bottom; }; // 動画サイズ変更 pecaPlayer.MovieSizeChange += (sender, e) => { // Formサイズ変更 if (FrameInvisible) { Size = new Size(pecaPlayer.Width, pecaPlayer.Height + statusBar.Height); } else { ClientSize = new Size(pecaPlayer.Width, pecaPlayer.Height + statusBar.Height); } // 幅 statusBar.Width = pecaPlayer.Width; // 高さ statusBar.Top = pecaPlayer.Bottom; }; // 音量変更イベント pecaPlayer.VolumeChange += (sender, e) => statusBar.Volume = (pecaPlayer.Mute ? "-" : pecaPlayer.Volume.ToString()); // スレッドタイトル右クリックイベント statusBar.ThreadTitleRightClick += (sender, e) => shortcut.RaiseEvent(ShortcutEvents.ThreadTitleRightClick); // マウスジェスチャー MouseGesture mouseGesture = new MouseGesture(); mouseGesture.Interval = PlayerSettings.MouseGestureInterval; bool isGesturing = false; // タイマーイベント Timer timer = new Timer(); timer.Interval = MovieStatusUpdateInterval; timer.Tick += (sender, e) => { // 自動表示ボタンの表示切り替え if (toolStrip.Visible && !IsVisibleToolStrip(PointToClient(MousePosition))) { toolStrip.Visible = false; } // 画面外に出たらマウスジェスチャー解除 if (!RectangleToScreen(ClientRectangle).Contains(MousePosition)) { isGesturing = false; } // 動画ステータスを表示 if (pecaPlayer.Duration.Length == 0) { switch (pecaPlayer.PlayState) { case WMPPlayState.wmppsUndefined: statusBar.MovieStatus = ""; break; case WMPPlayState.wmppsStopped: statusBar.MovieStatus = "停止"; break; case WMPPlayState.wmppsPaused: statusBar.MovieStatus = "一時停止"; break; case WMPPlayState.wmppsPlaying: statusBar.MovieStatus = "再生中"; break; case WMPPlayState.wmppsScanForward: statusBar.MovieStatus = "早送り"; break; case WMPPlayState.wmppsScanReverse: statusBar.MovieStatus = "巻き戻し"; break; case WMPPlayState.wmppsWaiting: statusBar.MovieStatus = "接続待機"; break; case WMPPlayState.wmppsMediaEnded: statusBar.MovieStatus = "再生完了"; break; case WMPPlayState.wmppsTransitioning: statusBar.MovieStatus = "準備中"; break; case WMPPlayState.wmppsReady: statusBar.MovieStatus = "準備完了"; break; case WMPPlayState.wmppsReconnecting: statusBar.MovieStatus = "再接続"; break; case WMPPlayState.wmppsBuffering: statusBar.MovieStatus = string.Format("バッファ{0}%", pecaPlayer.BufferingProgress); break; } } // 再生時間を表示 else { statusBar.MovieStatus = pecaPlayer.Duration; } // 動画情報を更新 ChannelInfo info = pecaPlayer.ChannelInfo ?? new ChannelInfo(); statusBar.UpdateMovieInfo( new MovieInfo() { NowFps = pecaPlayer.NowFrameRate, Fps = pecaPlayer.FrameRate, NowBitrate = pecaPlayer.NowBitrate, Bitrate = pecaPlayer.Bitrate, ListenerNumber = info.Listeners, RelayNumber = info.Relays, Status = info.Status, StreamType = info.Type, }); }; timer.Start(); // マウスダウンイベント pecaPlayer.MouseDownEvent += (sender, e) => { if (e.nButton == (short)Keys.LButton) { // マウスドラッグ FormUtility.WindowDragStart(this.Handle); } else if (e.nButton == (short)Keys.RButton) { // マウスジェスチャー開始 mouseGesture.Start(); isGesturing = true; } else if (e.nButton == (short)Keys.MButton) { // 中クリック shortcut.RaiseEvent(ShortcutEvents.MiddleClick); } }; // マウスアップイベント pecaPlayer.MouseUpEvent += (sender, e) => { if (e.nButton == (short)Keys.RButton) { // チャンネル詳細を再描画 ChannelInfo info = pecaPlayer.ChannelInfo; if (info != null) { UpdateChannelDetail(info); } // マウスジェスチャーが実行されていなければ string gesture = mouseGesture.ToString(); if (string.IsNullOrEmpty(gesture)) { // コンテキストメニュー表示 contextMenuStrip.Show(MousePosition); } else if (isGesturing) { // マウスジェスチャー実行 shortcut.ExecGesture(gesture); } isGesturing = false; } }; // マウス移動イベント pecaPlayer.MouseMoveEvent += (sender, e) => { // 自動表示ボタンの表示切り替え if (toolStrip.Visible != IsVisibleToolStrip(new Point(e.fX, e.fY))) { toolStrip.Visible = !toolStrip.Visible; } if (isGesturing) { // ジェスチャー表示 mouseGesture.Moving(new Point(e.fX, e.fY)); string gesture = mouseGesture.ToString(); string detail = shortcut.GetGestureDetail(gesture); if (!String.IsNullOrEmpty(gesture)) { string message = string.Format("ジェスチャ: {0} {1}", gesture, (String.IsNullOrEmpty(detail) ? "" : "(" + detail + ")")); ToastMessage.Show(message); } } }; // キー押下イベント pecaPlayer.KeyDownEvent += (sender, e) => shortcut.RaiseKeyEvent(e); // ステータスバー マウスホバーイベント statusBar.MouseHoverEvent += (sender, e) => shortcut.RaiseEvent(ShortcutEvents.StatusbarHover); // 終了処理 FormClosed += (sender, e) => { Visible = false; Logger.Instance.Debug("FormClosed"); pecaPlayer.Close(); statusBar.Close(); }; // グローウィンドウの弊害で消えなくなっていたので自分で消えるようにする Deactivate += (sender, e) => { contextMenuStrip.Hide(); }; // 動画再生イベント pecaPlayer.MovieStart += (sender, e) => { pecaPlayer.UpdateChannelInfo(); shortcut.ExecCommand(PlayerSettings.MovieStartCommand); }; // コマンド実行内容の表示 shortcut.CommandExecuted += (sender, e) => { CommnadExecutedEventArgs args = (CommnadExecutedEventArgs)e; // ステータスバー表示切り替えはメッセージを出さない if (args.Command != Commands.VisibleStatusBar) { ToastMessage.Show(string.Format("コマンド: {0}", args.Detail)); } }; //----------------------------------------------------- // コンテキストメニュー //----------------------------------------------------- // 拡大率 scale25PerToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowScale25Per); scale50PerToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowScale50Per); scale75PerToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowScale75Per); scale100PerToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowScale100Per); scale150PerToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowScale150Per); scale200PerToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowScale200Per); // サイズ変更 size160x120ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowSize160x120); size320x240ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowSize320x240); size480x360ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowSize480x360); size640x480ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowSize640x480); size800x600ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WindowSize800x600); fitMovieSizeToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.FitMovieSize); // 画面分割 screenSplitWidthx5ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.ScreenSplitWidthx5); screenSplitWidthx4ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.ScreenSplitWidthx4); screenSplitWidthx3ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.ScreenSplitWidthx3); screenSplitWidthx2ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.ScreenSplitWidthx2); screenSplitHeightx5ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.ScreenSplitHeightx5); screenSplitHeightx4ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.ScreenSplitHeightx4); screenSplitHeightx3ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.ScreenSplitHeightx3); screenSplitHeightx2ToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.ScreenSplitHeightx2); // 機能 topMostToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.TopMost); updateChannelInfoToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.UpdateChannelInfo); bumpToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.Bump); functionToolStripMenuItem.DropDownOpening += (sender, e) => topMostToolStripMenuItem.Checked = TopMost; screenshotToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.Screenshot); openScreenshotFolderToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.OpenScreenshotFolder); retryPlayerToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.RetryPlayer); // ファイルから開く openFromFileToolStripMenuItem.Click += (sender, e) => { var dialog = new OpenFileDialog(); if (dialog.ShowDialog() == DialogResult.OK) { // TODO スレッド選択を解除 // TODO ステータスバーを変更 Open(dialog.FileName); } }; // URLから開く openFromUrlToolStripTextBox.KeyDown += (sender, e) => { if (e.KeyCode == Keys.Return) { // TODO FLV or WMVの判定をして、PecaPlayerコントロールを再初期化する // TODO スレッド選択を解除 + 新しいスレッドへ移動 // TODO ステータスバーを変更 Open(((ToolStripTextBox)sender).Text); contextMenuStrip.Close(); } }; // クリップボードから開く openFromClipboardToolStripMenuItem.Click += (sender, e) => { try { if (Clipboard.ContainsText()) { // TODO FLV or WMVの判定をして、PecaPlayerコントロールを再初期化する // TODO スレッド選択を解除 + 新しいスレッドへ移動 // TODO ステータスバーを変更 Open(Clipboard.GetText()); } } catch (System.Runtime.InteropServices.ExternalException) { MessageBox.Show("クリップボードのオープンに失敗しました"); } }; // 音量 volumeUpToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.VolumeUp); volumeDownToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.VolumeDown); muteToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.Mute); volumeBalanceLeftToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.VolumeBalanceLeft); volumeBalanceMiddleToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.VolumeBalanceMiddle); volumeBalanceRightToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.VolumeBalanceRight); volumeToolStripMenuItem.DropDownOpening += (sender, e) => muteToolStripMenuItem.Checked = pecaPlayer.Mute; volumeToolStripMenuItem.DropDownOpening += (sender, e) => volumeBalanceLeftToolStripMenuItem.Checked = (pecaPlayer.VolumeBalance == VolumeBalanceCommandArgs.BalanceLeft); volumeToolStripMenuItem.DropDownOpening += (sender, e) => volumeBalanceMiddleToolStripMenuItem.Checked = (pecaPlayer.VolumeBalance == VolumeBalanceCommandArgs.BalanceMiddle); volumeToolStripMenuItem.DropDownOpening += (sender, e) => volumeBalanceRightToolStripMenuItem.Checked = (pecaPlayer.VolumeBalance == VolumeBalanceCommandArgs.BalanceRight); // 設定メニュー押下 settingToolStripMenuItem.Click += (sender, e) => { PlayerSettingView view = new PlayerSettingView(shortcut); view.TopMost = TopMost; view.ShowDialog(); }; // WMPメニュー押下 wmpMenuToolStripMenuItem.Click += (sender, e) => shortcut.ExecCommand(Commands.WmpMenu); // 動画情報表示押下 showDebugToolStripMenuItem.Click += (sender, e) => pecaPlayer.ShowDebug(); }
public ChannelInfo SaveChannel(ChannelInfo channel) { return(DataAccess.ChannelDataAdapter.Save(channel)); }
public void Play(IMediaFile file) { this.CleanUpSound(ref this.sound); this.timer.Start(); this.CurrentMediaFile = file; var mode = FMOD.MODE._2D | FMOD.MODE.CREATESTREAM; if (file.IsVBR) { mode |= FMOD.MODE.ACCURATETIME; } if (this.Equalizer != null) { mode |= MODE.SOFTWARE; } else { mode |= MODE.HARDWARE; } var result = this.system.createSound(file.FullFileName, mode, ref this.sound); if (!result.ERRCHECK()) { return; } uint lenms = 0; result = this.sound.getLength(ref lenms, FMOD.TIMEUNIT.MS); result.ERRCHECK(); this.LengthMs = lenms; FMOD.Channel channel = null; result = this.system.playSound(FMOD.CHANNELINDEX.FREE, this.sound, false, ref channel); if (!result.ERRCHECK()) { return; } this.State = PlayerState.Play; file.State = PlayerState.Play; if (channel != null) { this.channelInfo = new ChannelInfo() {Channel = channel, File = file}; result = this.channelInfo.Channel.setCallback(this.channelEndCallback); result.ERRCHECK(); result = this.channelInfo.Channel.setVolume(this.Volume / 100f); result.ERRCHECK(); } }
internal void Update(InviteReference model) { if (model.Guild != null) Server = new ServerInfo(model.Guild.Id, model.Guild.Name); if (model.Channel != null) Channel = new ChannelInfo(model.Channel.Id, model.Channel.Name); }
/// <summary> /// Write all data to disk /// </summary> public void Snapshot() { lock (protocol.NetworkList) { List<Network> unknown = new List<Network>(); foreach (Network network in protocol.NetworkList) { string uid = protocol.sBuffer.getUID(network.ServerName); if (uid == null) { unknown.Add(network); continue; } lock (networkInfo) { if (networkInfo.ContainsKey(uid)) { networkInfo[uid]._windows.Clear(); networkInfo[uid]._channels.Clear(); networkInfo[uid].PrivateWins.Clear(); networkInfo[uid]._windows.Add(new Buffer.Window(network.SystemWindow)); networkInfo[uid].CModes = network.CModes; networkInfo[uid].CUModes = network.CUModes; networkInfo[uid].PModes = network.PModes; networkInfo[uid].mode = network.usermode.ToString(); networkInfo[uid].Version = network.IrcdVersion; networkInfo[uid].SModes = network.SModes; networkInfo[uid].ChannelList = new List<Network.ChannelData>(); lock (network.ChannelList) { networkInfo[uid].ChannelList.AddRange(network.ChannelList); } lock (network.Descriptions) { networkInfo[uid].Descriptions.Clear(); foreach (KeyValuePair<char, string> description in network.Descriptions) { networkInfo[uid].Descriptions.Add(new NetworkInfo.Description(description.Key, description.Value)); } } networkInfo[uid].XModes = network.XModes; networkInfo[uid].UChars = network.UChars; lock (network.Channels) { foreach (Channel xx in network.Channels) { Graphics.Window window = xx.RetrieveWindow(); if (window != null) { networkInfo[uid]._windows.Add(new Buffer.Window(window)); } ChannelInfo info = new ChannelInfo(); info.Bans = xx.Bans; info.dispose = xx.dispose; info.Exceptions = xx.Exceptions; info.Invites = xx.Invites; info.Name = xx.Name; info.parsing_bans = xx.IsParsingBanData; info.parsing_wh = xx.IsParsingWhoisData; info.parsing_who = xx.IsParsingWhoData; info.parsing_xe = xx.IsParsingExceptionData; info.Redraw = xx.Redraw; info.mode = xx.ChannelMode.ToString(); info.temporary_hide = xx.TemporarilyHidden; info.Topic = xx.Topic; info.TopicDate = xx.TopicDate; info.ChannelWork = xx.ChannelWork; info.TopicUser = xx.TopicUser; networkInfo[uid]._channels.Add(info); } foreach (KeyValuePair<User, Graphics.Window> wn in network.PrivateWins) { Buffer.Window window = new Buffer.Window(wn.Value); if (!networkInfo[uid].PrivateWins.Contains(window.Name)) { networkInfo[uid].PrivateWins.Add(window.Name); networkInfo[uid]._windows.Add(window); } else { Core.DebugLog("ERROR: Multiple same private windows detected of " + window.Name); } } } } } } } WriteDisk(); }
public static int GetCount(SiteInfo siteInfo, ChannelInfo channelInfo, bool isChecked) { return(CountCache.GetChannelCountByIsChecked(siteInfo, channelInfo, isChecked)); }
/// <summary> /// Stops playback on the specified channel. /// </summary> /// <param name="channel">channel.</param> /// <param name="immediately">If set to <c>true</c> stops the channel immediately. (no fading)</param> public void Stop(ChannelInfo channel, bool immediately) { channel.Channel.Stop(immediately); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); _channelId = AuthRequest.IsQueryExists("channelId") ? AuthRequest.GetQueryInt("channelId") : SiteId; _isCheckOnly = AuthRequest.GetQueryBool("isCheckOnly"); _isTrashOnly = AuthRequest.GetQueryBool("isTrashOnly"); _isWritingOnly = AuthRequest.GetQueryBool("isWritingOnly"); _isAdminOnly = AuthRequest.GetQueryBool("isAdminOnly"); _channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var tableName = "siteserver_comment";//ChannelManager.GetTableName(SiteInfo, _channelInfo); _styleInfoList = TableStyleManager.GetContentStyleInfoList(SiteInfo, _channelInfo); _attributesOfDisplay = TranslateUtils.StringCollectionToStringCollection(ChannelManager.GetContentAttributesOfDisplay(SiteId, _channelId)); _allStyleInfoList = ContentUtility.GetAllTableStyleInfoList(_styleInfoList); _pluginIds = PluginContentManager.GetContentPluginIds(_channelInfo); _pluginColumns = PluginContentManager.GetContentColumns(_pluginIds); _isEdit = TextUtility.IsEdit(SiteInfo, _channelId, AuthRequest.AdminPermissionsImpl); var state = AuthRequest.IsQueryExists("state") ? AuthRequest.GetQueryInt("state") : CheckManager.LevelInt.All; var searchType = AuthRequest.IsQueryExists("searchType") ? AuthRequest.GetQueryString("searchType") : ContentAttribute.Title; var dateFrom = AuthRequest.IsQueryExists("dateFrom") ? AuthRequest.GetQueryString("dateFrom") : string.Empty; var dateTo = AuthRequest.IsQueryExists("dateTo") ? AuthRequest.GetQueryString("dateTo") : string.Empty; var keyword = AuthRequest.IsQueryExists("keyword") ? AuthRequest.GetQueryString("keyword") : string.Empty; var checkedLevel = 5; var isChecked = true; foreach (var owningChannelId in AuthRequest.AdminPermissionsImpl.ChannelIdList) { int checkedLevelByChannelId; var isCheckedByChannelId = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, owningChannelId, out checkedLevelByChannelId); if (checkedLevel > checkedLevelByChannelId) { checkedLevel = checkedLevelByChannelId; } if (!isCheckedByChannelId) { isChecked = false; } } RptContents.ItemDataBound += RptContents_ItemDataBound; var allAttributeNameList = new List <string>() { "id", "title", "create_time", "content_id" }; TableColumnManager.GetTableColumnNameList(tableName, DataType.Text); var whereString = " WHERE isCheck=0";// DataProvider.ContentDao.GetPagerWhereSqlString(SiteInfo, _channelInfo, //searchType, keyword, //dateFrom, dateTo, state, _isCheckOnly, false, _isTrashOnly, _isWritingOnly, _isAdminOnly, //AuthRequest.AdminPermissionsImpl, //allAttributeNameList); PgContents.Param = new PagerParam { ControlToPaginate = RptContents, TableName = "siteserver_comment", // tableName, PageSize = 10, //SiteInfo.Additional.PageSize, Page = AuthRequest.GetQueryInt(Pager.QueryNamePage, 1), OrderSqlString = "order by id desc", // ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByIdDesc), ReturnColumnNames = "id, title, create_time, content_id", //TranslateUtils.ObjectCollectionToString(allAttributeNameList), WhereSqlString = whereString, TotalCount = DataProvider.DatabaseDao.GetPageTotalCount(tableName, whereString) }; if (IsPostBack) { return; } //if (_isTrashOnly) //{ // if (AuthRequest.IsQueryExists("IsDeleteAll")) // { // DataProvider.ContentDao.DeleteContentsByTrash(SiteId, _channelId, tableName); // AuthRequest.AddSiteLog(SiteId, "清空回收站"); // SuccessMessage("成功清空回收站!"); // } // else if (AuthRequest.IsQueryExists("IsRestore")) // { // var idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString); // foreach (var channelId in idsDictionary.Keys) // { // var contentIdList = idsDictionary[channelId]; // DataProvider.ContentDao.UpdateTrashContents(SiteId, channelId, ChannelManager.GetTableName(SiteInfo, channelId), contentIdList); // } // AuthRequest.AddSiteLog(SiteId, "从回收站还原内容"); // SuccessMessage("成功还原内容!"); // } // else if (AuthRequest.IsQueryExists("IsRestoreAll")) // { // DataProvider.ContentDao.UpdateRestoreContentsByTrash(SiteId, _channelId, tableName); // AuthRequest.AddSiteLog(SiteId, "从回收站还原所有内容"); // SuccessMessage("成功还原所有内容!"); // } //} //ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, true, AuthRequest.AdminPermissionsImpl); //if (_isCheckOnly) //{ // CheckManager.LoadContentLevelToCheck(DdlState, SiteInfo, isChecked, checkedLevel); //} //else //{ // CheckManager.LoadContentLevelToList(DdlState, SiteInfo, _isCheckOnly, isChecked, checkedLevel); //} //ControlUtils.SelectSingleItem(DdlState, state.ToString()); //foreach (var styleInfo in _allStyleInfoList) //{ // if (styleInfo.InputType == InputType.TextEditor) continue; // var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName); // DdlSearchType.Items.Add(listitem); //} //ETriStateUtils.AddListItems(DdlState, "全部", "已审核", "待审核"); //if (SiteId != _channelId) //{ // ControlUtils.SelectSingleItem(DdlChannelId, _channelId.ToString()); //} ////ControlUtils.SelectSingleItem(DdlState, AuthRequest.GetQueryString("State")); //ControlUtils.SelectSingleItem(DdlSearchType, searchType); //TbKeyword.Text = keyword; //TbDateFrom.Text = dateFrom; //TbDateTo.Text = dateTo; PgContents.DataBind(); //LtlColumnsHead.Text += TextUtility.GetColumnsHeadHtml(_styleInfoList, _pluginColumns, _attributesOfDisplay); //BtnSelect.Attributes.Add("onclick", ModalSelectColumns.GetOpenWindowString(SiteId, _channelId)); //if (_isTrashOnly) //{ // LtlColumnsHead.Text += @"<th class=""text-center text-nowrap"" width=""150"">删除时间</th>"; // BtnAddToGroup.Visible = BtnTranslate.Visible = BtnCheck.Visible = false; // PhTrash.Visible = true; // if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentDelete)) // { // BtnDelete.Visible = false; // BtnDeleteAll.Visible = false; // } // else // { // BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, true, PageUrl)); // BtnDeleteAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsDeleteAll", "True"), "确实要清空回收站吗?")); // } // BtnRestore.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValue(PageUtils.AddQueryString(PageUrl, "IsRestore", "True"), "IDsCollection", "IDsCollection", "请选择需要还原的内容!")); // BtnRestoreAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsRestoreAll", "True"), "确实要还原所有内容吗?")); //} //else //{ // LtlColumnsHead.Text += @"<th class=""text-center text-nowrap"" width=""100"">操作</th>"; // BtnAddToGroup.Attributes.Add("onclick", ModalAddToGroup.GetOpenWindowStringToContentForMultiChannels(SiteId)); // if (HasChannelPermissions(SiteId, ConfigManager.ChannelPermissions.ContentCheck)) // { // BtnCheck.Attributes.Add("onclick", ModalContentCheck.GetOpenWindowStringForMultiChannels(SiteId, PageUrl)); // if (_isCheckOnly) // { // BtnCheck.CssClass = "btn m-r-5 btn-success"; // } // } // else // { // PhCheck.Visible = false; // } // if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentTranslate)) // { // BtnTranslate.Visible = false; // } // else // { // BtnTranslate.Attributes.Add("onclick", PageContentTranslate.GetRedirectClickStringForMultiChannels(SiteId, PageUrl)); // } // if (!HasChannelPermissions(_channelId, ConfigManager.ChannelPermissions.ContentDelete)) // { // BtnDelete.Visible = false; // } // else // { // BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, false, PageUrl)); // } //} }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } int insertChannelId; try { var channelId = AuthRequest.GetQueryInt("ChannelId"); var contentModelPluginId = DdlContentModelPluginId.SelectedValue; var contentRelatedPluginIds = ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds); var channelName = TbNodeName.Text; var indexName = TbNodeIndexName.Text; var filePath = TbFilePath.Text; var channelFilePathRule = TbChannelFilePathRule.Text; var contentFilePathRule = TbContentFilePathRule.Text; var groupNameCollection = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueStringList(CblNodeGroupNameCollection)); var imageUrl = TbImageUrl.Text; var content = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]); var keywords = TbKeywords.Text; var description = TbDescription.Text; var isChannelAddable = TranslateUtils.ToBool(RblIsChannelAddable.SelectedValue); var isContentAddable = TranslateUtils.ToBool(RblIsContentAddable.SelectedValue); var linkUrl = TbLinkUrl.Text; var linkType = DdlLinkType.SelectedValue; var defaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue)); var channelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0; var contentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0; var channelInfo = new ChannelInfo { SiteId = SiteId, ParentId = channelId, ContentModelPluginId = contentModelPluginId, ContentRelatedPluginIds = contentRelatedPluginIds }; if (!string.IsNullOrEmpty(indexName)) { var indexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId); if (indexNameList.IndexOf(indexName) != -1) { FailMessage("栏目添加失败,栏目索引已存在!"); return; } } if (!string.IsNullOrEmpty(filePath)) { if (!DirectoryUtils.IsDirectoryNameCompliant(filePath)) { FailMessage("栏目页面路径不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(filePath)) { filePath = PageUtils.Combine(filePath, "index.html"); } var filePathList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId); if (filePathList.IndexOf(filePath) != -1) { FailMessage("栏目添加失败,栏目页面路径已存在!"); return; } } if (!string.IsNullOrEmpty(channelFilePathRule)) { if (!DirectoryUtils.IsDirectoryNameCompliant(channelFilePathRule)) { FailMessage("栏目页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(channelFilePathRule)) { FailMessage("栏目页面命名规则必须包含生成文件的后缀!"); return; } } if (!string.IsNullOrEmpty(contentFilePathRule)) { if (!DirectoryUtils.IsDirectoryNameCompliant(contentFilePathRule)) { FailMessage("内容页面命名规则不符合系统要求!"); return; } if (PathUtils.IsDirectoryPath(contentFilePathRule)) { FailMessage("内容页面命名规则必须包含生成文件的后缀!"); return; } } var parentChannelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId); var styleInfoList = TableStyleManager.GetChannelStyleInfoList(parentChannelInfo); var extendedAttributes = BackgroundInputTypeParser.SaveAttributes(SiteInfo, styleInfoList, Request.Form, null); channelInfo.Additional.Load(extendedAttributes); //foreach (string key in attributes) //{ // channelInfo.Additional.SetExtendedAttribute(key, attributes[key]); //} channelInfo.ChannelName = channelName; channelInfo.IndexName = indexName; channelInfo.FilePath = filePath; channelInfo.ChannelFilePathRule = channelFilePathRule; channelInfo.ContentFilePathRule = contentFilePathRule; channelInfo.GroupNameCollection = groupNameCollection; channelInfo.ImageUrl = imageUrl; channelInfo.Content = content; channelInfo.Keywords = keywords; channelInfo.Description = description; channelInfo.Additional.IsChannelAddable = isChannelAddable; channelInfo.Additional.IsContentAddable = isContentAddable; channelInfo.LinkUrl = linkUrl; channelInfo.LinkType = linkType; channelInfo.Additional.DefaultTaxisType = defaultTaxisType; channelInfo.ChannelTemplateId = channelTemplateId; channelInfo.ContentTemplateId = contentTemplateId; channelInfo.AddDate = DateTime.Now; insertChannelId = DataProvider.ChannelDao.Insert(channelInfo); //栏目选择投票样式后,内容 } catch (Exception ex) { LogUtils.AddErrorLog(ex); FailMessage(ex, $"栏目添加失败:{ex.Message}"); return; } CreateManager.CreateChannel(SiteId, insertChannelId); AuthRequest.AddSiteLog(SiteId, "添加栏目", $"栏目:{TbNodeName.Text}"); SuccessMessage("栏目添加成功!"); AddWaitAndRedirectScript(ReturnUrl); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId", "channelId"); var channelId = AuthRequest.GetQueryInt("channelId"); var contentId = AuthRequest.GetQueryInt("id"); ReturnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl")); if (string.IsNullOrEmpty(ReturnUrl)) { ReturnUrl = CmsPages.GetContentsUrl(SiteId, channelId); } _channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId); _tableName = ChannelManager.GetTableName(SiteInfo, _channelInfo); ContentInfo contentInfo = null; _styleInfoList = TableStyleManager.GetContentStyleInfoList(SiteInfo, _channelInfo); if (!IsPermissions(contentId)) { return; } if (contentId > 0) { contentInfo = ContentManager.GetContentInfo(SiteInfo, _channelInfo, contentId); } var titleFormat = IsPostBack ? Request.Form[ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)] : contentInfo?.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)); LtlTitleHtml.Text = ContentUtility.GetTitleHtml(titleFormat); AcAttributes.SiteInfo = SiteInfo; AcAttributes.ChannelId = _channelInfo.Id; AcAttributes.ContentId = contentId; AcAttributes.StyleInfoList = _styleInfoList; if (!IsPostBack) { var pageTitle = contentId == 0 ? "添加内容" : "编辑内容"; LtlPageTitle.Text = pageTitle; if (HasChannelPermissions(_channelInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate)) { PhTranslate.Visible = true; BtnTranslate.Attributes.Add("onclick", ModalChannelMultipleSelect.GetOpenWindowString(SiteId, true)); ETranslateContentTypeUtils.AddListItems(DdlTranslateType, true); ControlUtils.SelectSingleItem(DdlTranslateType, ETranslateContentTypeUtils.GetValue(ETranslateContentType.Copy)); } else { PhTranslate.Visible = false; } CblContentAttributes.Items.Add(new ListItem("置顶", ContentAttribute.IsTop)); CblContentAttributes.Items.Add(new ListItem("推荐", ContentAttribute.IsRecommend)); CblContentAttributes.Items.Add(new ListItem("热点", ContentAttribute.IsHot)); CblContentAttributes.Items.Add(new ListItem("醒目", ContentAttribute.IsColor)); TbAddDate.DateTime = DateTime.Now; TbAddDate.Now = true; var contentGroupNameList = ContentGroupManager.GetGroupNameList(SiteId); foreach (var groupName in contentGroupNameList) { var item = new ListItem(groupName, groupName); CblContentGroups.Items.Add(item); } BtnContentGroupAdd.Attributes.Add("onclick", ModalContentGroupAdd.GetOpenWindowString(SiteId)); LtlTags.Text = ContentUtility.GetTagsHtml(AjaxCmsService.GetTagsUrl(SiteId)); if (HasChannelPermissions(_channelInfo.Id, ConfigManager.ChannelPermissions.ContentCheck)) { PhStatus.Visible = true; int checkedLevel; var isChecked = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, _channelInfo.Id, out checkedLevel); if (AuthRequest.IsQueryExists("contentLevel")) { checkedLevel = TranslateUtils.ToIntWithNagetive(AuthRequest.GetQueryString("contentLevel")); if (checkedLevel != CheckManager.LevelInt.NotChange) { isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel; } } CheckManager.LoadContentLevelToEdit(DdlContentLevel, SiteInfo, contentInfo, isChecked, checkedLevel); } else { PhStatus.Visible = false; } BtnSubmit.Attributes.Add("onclick", InputParserUtils.GetValidateSubmitOnClickScript("myForm", true, "autoCheckKeywords()")); //自动检测敏感词 ClientScriptRegisterStartupScript("autoCheckKeywords", WebUtils.GetAutoCheckKeywordsScript(SiteInfo)); if (contentId == 0) { var attributes = TableStyleManager.GetDefaultAttributes(_styleInfoList); if (AuthRequest.IsQueryExists("isUploadWord")) { var isFirstLineTitle = AuthRequest.GetQueryBool("isFirstLineTitle"); var isFirstLineRemove = AuthRequest.GetQueryBool("isFirstLineRemove"); var isClearFormat = AuthRequest.GetQueryBool("isClearFormat"); var isFirstLineIndent = AuthRequest.GetQueryBool("isFirstLineIndent"); var isClearFontSize = AuthRequest.GetQueryBool("isClearFontSize"); var isClearFontFamily = AuthRequest.GetQueryBool("isClearFontFamily"); var isClearImages = AuthRequest.GetQueryBool("isClearImages"); var contentLevel = AuthRequest.GetQueryInt("contentLevel"); var fileName = AuthRequest.GetQueryString("fileName"); var formCollection = WordUtils.GetWordNameValueCollection(SiteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, fileName); attributes.Load(formCollection); TbTitle.Text = formCollection[ContentAttribute.Title]; } AcAttributes.Attributes = attributes; } else if (contentInfo != null) { TbTitle.Text = contentInfo.Title; TbTags.Text = contentInfo.Tags; var list = new List <string>(); if (contentInfo.IsTop) { list.Add(ContentAttribute.IsTop); } if (contentInfo.IsRecommend) { list.Add(ContentAttribute.IsRecommend); } if (contentInfo.IsHot) { list.Add(ContentAttribute.IsHot); } if (contentInfo.IsColor) { list.Add(ContentAttribute.IsColor); } ControlUtils.SelectMultiItems(CblContentAttributes, list); TbLinkUrl.Text = contentInfo.LinkUrl; if (contentInfo.AddDate.HasValue) { TbAddDate.DateTime = contentInfo.AddDate.Value; } ControlUtils.SelectMultiItems(CblContentGroups, TranslateUtils.StringCollectionToStringList(contentInfo.GroupNameCollection)); AcAttributes.Attributes = contentInfo; } } else { AcAttributes.Attributes = new AttributesImpl(Request.Form); } //DataBind(); }
public static int GetCount(SiteInfo siteInfo, ChannelInfo channelInfo) { var ccIds = GetChannelContentIdList(siteInfo, channelInfo, 0, false); return(ccIds.Count()); }
protected object UnmarshalArgument(object arg, ArrayList args) { if (arg == null) { return(null); } // Check if argument is an holder (then we know that it's a serialized argument) CADArgHolder holder = arg as CADArgHolder; if (null != holder) { return(args [holder.index]); } CADObjRef objref = arg as CADObjRef; if (null != objref) { string typeName = string.Copy(objref.TypeName); string uri = string.Copy(objref.URI); int domid = objref.SourceDomain; ChannelInfo cinfo = new ChannelInfo(new CrossAppDomainData(domid)); ObjRef localRef = new ObjRef(typeName, uri, cinfo); return(RemotingServices.Unmarshal(localRef)); } if (arg is Array) { Array argb = (Array)arg; Array argn; // We can't use Array.CreateInstance (arg.GetType().GetElementType()) because // GetElementType() returns a type from the source domain. switch (Type.GetTypeCode(arg.GetType().GetElementType())) { case TypeCode.Boolean: argn = new bool [argb.Length]; break; case TypeCode.Byte: argn = new Byte [argb.Length]; break; case TypeCode.Char: argn = new Char [argb.Length]; break; case TypeCode.Decimal: argn = new Decimal [argb.Length]; break; case TypeCode.Double: argn = new Double [argb.Length]; break; case TypeCode.Int16: argn = new Int16 [argb.Length]; break; case TypeCode.Int32: argn = new Int32 [argb.Length]; break; case TypeCode.Int64: argn = new Int64 [argb.Length]; break; case TypeCode.SByte: argn = new SByte [argb.Length]; break; case TypeCode.Single: argn = new Single [argb.Length]; break; case TypeCode.UInt16: argn = new UInt16 [argb.Length]; break; case TypeCode.UInt32: argn = new UInt32 [argb.Length]; break; case TypeCode.UInt64: argn = new UInt64 [argb.Length]; break; default: throw new NotSupportedException(); } argb.CopyTo(argn, 0); return(argn); } switch (Type.GetTypeCode(arg.GetType())) { case TypeCode.Boolean: return((bool)arg); case TypeCode.Byte: return((byte)arg); case TypeCode.Char: return((char)arg); case TypeCode.Decimal: return((decimal)arg); case TypeCode.Double: return((double)arg); case TypeCode.Int16: return((Int16)arg); case TypeCode.Int32: return((Int32)arg); case TypeCode.Int64: return((Int64)arg); case TypeCode.SByte: return((SByte)arg); case TypeCode.Single: return((Single)arg); case TypeCode.UInt16: return((UInt16)arg); case TypeCode.UInt32: return((UInt32)arg); case TypeCode.UInt64: return((UInt64)arg); case TypeCode.String: return(string.Copy((string)arg)); case TypeCode.DateTime: return(new DateTime(((DateTime)arg).Ticks)); default: if (arg is TimeSpan) { return(new TimeSpan(((TimeSpan)arg).Ticks)); } if (arg is IntPtr) { return((IntPtr)arg); } break; } throw new NotSupportedException("Parameter of type " + arg.GetType() + " cannot be unmarshalled"); }
public static List <(int ChannelId, int ContentId)> GetChannelContentIdList(SiteInfo siteInfo, ChannelInfo channelInfo, int adminId, bool isAllContents) { var cacheKey = ListCacheKey(siteInfo.Id, channelInfo.Id, adminId, isAllContents); var retVal = CacheUtils.Get <List <(int ChannelId, int ContentId)> >(cacheKey); if (retVal != null) { return(retVal); } var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); retVal = DataProvider.ContentDao.GetCacheChannelContentIdList(tableName, DataProvider.ContentDao.GetCacheWhereString(siteInfo, channelInfo, adminId, isAllContents, string.Empty, string.Empty), DataProvider.ContentDao.GetOrderString(string.Empty, isAllContents)); CacheUtils.Insert(cacheKey, retVal); return(retVal); }
protected override async Task <List <MediaSourceInfo> > GetChannelStreamMediaSources(TunerHostInfo info, ChannelInfo channelInfo, CancellationToken cancellationToken) { var list = new List <MediaSourceInfo>(); var channelId = channelInfo.Id; var hdhrId = GetHdHrIdFromChannelId(channelId); var hdHomerunChannelInfo = channelInfo as HdHomerunChannelInfo; var isLegacyTuner = hdHomerunChannelInfo != null && hdHomerunChannelInfo.IsLegacyTuner; if (isLegacyTuner) { list.Add(GetMediaSource(info, hdhrId, channelInfo, "native")); } else { try { var modelInfo = await GetModelInfo(info, false, cancellationToken).ConfigureAwait(false); if (modelInfo != null && modelInfo.SupportsTranscoding) { if (info.AllowHWTranscoding) { list.Add(GetMediaSource(info, hdhrId, channelInfo, "heavy")); list.Add(GetMediaSource(info, hdhrId, channelInfo, "internet540")); list.Add(GetMediaSource(info, hdhrId, channelInfo, "internet480")); list.Add(GetMediaSource(info, hdhrId, channelInfo, "internet360")); list.Add(GetMediaSource(info, hdhrId, channelInfo, "internet240")); list.Add(GetMediaSource(info, hdhrId, channelInfo, "mobile")); } list.Add(GetMediaSource(info, hdhrId, channelInfo, "native")); } } catch { } if (list.Count == 0) { list.Add(GetMediaSource(info, hdhrId, channelInfo, "native")); } } return(list); }
protected override Task OnTeamsChannelRenamedAsync(ChannelInfo channelInfo, TeamInfo teamInfo, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) { Record.Add(MethodBase.GetCurrentMethod().Name); return(base.OnTeamsChannelRenamedAsync(channelInfo, teamInfo, turnContext, cancellationToken)); }
/// <summary> /// Sends channel setup to each module and waits for them to settle. If the same setup is to be /// used for all modules, then only the first setup-file from 'channelSetupFiles []' array is /// used otherwise the function expects to find a setup per module. /// </summary> /// <param name="tasks">A list of Tasks</param> static void RecorderSetup(List <Task <int> > tasks) { try { for (int i = 0; i < numOfModules; i++) { tasks.Add(Task.Factory.StartNew <int>((object idx) => { string line = " "; string setup; channelInfo[(int)idx] = new ChannelInfo("", 0); if (useSameSetupForAllModules) { setup = inputFilePath + channelSetupFiles[0]; } else { setup = inputFilePath + channelSetupFiles[modules_ip_json[(int)idx]]; } // Configuration for the input channels. Default configuration can be obtained by sending a GET request to /rest/rec/channels/input/default. // The body has been prepared and stored in PTPInputStreaming_InputChannelSetup.json. string inputChannelConfiguration = File.ReadAllText(setup); modules[(int)idx].PutRequestWithPath("/rest/rec/channels/input", inputChannelConfiguration); // Find the number of active channels for each module. // Note: Normally configuration file contains one setup for each input channel, however inactive channels can be omitted. var serializer = new JavaScriptSerializer(); Dictionary <string, dynamic> dict = serializer.Deserialize <Dictionary <string, object> >(inputChannelConfiguration); var numberOfChannels = ((ArrayList)dict["channels"]).Count; for (int n = 0; n < numberOfChannels; n++) { // Find number of active channels if (dict["channels"][n]["enabled"] == true) // If channel is enabled { channelInfo[(int)idx].numOfactiveChannels++; // Create a lable containing channel info, which will be added at the top of each file string channelName = "Channel " + dict["channels"][n]["channel"]; channelInfo[(int)idx].lable += string.Format("{0,16}", channelName); line += "---------------"; if (dict["channels"][n]["destinations"][0] == "sd") { destIsSDcard = true; } } } channelInfo[(int)idx].lable += Environment.NewLine + line; if (numOfModules == 1) // If single module { modules[(int)idx].WaitForRecorderState("RecorderStreaming"); } else { modules[(int)idx].WaitForInputState("Settled"); } return(1); }, i)); } Task.WaitAll(tasks.ToArray()); } catch (Exception ex) { Console.WriteLine("RecorderSetup(exception): {0}", ex.Message); } }
public async Task FeedToClients(List<SniperInfo> snipeList, ChannelInfo channelInfo) { // Remove any clients that have disconnected if (GlobalSettings.ThreadPause) return; _arrSocket.RemoveAll(x => !IsConnected(x.Client)); var verifiedSniperInfos = SkipLaggedPokemonLocationValidator.FilterNonAvailableAndUpdateMissingPokemonId(snipeList); var verifiedUnsentMessages = _messageCache.FindUnSentMessages(verifiedSniperInfos); var sortedMessages = verifiedUnsentMessages.OrderBy(m => m.ExpirationTimestamp).ToList(); foreach (var target in sortedMessages) { if (!GlobalSettings.PokekomsToFeedFilter.Contains(target.Id.ToString()) && GlobalSettings.UseFilter) { Log.Info($"Ignoring {target.Id}, it's not in Filterlist"); continue; } foreach (var socket in _arrSocket) // Repeat for each connected client (socket held in a dynamic array) { try { var networkStream = socket.GetStream(); var s = new StreamWriter(networkStream); s.WriteLine(JsonConvert.SerializeObject(target)); s.Flush(); } catch (Exception e) { Log.Error($"Caught exception", e); } } // debug output if (GlobalSettings.Output != null) GlobalSettings.Output.PrintPokemon(target, channelInfo); const string timeFormat = "HH:mm:ss"; Log.Pokemon($"{channelInfo}: {target.Id} at {target.Latitude.ToString(CultureInfo.InvariantCulture)},{target.Longitude.ToString(CultureInfo.InvariantCulture)}" + " with " + (!target.IV.Equals(default(double)) ? $"{target.IV}% IV" : "unknown IV") + (target.ExpirationTimestamp != default(DateTime) ? $" until {target.ExpirationTimestamp.ToString(timeFormat)}" : "")); } }
//得到栏目经过计算后的连接地址 public static string GetChannelUrl(SiteInfo siteInfo, ChannelInfo channelInfo, bool isLocal) { if (channelInfo == null) { return(string.Empty); } if (isLocal) { return(ApiRoutePreview.GetChannelUrl(siteInfo.Id, channelInfo.Id)); } var url = string.Empty; if (channelInfo.ParentId == 0) { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, isLocal); } else { var linkType = ELinkTypeUtils.GetEnumType(channelInfo.LinkType); if (linkType == ELinkType.None) { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, isLocal); } else if (linkType == ELinkType.NoLink) { url = PageUtils.UnclickedUrl; } else { if (linkType == ELinkType.NoLinkIfContentNotExists) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); url = count == 0 ? PageUtils.UnclickedUrl : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, isLocal); } else if (linkType == ELinkType.LinkToOnlyOneContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); if (count == 1) { var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, true, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType))); url = GetContentUrl(siteInfo, channelInfo, contentId, isLocal); } else { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, isLocal); } } else if (linkType == ELinkType.NoLinkIfContentNotExistsAndLinkToOnlyOneContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); if (count == 0) { url = PageUtils.UnclickedUrl; } else if (count == 1) { var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, true, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType))); url = GetContentUrl(siteInfo, channelInfo, contentId, isLocal); } else { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, isLocal); } } else if (linkType == ELinkType.LinkToFirstContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); if (count >= 1) { var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, true, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType))); //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo); url = GetContentUrl(siteInfo, channelInfo, contentId, isLocal); } else { url = GetChannelUrlNotComputed(siteInfo, channelInfo.Id, isLocal); } } else if (linkType == ELinkType.NoLinkIfContentNotExistsAndLinkToFirstContent) { var count = ContentManager.GetCount(siteInfo, channelInfo, true); if (count >= 1) { var tableName = ChannelManager.GetTableName(siteInfo, channelInfo); var contentId = StlContentCache.GetContentId(tableName, channelInfo.Id, true, ETaxisTypeUtils.GetContentOrderByString(ETaxisTypeUtils.GetEnumType(channelInfo.Additional.DefaultTaxisType))); //var contentId = StlCacheManager.FirstContentId.GetValue(siteInfo, nodeInfo); url = GetContentUrl(siteInfo, channelInfo, contentId, isLocal); } else { url = PageUtils.UnclickedUrl; } } else if (linkType == ELinkType.NoLinkIfChannelNotExists) { url = channelInfo.ChildrenCount == 0 ? PageUtils.UnclickedUrl : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, isLocal); } else if (linkType == ELinkType.LinkToLastAddChannel) { var lastAddChannelInfo = StlChannelCache.GetChannelInfoByLastAddDate(channelInfo.Id); url = lastAddChannelInfo != null?GetChannelUrl(siteInfo, lastAddChannelInfo, isLocal) : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, isLocal); } else if (linkType == ELinkType.LinkToFirstChannel) { var firstChannelInfo = StlChannelCache.GetChannelInfoByTaxis(channelInfo.Id); url = firstChannelInfo != null?GetChannelUrl(siteInfo, firstChannelInfo, isLocal) : GetChannelUrlNotComputed(siteInfo, channelInfo.Id, isLocal); } else if (linkType == ELinkType.NoLinkIfChannelNotExistsAndLinkToLastAddChannel) { var lastAddChannelInfo = StlChannelCache.GetChannelInfoByLastAddDate(channelInfo.Id); url = lastAddChannelInfo != null?GetChannelUrl(siteInfo, lastAddChannelInfo, isLocal) : PageUtils.UnclickedUrl; } else if (linkType == ELinkType.NoLinkIfChannelNotExistsAndLinkToFirstChannel) { var firstChannelInfo = StlChannelCache.GetChannelInfoByTaxis(channelInfo.Id); url = firstChannelInfo != null?GetChannelUrl(siteInfo, firstChannelInfo, isLocal) : PageUtils.UnclickedUrl; } } } return(RemoveDefaultFileName(siteInfo, url)); }