private void PopulateParalel(LogParser parser) { string id = ""; string info = string.Empty; List <string> listOfYear = new List <string>(); if (!parser.UseExistData) { listOfYear = GetListOfYear(parser.LogParserId.ToString()); } else { listOfYear.Add(IndihiangHelper.GetYearDataIndihiangFile(parser.FileName)); } _totalControls = 9; info = String.Format("{0:yyyy/MM/dd HH:mm:ss}[info]: {1}", DateTime.Now, "Populating data on GENERAL..."); AddLogStatus(info); id = LogFeature.GENERAL.ToString(); GeneralControl uc1 = new GeneralControl(); uc1.FileName = parser.FileName; if (!parser.UseExistData) { uc1.FeatureGuid = parser.LogParserId.ToString(); } else { uc1.FeatureGuid = string.Format("!!{0}", parser.FileName); } Attach(uc1, id, "General"); info = String.Format("{0:yyyy/MM/dd HH:mm:ss}[info]: {1}", DateTime.Now, "Populating data on USERAGENT..."); AddLogStatus(info); id = LogFeature.USERAGENT.ToString(); UserAgentControl uc2 = new UserAgentControl(); uc2.FileName = parser.FileName; if (!parser.UseExistData) { uc2.FeatureGuid = parser.LogParserId.ToString(); } else { uc2.FeatureGuid = string.Format("!!{0}", parser.FileName); } uc2.ListOfYear = listOfYear; Attach(uc2, id, "User Agent"); info = String.Format("{0:yyyy/MM/dd HH:mm:ss}[info]: {1}", DateTime.Now, "Populating data on HITS..."); AddLogStatus(info); id = LogFeature.HITS.ToString(); HitsControl uc3 = new HitsControl(); uc3.FileName = parser.FileName; if (!parser.UseExistData) { uc3.FeatureGuid = parser.LogParserId.ToString(); } else { uc3.FeatureGuid = string.Format("!!{0}", parser.FileName); } uc3.ListOfYear = listOfYear; Attach(uc3, id, "Hits"); info = String.Format("{0:yyyy/MM/dd HH:mm:ss}[info]: {1}", DateTime.Now, "Populating data on ACCESS..."); AddLogStatus(info); id = LogFeature.ACCESS.ToString(); AccessPageControl uc4 = new AccessPageControl(); uc4.FileName = parser.FileName; if (!parser.UseExistData) { uc4.FeatureGuid = parser.LogParserId.ToString(); } else { uc4.FeatureGuid = string.Format("!!{0}", parser.FileName); } uc4.ListOfYear = listOfYear; Attach(uc4, id, "Access Page"); info = String.Format("{0:yyyy/MM/dd HH:mm:ss}[info]: {1}", DateTime.Now, "Populating data on IPADDRESS..."); AddLogStatus(info); id = LogFeature.IPADDRESS.ToString(); IPAddressControl uc5 = new IPAddressControl(); uc5.FileName = parser.FileName; if (!parser.UseExistData) { uc5.FeatureGuid = parser.LogParserId.ToString(); } else { uc5.FeatureGuid = string.Format("!!{0}", parser.FileName); } uc5.ListOfYear = listOfYear; Attach(uc5, id, "IP Address"); info = String.Format("{0:yyyy/MM/dd HH:mm:ss}[info]: {1}", DateTime.Now, "Populating data on STATUS..."); AddLogStatus(info); id = LogFeature.STATUS.ToString(); AccessStatusControl uc6 = new AccessStatusControl(); uc6.FileName = parser.FileName; if (!parser.UseExistData) { uc6.FeatureGuid = parser.LogParserId.ToString(); } else { uc6.FeatureGuid = string.Format("!!{0}", parser.FileName); } uc6.ListOfYear = listOfYear; Attach(uc6, id, "HTTP Status"); info = String.Format("{0:yyyy/MM/dd HH:mm:ss}[info]: {1}", DateTime.Now, "Populating data on BANDWIDTH..."); AddLogStatus(info); id = LogFeature.BANDWIDTH.ToString(); BandwidthControl uc7 = new BandwidthControl(); uc7.FileName = parser.FileName; if (!parser.UseExistData) { uc7.FeatureGuid = parser.LogParserId.ToString(); } else { uc7.FeatureGuid = string.Format("!!{0}", parser.FileName); } uc7.ListOfYear = listOfYear; Attach(uc7, id, "Bandwidth"); info = String.Format("{0:yyyy/MM/dd HH:mm:ss}[info]: {1}", DateTime.Now, "Populating data on REQUEST..."); AddLogStatus(info); id = LogFeature.REQUEST.ToString(); RequestProcessingControl uc8 = new RequestProcessingControl(); uc8.FileName = parser.FileName; if (!parser.UseExistData) { uc8.FeatureGuid = parser.LogParserId.ToString(); } else { uc8.FeatureGuid = string.Format("!!{0}", parser.FileName); } uc8.ListOfYear = listOfYear; Attach(uc8, id, "Processing Request"); info = String.Format("{0:yyyy/MM/dd HH:mm:ss}[info]: {1}", DateTime.Now, "Populating data on REFERER..."); AddLogStatus(info); id = LogFeature.REFERER.ToString(); RefererControl uc9 = new RefererControl(); uc9.FileName = parser.FileName; if (!parser.UseExistData) { uc9.FeatureGuid = parser.LogParserId.ToString(); } else { uc9.FeatureGuid = string.Format("!!{0}", parser.FileName); } uc9.ListOfYear = listOfYear; Attach(uc9, id, "Referer"); tabMainLog.SelectedTab = tabMainLog.TabPages[LogFeature.GENERAL.ToString()]; }
protected override bool ExportData() { bool success = false; string year = IndihiangHelper.GetYearDataIndihiangFile(_databaseFile); string conString = string.Format("server={0};database={1};uid={2};pwd={3}", _svr, _db, _uid, _pwd); if (!string.IsNullOrEmpty(year)) { SQLiteConnection con = null; SQLiteDataReader rd = null; OracleConnection con2 = null; OracleTransaction trans = null; con2 = new OracleConnection(conString); con2.Open(); trans = con2.BeginTransaction(); using (OracleCommand cmd2 = con2.CreateCommand()) { StringBuilder builder = new StringBuilder(); builder.Append("insert into [indihiang_data](fullfilename,a_day,a_month,a_year,server_ip,"); builder.Append("server_port,client_ip,page_access,query_page_access,access_username,"); builder.Append("user_agent,protocol_status,bytes_sent,bytes_received,referer,ip_country,time_taken,referer_class)"); builder.Append(" values(@par1,@par2,@par3,@par4,@par5,@par6,@par7,@par8,@par9,@par10,@par11,@par12,@par13,@par14,@par15,@par16,@par17,@par18)"); cmd2.CommandText = builder.ToString(); cmd2.Transaction = trans; OracleParameter par1 = new OracleParameter("@par1", DbType.String); cmd2.Parameters.Add(par1); OracleParameter par2 = new OracleParameter("@par2", DbType.Int32); cmd2.Parameters.Add(par2); OracleParameter par3 = new OracleParameter("@par3", DbType.Int32); cmd2.Parameters.Add(par3); OracleParameter par4 = new OracleParameter("@par4", DbType.Int32); cmd2.Parameters.Add(par4); OracleParameter par5 = new OracleParameter("@par5", DbType.String); cmd2.Parameters.Add(par5); OracleParameter par6 = new OracleParameter("@par6", DbType.String); cmd2.Parameters.Add(par6); OracleParameter par7 = new OracleParameter("@par7", DbType.String); cmd2.Parameters.Add(par7); OracleParameter par8 = new OracleParameter("@par8", DbType.String); cmd2.Parameters.Add(par8); OracleParameter par9 = new OracleParameter("@par9", DbType.String); cmd2.Parameters.Add(par9); OracleParameter par10 = new OracleParameter("@par10", DbType.String); cmd2.Parameters.Add(par10); OracleParameter par11 = new OracleParameter("@par11", DbType.String); cmd2.Parameters.Add(par11); OracleParameter par12 = new OracleParameter("@par12", DbType.String); cmd2.Parameters.Add(par12); OracleParameter par13 = new OracleParameter("@par13", DbType.String); cmd2.Parameters.Add(par13); OracleParameter par14 = new OracleParameter("@par14", DbType.String); cmd2.Parameters.Add(par14); OracleParameter par15 = new OracleParameter("@par15", DbType.String); cmd2.Parameters.Add(par15); OracleParameter par16 = new OracleParameter("@par16", DbType.String); cmd2.Parameters.Add(par16); OracleParameter par17 = new OracleParameter("@par17", DbType.String); cmd2.Parameters.Add(par17); OracleParameter par18 = new OracleParameter("@par18", DbType.String); cmd2.Parameters.Add(par18); try { con = new SQLiteConnection(string.Format("Data Source={0}", _databaseFile)); con.Open(); string query = "select * from log_data"; SQLiteCommand cmd = new SQLiteCommand(query, con); rd = cmd.ExecuteReader(); while (rd.Read()) { par1.Value = rd["fullfilename"]; par2.Value = rd["a_day"]; par3.Value = rd["a_month"]; par4.Value = Convert.ToInt32(year); par5.Value = rd["server_ip"]; par6.Value = rd["server_port"]; par7.Value = rd["client_ip"]; par8.Value = rd["page_access"]; par9.Value = rd["query_page_access"]; par10.Value = rd["access_username"]; par11.Value = rd["user_agent"]; par12.Value = rd["protocol_status"]; par13.Value = rd["bytes_sent"]; par14.Value = rd["bytes_received"]; par15.Value = rd["referer"]; par16.Value = rd["ip_country"]; par17.Value = rd["time_taken"]; par18.Value = rd["referer_class"]; cmd2.ExecuteNonQuery(); } trans.Commit(); con2.Close(); success = true; } catch (Exception err) { System.Diagnostics.Debug.WriteLine(err.StackTrace); } finally { if (rd != null) { rd.Close(); } if (con != null) { con.Close(); } } } } return(success); }