Esempio n. 1
0
        /// <summary>
        ///    加入公告資訊
        /// </summary>
        /// <param name="StockId">公告代號</param>
        /// <param name="SerialNo">公告序號</param>
        /// <param name="Number">公告編號(從0開始編號 0=標題....)</param>
        /// <param name="Count">公告個數</param>
        /// <param name="Time">公告時間</param>
        /// <param name="Text">公告內容</param>
        /// <returns>返回值:null=公告尚未接收完成, 否則返回公告內容</returns>
        internal MitakeNotice Merge(int StockId, int SerialNo, byte Number, byte Count, string Time, string Text)
        {
            MitakeNotice cNoticeRET = null;

            lock (__cDict) {
                MitakeNotice cNotice = null;
                if (__cDict.ContainsKey(SerialNo))
                {
                    cNotice = __cDict[SerialNo];
                    if (MergeNotice(cNotice, StockId, Number, Count, Time, Text))
                    {
                        __cDict.Remove(SerialNo);
                        cNoticeRET = cNotice;
                    }
                }
                else
                {
                    cNotice = new MitakeNotice();
                    if (MergeNotice(cNotice, StockId, Number, Count, Time, Text))
                    {
                        cNoticeRET = cNotice;
                    }
                    else
                    {
                        __cDict.Add(SerialNo, cNotice);
                    }
                }
            }
            return(cNoticeRET);
        }
Esempio n. 2
0
                internal static MitakeNotice Decode(Mitake.Sockets.Data.PacketBuffer Buffer) {
                        MitakeNotice cNotice = new MitakeNotice();
                        cNotice.NoticeId = (Buffer.Data[5] << 8) + Buffer.Data[6];
                        cNotice.Level = Buffer.Data[7];
                        cNotice.Time = Buffer.Data[8].ToString("0#") + ":" + Buffer.Data[9].ToString("0#");

                        int iHeadSize = (Buffer.Data[10] << 8) + Buffer.Data[11];   //取得標題長度
                        cNotice.Title = Encoding.UTF8.GetString(Buffer.Data, 12, iHeadSize);

                        int iBodySize = Buffer.Length - (iHeadSize + 13); //取得內容長度
                        cNotice.Content = Encoding.UTF8.GetString(Buffer.Data, (iHeadSize + 12), iBodySize);

                        return cNotice;
                }
Esempio n. 3
0
                /// <summary>
                ///    合併公告資訊(組合公告資訊封包)
                /// </summary>
                /// <param name="notice">公告類別</param>
                /// <param name="StockId">公告代號</param>
                /// <param name="Number">公告編號(從0開始編號 0=標題....)</param>
                /// <param name="Count">公告總個數</param>
                /// <param name="Time">公告時間</param>
                /// <param name="Text">公告內容</param>
                /// <returns>返回值:true=封包已經接收完畢  false=封包尚未接收完畢</returns>
                private bool MergeNotice(MitakeNotice notice, int StockId, byte Number, byte Count, string Time, string Text) {
                        if (Number == 0) {
                                notice.NoticeId = StockId;
                                notice.Time = Time;
                                notice.Title = Text;
                                notice.Count = Count;
                        } else {
                                notice.Content += Text;
                        }

                        if (Number == notice.Count) {
                                return true;
                        } else {
                                return false;
                        }
                }
Esempio n. 4
0
		/// <summary>
		///    加入公告資訊
		/// </summary>
		/// <param name="StockId">公告代號</param>
		/// <param name="SerialNo">公告序號</param>
		/// <param name="Number">公告編號(從0開始編號 0=標題....)</param>
		/// <param name="Count">公告個數</param>
		/// <param name="Time">公告時間</param>
		/// <param name="Text">公告內容</param>
		/// <returns>返回值:null=公告尚未接收完成, 否則返回公告內容</returns>
		internal MitakeNotice Merge(int StockId, int SerialNo, byte Number, byte Count, string Time, string Text) {
			MitakeNotice cNoticeRET = null;
			lock (__cDict) {
				MitakeNotice cNotice = null;
				if (__cDict.ContainsKey(SerialNo)) {
                                        cNotice = __cDict[SerialNo];
                                        if (MergeNotice(cNotice, StockId, Number, Count, Time, Text)) {
                                                __cDict.Remove(SerialNo);
						cNoticeRET = cNotice;
                                        }
                                } else {
                                        cNotice = new MitakeNotice();
                                        if (MergeNotice(cNotice, StockId, Number, Count, Time, Text)) {
						cNoticeRET = cNotice;
					} else {
                                                __cDict.Add(SerialNo, cNotice);
                                        }
                                }
                        }
			return cNoticeRET;
                }
Esempio n. 5
0
        /// <summary>
        ///    合併公告資訊(組合公告資訊封包)
        /// </summary>
        /// <param name="notice">公告類別</param>
        /// <param name="StockId">公告代號</param>
        /// <param name="Number">公告編號(從0開始編號 0=標題....)</param>
        /// <param name="Count">公告總個數</param>
        /// <param name="Time">公告時間</param>
        /// <param name="Text">公告內容</param>
        /// <returns>返回值:true=封包已經接收完畢  false=封包尚未接收完畢</returns>
        private bool MergeNotice(MitakeNotice notice, int StockId, byte Number, byte Count, string Time, string Text)
        {
            if (Number == 0)
            {
                notice.NoticeId = StockId;
                notice.Time     = Time;
                notice.Title    = Text;
                notice.Count    = Count;
            }
            else
            {
                notice.Content += Text;
            }

            if (Number == notice.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }