public void Start() { //Recreate database ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;")); DropDatabaseTask.Drop("DemoDB"); CreateDatabaseTask.Create("DemoDB"); ControlFlow.CurrentDbConnection = new SqlConnectionManager(new ConnectionString("Data Source=.;Integrated Security=SSPI;Initial Catalog=DemoDB;")); //Logging (only works with existing configuration nlog config in App.config) CreateLogTablesTask.CreateLog(); StartLoadProcessTask.Start("Process 1"); ControlFlow.STAGE = "Staging"; SqlTask.ExecuteNonQuery("some sql", "Select 1 as test"); TransferCompletedForLoadProcessTask.Complete(); ControlFlow.STAGE = "DataVault"; Sequence.Execute("some custom code", () => { }); LogTask.Warn("Some warning!"); EndLoadProcessTask.End("Everything successful"); string jsonLP = GetLoadProcessAsJSONTask.GetJSON(); string jsonLog = GetLogAsJSONTask.GetJSON(1); }
public void ShowMessage(LogTask log) { this.Invoke(new Action(() => { try { string str = log.EventLog; string nameOfTab = log.EventLog; if (!this.lstFrmLogForm.ContainsKey(nameOfTab)) { XtraTabPage pageNew = new XtraTabPage(); pageNew.Text = nameOfTab; this.xtraTabContorl.TabPages.Add(pageNew); var ucLogD = (new ucLog()); pageNew.Controls.Add(ucLogD); ucLogD.Dock = DockStyle.Fill; lstFrmLogForm.Add(nameOfTab, pageNew); } (this.lstFrmLogForm[nameOfTab].Controls[0] as ucLog).AddLog(log.Message); } catch (Exception ex) { } })); }
public void TestErrorLogging(IConnectionManager conn) { //Arrange CreateLogTableTask.Create(conn, "test_log"); ControlFlow.AddLoggingDatabaseToConfig(conn, NLog.LogLevel.Trace, "test_log"); //Act LogTask.Error(conn, "Error!"); LogTask.Warn(conn, "Warn!"); LogTask.Info(conn, "Info!"); LogTask.Debug(conn, "Debug!"); LogTask.Trace(conn, "Trace!"); LogTask.Fatal(conn, "Fatal!"); //Assert Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable, $"{conn.QB}message{conn.QE} = 'Error!' AND {conn.QB}level{conn.QE} = 'Error' AND {conn.QB}task_action{conn.QE} = 'LOG'")); Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable, $"{conn.QB}message{conn.QE} = 'Warn!' AND {conn.QB}level{conn.QE} = 'Warn' AND {conn.QB}task_action{conn.QE} = 'LOG'")); Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable, $"{conn.QB}message{conn.QE} = 'Info!' AND {conn.QB}level{conn.QE} = 'Info' AND {conn.QB}task_action{conn.QE} = 'LOG'")); Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable, $"{conn.QB}message{conn.QE} = 'Debug!' AND {conn.QB}level{conn.QE} = 'Debug' AND {conn.QB}task_action{conn.QE} = 'LOG'")); Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable, $"{conn.QB}message{conn.QE} = 'Trace!' AND {conn.QB}level{conn.QE} = 'Trace' AND {conn.QB}task_action{conn.QE} = 'LOG'")); Assert.Equal(1, RowCountTask.Count(conn, ControlFlow.LogTable, $"{conn.QB}message{conn.QE} = 'Fatal!' AND {conn.QB}level{conn.QE} = 'Fatal' AND {conn.QB}task_action{conn.QE} = 'LOG'")); //Cleanup DropTableTask.Drop(conn, ControlFlow.LogTable); }
public void TestErrorLogging() { LogTask.Error("Error"); LogTask.Warn("Warn"); LogTask.Info("Info"); Assert.AreEqual(3, SqlTask.ExecuteScalar <int>("Check if default log works", "select count(*) from etl.Log where Message in ('Error','Warn','Info')")); }
public void IsLoadProcessKeySetForLogTask() { //Arrange ControlFlow.DefaultDbConnection = SqlConnection; CreateLoadProcessTableTask.Create("test_lp_logtask"); CreateLogTableTask.Create("test_log_logtask"); ControlFlow.AddLoggingDatabaseToConfig(SqlConnection, NLog.LogLevel.Info, "test_log_logtask"); //Act StartLoadProcessTask.Start("Test process 15"); long?processId1 = ControlFlow.CurrentLoadProcess.Id; LogTask.Error("Test1"); LogTask.Warn("Test2"); LogTask.Info("Test3"); //Assert Assert.Equal(3, new RowCountTask("test_log_logtask", $"message like 'Test%' AND load_process_id = {processId1}") { DisableLogging = true }.Count().Rows); //Cleanup DropTableTask.Drop(ControlFlow.LogTable); DropTableTask.Drop(ControlFlow.LoadProcessTable); }
public void TestLoggingWithOdbc() { ControlFlow.CurrentDbConnection = new OdbcConnectionManager(new OdbcConnectionString(OdbcConnectionStringParameter)); CreateLogTablesTask.CreateLog(); LogTask.Info("Info"); Assert.AreEqual(1, SqlTask.ExecuteScalar <int>("Check if default log works", "select count(*) from etl.Log where Message in ('Error','Warn','Info')")); }
public async Task <string> StartTaskDb(string nameMethod, string optionalParameter, string token) { Driver driver = context.Drivers.First(d => d.Token == token); LogTask logTask = context.LogTasks .Include(l => l.TaskLoads) .FirstOrDefault(); if (logTask == null) { context.LogTasks.Add(new LogTask() { TaskLoads = new List <TaskLoad>() }); context.SaveChanges(); logTask = context.LogTasks .Include(l => l.TaskLoads) .FirstOrDefault(); } TaskLoad taskLoad = new TaskLoad() { Array = new byte[0], NameMethod = nameMethod, OptionalParameter = optionalParameter, IdDriver = driver.Id.ToString() }; logTask.TaskLoads.Add(taskLoad); context.SaveChanges(); return(taskLoad.Id.ToString()); }
/// <summary> /// Benachrichtigung für Waiter dass der Artikel fertiggestellt wurde und serviert werden kann /// </summary> /// <param name="sender"></param> /// <param name="time"></param> public void Instance_OneMinuteIsOver(object sender, DateTime time) { if (_startToBuild.AddMinutes(_order.Article.TimeToBuild) == time) { _order.OrderType = OrderType.Ready; LogTask?.Invoke(this, _order); } }
public void Start(int taskNumber, DateTime time, Queue <Task> tasks) { TaskNumber = taskNumber; _count++; CreationTime = time; tasks.Enqueue(this); LogTask?.Invoke(this, $"Quelength {_count}, Task {TaskNumber} erzeugt!"); }
private void RunDemoProcess() { new Sequence("Test sequence 1", RunSubSequence) { TaskType = "SUBPACKAGE" }.Execute(); SqlTask.ExecuteNonQuery($"Sql #1", "Select 1 as test"); LogTask.Info("Info message"); }
public void Log(string str, bool upLoadLog = false) { LogTask task = new LogTask(flog, str); if (upLoadLog) { task.CallBackHandler = Upload; } AddTask(task); }
public static TimeSpan LogExecutionTime(string name, Action action) { Stopwatch watch = new Stopwatch(); LogTask.Warn($"Starting: {name}"); watch.Start(); action.Invoke(); watch.Stop(); LogTask.Warn($"Stopping: {name} -- Time elapsed: {watch.Elapsed.TotalSeconds} seconds."); return(watch.Elapsed); }
public void TestTransferAndLogging() { //CurrentDbConnection is always use if ConnectionManager is not specified otherwise! ControlFlow.CurrentDbConnection = new SqlConnectionManager(ConnectionStringSource); SqlTask.ExecuteNonQuery("Create source table", @"CREATE TABLE test.Source (Col1 nvarchar(100) null, Col2 int null)"); SqlTask.ExecuteNonQuery("Insert demo data", "insert into test.Source values('Test1',1)"); SqlTask.ExecuteNonQuery("Insert demo data", "insert into test.Source values('Test2',2)"); SqlTask.ExecuteNonQuery("Insert demo data", "insert into test.Source values('Test3',3)"); ControlFlow.CurrentDbConnection = new SqlConnectionManager(ConnectionStringLog); CreateLogTablesTask.CreateLog(); new CreateTableTask("test.Destination", new List <ITableColumn>() { new TableColumn("Col1", "nvarchar(100)", allowNulls: false), new TableColumn("Col2", "int", allowNulls: true) }) { ConnectionManager = new SqlConnectionManager(ConnectionStringDest) }.Execute(); var sourceConnection = new SqlConnectionManager(new ConnectionString(ConnectionStringSource)); var destConnection = new SqlConnectionManager(new ConnectionString(ConnectionStringDest)); DBSource source = new DBSource(sourceConnection, "test.Source"); RowTransformation trans = new RowTransformation(row => { LogTask.Info($"Test message: {row[0]}, {row[1]}"); //Log DB is used as this is the ControlFlow.CurrentDBConnection! return(row); }); DBDestination destination = new DBDestination(destConnection, "test.Destination"); source.LinkTo(trans); trans.LinkTo(destination); source.Execute(); destination.Wait(); Assert.AreEqual(1, new RowCountTask("test.Destination", "Col1 = 'Test1' AND Col2=1") { ConnectionManager = new SqlConnectionManager(ConnectionStringDest) }.Count().Rows); Assert.AreEqual(1, new RowCountTask("test.Destination", "Col1 = 'Test2' AND Col2=2") { ConnectionManager = new SqlConnectionManager(ConnectionStringDest) }.Count().Rows); Assert.AreEqual(1, new RowCountTask("test.Destination", "Col1 = 'Test3' AND Col2=3") { ConnectionManager = new SqlConnectionManager(ConnectionStringDest) }.Count().Rows); }
public void TestErrorLogging() { //Arrange //Act LogTask.Error(Connection, "Error"); LogTask.Warn(Connection, "Warn"); LogTask.Info(Connection, "Info"); //Assert Assert.Equal(3, RowCountTask.Count(Connection, "etl.Log", "Message in ('Error','Warn','Info')")); }
public void TestLogCleanup() { LogTask.Error("Error"); LogTask.Warn("Warn"); LogTask.Info("Info"); CleanUpLogTask.CleanUp(0); Assert.AreEqual(0, new SqlTask("Check if log table is empty", $"select count(*) from etl.Log ") { DisableLogging = true }.ExecuteScalar <int>()); }
public void BigData_CSV_ACCESS_ViaOdbc() { int numberOfRows = 2000; ControlFlow.CurrentDbConnection = new AccessOdbcConnectionManager(new OdbcConnectionString(AccessConnectionStringParameter)) { AlwaysUseSameConnection = false }; Stopwatch watch = new Stopwatch(); TableDefinition stagingTable = new TableDefinition("staging", new List <TableColumn>() { new TableColumn("Col1", "CHAR", allowNulls: true), new TableColumn("Col2", "CHAR", allowNulls: true), new TableColumn("Col3", "CHAR", allowNulls: false), new TableColumn("Col4", "CHAR", allowNulls: false), }); try { SqlTask.ExecuteNonQuery("Try to drop table", $@"DROP TABLE {stagingTable.Name};"); } catch { } new CreateTableTask(stagingTable) { ThrowErrorIfTableExists = true }.Execute(); string fileName = "src/ConnectionManager/AccessBigData_CSV2DB.csv"; BigDataHelper bigData = new BigDataHelper() { FileName = fileName, NumberOfRows = numberOfRows, TableDefinition = stagingTable }; watch.Start(); LogTask.Info($"Create .csv file {fileName} with {numberOfRows} Rows"); bigData.CreateBigDataCSV(); LogTask.Info($"Needed {watch.Elapsed.TotalMinutes} to create .csv file"); watch.Reset(); CSVSource source = new CSVSource(fileName); DBDestination <string[]> dest = new DBDestination <string[]>(30) { DestinationTableDefinition = stagingTable }; source.LinkTo(dest); watch.Start(); source.Execute(); dest.Wait(); LogTask.Info($"Needed {watch.Elapsed.TotalMinutes} to write everything into database"); Assert.AreEqual(numberOfRows, RowCountTask.Count(stagingTable.Name)); }
public void TestLoadProcessKeyForLogTask() { StartLoadProcessTask.Start("Test process 8"); int?processKey1 = ControlFlow.CurrentLoadProcess.LoadProcessKey; LogTask.Error("Test1"); LogTask.Warn("Test2"); LogTask.Info("Test3"); Assert.AreEqual(3, new SqlTask("Check if load process key is set", $"select count(*) from etl.Log where Message like 'Test%' and LoadProcessKey = {processKey1}") { DisableLogging = true }.ExecuteScalar <int>()); }
protected void RunSelenium(List <Action> actionsList) { SetLogText(""); LogDir = (_actionArgs != null) ? _actionArgs.LogFilePath : GetCurrentFolder(); Log.Reset(LogDir); if (txtRootURL.Text == "" && _actionArgs == null) { MessageBox.Show("Please provide root url!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { EnablePaneAction(false); /////////////////////////////////////////////////////////////////////////////// var actionRunner = new ActionRunner(new ActionRunnerArgs { LogFilePath = LogDir, URL = txtRootURL.Text, RunTimes = Convert.ToInt32(txtRunTimes.Value) }); actionRunner.RunActions(this, GetActionsList()); } catch (Exception ex) { LogTask logMsg = new LogTask { message = ex.Message, status = TaskCompletionStatus.Error, TaskName = "MainForm class - RunSelenium", TimeNetto = TimeSpan.MinValue }; Log.WriteLog(logMsg); } finally { Log.Close(); } EnablePaneAction(true); ShowNotification(false); if (_actionArgs != null) { Close(); } }
public void CompareWithHiddenReflection(int objectsToCreate, double deviation) { //Arrange //Act var timeWithReflection = BigDataHelper.LogExecutionTime("Creation with Reflection", () => { for (int i = 0; i < objectsToCreate; i++) { MergeableTestRow row = new MergeableTestRow() { ColKey1 = i, ColKey2 = "Test", ColValue1 = "X1" + i, ColValue2 = "T1" + i }; string id = row.UniqueId; bool isequal = row.Equals(row); LogTask.Trace("Id:" + id + " Equals:" + isequal.ToString()); } ; }); output.WriteLine("Elapsed " + timeWithReflection.TotalSeconds + " seconds for creation with reflection."); var timeWithoutReflection = BigDataHelper.LogExecutionTime("Creation without Reflection", () => { for (int i = 0; i < objectsToCreate; i++) { MergeableTestHidingRefĺection row = new MergeableTestHidingRefĺection() { ColKey1 = i, ColKey2 = "Test", ColValue1 = "X2" + i, ColValue2 = "T2" + i }; string id = row.UniqueId; bool isequal = row.Equals(row); LogTask.Trace("Id:" + id + " Equals:" + isequal.ToString()); } }); output.WriteLine("Elapsed " + timeWithoutReflection.TotalSeconds + " seconds for creation without reflection."); //Assert Assert.True(timeWithoutReflection < timeWithReflection); Assert.True(timeWithoutReflection.TotalMilliseconds * (deviation + 1) > timeWithReflection.TotalMilliseconds); }
public void TestDuplicateCheckInRowTrans() { CSVSource <Poco> source = new CSVSource <Poco>("src/DataFlowExamples/Duplicate.csv"); source.Configuration.Delimiter = ";"; source.Configuration.TrimOptions = CsvHelper.Configuration.TrimOptions.Trim; source.Configuration.MissingFieldFound = null; List <int> IDs = new List <int>(); //at the end of the flow, this list will contain all IDs of your source RowTransformation <Poco, Poco> rowTrans = new RowTransformation <Poco, Poco>(input => { if (IDs.Contains(input.ID)) { input.IsDuplicate = true; } else { IDs.Add(input.ID); } return(input); }); var multicast = new Multicast <Poco>(); var dest = new DBDestination <Poco>("dbo.Staging"); TableDefinition stagingTable = new TableDefinition("dbo.Staging", new List <TableColumn>() { new TableColumn("Key", "INT", allowNulls: false, isPrimaryKey: true, isIdentity: true), new TableColumn("ID", "INT", allowNulls: false), new TableColumn("Value", "NVARCHAR(100)", allowNulls: false), new TableColumn("Name", "NVARCHAR(100)", allowNulls: false) }); stagingTable.CreateTable(); var trash = new CustomDestination <Poco>(input => { LogTask.Warn($"Duplicate found. ID: {input.ID} Name: {input.Name}"); }); source.LinkTo(rowTrans); rowTrans.LinkTo(multicast); multicast.LinkTo(dest, input => input.IsDuplicate == false); multicast.LinkTo(trash, input => input.IsDuplicate == true); source.Execute(); dest.Wait(); trash.Wait(); }
public void LogCleanup() { //Arrange LogTask.Error("Error"); LogTask.Warn("Warn"); LogTask.Info("Info"); //Act CleanUpLogTask.CleanUp(Connection, 0); //Assert Assert.Equal(0, new RowCountTask("etl.Log ") { DisableLogging = true, ConnectionManager = Connection }.Count().Rows); }
private static void StartDefaultCSVLoad(Stopwatch watch, TableDefinition stagingTable, string fileName) { CSVSource source = new CSVSource(fileName); DBDestination <string[]> dest = new DBDestination <string[]>(1000) { DestinationTableDefinition = stagingTable }; source.LinkTo(dest); watch.Start(); source.Execute(); LogTask.Info($"Needed {watch.Elapsed.TotalMinutes} to read everything into memory (while constantly writing)"); LogTask.Info($"Already {RowCountTask.Count("test.Staging", RowCountOptions.QuickQueryMode)} inserted into table"); dest.Wait(); }
public void IsLoadProcessKeySetForLogTask() { //Arrange StartLoadProcessTask.Start("Test process 15"); int?processKey1 = ControlFlow.CurrentLoadProcess.LoadProcessKey; //Act LogTask.Error("Test1"); LogTask.Warn("Test2"); LogTask.Info("Test3"); //Assert Assert.Equal(3, new RowCountTask("etl.Log", $"Message like 'Test%' AND LoadProcessKey = {processKey1}") { DisableLogging = true }.Count().Rows); }
public virtual Result Run(IWebDriver browser, Stopwatch sw, string URL) { var retVal = Result.StopAndCloseBrowser; try { sw.Restart(); retVal = this.Run2(browser, sw, URL); sw.Stop(); LogTask logMsg = new LogTask { message = "Completed. " + (String.IsNullOrEmpty(this.Message)? string.Empty : this.Message), status = TaskCompletionStatus.Passed, TaskName = this.Name, TimeNetto = sw.Elapsed }; Log.WriteLog(logMsg); } catch (TestErrorException testEx) { sw.Stop(); LogTask logMsg = new LogTask { message = testEx.Message, status = TaskCompletionStatus.Error, TaskName = this.Name, TimeNetto = sw.Elapsed }; Log.WriteLog(logMsg); retVal = testEx.result; } catch (Exception ex) { sw.Stop(); LogTask logMsg = new LogTask { message = ex.Message, status = TaskCompletionStatus.Error, TaskName = this.Name, TimeNetto = sw.Elapsed }; Log.WriteLog(logMsg); } return(retVal); }
public void ThreadTest_1(object num) { var _logtask = new LogTask(); var number = (int)num; for (var i = 0; i < number; i++) { var log = new Log() { CreateTime = DateTime.Now, Msg = num + "No:" + i, Ret = 89, }; _logtask.AddLog(log); Thread.Sleep(1000 * number); } }
private static void Upload(AsynTask task) { LogTask ltask = task as LogTask; string url = Global.Instance.LogServerUrl; if (string.IsNullOrEmpty(url)) { return; } string saveName = ""; //获取机器唯一标志 if (string.IsNullOrEmpty(saveName)) { return; } WebExecWorker.Instance.UploadFile(WebExecWorker.DEFAULT_ID, url, ltask.m_flog.path, "file", saveName, true, true); }
private void RunSubSequence() { Sequence.Execute("Test sub sequence 1.1", () => { SqlTask.ExecuteNonQuery($"Sql #2", "Select 1 as test"); SqlTask.ExecuteNonQuery($"Sql #3", "Select 1 as test"); LogTask.Warn("Warn message #1"); }); Sequence.Execute("Test sub sequence 1.2", () => { SqlTask.ExecuteNonQuery($"Sql #4", "Select 1 as test"); }); Sequence.Execute("Test sub sequence 1.3", () => { Sequence.Execute("Test sub sequence 2.1", () => { Sequence.Execute("Test sub sequence 3.1", () => { SqlTask.ExecuteNonQuery($"Sql #5", "Select 1 as test"); SqlTask.ExecuteNonQuery($"Sql #6", "Select 1 as test"); LogTask.Warn("Warn message #2"); }); CustomTask.Execute($"Custom #1", () => {; }); SqlTask.ExecuteNonQuery($"Sql #7", "Select 1 as test"); }); Sequence.Execute("Test sub sequence 2.2", () => { CustomTask.Execute($"Custom #2", () => {; }); SqlTask.ExecuteNonQuery($"Sql #7", "Select 1 as test"); }); Sequence.Execute("Test sub sequence 2.3", () => { SqlTask.ExecuteNonQuery($"Sql #8", "Select 1 as test"); CustomTask.Execute($"Custom #2", () => {; }); Sequence.Execute("Test sub sequence 3.3", () => { SqlTask.ExecuteNonQuery($"Sql #9", "Select 1 as test"); SqlTask.ExecuteNonQuery($"Sql #10", "Select 1 as test"); LogTask.Error("Error message"); }); }); }); CustomTask.Execute($"Custom #3", () => {; }); }
public void BigData_CSV_DB(int numberOfRows) { Stopwatch watch = new Stopwatch(); TableDefinition stagingTable = new TableDefinition("test.Staging", new List <TableColumn>() { new TableColumn("Col1", "nchar(1000)", allowNulls: false), new TableColumn("Col2", "nchar(1000)", allowNulls: false), new TableColumn("Col3", "nchar(1000)", allowNulls: false), new TableColumn("Col4", "nchar(1000)", allowNulls: false), }); stagingTable.CreateTable(); string fileName = "src/DataFlow/BigData_CSV2DB.csv"; BigDataHelper bigData = new BigDataHelper() { FileName = fileName, NumberOfRows = numberOfRows, TableDefinition = stagingTable }; watch.Start(); LogTask.Info($"Create .csv file {fileName} with {numberOfRows} Rows"); bigData.CreateBigDataCSV(); LogTask.Info($"Needed {watch.Elapsed.TotalMinutes} to create .csv file"); watch.Reset(); CSVSource source = new CSVSource(fileName); DBDestination <string[]> dest = new DBDestination <string[]>(1000) { DestinationTableDefinition = stagingTable }; source.LinkTo(dest); watch.Start(); source.Execute(); LogTask.Info($"Needed {watch.Elapsed.TotalMinutes} to read everything into memory (while constantly writing)"); LogTask.Info($"Already {RowCountTask.Count("test.Staging", RowCountOptions.QuickQueryMode)} inserted into table"); dest.Wait(); //TODO Wait should be part of source LogTask.Info($"Needed {watch.Elapsed.TotalMinutes} to write everything into database"); Assert.AreEqual(numberOfRows, SqlTask.ExecuteScalar <int>("Check staging table", $"select count(*) from test.Staging")); }
protected void CloseBrowserIfNeeded(IWebDriver browser, bool keepBrowser = false) { try { browser.Quit(); browser = null; } catch (Exception ex) { LogTask logMsg = new LogTask { message = ex.Message, status = TaskCompletionStatus.Error, TaskName = "ActionRunner class - CloseBrowserIfNeeded", TimeNetto = TimeSpan.MinValue }; Log.WriteLog(logMsg); } }
//执行代理请求 public void GoProxy(object obj) { var list = (List <IpProxy>)obj; var errornum = 0; var oknum = 0; var newtime = DateTime.Now; foreach (var item in list) { var res = Services.Utility.WebUtils.DoGetProxy("http://baidu.com", item.Host, Convert.ToInt32(item.Port)); if (res != "OK") { _ipProxyTask.DelIpProxy(item.Host); } else { item.Serve = item.Serve + res; _ipProxyTask.UpdateIpProxy(item); foreach (var url in _urlList) { res = Services.Utility.WebUtils.DoGetProxy(url, item.Host, Convert.ToInt32(item.Port)); if (res != "OK") { errornum++; } else { oknum++; } } } } var _logtask = new LogTask(); var log = new Log() { CreateTime = DateTime.Now, Msg = "newtime:" + newtime + ";oknum:" + oknum + ";errornum:" + errornum, Ret = 88, }; _logtask.AddLog(log); }
/// <summary> /// 施宇帆 2015-12-22 获取某版本计划下所有任务的信息 /// </summary> /// <param name="pclsCache"></param> /// <param name="PlanNo"></param> /// <param name="piEdition"></param> /// <returns></returns> public List<LogTask> GetAllTaskByLogPlan(DataConnection pclsCache, string PlanNo, int piEdition) { List<LogTask> list = new List<LogTask>(); CacheCommand cmd = null; CacheDataReader cdr = null; try { if (!pclsCache.Connect()) { return null; } cmd = new CacheCommand(); cmd = Ps.LogTask.GetAllTaskByLogPlan(pclsCache.CacheConnectionObject); cmd.Parameters.Add("PlanNo", CacheDbType.NVarChar).Value = PlanNo; cmd.Parameters.Add("piEdition", CacheDbType.NVarChar).Value = piEdition; cdr = cmd.ExecuteReader(); while (cdr.Read()) { LogTask NewLine = new LogTask(); NewLine.Type = cdr["Type"].ToString(); NewLine.Code = cdr["Code"].ToString(); NewLine.SortNo = cdr["SortNo"].ToString(); NewLine.Edition = cdr["Edition"].ToString(); NewLine.Instruction = cdr["Instruction"].ToString(); list.Add(NewLine); } return list; } catch (Exception ex) { HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "PlanInfoMethod.GetAllTaskByLogPlan", "数据库操作异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace); return null; } finally { if ((cdr != null)) { cdr.Close(); cdr.Dispose(true); cdr = null; } if ((cmd != null)) { cmd.Parameters.Clear(); cmd.Dispose(); cmd = null; } pclsCache.DisConnect(); } }