Esempio n. 1
0
        /// <summary>
        /// 提供对RecordCollection对象的操做。插入、更新、删除、插入或更新
        /// </summary>
        /// <param name="recCollection"></param>
        /// <param name="execMode"></param>
        /// <returns>返回成功行数</returns>
        public int ProcessRecord(RecordCollection recCollection, ExecuteMode execMode, string type)
        {
            int count = 0;

            foreach (Record record in recCollection)
            {
                if (ProcessRecord(record, execMode) != -1)
                {
                    //addLog(record);
                    if (type == "err")
                    {
                        //cmd_OnProgressOK((string)record.FieldCollection["EID"].Value);
                        cmd_OnProgressOK(record.SetOldKeyValue());
                    }
                    count++;
                }
                else
                {
                    if (this._conn.mTransaction != null)
                    {
                        throw new Exception("更新有错");
                    }
                }
            }
            return(count);
        }
Esempio n. 2
0
        /// <summary>
        /// 提供对RecordCollection对象的操做。插入、更新、删除、插入或更新
        /// </summary>
        /// <param name="recCollection"></param>
        /// <param name="execMode"></param>
        /// <returns>返回成功行数</returns>
        public int ProcessRecord(RecordCollection recCollection, ExecuteMode execMode)
        {
            int count = 0;

            try
            {
                foreach (Record record in recCollection)
                {
                    if (ProcessRecord(record, execMode) != -1)
                    {
                        //addLog(record);
                        count++;
                    }
                    else
                    {
                        if (this._conn.mTransaction != null)
                        {
                            this._conn.mTransaction.Rollback();
                            return(0);
                        }
                    }
                }
                if (this._conn.mTransaction != null)
                {
                    this._conn.mTransaction.Commit();
                    return(count);
                }
            }
            finally
            {
                this.CloseConn();
            }
            return(count);
        }
Esempio n. 3
0
        public int RecordUpdate()
        {
            string    sql    = "select  *  from   hqftable1";
            DataTable dtCols = acc.GetDataTable(sql);

            DataAccess.RecordCollection rc = _GeneralRecords(dtCols, SourceDBInfo.DBType);
            return(acc.ProcessRecord(rc, DataAccess.ExecuteMode.InsertOrUpdate));
        }
Esempio n. 4
0
        public int RecordUpdate(bool isaddlog)
        {
            string    sql    = "select  Name,content,photo   from   hqftable1";
            DataTable dtCols = acc.GetDataTable(sql);

            DataAccess.RecordCollection rc = _GeneralRecords(dtCols, SourceDBInfo.DBType);

            return(acc.ProcessRecord(rc[0], DataAccess.ExecuteMode.InsertOrUpdate, true));
        }
Esempio n. 5
0
        /// <summary>
        /// 反序列化对象
        /// <code>
        /// RecordCollection rc=RecordCollection.Deserialize( XmlDocument );
        /// </code>
        /// </summary>
        /// <param name="_Records">XmlDocument</param>
        /// <returns>RecordCollection</returns>
        public static RecordCollection Deserialize(XmlDocument _Records)
        {
            RecordCollection tempRecordCollection = new RecordCollection();

            tempRecordCollection.Clear();
            XmlElement xeRecords = _Records["Records"];

            foreach (XmlElement xeRecord in xeRecords.ChildNodes)
            {
                tempRecordCollection.Add(Record.Deserialize(xeRecord));
            }
            return(tempRecordCollection);
        }
Esempio n. 6
0
        private DataAccess.RecordCollection _GeneralRecords(DataTable sourDt, DBType type)
        {
            DataAccess.RecordCollection rc = new DataAccess.RecordCollection();

            int index = 0;

            foreach (DataRow dr in sourDt.Rows)
            {
                DataAccess.Record rec = _GeneralRecord(dr, type);
                rec.Index = index;
                rc.Add(rec);
                index++;
            }
            return(rc);
        }
Esempio n. 7
0
        /// <summary>
        /// 提供对RecordCollection对象的操做。插入、更新、删除、插入或更新
        /// </summary>
        /// <param name="recCollection">RecordCollection对象集</param>
        /// <param name="execMode">插入、更新、删除、插入或更新</param>
        /// <param name="type">err:处理错误记录</param>
        /// <param name="isAddLog">是否写入emlog</param>
        /// <returns>返回成功行数</returns>
        public int ProcessRecord(RecordCollection recCollection, ExecuteMode execMode, string type, bool isAddLog, bool isSub)
        {
            int count = 0;

            try
            {
                foreach (Record record in recCollection)
                {
                    if (ProcessRecord(record, execMode, isAddLog) != -1)
                    {
                        //addLog(record);
                        if (type == "err" && !isSub)
                        {
                            cmd_OnProgressOK(record.SetOldKeyValue());
                        }

                        count++;
                    }
                    else
                    {
                        if (this._conn.mTransaction != null)
                        {
                            this._conn.mTransaction.Rollback();
                            count = -1;
                            return(count);
                        }
                    }
                }
                if (this._conn.mTransaction != null)
                {
                    this._conn.mTransaction.Commit();
                    return(count);
                }
            }
            finally
            {
                this.CloseConn();
            }
            return(count);
        }
Esempio n. 8
0
        /// <summary>
        /// 提供对RecordCollection对象的操做。插入、更新、删除、插入或更新
        /// </summary>
        /// <param name="recCollection"></param>
        /// <param name="execMode"></param>
        /// <param name="type">正常同步,处理错误同步</param>
        /// <param name="dbType">源记录的数据库类型</param>
        /// <returns></returns>
        public int ProcessRecord(RecordCollection recCollection, ExecuteMode execMode, string type, DBType dbType)
        {
            int count = 0;

            foreach (Record record in recCollection)
            {
                if (ProcessRecord(record, execMode) != -1)
                {
                    if (type == "err")
                    {
                        cmd_OnProgressOK(record.SetOldKeyValue(dbType));
                    }
                    count++;
                }
                else
                {
                    if (this._conn.mTransaction != null)
                    {
                        throw new Exception("更新有错");
                    }
                }
            }
            return(count);
        }