Example #1
0
        /// <summary>
        /// 删除当前任务组。
        /// </summary>
        public void Delete()
        {
            AC.Base.Database.DbConnection dbConn = this.Application.GetDbConnection();
            if (dbConn != null)
            {
                try
                {
                    //还需添加删除任务日志的代码

                    string strSql;
                    strSql = "Delete From " + Tables.TaskConfig.TableName + " Where " + Tables.TaskConfig.TaskGroupId + "=" + this.TaskGroupId;
                    dbConn.ExecuteNonQuery(strSql);

                    strSql = "Delete From " + Tables.TaskGroup.TableName + " Where " + Tables.TaskGroup.TaskGroupId + "=" + this.TaskGroupId;
                    dbConn.ExecuteNonQuery(strSql);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
Example #2
0
        /// <summary>
        /// 删除分类。
        /// </summary>
        public virtual void Delete()
        {
            foreach (Classify children in this.Children)
            {
                children.Delete();
            }

            AC.Base.Database.DbConnection dbConn = this.Application.GetDbConnection();
            if (dbConn != null)
            {
                try
                {
                    string strSql;

                    strSql = "Delete From " + Tables.ClassifyDeviceAll.TableName + " Where " + Tables.ClassifyDeviceAll.ClassifyId + "=" + this.ClassifyId;
                    dbConn.ExecuteNonQuery(strSql);

                    strSql = "Delete From " + Tables.ClassifyDevice.TableName + " Where " + Tables.ClassifyDevice.ClassifyId + "=" + this.ClassifyId;
                    dbConn.ExecuteNonQuery(strSql);

                    strSql = "Delete From " + Tables.Classify.TableName + " Where " + Tables.Classify.ClassifyId + "=" + this.ClassifyId;
                    dbConn.ExecuteNonQuery(strSql);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
Example #3
0
        /// <summary>
        /// 删除当前任务。
        /// </summary>
        public void Delete()
        {
            AC.Base.Database.DbConnection dbConn = this.Application.GetDbConnection();
            if (dbConn != null)
            {
                try
                {
                    //删除任务
                    string strSql;
                    strSql = "Delete From " + Tables.TaskConfig.TableName + " Where " + Tables.TaskConfig.TaskConfigId + "=" + this.TaskConfigId;
                    dbConn.ExecuteNonQuery(strSql);

                    //删除任务日志(当年)
                    strSql = "Delete From " + Tables.TaskLog.GetTableName(DateTime.Today) + " Where " + Tables.TaskLog.TaskConfigId + "=" + this.TaskConfigId;
                    dbConn.ExecuteNonQuery(strSql);

                    //删除任务运行日志
                    //strSql = "Delete From " + Tables.TaskRunLog.GetTableName(DateTime.Today) + " Where " + Tables.TaskRunLog.TaskConfigId + "=" + this.TaskConfigId;
                    //dbConn.ExecuteNonQuery(strSql);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
Example #4
0
        public void insert(ExamType examType)
        {
            examType.BaseKey = this.getMaxKeyValue();
            String sql = "insert into examType(BaseKey,TestType,Item) \n"
                         + "values(@BaseKey,@TestType,@Item)";

            SqlParameter[] parameters =
            {
                new SqlParameter("@BaseKey",  examType.BaseKey),
                new SqlParameter("@TestType", examType.TestType),
                new SqlParameter("@Item",     examType.Item)
            };

            try
            {
                dbConnection.ExecuteNonQuery(sql);
            }
            catch (Exception)
            {
            }
            finally
            {
                dbConnection.Close();
            }
        }
Example #5
0
        public void insert(ExamItem examItem)
        {
            examItem.BaseKey = this.getMaxKeyValue();
            String sql = "insert into examItem(BaseKey,Item,FunCode,ParentId) \n"
                         + "values(@BaseKey,@Item,@FunCode,@ParentId)";

            SqlParameter[] parameters =
            {
                new SqlParameter("@BaseKey",  examItem.BaseKey),
                new SqlParameter("@Item",     examItem.Item),
                new SqlParameter("@FunCode",  examItem.FunCode),
                new SqlParameter("@ParentId", examItem.ParentId)
            };

            try
            {
                dbConnection.ExecuteNonQuery(sql);
            }
            catch (Exception)
            {
            }
            finally
            {
                dbConnection.Close();
            }
        }
Example #6
0
 internal void SaveSqlToDb()
 {
     if (SaveSQL != null)
     {
         AC.Base.Database.DbConnection dbConn = this.Device.Application.GetDbConnection();
         if (dbConn != null)
         {
             try
             {
                 foreach (string strSql in this.SaveSQL)
                 {
                     dbConn.ExecuteNonQuery(strSql);
                 }
             }
             catch (Exception ex)
             {
                 throw ex;
             }
             finally
             {
                 dbConn.Close();
             }
         }
     }
 }
Example #7
0
        /// <summary>
        /// 保存日志附加的字符串值。
        /// </summary>
        /// <param name="code">属性类型,通常使用搜索筛选器的类名。</param>
        /// <param name="ordinalNumber">序号,用于存储同一属性的多个值。</param>
        /// <param name="dataValue">数据值,长度在 250 个字符之内。</param>
        protected void Save(string code, int ordinalNumber, string dataValue)
        {
            AC.Base.Database.DbConnection dbConn = this.Application.GetDbConnection();
            if (dbConn != null)
            {
                string strTableName = Tables.LogString.GetTableName(this.LogTime);
                if (dbConn.TableIsExist(strTableName) == false)
                {
                    dbConn.CreateTable(typeof(Tables.LogString), strTableName);
                }

                try
                {
                    string strSql = this.LogId + "," + Function.SqlStr(code, 250) + "," + ordinalNumber + "," + Function.SqlStr(dataValue, 250);
                    strSql = "INSERT INTO " + strTableName + " (" + Tables.LogString.LogId + "," + Tables.LogString.Code + "," + Tables.LogString.OrdinalNumber + "," + Tables.LogString.DataValue + ") VALUES (" + strSql + ")";
                    dbConn.ExecuteNonQuery(strSql);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
Example #8
0
        public void insert(Record record)
        {
            record.BaseKey = this.getMaxKeyValue();
            String sql = "insert into record(BaseKey,TaskConfigId,XmlConfig) \n"
                         + "values(" + record.BaseKey + "," + record.TaskConfigId + ",'" + record.XmlConfig + "')";

            try
            {
                dbConnection.ExecuteNonQuery(sql);
            }
            catch (Exception)
            {
            }
            finally
            {
                dbConnection.Close();
            }
        }
Example #9
0
        public int insert(Devices devices)
        {
            devices.BaseKey = this.getMaxKeyValue();
            String sql = "insert into devices(BaseKey,TaskConfigId,Suite,Factory,Address,DeviceType) \n"
                         + "values(" + devices.BaseKey + "," + devices.TaskConfigId + "," + (devices.Suite == "" ? "null" : devices.Suite) + "," + (devices.Factory == "" ? "null" : devices.Factory) + "," + devices.Address + "," + devices.DeviceType + ")";

            try
            {
                return(dbConnection.ExecuteNonQuery(sql));
            }
            catch (Exception)
            {
                return(0);
            }
            finally
            {
                dbConnection.Close();
            }
        }
Example #10
0
        public int insert(Factory factory)
        {
            factory.BaseKey = this.getMaxKeyValue();
            String sql = "insert into factory(BaseKey,FactoryName) \n"
                         + "values(" + factory.BaseKey + ",'" + factory.FactoryName + "')";

            try
            {
                return(dbConnection.ExecuteNonQuery(sql));
            }
            catch (Exception)
            {
                return(0);
            }
            finally
            {
                dbConnection.Close();
            }
        }
Example #11
0
        /// <summary>
        /// 保存任务组。
        /// </summary>
        public void Save()
        {
            if (this.Name == null || this.Name.Length == 0)
            {
                throw new Exception("任务组名称必须输入。");
            }

            AC.Base.Database.DbConnection dbConn = this.Application.GetDbConnection();
            if (dbConn != null)
            {
                try
                {
                    if (this.TaskGroupId == 0)
                    {
                        string strSql = "SELECT MAX(" + Tables.TaskGroup.TaskGroupId + ") FROM " + Tables.TaskGroup.TableName;
                        this.TaskGroupId = Function.ToInt(dbConn.ExecuteScalar(strSql)) + 1;

                        strSql = this.TaskGroupId + "," + Function.SqlStr(this.Name, 250);
                        strSql = "INSERT INTO " + Tables.TaskGroup.TableName + " (" + Tables.TaskGroup.TaskGroupId + "," + Tables.TaskGroup.Name + ") VALUES (" + strSql + ")";
                        dbConn.ExecuteNonQuery(strSql);
                    }
                    else
                    {
                        string strSql = "UPDATE " + Tables.TaskGroup.TableName + " Set " + Tables.TaskGroup.Name + "=" + Function.SqlStr(this.Name, 250) + " Where " + Tables.TaskGroup.TaskGroupId + "=" + this.TaskGroupId;
                        dbConn.ExecuteNonQuery(strSql);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
Example #12
0
 /// <summary>
 /// 保存长文本数值
 /// </summary>
 /// <param name="serialNumber">序号</param>
 /// <param name="dataValue">长文本数值</param>
 protected void SaveText(int serialNumber, string dataValue)
 {
     AC.Base.Database.DbConnection dbConn = this.Device.Application.GetDbConnection();
     if (dbConn != null)
     {
         try
         {
             string strSql = this.Device.DeviceId + "," + Function.SqlStr(this.GetType().FullName) + "," + serialNumber + "," + Function.SqlStr(dataValue);
             strSql = "INSERT INTO " + Tables.DevicePropertyText.TableName + " (" + Tables.DevicePropertyText.DeviceId + "," + Tables.DevicePropertyText.PropertyType + "," + Tables.DevicePropertyText.SerialNumber + "," + Tables.DevicePropertyText.DataValue + ") VALUES (" + strSql + ")";
             dbConn.ExecuteNonQuery(strSql);
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             dbConn.Close();
         }
     }
 }
Example #13
0
        /// <summary>
        /// 保存二进制数值
        /// </summary>
        /// <param name="serialNumber">序号</param>
        /// <param name="dataValue">二进制数值</param>
        protected void SaveBytes(int serialNumber, byte[] dataValue)
        {
            AC.Base.Database.DbConnection dbConn = this.Device.Application.GetDbConnection();
            if (dbConn != null)
            {
                try
                {
                    System.Data.IDbDataParameter parDeviceId = (System.Data.IDbDataParameter)dbConn.GetNewDbDataParameter();
                    parDeviceId.ParameterName = "@" + Tables.DevicePropertyBytes.DeviceId;
                    parDeviceId.Value         = this.Device.DeviceId;

                    System.Data.IDbDataParameter parPropertyType = (System.Data.IDbDataParameter)dbConn.GetNewDbDataParameter();
                    parPropertyType.ParameterName = "@" + Tables.DevicePropertyBytes.PropertyType;
                    parPropertyType.Value         = Function.SqlStr(this.GetType().FullName);

                    System.Data.IDbDataParameter parSerialNumber = (System.Data.IDbDataParameter)dbConn.GetNewDbDataParameter();
                    parSerialNumber.ParameterName = "@" + Tables.DevicePropertyBytes.SerialNumber;
                    parSerialNumber.Value         = serialNumber;

                    System.Data.IDbDataParameter parDataValue = (System.Data.IDbDataParameter)dbConn.GetNewDbDataParameter();
                    parDataValue.ParameterName = "@" + Tables.DevicePropertyBytes.DataValue;
                    parDataValue.Value         = dataValue;

                    string strSql = "@" + Tables.DevicePropertyBytes.DeviceId + "," + "@" + Tables.DevicePropertyBytes.PropertyType + "," + "@" + Tables.DevicePropertyBytes.SerialNumber + "," + "@" + Tables.DevicePropertyBytes.DataValue;
                    strSql = "INSERT INTO " + Tables.DevicePropertyBytes.TableName + " (" + Tables.DevicePropertyBytes.DeviceId + "," + Tables.DevicePropertyBytes.PropertyType + "," + Tables.DevicePropertyBytes.SerialNumber + "," + Tables.DevicePropertyBytes.DataValue + ") VALUES (" + strSql + ")";
                    dbConn.ExecuteNonQuery(strSql, -1, System.Data.CommandType.Text, parDeviceId, parPropertyType, parSerialNumber, parDataValue);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
Example #14
0
        /// <summary>
        /// 删除该属性数据。
        /// </summary>
        internal void Delete()
        {
            AC.Base.Database.DbConnection dbConn = this.Device.Application.GetDbConnection();
            if (dbConn != null)
            {
                try
                {
                    string strSql;

                    strSql = "DELETE FROM " + Tables.DevicePropertyInt.TableName + " WHERE " + Tables.DevicePropertyInt.DeviceId + "=" + this.Device.DeviceId + " AND " + Tables.DevicePropertyInt.PropertyType + "=" + Function.SqlStr(this.GetType().FullName);
                    dbConn.ExecuteNonQuery(strSql);

                    strSql = "DELETE FROM " + Tables.DevicePropertyLong.TableName + " WHERE " + Tables.DevicePropertyLong.DeviceId + "=" + this.Device.DeviceId + " AND " + Tables.DevicePropertyLong.PropertyType + "=" + Function.SqlStr(this.GetType().FullName);
                    dbConn.ExecuteNonQuery(strSql);

                    strSql = "DELETE FROM " + Tables.DevicePropertyDecimal.TableName + " WHERE " + Tables.DevicePropertyDecimal.DeviceId + "=" + this.Device.DeviceId + " AND " + Tables.DevicePropertyDecimal.PropertyType + "=" + Function.SqlStr(this.GetType().FullName);
                    dbConn.ExecuteNonQuery(strSql);

                    strSql = "DELETE FROM " + Tables.DevicePropertyString.TableName + " WHERE " + Tables.DevicePropertyString.DeviceId + "=" + this.Device.DeviceId + " AND " + Tables.DevicePropertyString.PropertyType + "=" + Function.SqlStr(this.GetType().FullName);
                    dbConn.ExecuteNonQuery(strSql);

                    strSql = "DELETE FROM " + Tables.DevicePropertyText.TableName + " WHERE " + Tables.DevicePropertyText.DeviceId + "=" + this.Device.DeviceId + " AND " + Tables.DevicePropertyText.PropertyType + "=" + Function.SqlStr(this.GetType().FullName);
                    dbConn.ExecuteNonQuery(strSql);

                    strSql = "DELETE FROM " + Tables.DevicePropertyBytes.TableName + " WHERE " + Tables.DevicePropertyBytes.DeviceId + "=" + this.Device.DeviceId + " AND " + Tables.DevicePropertyBytes.PropertyType + "=" + Function.SqlStr(this.GetType().FullName);
                    dbConn.ExecuteNonQuery(strSql);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
Example #15
0
        /// <summary>
        /// 保存分类。
        /// </summary>
        public virtual void Save()
        {
            if (this.Name == null || this.Name.Trim().Length == 0)
            {
                throw new Exception("未设置分类名称。");
            }
            else
            {
                //配置信息
                System.Xml.XmlDocument xmlDoc   = new System.Xml.XmlDocument();
                System.Xml.XmlNode     xnConfig = xmlDoc.CreateElement(this.GetType().Name);
                xmlDoc.AppendChild(xnConfig);

                System.Xml.XmlNode xnEnabledDevice = xmlDoc.CreateElement("EnabledDevice");
                xnEnabledDevice.InnerText = Function.BoolToByte(this.EnabledDevice).ToString();
                xnConfig.AppendChild(xnEnabledDevice);

                if (this.DeviceFilters != null && this.DeviceFilters.Count > 0)
                {
                    System.Xml.XmlNode xnDeviceFilters = xmlDoc.CreateElement("DeviceFilters");
                    xnDeviceFilters.AppendChild(this.DeviceFilters.GetFilterConfig(xmlDoc));
                    xnConfig.AppendChild(xnDeviceFilters);
                }

                System.Xml.XmlNode xnClassifyConfig = this.GetClassifyConfig(xmlDoc);
                if (xnClassifyConfig != null)
                {
                    xnConfig.AppendChild(xnClassifyConfig);
                }

                string strConfig = xmlDoc.OuterXml;

                //插入或更新
                string strSql;
                if (this.ClassifyId == 0)
                {
                    AC.Base.Database.DbConnection dbConn = this.Application.GetDbConnection();
                    if (dbConn != null)
                    {
                        strSql          = "SELECT MAX(" + Tables.Classify.ClassifyId + ") FROM " + Tables.Classify.TableName;
                        this.ClassifyId = Function.ToInt(dbConn.ExecuteScalar(strSql)) + 1;

                        try
                        {
                            if (this.OrdinalNumber == 0)
                            {
                                this.OrdinalNumber = this.ClassifyId;
                            }

                            strSql = this.ClassifyId + "," + Function.SqlStr(this.ClassifyType.Code, 250) + "," + (this.Parent == null ? 0 : this.Parent.ClassifyId) + "," + Function.SqlStr(this.Name, 250) + "," + Function.SqlStr(this.NameShortcut, 250) + "," + Function.SqlStr(this.Identifier, 250) + "," + this.OrdinalNumber + "," + Function.SqlStr(strConfig);
                            strSql = "INSERT INTO " + Tables.Classify.TableName + " (" + Tables.Classify.ClassifyId + "," + Tables.Classify.ClassifyType + "," + Tables.Classify.ParentId + "," + Tables.Classify.Name + "," + Tables.Classify.NameShortcut + "," + Tables.Classify.Identifier + "," + Tables.Classify.OrdinalNumber + "," + Tables.Classify.XMLConfig + ") VALUES (" + strSql + ")";
                            dbConn.ExecuteNonQuery(strSql);

                            if (this.Parent != null)
                            {
                                this.Parent.Children.Add(this);
                            }
                        }
                        finally
                        {
                            dbConn.Close();
                        }
                    }
                }
                else
                {
                    AC.Base.Database.DbConnection dbConn = this.Application.GetDbConnection();
                    if (dbConn != null)
                    {
                        try
                        {
                            strSql = "UPDATE " + Tables.Classify.TableName + " Set " + Tables.Classify.Name + "=" + Function.SqlStr(this.Name, 250) + "," + Tables.Device.NameShortcut + "=" + Function.SqlStr(this.NameShortcut, 250) + "," + Tables.Classify.Identifier + "=" + Function.SqlStr(this.Identifier, 250) + "," + Tables.Classify.OrdinalNumber + "=" + this.OrdinalNumber + "," + Tables.Classify.XMLConfig + "=" + Function.SqlStr(strConfig) + " Where " + Tables.Classify.ClassifyId + "=" + this.ClassifyId;
                            dbConn.ExecuteNonQuery(strSql);
                        }
                        finally
                        {
                            dbConn.Close();
                        }
                    }
                }
            }
        }
Example #16
0
        /// <summary>
        /// 保存当前任务信息。
        /// </summary>
        public void Save()
        {
            if (this.Name == null || this.Name.Length == 0)
            {
                throw new Exception("任务名称必须输入。");
            }
            else if (this.Group == null)
            {
                throw new Exception("必须设置任务所属的任务组。");
            }
            else if (this.Period == null)
            {
                throw new Exception("必须配置任务的运行周期。");
            }

            AC.Base.Database.DbConnection dbConn = this.Application.GetDbConnection();
            if (dbConn != null)
            {
                try
                {
                    string strConfig = null;
                    System.Xml.XmlDocument xmlDoc   = new System.Xml.XmlDocument();
                    System.Xml.XmlNode     xnConfig = xmlDoc.CreateElement(this.GetType().Name);
                    xmlDoc.AppendChild(xnConfig);

                    System.Xml.XmlNode xnPeriodType = xmlDoc.CreateElement("PeriodType");
                    xnPeriodType.InnerText = this.Period.GetType().FullName;
                    xnConfig.AppendChild(xnPeriodType);

                    System.Xml.XmlNode xnPeriodConfig = this.Period.GetTaskPeriodConfig(xmlDoc);
                    if (xnPeriodConfig != null)
                    {
                        System.Xml.XmlNode xnPeriod = xmlDoc.CreateElement("Period");
                        xnPeriod.AppendChild(xnPeriodConfig);
                        xnConfig.AppendChild(xnPeriod);
                    }

                    System.Xml.XmlNode xnMaxRunTime = xmlDoc.CreateElement("MaxRunTime");
                    xnMaxRunTime.InnerText = this.MaxRunTime.ToString();
                    xnConfig.AppendChild(xnMaxRunTime);

                    System.Xml.XmlNode xnRetryProgress = xmlDoc.CreateElement("RetryProgress");
                    xnRetryProgress.InnerText = this.RetryProgress.ToString();
                    xnConfig.AppendChild(xnRetryProgress);

                    System.Xml.XmlNode xnIsUnqualifiedRetry = xmlDoc.CreateElement("IsUnqualifiedRetry");
                    xnIsUnqualifiedRetry.InnerText = this.IsUnqualifiedRetry.ToString();
                    xnConfig.AppendChild(xnIsUnqualifiedRetry);

                    System.Xml.XmlNode xnRetryInterval = xmlDoc.CreateElement("RetryInterval");
                    for (int i = 0; i < this.RetryInterval.Length; i++)
                    {
                        System.Xml.XmlNode xnRetryIntervalChild = xmlDoc.CreateElement(string.Format("Interval{0}", i + 1));
                        xnRetryIntervalChild.InnerText = this.RetryInterval[i].ToString();
                        xnRetryInterval.AppendChild(xnRetryIntervalChild);
                    }
                    xnConfig.AppendChild(xnRetryInterval);

                    System.Xml.XmlNode xnTaskConfig = this.GetTaskConfig(xmlDoc);
                    if (xnTaskConfig != null)
                    {
                        System.Xml.XmlNode xn = xmlDoc.CreateElement("TaskConfig");
                        xn.AppendChild(xnTaskConfig);
                        xnConfig.AppendChild(xn);
                    }

                    strConfig = xmlDoc.OuterXml;

                    if (this.TaskConfigId == 0)
                    {
                        string strSql = "SELECT MAX(" + Tables.TaskConfig.TaskConfigId + ") FROM " + Tables.TaskConfig.TableName;
                        this.TaskConfigId = Function.ToInt(dbConn.ExecuteScalar(strSql)) + 1;

                        strSql = this.TaskConfigId + "," + Function.SqlStr(this.TaskType.Code, 250) + "," + Function.SqlStr(this.Name, 250) + "," + this.Group.TaskGroupId + "," + Function.BoolToByte(this.Enable) + "," + Function.SqlStr(strConfig);
                        strSql = "INSERT INTO " + Tables.TaskConfig.TableName + " (" + Tables.TaskConfig.TaskConfigId + "," + Tables.TaskConfig.TaskType + "," + Tables.TaskConfig.Name + "," + Tables.TaskConfig.TaskGroupId + "," + Tables.TaskConfig.EnableAuto + "," + Tables.TaskConfig.XMLConfig + ") VALUES (" + strSql + ")";
                        dbConn.ExecuteNonQuery(strSql);

                        this.Group.TaskConfigs.Add(this);
                    }
                    else
                    {
                        string strSql = "UPDATE " + Tables.TaskConfig.TableName + " Set " + Tables.TaskConfig.Name + "=" + Function.SqlStr(this.Name, 250) + "," + Tables.TaskConfig.EnableAuto + "=" + Function.BoolToByte(this.Enable) + "," + Tables.Device.XMLConfig + "=" + Function.SqlStr(strConfig) + " Where " + Tables.TaskConfig.TaskConfigId + "=" + this.TaskConfigId;
                        dbConn.ExecuteNonQuery(strSql);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
Example #17
0
File: Task.cs Project: jujianfei/AC
        //任务运行完成后必须调用该方法
        private void Save()
        {
            this.StopTime = DateTime.Now;
            AC.Base.Database.DbConnection dbConn = this.Config.Application.GetDbConnection();
            if (dbConn != null)
            {
                try
                {
                    string strTableName = Tables.TaskRunLog.GetTableName(this.Log.LogTime);
                    if (dbConn.TableIsExist(strTableName) == false)
                    {
                        dbConn.CreateTable(typeof(Tables.TaskRunLog), strTableName);
                    }
                    string strConfig = null;
                    System.Xml.XmlDocument xmlDoc   = new System.Xml.XmlDocument();
                    System.Xml.XmlNode     xnConfig = this.GetTaskRunConfig(xmlDoc);
                    if (xnConfig != null)
                    {
                        xmlDoc.AppendChild(xnConfig);
                        strConfig = xmlDoc.OuterXml;
                    }
                    this.TimeStr = this.Log.LogId.ToString() + "_" + this.RetryTimes;

                    string strSql = Function.SqlStr(this.Log.LogId.ToString()) + "," +
                                    this.RetryTimes + "," +
                                    this.StartTime.Ticks + "," +
                                    this.StopTime.Ticks + "," +
                                    (this.StopTime - this.StartTime).TotalMilliseconds + "," +
                                    ((int)this.State) + "," +
                                    this.Progress + "," +
                                    Function.SqlStr(this.taskName) + "," +
                                    Function.SqlStr(this.TimeStr) + "," +
                                    Function.SqlStr(strConfig);

                    strSql = "INSERT INTO " + strTableName + " (" + Tables.TaskRunLog.TaskLogId + "," + Tables.TaskRunLog.RetryTimes + "," + Tables.TaskRunLog.StartTime + "," + Tables.TaskRunLog.StopTime + "," + Tables.TaskRunLog.TimeSpan + "," + Tables.TaskRunLog.TaskState + "," + Tables.TaskRunLog.TaskProgress + "," + Tables.TaskRunLog.DeviceName + "," + Tables.TaskRunLog.TimeStr + "," + Tables.TaskRunLog.XMLConfig + ") VALUES (" + strSql + ")";
                    dbConn.ExecuteNonQuery(strSql);

                    strTableName = Tables.TaskLog.GetTableName(this.Log.LogTime);
                    strSql       = "UPDATE " + strTableName + " Set " + Tables.TaskLog.RetryTimes + "=" + this.RetryTimes + "," + Tables.TaskLog.LastProgress + "=" + this.Progress + " Where " + Tables.TaskLog.TaskLogId + "=" + Function.SqlStr(this.Log.LogId.ToString());
                    dbConn.ExecuteNonQuery(strSql);

                    if (this.ExceptionInfos.Count > 0)
                    {
                        strTableName = Tables.TaskExceptionLog.GetTableName(this.Log.LogTime);
                        if (dbConn.TableIsExist(strTableName) == false)
                        {
                            dbConn.CreateTable(typeof(Tables.TaskExceptionLog), strTableName);
                        }

                        for (int intIndex = 0; intIndex < this.ExceptionInfos.Count; intIndex++)
                        {
                            strSql = this.Log.LogId + "," + this.RetryTimes + "," + (intIndex + 1) + "," + this.ExceptionInfos[intIndex].ExceptionTime.Ticks + "," + Function.SqlStr(this.ExceptionInfos[intIndex].ExceptionInfo);
                            strSql = "INSERT INTO " + strTableName + " (" + Tables.TaskExceptionLog.TaskLogId + "," + Tables.TaskExceptionLog.RetryTimes + "," + Tables.TaskExceptionLog.ExceptionId + "," + Tables.TaskExceptionLog.ExceptionTime + "," + Tables.TaskExceptionLog.XMLConfig + ") VALUES (" + strSql + ")";
                            dbConn.ExecuteNonQuery(strSql);
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.OnException(ex);
                }
                finally
                {
                    dbConn.Close();
                }
            }

            this.Log.Tasks.Add(this);

            if (this.Stopped != null)
            {
                try
                {
                    this.Stopped(this);
                }
                catch (Exception ex)
                {
                    this.OnException(ex.Message);
                }
            }
        }