コード例 #1
0
        public IEnumerable<ciBVCI> GetCiTypeCollection(int filenum)
        {
            localdb = new DataClasses1DataContext(streamType.LocalConnString);
            localdb.CommandTimeout = 0;

            var m = localdb.IP_stream
                .Where(p => p.FileNum == filenum)
                .Select(p => new { p.FileNum, p.lac, p.ci, p.bvci });
            var n = m.Where(e => e.ci != null && e.bvci != null).ToLookup(ci => ci.lac + "-" + ci.ci);
            foreach (var ci in n)
            {
                ciBVCI a = new ciBVCI();

                //cibvciid = cibvciid + 1;
                //a.ciBVCI_id = cibvciid;

                a.fileNum = ci.Select(e => e.FileNum).FirstOrDefault();
                a.bvci = ci.Select(e => e.bvci).FirstOrDefault();
                a.lacCi = ci.Key;
                if (a.lacCi != null)
                {
                    if (ciAllocPDCH.Contains(a.lacCi))
                    {
                        a.ciAllocPDCH = ciAllocPDCH[a.lacCi].Select(e => e.ciAllocPDCH).FirstOrDefault();
                        a.ciUsePDCH = ciAllocPDCH[a.lacCi].Select(e => e.ciUsePDCH).FirstOrDefault();
                    }
                }
                yield return a;
            }
        }
コード例 #2
0
 private void protocolTypeReverseIpType()
 {
     localdb = new DataClasses1DataContext(streamType.LocalConnString);
     //using (DataClasses1DataContext localdb = new DataClasses1DataContext(streamType.LocalConnString))
     //{
     protocolType _protocolType = new protocolType();
     //协议取下行包  ip_s
     var protocol = from p in localdb.IP_stream
                    select new
                    {
                        cpro = p.mmse != null ? "MMSE" : null +
                            p.rtsp_type != null ? "rtsp" : null +
                            p.smtp_type != null ? "smtp" : null +
                            p.bittorrent != null ? "BitTorrent" : null +
                            p.edonkey != null ? "eDonkey" : null +
                            p.oicqVersion != null ? "oicq" : null,
                        p.ip_s
                    };
     var protocolL = protocol.Where(e => e.cpro != null).ToLookup(e => e.cpro);
     foreach (var t in protocolL)
         foreach (var t1 in t)
             if (_protocolType.d.ContainsKey(t.Key))
                 if (!dIP.ContainsKey(t1.ip_s))
                     dIP.Add(t1.ip_s, _protocolType.ConvertProtocol2trType(t.Key));
     //}
 }
コード例 #3
0
 private IEnumerable<mUri> GetmUriCollection()
 {
     #region
     //远程取上下行的URI关联
     #endregion
     localdb = new DataClasses1DataContext(streamType.LocalConnString);
     //using (DataClasses1DataContext localdb = new DataClasses1DataContext(streamType.LocalConnString))
     //{
     var m = localdb.IP_stream.Where(e => e.http_uri != null || e.wsp_uri != null).Where(e => e.tcp_d != null);
     foreach (var ms in m)
     {
         mUri a = new mUri();
         a.fileNum = ms.FileNum;
         a.tlli = ms.tlli;
         a.sport = ms.tcp_s;
         a.dport = ms.tcp_d;
         //a.tcp_seq = ms.tcp_seq;
         //a.tcp_ack = ms.tcp_ack;
         a.uri = ms.http_uri == null ? "-" : ms.http_uri;
         a.uri += ms.wsp_uri == null ? "-" : ms.wsp_uri;
         a.uri += ms.http_x_online == null ? "-" : ms.http_x_online;
         a.uri += ms.http_host == null ? "-" : ms.http_host;
         a.uriStreamType = ConvertUri2trType(a.uri);
         yield return a;
     }
     //}
 }
コード例 #4
0
        //ci运行过程中,连接关闭。
        public ciType(bool init)
        {
            localdb = new DataClasses1DataContext(streamType.LocalConnString);
            localdb.CommandTimeout = 0;

            if (init == true)
                ciAllocPDCH = localdb.ciCoverType.Where(e => e.lacCI.IndexOf("-") != -1).ToLookup(e => e.lacCI);
        }
コード例 #5
0
        //private decimal _msimeiid = 0;
        //private decimal msimeiid { get { return _msimeiid; } set { _msimeiid = value; } }
        public imeiTypeClass(bool init)
        {
            localdb = new DataClasses1DataContext(streamType.LocalConnString);
            localdb.CommandTimeout = 0;

            if (init == true)
                imeiL = localdb.imeiType.Where(e => e.imei != null).ToLookup(e => e.imei);
        }
コード例 #6
0
 private void portTypeReverseIpType()
 {
     localdb = new DataClasses1DataContext(streamType.LocalConnString);
     //{
     //端口取下行包  ip_s
     var port_s = from p in localdb.IP_stream select new { p.tcp_s, p.ip_s };
     var portL = port_s.Where(e => e.tcp_s != null).ToLookup(e => e.tcp_s);
     foreach (var t in portL)
         foreach (var t1 in t)
             if (_portType.dPort.ContainsKey(t.Key))
                 if (!dIP.ContainsKey(t1.ip_s))
                     dIP.Add(t1.ip_s, _portType.ConvertPort2trType(t.Key));
     //}
 }
コード例 #7
0
        private void ImportimeiTypeFile()
        {
            //            string dropsql = @"
            //                            IF  EXISTS (SELECT * FROM sys.objects
            //                            WHERE object_id = OBJECT_ID(N'[dbo].[imeiType]') AND type in (N'U'))
            //                            DROP TABLE [dbo].[imeiType]
            //                            ";

            //            string createsql = @"
            //                                CREATE TABLE [dbo].[imeiType](
            //	                                [imeiType_id] [decimal](18, 0) IDENTITY(1,1) NOT NULL,
            //	                                [imei] [nvarchar](50) NULL,
            //	                                [imeiFactory] [nvarchar](50) NULL,
            //	                                [imeiModel] [nvarchar](500) NULL,
            //	                                [imeiClass] [nvarchar](500) NULL
            //                                ) ON [PRIMARY]
            //                                ";

            handleTable.CreateTable(typeof(imeiType));

            string insertsql = @" BULK INSERT imeiType
                                    FROM '" + streamType.imeiTypeFile
                                 + "'  WITH ( FIRSTROW = 2,FIELDTERMINATOR = ',', ROWTERMINATOR = '\n'  )";

            using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
            {

                try
                {
                    //mess.ExecuteCommand(dropsql);
                    //mess.ExecuteCommand(createsql);
                    mess.ExecuteCommand(insertsql);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    string remotefilename = InputBox("与远程计算机的路径相匹配", "请选定imeiType.csv文件", @"F:\黑点项目\ips_setup\imeiType.csv");
                    string new_insertsql = @" BULK INSERT imeiType
                                    FROM '" + remotefilename
                                + "'  WITH ( FIRSTROW = 2,FIELDTERMINATOR = ',', ROWTERMINATOR = '\n'  )";
                    mess.ExecuteCommand(new_insertsql);
                }

            }
            MessageBox.Show("OK");
        }
コード例 #8
0
 private void ImportCiCoverType(string stattime)
 {
     string createsql = @" IF  EXISTS (SELECT * FROM sys.objects
                         WHERE object_id = OBJECT_ID(N'[dbo].[ciCoverType]') AND type in (N'U'))
                         DROP TABLE [dbo].[ciCoverType]";
     string insertsql = @" SELECT IDENTITY(int, 1,1) AS ciCoverType_id,* into ciCoverType
                         from (select lac+'-'+ci as lacCI,ci_name as ciName,
                         available_pdch as ciAllocPDCH,use_pdch as ciUsePDCH
                         from dbo.ciPdchBulk
                         where stat_time='" + stattime + "') as a";
     DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString);
     mess.ExecuteCommand(createsql);
     mess.ExecuteCommand(insertsql);
     MessageBox.Show("OK");
     QueryTable("ciCoverType");
 }
コード例 #9
0
 private void DisplayResultTable()
 {
     using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
         dataGridView1.DataSource = mess.mLocatingType;
 }
コード例 #10
0
 private void DisplayOrignalTable()
 {
     using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
         dataGridView1.DataSource = mess.IP_stream;
 }
コード例 #11
0
        private void ciPdchBulk(string csvfile)
        {
            string dropsql = @"  IF  EXISTS (SELECT * FROM sys.objects
                                WHERE object_id = OBJECT_ID(N'[dbo].[ciPdchBulk]') AND type in (N'U'))
                                DROP TABLE [dbo].[ciPdchBulk]";
            string createsql = @"
                                CREATE TABLE ciPdchBulk
                                (
                                    lac  VARCHAR(32) null,
                                    ci  VARCHAR(32) null,
                                    ci_name VARCHAR(32) null,
                                    stat_time  VARCHAR(32) null,

                                    available_pdch VARCHAR(32) null,
                                    use_pdch VARCHAR(32) null,
                                    assignment_pdch_rate VARCHAR(32) null,
                                )";

            string insertsql = @" BULK INSERT ciPdchBulk
                                    FROM '" + csvfile + @"'
                                    WITH (
                                     FIRSTROW = 2,
                                     FIELDTERMINATOR = ',',
                                     ROWTERMINATOR = '\n'
                                     )";
            DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString);
            mess.ExecuteCommand(dropsql);
            mess.ExecuteCommand(createsql);
            mess.ExecuteCommand(insertsql);
            MessageBox.Show("OK");
        }
コード例 #12
0
        private void shrinkDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {

                //DUMP   TRANSACTION   [数据库名]   WITH     NO_LOG
                //BACKUP   LOG   [数据库名]   WITH   NO_LOG
                //DBCC   SHRINKDATABASE([数据库名])
                using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
                {
                    mess.ExecuteCommand("DUMP   TRANSACTION   [" + mess.Connection.Database + "]   WITH     NO_LOG");
                    mess.ExecuteCommand("BACKUP   LOG   [" + mess.Connection.Database + "]   WITH   NO_LOG");
                    mess.ExecuteCommand("DBCC   SHRINKDATABASE([" + mess.Connection.Database + "])");
                }
                MessageBox.Show("OK");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #13
0
        public string AlterPrimaryKey()
        {
            //try
            //{
            localdb = new DataClasses1DataContext(streamType.LocalConnString);
            localdb.CommandTimeout = 0;//sql连接超时的问题
            //Stopwatch sw = new Stopwatch();
            //sw.Start();
            //pk的问题
            string sqlstr = @"select count(*) from sysobjects where parent_obj=object_id('IP_stream') and xtype='PK'";
            int ti = int.Parse(localdb.ExecuteQuery<int>(sqlstr).ToDataTable().Rows[0][0].ToString());
            //MessageBox.Show(ti.ToString());

            if (ti < 1)
            {
                string sqlstr1 = @"alter table IP_stream alter column FileNum int not null";
                localdb.ExecuteCommand(sqlstr1);
                Application.DoEvents();

                string sqlstr2 = @"alter table IP_stream alter column PacketNum int not null";
                localdb.ExecuteCommand(sqlstr2);
                Application.DoEvents();

                string sqlstr3 = @"alter table IP_stream add constraint sid_pk primary key(FileNum,PacketNum)";
                localdb.ExecuteCommand(sqlstr3);
                Application.DoEvents();
            }

            CreateTable(typeof(msIMEI));
            CreateTable(typeof(ciBVCI));
            CreateTable(typeof(mLocatingType));

            //sw.Stop();
            //MessageBox.Show(sw.Elapsed.TotalSeconds.ToString());
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.ToString());
            //}
            //finally
            //{
            //    localdb.Dispose();
            //}
            return localdb.Connection.ConnectionString;
        }
コード例 #14
0
 private void QueryTable(string tbName)
 {
     //只有IP_stream不在本地
     try
     {
         if (tbName == "ciCoverType" || tbName == "imeiType")
             using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
             {
                 dataGridView1.DataSource = mess.GetTableByName(tbName);
                 toolStripStatusLabel1.Text = mess.Connection.ConnectionString;
             }
         else
         {
             //DialogResult dlgResult = MessageBox.Show("Do you want to continue Access Remote Database ?", "Continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             //if (dlgResult == DialogResult.Yes && tbName != "OutPutPDCH")
             using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
             {
                 dataGridView1.DataSource = mess.GetTableByName(tbName);
                 toolStripStatusLabel1.Text = mess.Connection.ConnectionString;
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
     }
 }
コード例 #15
0
        private IEnumerable<msIMEI> GetMsImeiCollection(int filenum)
        {
            localdb = new DataClasses1DataContext(streamType.LocalConnString);
            localdb.CommandTimeout = 0;

            var stream = localdb.IP_stream
                .Where(p => p.FileNum == filenum)
                .Select(p => new { p.FileNum, p.tlli, p.imsi, p.imei });
            var tlliL = stream.ToLookup(e => e.FileNum + "-" + e.tlli);
            foreach (var t in tlliL)
            {
                msIMEI a = new msIMEI();

                //msimeiid = msimeiid + 1;
                //a.msIMEI_id = msimeiid;

                a.fileNum = t.Select(e => e.FileNum).FirstOrDefault();
                a.tlli = t.Select(e => e.tlli).FirstOrDefault();
                a.imsi = t.Where(e => e.imsi != null).Select(e => e.imsi).FirstOrDefault();
                a.imei = t.Where(e => e.imei != null).Select(e => e.imei).FirstOrDefault();
                yield return a;
            }
        }
コード例 #16
0
        public IEnumerable<msIMEI> UpdateMsImeiCollection()
        {
            localdb = new DataClasses1DataContext(streamType.LocalConnString);
            localdb.CommandTimeout = 0;

            var stream = localdb.msIMEI;
            var imsiL = stream.Where(e => e.imsi != null).ToLookup(e => e.imsi);
            var tlliL = stream.ToLookup(e => e.fileNum + "-" + e.tlli);
            foreach (var t in tlliL)
            {
                msIMEI a = new msIMEI();

                //msimeiid = msimeiid + 1;
                //a.msIMEI_id = msimeiid;

                a.fileNum = t.Select(e => e.fileNum).FirstOrDefault();
                a.tlli = t.Select(e => e.tlli).FirstOrDefault();
                a.imsi = t.Where(e => e.imsi != null).Select(e => e.imsi).FirstOrDefault();
                a.imei = t.Where(e => e.imei != null).Select(e => e.imei).FirstOrDefault();
                a.imeitype = t.Where(e => e.imei != null).Select(e => e.imeitype).FirstOrDefault();
                a.imeiclass = t.Where(e => e.imei != null).Select(e => e.imeiclass).FirstOrDefault();
                if (a.imei == null)
                {
                    var tlli = imsiL[a.imsi].Where(e => e.imei != null);
                    if (tlli != null)
                    {
                        a.imei = tlli.Select(e => e.imei).FirstOrDefault();
                        a.imeitype = tlli.Select(e => e.imeitype).FirstOrDefault();
                        a.imeiclass = tlli.Select(e => e.imeiclass).FirstOrDefault();
                    }
                }
                yield return a;
            }
        }
コード例 #17
0
 public void UpdateImeiType()
 {
     //Stopwatch sw = new Stopwatch();
     //sw.Start();
     int maxUser = 0;
     using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
         maxUser = mess.msIMEI.Count();
     //MessageBox.Show(maxUser.ToString());
     using (SqlConnection con = new SqlConnection(streamType.LocalConnString))
     {
         con.Open();
         using (SqlTransaction tran = con.BeginTransaction())
         {
             imeiTypeClass _imeiTypeClass = new imeiTypeClass(false);
             var newOrders = _imeiTypeClass.UpdateMsImeiCollection();
             SqlBulkCopy bc = new SqlBulkCopy(con,
               //SqlBulkCopyOptions.CheckConstraints |
               //SqlBulkCopyOptions.FireTriggers |
               SqlBulkCopyOptions.KeepNulls, tran);
             bc.BulkCopyTimeout = 36000;
             bc.BatchSize = 1000;
             bc.DestinationTableName = "msIMEI";
             bc.WriteToServer(newOrders.AsDataReader());
             tran.Commit();
         }
         con.Close();
     }
     using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
         mess.ExecuteCommand("delete from msIMEI where msIMEI_id<=" + maxUser);
     //Thread.Sleep(1); GC.Collect(); GC.Collect(); Application.DoEvents();
     //sw.Stop();
     //MessageBox.Show(sw.Elapsed.TotalSeconds.ToString());
 }
コード例 #18
0
 private void responseTypeReverseIpType()
 {
     localdb = new DataClasses1DataContext(streamType.LocalConnString);
     //using (DataClasses1DataContext localdb = new DataClasses1DataContext(streamType.LocalConnString))
     //{
     responseType _responseType = new responseType();
     //response取下行包  ip_s
     var response = from p in localdb.IP_stream select new { cres = p.http_type, p.ip_s };
     var responseL = response.Where(e => e.cres != null).ToLookup(e => e.cres);
     foreach (var t in responseL)
         foreach (var t1 in t)
             if (_responseType.d.ContainsKey(t.Key))
                 if (!dIP.ContainsKey(t1.ip_s))
                     dIP.Add(t1.ip_s, _responseType.ConvertResponse2trType(t.Key));
     //}
 }
コード例 #19
0
        /*
        private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs c)
        {

        XElement dataConfig = XElement.Load(streamType.configXmlPath);
        foreach (var q1 in dataConfig.Elements("connectionStrings"))
            if (q1.Element("connectionString").Value == a)
                b = a;
        if (b == null)
            b = appConfig.GetConnectionStringsConfig("IP_stream.Properties.Settings.IP_StreamConnectionString");
         *

        //checkedListBox1.GetItemText(checkedListBox1.SelectedItem);

        }
        * */
        private void refreshTreeViewGetTables()
        {
            using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
            {
                TreeNode tn = new TreeNode(mess.Connection.DataSource + "_" + mess.Connection.Database);
                foreach (var t in mess.Mapping.GetTables())
                    if (t.TableName.IndexOf(".") == -1)
                        tn.Nodes.Add(t.TableName);
                    else
                        tn.Nodes.Add(t.TableName.Substring(4));
                treeView1.Nodes.Add(tn);

                foreach (TreeNode t in tn.Nodes)
                {
                    if (t.Text == "imeiType" || t.Text == "ciCoverType")
                        t.ForeColor = Color.Red;
                    if (t.Text == "mLocatingType")
                        t.BackColor = Color.Blue;
                }
            }
            treeView1.ExpandAll();
        }
コード例 #20
0
        private IEnumerable<OpCiPDCH> OutCiUsePDCH(int? filenum)
        {
            mess = new DataClasses1DataContext(streamType.LocalConnString);
            mess.CommandTimeout = 0;

            var temp = mess.mLocatingType.Where(e => e.fileNum == filenum)
                .Select(e => new { e.lacCI, e.ciCoverUsePDCH, e.trafficType, e.mLen });

            var itemp = temp.ToLookup(e => e.lacCI);

            foreach (var tt in itemp.Where(e=>e.Key !=null)) //删除空的部分
            {
                OpCiPDCH ci = new OpCiPDCH();

                //outputtableid = outputtableid + 1;
                //ci.OpCiPDCH_id = outputtableid;

                ci.LacCi = tt.Key;
                ci.CiKbps = tt.Sum(e => e.mLen.ByteToKbps()) / mTime;
                ci.CiPDCH = tt.Max(e => e.ciCoverUsePDCH.StringToDouble());
                ci.StreamingMedia = tt.Where(e => e.trafficType == "StreamingMedia").Sum(e => e.mLen.ByteToKbps()) / mTime;
                ci.StockCategory = tt.Where(e => e.trafficType == "StockCategory").Sum(e => e.mLen.ByteToKbps()) / mTime;
                ci.OtherCategory = tt.Where(e => e.trafficType == "OtherCategory").Sum(e => e.mLen.ByteToKbps()) / mTime;
                ci.MMS = tt.Where(e => e.trafficType == "MMS").Sum(e => e.mLen.ByteToKbps()) / mTime;
                ci.IM = tt.Where(e => e.trafficType == "IM").Sum(e => e.mLen.ByteToKbps()) / mTime;
                ci.GeneralDownloads = tt.Where(e => e.trafficType == "GeneralDownloads").Sum(e => e.mLen.ByteToKbps()) / mTime;
                ci.GameCategory = tt.Where(e => e.trafficType == "GameCategory").Sum(e => e.mLen.ByteToKbps()) / mTime;
                ci.BrowseCategory = tt.Where(e => e.trafficType == "BrowseCategory").Sum(e => e.mLen.ByteToKbps()) / mTime;
                ci.P2P = tt.Where(e => e.trafficType == "P2P").Sum(e => e.mLen.ByteToKbps()) / mTime;

                yield return ci;
            }
        }
コード例 #21
0
 //public string InitImeiCiTypeTable()
 //        {
 //            //DialogResult result; //Messagebox所属于的类
 //            //result = MessageBox.Show("YesOrNo", "你确定要执行查询吗?",
 //            //    MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 //            //if (result == DialogResult.Yes)//Messagebox返回的值
 //            //{
 //                //CreateImeiCiTypeTable();
 //                //localdb = new DataClasses1DataContext(streamType.LocalConnString);
 //                ////using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
 //                ////{
 //                //localdb.ExecuteCommand("delete from ciBVCI");
 //                //localdb.ExecuteCommand("delete from msIMEI");
 //                //}
 //                //GC.Collect();
 //                //MessageBox.Show("OK");
 //                CreateTable(typeof(msIMEI));
 //                CreateTable(typeof(ciBVCI));
 //            //}
 //            return streamType.LocalConnString;
 //        }
 //        //public string InitMlocationTable()
 //        {
 //            CreateTable(typeof(mLocatingType));
 //            //localdb = new DataClasses1DataContext(streamType.LocalConnString);
 //            //using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))//此处关键,数据插入到何处
 //            //{
 //            //mess.CommandTimeout = 6000;//sql连接超时的问题
 ////            DialogResult result; //Messagebox所属于的类
 ////            result = MessageBox.Show("YesOrNo", "你确定要执行查询吗?",
 ////                MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 ////            if (result == DialogResult.Yes)//Messagebox返回的值
 ////            {
 ////                CreateTable(typeof(mLocatingType));
 //////                var typeName = "System.Data.Linq.SqlClient.SqlBuilder";
 //////                var type = typeof(DataContext).Assembly.GetType(typeName);
 //////                var bf = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod;
 //////                var metaTable = localdb.Mapping.GetTable(typeof(mLocatingType));
 //////                var sql = type.InvokeMember("GetCreateTableCommand", bf, null, null, new[] { metaTable });
 //////                //MessageBox.Show(sql.ToString ());
 //////                string delSql = @"if exists (select 1 from  sysobjects where  id = object_id('dbo.mLocatingType') and   type = 'U')
 //////                            drop table dbo.mLocatingType";
 //////                localdb.ExecuteCommand(delSql.ToString());
 //////                localdb.ExecuteCommand(sql.ToString());
 ////                //mess.ExecuteCommand("delete  from mLocatingType");
 ////                //MessageBox.Show("OK");
 ////            }
 //            //return mess.Connection.ConnectionString;
 //            //}
 //            //GC.Collect();
 //            //MessageBox.Show("OK");
 //            return streamType.LocalConnString;
 //        }
 //        private void CreateImeiCiTypeTable()
 //        {
 //            localdb = new DataClasses1DataContext(streamType.LocalConnString);
 //            //using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
 //            //{
 //            var typeName = "System.Data.Linq.SqlClient.SqlBuilder";
 //            var type = typeof(DataContext).Assembly.GetType(typeName);
 //            var bf = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod;
 //            #region 初始化《mlocating》
 //            /*
 //                var metaTable = mess.Mapping.GetTable(typeof(mLocatingType));
 //                var sql = type.InvokeMember("GetCreateTableCommand", bf, null, null, new[] { metaTable });
 //                //MessageBox.Show(sql.ToString ());
 //                string delSql = @"if exists (select 1 from  sysobjects where  id = object_id('dbo.mLocatingType') and   type = 'U')
 //                            drop table dbo.mLocatingType";
 //                mess.ExecuteCommand(delSql.ToString());
 //                mess.ExecuteCommand(sql.ToString());
 //                 * */
 //            #endregion
 //            #region  初始化《imei库》和《ci覆盖类型库》的时候 执行
 //            /*
 //                metaTable = mess.Mapping.GetTable(typeof(ciCoverType));
 //                sql = type.InvokeMember("GetCreateTableCommand", bf, null, null, new[] { metaTable });
 //                delSql = @"if exists (select 1 from  sysobjects where  id = object_id('dbo.ciCoverType') and   type = 'U')
 //                                            drop table dbo.ciCoverType";
 //                mess.ExecuteCommand(delSql.ToString());
 //                mess.ExecuteCommand(sql.ToString());
 //                metaTable = mess.Mapping.GetTable(typeof(imeiType));
 //                sql = type.InvokeMember("GetCreateTableCommand", bf, null, null, new[] { metaTable });
 //                delSql = @"if exists (select 1 from  sysobjects where  id = object_id('dbo.imeiType') and   type = 'U')
 //                                            drop table dbo.imeiType";
 //                mess.ExecuteCommand(delSql.ToString());
 //                mess.ExecuteCommand(sql.ToString());
 //                 * */
 //            #endregion
 //            var metaTable = localdb.Mapping.GetTable(typeof(msIMEI));
 //            var sql = type.InvokeMember("GetCreateTableCommand", bf, null, null, new[] { metaTable });
 //            string delSql = @"if exists (select 1 from  sysobjects where  id = object_id('dbo.msIMEI') and   type = 'U')
 //                            drop table dbo.msIMEI";
 //            localdb.ExecuteCommand(delSql.ToString());
 //            localdb.ExecuteCommand(sql.ToString());
 //            metaTable = localdb.Mapping.GetTable(typeof(ciBVCI));
 //            sql = type.InvokeMember("GetCreateTableCommand", bf, null, null, new[] { metaTable });
 //            delSql = @"if exists (select 1 from  sysobjects where  id = object_id('dbo.ciBVCI') and   type = 'U')
 //                            drop table dbo.ciBVCI";
 //            localdb.ExecuteCommand(delSql.ToString());
 //            localdb.ExecuteCommand(sql.ToString());
 //            //MessageBox.Show("OK");
 //        }
 public static bool CreateTable(Type linqTableClass)
 {
     bool suc = true;
     string createtable = linqTableClass.Name;
     //MessageBox.Show(createtable);
     //混淆以后反射名称被改变出现问题
     using (DataClasses1DataContext localdb = new DataClasses1DataContext(streamType.LocalConnString))
     {
         try
         {
             var metaTable = localdb.Mapping.GetTable(linqTableClass);
             var typeName = "System.Data.Linq.SqlClient.SqlBuilder";
             var type = typeof(DataContext).Assembly.GetType(typeName);
             var bf = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.InvokeMethod;
             var sql = type.InvokeMember("GetCreateTableCommand", bf, null, null, new[] { metaTable });
             string delSql = @"if exists (select 1 from  sysobjects where  id = object_id('dbo." + createtable + @"') and   type = 'U')
                     drop table dbo." + createtable;
             localdb.ExecuteCommand(delSql.ToString());
             localdb.ExecuteCommand(sql.ToString());
         }
         catch (Exception ex)
         {
             suc = false;
             MessageBox.Show(ex.ToString());
         }
     }
     return suc;
 }
コード例 #22
0
        public IEnumerable<mLocatingType> mLocatingTypeLength(int filenum)
        {
            localdb = new DataClasses1DataContext(streamType.LocalConnString);
            localdb.CommandTimeout = 0;

            var ipstreamfilnum=localdb.IP_stream.Where(e => e.FileNum == filenum);

            foreach (var p in ipstreamfilnum)
            {
                mLocatingType down = new mLocatingType();

                //locating 过程中,pk冲突
                //messageid = messageid + 1;
                //down.MLocatingType_id = messageid;

                down.fileNum = p.FileNum;
                down.frame = p.PacketNum;
                down.bvci = p.FileNum + "-" + p.bvci;
                down.tlli = p.tlli;
                down.responseType = p.http_type;
                down.mLen = p.ip_length;

                if (p.link == "Down")
                {
                    down.portType = p.tcp_s + p.udp_s;
                    serviceIP = p.ip_s;
                    response = down.fileNum + "-" + down.tlli + "-" + p.tcp_d + "-" + p.tcp_s;
                }
                else
                {
                    down.portType = p.tcp_d + p.udp_d;
                    serviceIP = p.ip_d;
                    response = down.fileNum + "-" + down.tlli + "-" + p.tcp_s + "-" + p.tcp_d;
                }

                //var ci = _ciType.CiTypeCollection[down.fileNum + "-" + down.bvci];
                if (_ciType.CiTypeCollection.ContainsKey(down.bvci))
                {
                    var ci = _ciType.CiTypeCollection[down.bvci];
                    down.lacCI = ci.lacCi;
                    down.ciCoverAllocPDCH = ci.ciAllocPDCH;
                    down.ciCoverUsePDCH = ci.ciUsePDCH;
                }

                if (_imeiTypeClass.MsImeiCollection.ContainsKey(down.fileNum + "-" + down.tlli))
                {
                    var imei = _imeiTypeClass.MsImeiCollection[down.fileNum + "-" + down.tlli];
                    down.imsi = imei.imsi;
                    down.imei = imei.imei;
                    down.msimeiType = imei.imeitype;
                    down.msimeiClass = imei.imeiclass;
                }

                //初始化其值
                protocol = null;

                //协议识别
                if (p.mmse != null) protocol = "MMSE";
                if (p.rtsp_type != null) protocol = "rtsp";
                if (p.smtp_type != null) protocol = "smtp";
                if (p.bittorrent != null) protocol = "BitTorrent";
                if (p.edonkey != null) protocol = "eDonkey";
                if (p.oicqVersion != null) protocol = "oicq";
                down.protocolType = protocol;
                if (down.protocolType != null)
                    down.trafficType = _protocolType.ConvertProtocol2trType(down.protocolType);

                //端口识别

                if (down.portType != null && down.trafficType == null)
                    down.trafficType = _portType.ConvertPort2trType(down.portType);

                //ip识别
                if (serviceIP != null && down.trafficType == null)
                    down.trafficType = _ipType.ConvertIP2trType(serviceIP);

                //reponse识别流媒体业务
                if (down.trafficType == null)
                    if (down.responseType != null)
                        down.trafficType = _responseType.ConvertResponse2trType(down.responseType);

                //uri识别, uri中的裸ip识别
                var uri = _uriType.mUriCollection[response].Where(e => e.uri != null).FirstOrDefault();
                if (uri != null)
                {
                    down.uriType = uri.uri;
                    if (down.trafficType == null)
                        if (down.uriType != null)
                            down.trafficType = _ipType.ConvertIP2trType(down.uriType);
                    if (down.trafficType == null)
                        down.trafficType = uri.uriStreamType;
                }

                down.responseType += "-" + serviceIP;

                //上述都不能识别时,放入其他

                if (down.trafficType == null)
                    down.trafficType = "OtherCategory";

                yield return down;
            }
        }
コード例 #23
0
        private void BulkExcute()
        {
            if (!ls.bRegOK) return;

            try
            {
                using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
                {
                    minFileNum = mess.IP_stream.Min(e => e.FileNum).Value;
                    maxFileNum = mess.IP_stream.Max(e => e.FileNum).Value + 1;
                }
                // MessageBox.Show(minFileNum.ToString() + "  -   " + maxFileNum.ToString());
                //DualTests dt = new DualTests();
                //dt.Show(); dt.Focus();
                dualTests1.Location = new Point(this.Width / 10, this.Height / 3);
                dualTests1.Show();
                dualTests1.Focus();

                handleTable h = new handleTable();
                toolStripStatusLabel1.Text = h.AlterPrimaryKey();

                //case"InitImeiCiTypeTable":
                //toolStripStatusLabel1.Text = h.InitImeiCiTypeTable();

                //case"InitMlocationTable":
                //toolStripStatusLabel1.Text = h.InitMlocationTable();

                //case"InsertImeiType":
                toolStripStatusLabel2.Text = "imei......";
                Application.DoEvents();
                imeiTypeClass _imeiTypeClass = new imeiTypeClass(true);
                Parallel.For(minFileNum, maxFileNum, i => { _imeiTypeClass.InsertImeiType(_imeiTypeClass, i); });
                Thread.Sleep(1); GC.Collect(); GC.Collect(); Application.DoEvents();
                dualTests1.Focus();

                //case"InsertCiType":
                toolStripStatusLabel2.Text = "ci......";
                Application.DoEvents();
                ciType _ciType = new ciType(true);
                Parallel.For(minFileNum, maxFileNum, i => { _ciType.InsertCiType(_ciType, i); });
                Thread.Sleep(1); GC.Collect(); GC.Collect(); Application.DoEvents();
                dualTests1.Focus();

                //case"UpdateImeiType":
                toolStripStatusLabel2.Text = "imei update......";
                Application.DoEvents();
                imeiTypeClass _imeiTypeClass_false = new imeiTypeClass(false);
                Task t2 = new Task(() => { _imeiTypeClass_false.UpdateImeiType(); }); t2.Start();
                Thread.Sleep(1); GC.Collect(); GC.Collect(); Application.DoEvents();
                dualTests1.Focus();

                //case"InsertResultTable":
                toolStripStatusLabel2.Text = "locating......";
                Application.DoEvents();
                mLocatingConvert ml = new mLocatingConvert();
                Parallel.For(minFileNum, maxFileNum, i => { ml.SendOrders(ml, i); });
                Thread.Sleep(1); GC.Collect(); GC.Collect(); Application.DoEvents();
                dualTests1.Focus();

                dualTests1.Hide();
                //dualTests1.Dispose();
                using (DataClasses1DataContext mess = new DataClasses1DataContext(streamType.LocalConnString))
                {
                    mess.CommandTimeout = 0;
                    string a=mess.mLocatingType.Max(e => e.mLocatingType_id).ToString();
                    string b = mess.IP_stream.Sum(e => e.IPstream).Value.ToString();
                    toolStripStatusLabel2.Text = "complete......"+ a + "/" + b;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #24
0
 private void uriTypeReverseIpType()
 {
     localdb = new DataClasses1DataContext(streamType.LocalConnString);
     //using (DataClasses1DataContext localdb = new DataClasses1DataContext(streamType.LocalConnString))
     //{
     uriType _uriType = new uriType();
     //http取上行包  ip_d
     var uri = from p in localdb.IP_stream
               select new
               {
                   curi = p.http_uri != null ? p.http_uri : null +
                          p.wsp_uri != null ? p.wsp_uri : null +
                          p.http_x_online != null ? p.http_x_online : null +
                          p.http_host != null ? p.http_host : null,
                   p.ip_d
               };
     var uriL = uri.Where(e => e.curi != null).ToLookup(e => e.curi);
     foreach (var t in uriL)
         foreach (var t1 in t)
             if (_uriType.d.ContainsKey(t.Key))
                 if (!dIP.ContainsKey(t1.ip_d))
                     dIP.Add(t1.ip_d, _uriType.ConvertUri2trType(t.Key));
     //}
 }