/// <summary> /// 2,设置sendingBuffSize=5,输入[[1,2,3,4],[5,6,7,8]],输出:true, 结果集:[1,2,3,4,5], LastSendingSegment:[6,7,8] /// </summary> public void sending_arraysegment_2array_test() { var bytes1 = new byte[] { 1, 2, 3, 4 }; var bytes2 = new byte[] { 5, 6, 7, 8 }; var _channel = new TempChannel(); _channel.SendingBufferSize = 5; _channel.appendToSendingQueue(new ArraySegment <byte>(bytes1)); _channel.appendToSendingQueue(new ArraySegment <byte>(bytes2)); ArraySegment <byte> _segment; bool _result = _channel.GetSendingSegment(out _segment); Assert.IsTrue(_result); Assert.IsTrue(_segment != null); Assert.AreEqual(bytes1[0], _segment.Array[0]); Assert.AreEqual(bytes1[1], _segment.Array[1]); Assert.AreEqual(bytes1[2], _segment.Array[2]); Assert.AreEqual(bytes1[3], _segment.Array[3]); Assert.AreEqual(bytes2[0], _segment.Array[4]); var _lastSendingSegment = _channel.GetLastSendingSegment(); Assert.IsTrue(_lastSendingSegment.Array != null); Assert.IsTrue(_lastSendingSegment.Count == 3); Assert.AreEqual(_lastSendingSegment.Array[1], bytes2[1]); Assert.AreEqual(_lastSendingSegment.Array[2], bytes2[2]); Assert.AreEqual(_lastSendingSegment.Array[3], bytes2[3]); }
public void sending_arraysegment_1array_test() { var bytes = new byte[] { 1, 2, 3, 4 }; var _channel = new TempChannel(); _channel.SendingBufferSize = 4; _channel.appendToSendingQueue(new ArraySegment <byte>(bytes)); ArraySegment <byte> _segment; bool _result = _channel.GetSendingSegment(out _segment); Assert.IsTrue(_result); Assert.IsTrue(_segment != null); Assert.AreEqual(bytes[0], _segment.Array[0]); Assert.AreEqual(bytes[1], _segment.Array[1]); Assert.AreEqual(bytes[2], _segment.Array[2]); Assert.AreEqual(bytes[3], _segment.Array[3]); }
// 권리사 시퀀스를 이용해서 채널을 구해온다. 동일 채널은 건너 뛴다. public Int32 GetChannelListByAuthoritySeq(Int32 AuthoritySeq, ref List <TempChannel> channel_list) { Int32 Result_Count = 0; Dictionary <Int32, Int32> inpulist = new Dictionary <Int32, Int32>(); // 오직 검사 용도로만 쓰임 foreach (var pData in List_) { if (pData.Value.PartnerSeq_ == AuthoritySeq) { if (inpulist.ContainsKey(pData.Value.ChannelSeq_) == false) { Result_Count++; TempChannel pTempChannel = new TempChannel(); pTempChannel.seq_ = pData.Value.ChannelSeq_; pTempChannel.ChannelName_ = pData.Value.ChannelName_; channel_list.Add(pTempChannel); inpulist.Add(pData.Value.ChannelSeq_, pData.Value.ChannelSeq_); } } } return(Result_Count); }
private void comboDropDown_SelectedIndexChanged_Channel(object sender, EventArgs e) { comboBox_AuthLogin.Items.Clear(); comboBox_AuthLogin.Items.Add("권리사 로그인을 선택하세요."); if (comboBox_Channel.SelectedIndex == 0) { comboBox_AuthLogin.Enabled = false; } else { comboBox_AuthLogin.Enabled = true; AuthorityInfoData pAuthorityInfoData = AuthorityManager.Instance.GetAuthrityByComboBoxIndex(comboBox_Authority.SelectedIndex); TempChannel pTempChannel = List_TempChannel_[comboBox_Channel.SelectedIndex - 1]; List_TempAutoLogin_.Clear(); AuthorityLoginManager.Instance.GetAuthorityLoginListByAuthoSeqAndChannelSeq(pAuthorityInfoData.seq_, pTempChannel.seq_, ref List_TempAutoLogin_); foreach (var pData in List_TempAutoLogin_) { comboBox_AuthLogin.Items.Add(pData.Name_); } } comboBox_AuthLogin.SelectedIndex = 0; }
void RefreshList() { const Int32 AuthoIndex = 6; const Int32 ChannelIndex = 3; const Int32 AuthoLoginIndex = 9; // 일단 다 켜고 for (Int32 i = 0; i < dataGridView_GoodList.Rows.Count; i++) { dataGridView_GoodList.Rows[i].Visible = true; } if (SelectIndex_Authority_ > 0) { AuthorityInfoData pAuthorityInfoData = AuthorityManager.Instance.GetAuthrityByComboBoxIndex(SelectIndex_Authority_); for (Int32 i = 0; i < dataGridView_GoodList.Rows.Count; i++) { if (dataGridView_GoodList.Rows[i].Visible == true) { string str_autho = dataGridView_GoodList.Rows[i].Cells[AuthoIndex].Value.ToString(); if (string.IsNullOrEmpty(str_autho) == true) { dataGridView_GoodList.Rows[i].Visible = false; } else { Int32 authoSeq = Convert.ToInt32(str_autho); if (authoSeq != pAuthorityInfoData.seq_) { dataGridView_GoodList.Rows[i].Visible = false; } } } } } if (SelectIndex_Channel_ > 0 && SelectIndex_Channel_ <= List_TempChannel_.Count) { TempChannel pTempChannel = List_TempChannel_[SelectIndex_Channel_ - 1]; for (Int32 i = 0; i < dataGridView_GoodList.Rows.Count; i++) { if (dataGridView_GoodList.Rows[i].Visible == true) { string str_channel = dataGridView_GoodList.Rows[i].Cells[ChannelIndex].Value.ToString(); if (string.IsNullOrEmpty(str_channel) == true) { dataGridView_GoodList.Rows[i].Visible = false; } else { Int32 channelseq = Convert.ToInt32(str_channel); if (channelseq != pTempChannel.seq_) { dataGridView_GoodList.Rows[i].Visible = false; } } } } } if (SelectIndex_AuthorityLogin_ > 0 && SelectIndex_AuthorityLogin_ <= List_TempAutoLogin_.Count) { TempAutoLogin pTempAutoLogin = List_TempAutoLogin_[SelectIndex_AuthorityLogin_ - 1]; for (Int32 i = 0; i < dataGridView_GoodList.Rows.Count; i++) { if (dataGridView_GoodList.Rows[i].Visible == true) { string str_authologin = dataGridView_GoodList.Rows[i].Cells[AuthoLoginIndex].Value.ToString(); if (string.IsNullOrEmpty(str_authologin) == true) { dataGridView_GoodList.Rows[i].Visible = false; } else { Int32 autologinseq = Convert.ToInt32(str_authologin); if (autologinseq != pTempAutoLogin.seq_) { dataGridView_GoodList.Rows[i].Visible = false; } } } } } }
static void ReleaseTempChannel(TempChannel temp) { if (temp.Session != null) temp.Session.CloseSession(); }
TempChannel GetTempChannel(string strPassword) { TempChannel temp = new TempChannel(); if (StringUtil.HasHead(this.Password, "token:") == true) { // 临时的SessionInfo对象 SessionInfo session = new SessionInfo(this.App); session.UserID = this.App.ManagerUserName; session.Password = this.App.ManagerPassword; session.IsReader = false; temp.Session = session; temp.Channel = session.Channel; } else { temp.Channel = this.Channel; } return temp; }
/// <summary> /// 4,设置sendingBufferSize=5,输入[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], [13, 14, 15, 16]] /// </summary> public void sending_arraysegment_mularray_test() { var bytes1 = new byte[] { 1, 2, 3, 4 }; var bytes2 = new byte[] { 5, 6, 7, 8 }; var bytes3 = new byte[] { 9, 10, 11, 12 }; var bytes4 = new byte[] { 13, 14, 15, 16 }; var _channel = new TempChannel(); _channel.SendingBufferSize = 5; _channel.appendToSendingQueue(new ArraySegment <byte>(bytes1)); _channel.appendToSendingQueue(new ArraySegment <byte>(bytes2)); ArraySegment <byte> _segment1; bool _result = _channel.GetSendingSegment(out _segment1); Assert.IsTrue(_result); Assert.IsTrue(_segment1.Array != null); Assert.AreEqual(bytes1[0], _segment1.Array[0]); Assert.AreEqual(bytes1[1], _segment1.Array[1]); Assert.AreEqual(bytes1[2], _segment1.Array[2]); Assert.AreEqual(bytes1[3], _segment1.Array[3]); Assert.AreEqual(bytes2[0], _segment1.Array[4]); var _lastSendingSegment = _channel.GetLastSendingSegment(); Assert.IsTrue(_lastSendingSegment.Array != null); Assert.IsTrue(_lastSendingSegment.Count == 3); Assert.AreEqual(_lastSendingSegment.Array[1], bytes2[1]); Assert.AreEqual(_lastSendingSegment.Array[2], bytes2[2]); Assert.AreEqual(_lastSendingSegment.Array[3], bytes2[3]); _channel.appendToSendingQueue(new ArraySegment <byte>(bytes3)); _channel.appendToSendingQueue(new ArraySegment <byte>(bytes4)); ArraySegment <byte> _segment2; bool _result2 = _channel.GetSendingSegment(out _segment2); Assert.IsTrue(_result2); Assert.IsTrue(_segment2.Array != null); Assert.AreEqual(bytes2[1], _segment2.Array[5]); Assert.AreEqual(bytes2[2], _segment2.Array[6]); Assert.AreEqual(bytes2[3], _segment2.Array[7]); Assert.AreEqual(bytes3[0], _segment2.Array[8]); Assert.AreEqual(bytes3[1], _segment2.Array[9]); var _lastSendingSegment2 = _channel.GetLastSendingSegment(); Assert.IsTrue(_lastSendingSegment2.Array != null); Assert.IsTrue(_lastSendingSegment2.Count == 2); Assert.AreEqual(_lastSendingSegment2.Array[_lastSendingSegment2.Offset], bytes3[2]); Assert.AreEqual(_lastSendingSegment2.Array[_lastSendingSegment2.Offset + 1], bytes3[3]); ArraySegment <byte> _segment3; bool _result3 = _channel.GetSendingSegment(out _segment3); Assert.AreEqual(bytes3[2], _segment3.Array[10]); Assert.AreEqual(bytes3[3], _segment3.Array[11]); Assert.AreEqual(bytes4[0], _segment3.Array[12]); Assert.AreEqual(bytes4[1], _segment3.Array[13]); Assert.AreEqual(bytes4[2], _segment3.Array[14]); var _lastSendingSegment3 = _channel.GetLastSendingSegment(); Assert.IsTrue(_lastSendingSegment3.Array != null); Assert.IsTrue(_lastSendingSegment3.Count == 1); Assert.AreEqual(_lastSendingSegment3.Array[_lastSendingSegment3.Offset], bytes4[3]); }
private void button_Confirm_Click(object sender, EventArgs e) { bool bChanged = false; MainForm pMainForm = (MainForm)this.Owner; if (comboBox_Authority.SelectedIndex == 0) { MessageBox.Show("권리사를 선택하세요"); return; } if (comboBox_Channel.SelectedIndex == 0 || List_TempChannel_.Count == 0) { MessageBox.Show("채널을 선택하세요"); return; } if (comboBox_AuthLogin.SelectedIndex == 0 || List_TempAutoLogin_.Count == 0) { MessageBox.Show("권리사 로그인을 선택하세요"); return; } if (comboBox_CrawlerMode.SelectedIndex == 0) { MessageBox.Show("모드를 선택하세요"); return; } Int32 xMonitorSeq = Convert.ToInt32(label_MonitorSeq.Text); string xCrawlerName = textBox_CrawlerName.Text; TempChannel pTempChannel = List_TempChannel_[comboBox_Channel.SelectedIndex - 1]; //ChannelInfoData pChannelInfoData = ChannelManager.Instance.GetChannelByComboBoxIndex(comboBox_Channel.SelectedIndex); Int32 xChannelSeq = pTempChannel.seq_; string xChannelName = pTempChannel.ChannelName_; TempAutoLogin pTempAutoLogin = List_TempAutoLogin_[comboBox_AuthLogin.SelectedIndex - 1]; Int32 xAuthLoginSeq = pTempAutoLogin.seq_; string xAuthLoginName = pTempAutoLogin.Name_; AuthorityInfoData pAuthorityInfoData = AuthorityManager.Instance.GetAuthrityByComboBoxIndex(comboBox_Authority.SelectedIndex); Int32 xAuthoritySeq = pAuthorityInfoData.seq_; string xAuthorityName = pAuthorityInfoData.partnerName_; Int32 xCrawlerSeq = 0; try { xCrawlerSeq = Convert.ToInt32(textBox_CrawlerSeq.Text); } catch (System.Exception ex) { xCrawlerSeq = 0; } if (xCrawlerSeq == 0) { MessageBox.Show("크롤러 시퀀스 값이 이상합니다."); return; } Int32 xMode = comboBox_CrawlerMode.SelectedIndex; string xCrawler_OnOff = ""; string xCrawler_location = ""; Int32 xCrawlerCheckTime = 0; Int32 xDBUpdateTime = 0; string xMemo = textBox_Memo.Text; if (xCrawlerName != CrawlerData_.CrawlerName_ || xCrawlerSeq != CrawlerData_.CrawlerSeq_ || xChannelSeq != CrawlerData_.ChannelSeq_ || xAuthoritySeq != CrawlerData_.AuthoritySeq_ || xMode != CrawlerData_.Mode_ || xMemo != CrawlerData_.Memo_ || xAuthLoginSeq != CrawlerData_.AuthorityLoginSeq_) { bChanged = CMDBInterFace.UpdateCrawlerMonitorInfo(CInfoManager.Instance.DB(), xMonitorSeq, xCrawlerName, xChannelSeq, xChannelName , xAuthoritySeq, xAuthorityName, xCrawlerSeq, xMode, xCrawler_OnOff, xCrawler_location, xCrawlerCheckTime, xDBUpdateTime , xMemo, xAuthLoginSeq, xAuthLoginName); if (bChanged == true) { CrawlerData_.CrawlerName_ = xCrawlerName; CrawlerData_.CrawlerSeq_ = xCrawlerSeq; CrawlerData_.ChannelSeq_ = xChannelSeq; CrawlerData_.ChannelName_ = xChannelName; CrawlerData_.AuthoritySeq_ = xAuthoritySeq; CrawlerData_.AuthorityLoginSeq_ = xAuthLoginSeq; CrawlerData_.AuthorityLoginName_ = xAuthLoginName; CrawlerData_.Mode_ = xMode; CrawlerData_.Memo_ = xMemo; pMainForm.ChangeCrawlerMonitorInfo(CrawlerData_); } } CrawlerData_ = null; Close(); if (bChanged == true) { MessageBox.Show("변경 완료 되었습니다."); } }