示例#1
0
        /// <summary>
        /// 提供对Record对象的操做。插入、更新、删除、插入或更新
        /// </summary>
        /// <param name="record">数据记录对象</param>
        /// <param name="execMode">插入、更新、删除、插入或更新</param>
        /// <param name="isAddLog">是否添加日志</param>
        /// <param name="isAddLog">是否生成新id</param>
        /// <returns></returns>
        public int ProcessRecord(Record record, ExecuteMode execMode, bool isAddLog, bool isNewID)
        {
            record.OnException   += new ExceptionHandler(record_OnException);
            record.OnExceptionEx += new ExceptionExHandler(cmd_OnExceptionEx);
            record.OnExceptionXP += new ExceptionXPHandler(record_OnExceptionXP);
            if (isNewID)
            {
                if (record.FieldCollection["EID"] == null || record.FieldCollection["EID"].Value == null)
                {
                    string eid = record.CreateEID();
                    if (record.FieldCollection["EID"] == null)
                    {
                        record.FieldCollection["EID"].Value = eid;
                    }
                    else
                    {
                        record.FieldCollection.Add(new Field("EID", eid));
                    }
                }
            }
            if (OnProgress != null)
            {
                OnProgress(string.Format(@"{2} 处理一条数据记录。记录关联表:{0};操作:{1}", record.TableName, execMode.ToString(), DateTime.Now));
            }
            record.Connection = this._conn;
            DateTime dt1 = DateTime.Now;
            int      i   = record.Process(execMode);

            if (record.Process(execMode) != -1)
            {
                DateTime dt2 = DateTime.Now;
#if debug
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2 - dt1;

                if (OnProgress != null)
                {
                    OnProgress(string.Format(@"{0} 处理一条数据记录。记录关联表:{1};操作花费时间{2}", DateTime.Now, record.TableName, ts.TotalMilliseconds));
                }
#endif

                dt1 = DateTime.Now;
                if (isAddLog)
                {
                    i = record.AddLog(this._emlogtable);
                }
                dt2 = DateTime.Now;
#if debug
                ts = dt2 - dt1;
                if (OnProgress != null)
                {
                    OnProgress(string.Format(@"{0} 处理一条数据记录。记录关联表:{1};写入log花费时间{2}", DateTime.Now, record.TableName, ts.TotalMilliseconds));
                }
#endif
                return(i);
            }

            return(-1);
        }
示例#2
0
        /// <summary>
        /// 记录Record对象的表名,表id,eid到emlog表
        /// </summary>
        /// <param name="record">数据记录对象</param>
        /// <returns></returns>
        public int addLog(Record record)
        {
            record.OnException   += new ExceptionHandler(record_OnException);
            record.OnExceptionEx += new ExceptionExHandler(cmd_OnExceptionEx);
            record.OnExceptionXP += new ExceptionXPHandler(record_OnExceptionXP);

            if (OnProgress != null)
            {
                OnProgress(string.Format(@"{0} 。记录表:{0}的log", DateTime.Now, record.TableName));
            }
            record.Connection = this._conn;
            return(record.AddLog(this._emlogtable));
        }
示例#3
0
        /// <summary>
        /// 提供对Record对象的操做。插入、更新、删除、插入或更新
        /// </summary>
        /// <param name="record">数据记录对象</param>
        /// <param name="execMode">插入、更新、删除、插入或更新</param>
        /// <param name="isAddLog">是否添加日志</param>
        /// <returns></returns>
        public int ProcessRecord(Record record, ExecuteMode execMode, bool isAddLog)
        {
            record.OnException   += new ExceptionHandler(record_OnException);
            record.OnExceptionXP += new ExceptionXPHandler(record_OnExceptionXP);
            record.OnExceptionEx += new ExceptionExHandler(cmd_OnExceptionEx);

            if (OnProgress != null)
            {
                OnProgress(string.Format(@"{2} 处理一条数据记录。记录关联表:{0};操作:{1}", record.TableName, execMode.ToString(), DateTime.Now));
            }
            record.Connection = this._conn;
            DateTime dt1 = DateTime.Now;
            int      i   = record.Process(execMode);

            if (i != -1)
            {
//#if debug
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2 - dt1;

                if (OnProgress != null)
                {
                    OnProgress(string.Format(@"{0} 处理一条数据记录。记录关联表:{1};操作花费时间{2}", DateTime.Now, record.TableName, ts.TotalMilliseconds));
                }


                dt1 = DateTime.Now;
//#endif
                if (isAddLog)
                {
                    i = record.AddLog(this._emlogtable);
                }
#if debug
                dt2 = DateTime.Now;

                ts = dt2 - dt1;
                if (OnProgress != null)
                {
                    OnProgress(string.Format(@"{0} 处理一条数据记录。记录关联表:{1};写入log花费时间{2}", DateTime.Now, record.TableName, ts.TotalMilliseconds));
                }
#endif
                return(i);
            }

            return(-1);
        }