コード例 #1
0
        private void DoUpdate(DataRow srow)
        {
            //将需要同步的ID赋值
            string  id = srow["BusinessID"].ToString();
            DataRow row;//声明需要同步的记录

            try
            {
                string tsql = "select * from AA_InventoryClass where id=@id";
                IList <SqlParameter> tlist = new List <SqlParameter>();
                tlist.Add(new SqlParameter("@id", srow["BusinessID"].Equals(null) ? DBNull.Value : srow["BusinessID"]));
                row = DBAccess.QueryDataTable(MainCon, tsql, tlist.ToArray()).Rows[0];//赋值需要同步的记录
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog(srow["BusinessID"].ToString(), srow["BusinessCode"].ToString(), srow["BusinessType"].ToString(), srow["SyncType"].ToString(),
                                     srow["CodeType"].ToString(), srow["IsFinish"].ToString(), "在正式帐套下找到ID为" + id + "的AA_InventoryClass条目");
                return;
            }
            IList <SqlParameter> paramList = new List <SqlParameter>();

            try
            {
                paramList.Add(new SqlParameter("@id", row["id"].Equals(null) ? DBNull.Value : row["id"]));
                paramList.Add(new SqlParameter("@code", row["code"].Equals(null) ? DBNull.Value : row["code"]));
                paramList.Add(new SqlParameter("@name", row["name"].Equals(null) ? DBNull.Value : row["name"]));
                paramList.Add(new SqlParameter("@isEndNode", row["isEndNode"].Equals(null) ? DBNull.Value : row["isEndNode"]));
                paramList.Add(new SqlParameter("@depth", row["depth"].Equals(null) ? DBNull.Value : row["depth"]));
                paramList.Add(new SqlParameter("@disabled", row["disabled"].Equals(null) ? DBNull.Value : row["disabled"]));
                paramList.Add(new SqlParameter("@updatedBy", row["updatedBy"].Equals(null) ? DBNull.Value : row["updatedBy"]));
                paramList.Add(new SqlParameter("@inId", row["inId"].Equals(null) ? DBNull.Value : row["inId"]));
                paramList.Add(new SqlParameter("@idMarketingOrgan", row["idMarketingOrgan"].Equals(null) ? DBNull.Value : row["idMarketingOrgan"]));
                paramList.Add(new SqlParameter("@idparent", row["idparent"].Equals(null) ? DBNull.Value : row["idparent"]));
                paramList.Add(new SqlParameter("@madeDate", row["madeDate"].Equals(null) ? DBNull.Value : row["madeDate"]));
                paramList.Add(new SqlParameter("@updated", row["updated"].Equals(null) ? DBNull.Value : row["updated"]));
                paramList.Add(new SqlParameter("@createdTime", row["createdTime"].Equals(null) ? DBNull.Value : row["createdTime"]));
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog(row["id"].ToString(), row["code"].ToString(), "AA_InventoryClass", "Update", "数据同步", "0",
                                     "When SyncSystem SyncInventoryClass Do Update,Some SqlParameter Throw Some Message,The Message Like[" + ex.InnerException + "]");
                return;
            }
            string sql = string.Empty;

            sql += "update AA_InventoryClass set code=@code,name=@name,isEndNode=@isEndNode,depth=@depth,disabled=@disabled,";
            sql += "updatedBy = @updatedBy,inId = @inId,idMarketing = @idMarketing,idparent = @idparent,madeDate = @madeDate,";
            sql += "updated = @updated,createdTime = @createdTime where id = @id";
            try
            {
                DBAccess.ExecSql(PDACon, sql, paramList.ToArray());
                SyncHelper.UpdateSyncList(srow["BusinessID"].ToString(), srow["BusinessType"].ToString(), srow["SyncType"].ToString(), 1.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog(row["id"].ToString(), row["code"].ToString(), "AA_InventoryClass", "Insert", "数据同步", "0",
                                     "When SyncSystem SyncInventoryClass Do Update,This Sql Throw Some Message,The Message Like[" + ex.InnerException + "]");
                return;
            }
        }
コード例 #2
0
        /// <summary>
        /// 执行Insert
        /// </summary>
        /// <param name="srow">NeedSyncList的条目</param>
        private void DoInsert(DataRow srow)
        {
            //将需要同步的ID赋值
            string  id = srow["BusinessID"].ToString();
            DataRow row;//声明需要同步的记录

            try
            {
                string tsql = "select * from AA_Inventory where id=@id";
                IList <SqlParameter> tlist = new List <SqlParameter>();
                tlist.Add(new SqlParameter("@id", srow["BusinessID"].Equals(null) ? DBNull.Value : srow["BusinessID"]));
                row = DBAccess.QueryDataTable(MainCon, tsql, tlist.ToArray()).Rows[0];//赋值需要同步的记录
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog(srow["BusinessID"].ToString(), srow["BusinessCode"].ToString(), srow["BusinessType"].ToString(), srow["SyncType"].ToString(),
                                     srow["CodeType"].ToString(), srow["IsFinish"].ToString(), "在正式帐套下未找到ID为" + id + "的AA_Inventory条目");
                return;
            }
            IList <SqlParameter> paramList = new List <SqlParameter>();

            try
            {
                SetSqlParameter(ref paramList, row);
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog(row["id"].ToString(), row["code"].ToString(), "AA_Inventory", "Insert", "数据同步", "0",
                                     "When SyncSystem SyncInventory Do Insert,Some SqlParameter Throw Some Message,The Message Like[" + ex.InnerException + "]");
                return;
            }
            try
            {
                DBAccess.ExecReturnSP(PDACon, "AA_Inventory_Insert", paramList.ToArray());
                SyncHelper.UpdateSyncList(srow["BusinessID"].ToString(), srow["BusinessType"].ToString(), srow["SyncType"].ToString(), 1.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog(row["id"].ToString(), row["code"].ToString(), "AA_Inventory", "Insert", "数据同步", "0",
                                     "When SyncSystem SyncInventory Do Insert,This Sql Throw Some Message,The Message Like[" + ex.InnerException + "]");
                return;
            }
        }
コード例 #3
0
        /// <summary>
        /// 同步主入口
        /// </summary>
        /// <param name="ID">同步记录表主键ID</param>
        public void DoSync(string ID)
        {
            string    sql = string.Format("select * from NeedSyncList where ID={0}", ID);
            DataTable dt  = new DataTable();

            try
            {
                dt = DBAccess.QueryDataTable(sql);
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog("未指定", "未指定", "未指定", "未指定", "未指定", "0", "查询需要NeedSyncList记录失败,主键ID值为:" + ID
                                     + "#" + ex.Message + "#" + ex.Source + "#" + ex.StackTrace.Trim() + "#" + ex.TargetSite);
                return;
            }
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    switch (row["SyncType"].ToString())
                    {
                    case "Insert": DoInsert(row); break;

                    case "Update": DoUpdate(row); break;

                    default:
                        SyncHelper.InsertLog(row["BusinessID"].ToString(), row["BusinessCode"].ToString(), row["BusinessType"].ToString(), row["SyncType"].ToString(),
                                             row["CodeType"].ToString(), row["IsFinish"].ToString(), "未找到指定的SyncType");
                        break;
                    }
                }
            }
            else
            {
                SyncHelper.InsertLog("未指定", "未指定", "未指定", "未指定", "未指定", "0", "NeedSyncList未查询到ID=" + ID + "的数据!");
                return;
            }
        }
コード例 #4
0
        private void DoInsert(DataRow row)
        {
            string    sql = string.Format("select * from AA_BOMChild where id={0}", row["BusinessID"]);
            DataTable dt  = MainDBAccess.QueryDataTable(sql);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow rows in dt.Rows)
                {
                    try
                    {
                        IList <SqlParameter> listParam = new List <SqlParameter>();
                        listParam.Add(new SqlParameter("@code", rows["code"].Equals(null) ? DBNull.Value : rows["code"]));
                        listParam.Add(new SqlParameter("@name", rows["name"].Equals(null) ? DBNull.Value : rows["name"]));
                        listParam.Add(new SqlParameter("@produceQuantity", rows["produceQuantity"].Equals(null) ? DBNull.Value : rows["produceQuantity"]));
                        listParam.Add(new SqlParameter("@rationQuantity", rows["rationQuantity"].Equals(null) ? DBNull.Value : rows["rationQuantity"]));
                        listParam.Add(new SqlParameter("@wasteRate", rows["wasteRate"].Equals(null) ? DBNull.Value : rows["wasteRate"]));
                        listParam.Add(new SqlParameter("@ts", rows["ts"].Equals(null) ? DBNull.Value : rows["ts"]));
                        listParam.Add(new SqlParameter("@updatedBy", rows["updatedBy"].Equals(null) ? DBNull.Value : rows["updatedBy"]));
                        listParam.Add(new SqlParameter("@freeItem0", rows["freeItem0"].Equals(null) ? DBNull.Value : rows["freeItem0"]));
                        listParam.Add(new SqlParameter("@freeItem1", rows["freeItem1"].Equals(null) ? DBNull.Value : rows["freeItem1"]));
                        listParam.Add(new SqlParameter("@freeItem2", rows["freeItem2"].Equals(null) ? DBNull.Value : rows["freeItem2"]));
                        listParam.Add(new SqlParameter("@freeItem3", rows["freeItem3"].Equals(null) ? DBNull.Value : rows["freeItem3"]));
                        listParam.Add(new SqlParameter("@freeItem4", rows["freeItem4"].Equals(null) ? DBNull.Value : rows["freeItem4"]));
                        listParam.Add(new SqlParameter("@freeItem5", rows["freeItem5"].Equals(null) ? DBNull.Value : rows["freeItem5"]));
                        listParam.Add(new SqlParameter("@freeItem6", rows["freeItem6"].Equals(null) ? DBNull.Value : rows["freeItem6"]));
                        listParam.Add(new SqlParameter("@freeItem7", rows["freeItem7"].Equals(null) ? DBNull.Value : rows["freeItem7"]));
                        listParam.Add(new SqlParameter("@freeItem8", rows["freeItem8"].Equals(null) ? DBNull.Value : rows["freeItem8"]));
                        listParam.Add(new SqlParameter("@freeItem9", rows["freeItem9"].Equals(null) ? DBNull.Value : rows["freeItem9"]));
                        listParam.Add(new SqlParameter("@memo", rows["memo"].Equals(null) ? DBNull.Value : rows["memo"]));
                        listParam.Add(new SqlParameter("@requiredquantity", rows["requiredquantity"].Equals(null) ? DBNull.Value : rows["requiredquantity"]));
                        listParam.Add(new SqlParameter("@requiredquantity2", rows["requiredquantity2"].Equals(null) ? DBNull.Value : rows["requiredquantity2"]));
                        listParam.Add(new SqlParameter("@rateofexchange", rows["rateofexchange"].Equals(null) ? DBNull.Value : rows["rateofexchange"]));
                        listParam.Add(new SqlParameter("@cost", rows["cost"].Equals(null) ? DBNull.Value : rows["cost"]));
                        listParam.Add(new SqlParameter("@backflushmaterial", rows["backflushmaterial"].Equals(null) ? DBNull.Value : rows["backflushmaterial"]));
                        listParam.Add(new SqlParameter("@defaultchoice", rows["defaultchoice"].Equals(null) ? DBNull.Value : rows["defaultchoice"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc1", rows["priuserdefnvc1"].Equals(null) ? DBNull.Value : rows["priuserdefnvc1"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc2", rows["priuserdefnvc2"].Equals(null) ? DBNull.Value : rows["priuserdefnvc2"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc3", rows["priuserdefnvc3"].Equals(null) ? DBNull.Value : rows["priuserdefnvc3"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc4", rows["priuserdefnvc4"].Equals(null) ? DBNull.Value : rows["priuserdefnvc4"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm1", rows["priuserdefdecm1"].Equals(null) ? DBNull.Value : rows["priuserdefdecm1"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm2", rows["priuserdefdecm2"].Equals(null) ? DBNull.Value : rows["priuserdefdecm2"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm3", rows["priuserdefdecm3"].Equals(null) ? DBNull.Value : rows["priuserdefdecm3"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm4", rows["priuserdefdecm4"].Equals(null) ? DBNull.Value : rows["priuserdefdecm4"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc1", rows["pubuserdefnvc1"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc1"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc2", rows["pubuserdefnvc2"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc2"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc3", rows["pubuserdefnvc3"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc3"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc4", rows["pubuserdefnvc4"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc4"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm1", rows["pubuserdefdecm1"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm1"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm2", rows["pubuserdefdecm2"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm2"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm3", rows["pubuserdefdecm3"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm3"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm4", rows["pubuserdefdecm4"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm4"]));
                        listParam.Add(new SqlParameter("@BatchNumber", rows["BatchNumber"].Equals(null) ? DBNull.Value : rows["BatchNumber"]));
                        listParam.Add(new SqlParameter("@FailDate", rows["FailDate"].Equals(null) ? DBNull.Value : rows["FailDate"]));
                        listParam.Add(new SqlParameter("@idchildbom", rows["idchildbom"].Equals(null) ? DBNull.Value : rows["idchildbom"]));
                        listParam.Add(new SqlParameter("@idbom", rows["idbom"].Equals(null) ? DBNull.Value : rows["idbom"]));
                        listParam.Add(new SqlParameter("@idBomRelationDTO", rows["idBomRelationDTO"].Equals(null) ? DBNull.Value : rows["idBomRelationDTO"]));
                        listParam.Add(new SqlParameter("@idinventory", rows["idinventory"].Equals(null) ? DBNull.Value : rows["idinventory"]));
                        listParam.Add(new SqlParameter("@idproductprocess", rows["idproductprocess"].Equals(null) ? DBNull.Value : rows["idproductprocess"]));
                        listParam.Add(new SqlParameter("@idunit", rows["idunit"].Equals(null) ? DBNull.Value : rows["idunit"]));
                        listParam.Add(new SqlParameter("@idunit2", rows["idunit2"].Equals(null) ? DBNull.Value : rows["idunit2"]));
                        listParam.Add(new SqlParameter("@idwarehouse", rows["idwarehouse"].Equals(null) ? DBNull.Value : rows["idwarehouse"]));
                        listParam.Add(new SqlParameter("@bomchildattribute", rows["bomchildattribute"].Equals(null) ? DBNull.Value : rows["bomchildattribute"]));
                        listParam.Add(new SqlParameter("@madeDate", rows["madeDate"].Equals(null) ? DBNull.Value : rows["madeDate"]));
                        listParam.Add(new SqlParameter("@updated", rows["updated"].Equals(null) ? DBNull.Value : rows["updated"]));
                        listParam.Add(new SqlParameter("@createdtime", rows["createdtime"].Equals(null) ? DBNull.Value : rows["createdtime"]));

                        string sqls = string.Empty;
                        sqls += "insert into AA_BOMChild(code,name,produceQuantity,rationQuantity,wasteRate,";
                        sqls += "updatedBy,freeItem0,freeItem1,freeItem2,freeItem3,freeItem4,freeItem5,";
                        sqls += "freeItem6,freeItem7,freeItem8,freeItem9,memo,requiredquantity,requiredquantity2,";
                        sqls += "rateofexchange,cost,backflushmaterial,defaultchoice,priuserdefnvc1,priuserdefnvc2,";
                        sqls += "priuserdefnvc3,priuserdefnvc4,priuserdefdecm1,priuserdefdecm2,priuserdefdecm3,";
                        sqls += "priuserdefdecm4,pubuserdefnvc1,pubuserdefnvc2,pubuserdefnvc3,pubuserdefnvc4,";
                        sqls += "pubuserdefdecm1,pubuserdefdecm2,pubuserdefdecm3,pubuserdefdecm4,";
                        sqls += "BatchNumber,FailDate,idchildbom,idbom,idBomRelationDTO,idinventory,";
                        sqls += "idproductprocess,idunit,idunit2,idwarehouse,bomchildattribute,madeDate,";
                        sqls += "updated,createdtime)";
                        sqls += " values(@code,@name,@produceQuantity,@rationQuantity,@wasteRate,";
                        sqls += "@updatedBy,@freeItem0,@freeItem1,@freeItem2,@freeItem3,@freeItem4,@freeItem5,";
                        sqls += "@freeItem6,@freeItem7,@freeItem8,@freeItem9,@memo,@requiredquantity,@requiredquantity2,";
                        sqls += "@rateofexchange,@cost,@backflushmaterial,@defaultchoice,@priuserdefnvc1,@priuserdefnvc2,";
                        sqls += "@priuserdefnvc3,@priuserdefnvc4,@priuserdefdecm1,@priuserdefdecm2,@priuserdefdecm3,";
                        sqls += "@priuserdefdecm4,@pubuserdefnvc1,@pubuserdefnvc2,@pubuserdefnvc3,@pubuserdefnvc4,";
                        sqls += "@pubuserdefdecm1,@pubuserdefdecm2,@pubuserdefdecm3,@pubuserdefdecm4,";
                        sqls += "@BatchNumber,@FailDate,@idchildbom,@idbom,@idBomRelationDTO,@idinventory,";
                        sqls += "@idproductprocess,@idunit,@idunit2,@idwarehouse,@bomchildattribute,@madeDate,";
                        sqls += "@updated,@createdtime)";
                        int count = PDADBAccess.ExecTransSql(sqls, listParam.ToArray());
                        if (count > 0)
                        {
                            SyncHelper.UpdateSyncList(row["BusinessID"].ToString(), row["SyncType"].ToString(), row["SyncType"].ToString(), 1.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        }
                    }
                    catch (Exception ex)
                    {
                        SyncHelper.InsertLog(row["id"].ToString(), row["code"].ToString(), "AA_BOMChild", "Insert", "数据同步", "0",
                                             "#" + ex.Message + "#" + ex.Source + "#" + ex.StackTrace.Trim() + "#" + ex.TargetSite);
                        return;
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// 执行Insert
        /// </summary>
        /// <param name="srow">NeedSyncList的条目</param>
        private void DoInsert(DataRow srow)
        {
            //将需要同步的ID赋值
            string  id = srow["BusinessID"].ToString();
            DataRow row;//声明需要同步的记录

            try
            {
                string tsql = "select * from AA_Unit where id=@id";
                IList <SqlParameter> tlist = new List <SqlParameter>();
                tlist.Add(new SqlParameter("@id", srow["BusinessID"].Equals(null) ? DBNull.Value : srow["BusinessID"]));
                row = DBAccess.QueryDataTable(MainCon, tsql, tlist.ToArray()).Rows[0];//赋值需要同步的记录
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog(srow["BusinessID"].ToString(), srow["BusinessCode"].ToString(), srow["BusinessType"].ToString(), srow["SyncType"].ToString(),
                                     srow["CodeType"].ToString(), srow["IsFinish"].ToString(), "在正式帐套下找到ID为" + id + "的AA_Unit条目");
                return;
            }
            IList <SqlParameter> paramList = new List <SqlParameter>();

            try
            {
                //IList<SqlParameter> paramList = new List<SqlParameter>();
                paramList.Add(new SqlParameter("@code", row["code"].Equals(null) ? DBNull.Value : row["code"]));
                paramList.Add(new SqlParameter("@name", row["name"].Equals(null) ? DBNull.Value : row["name"]));
                paramList.Add(new SqlParameter("@isMainUnit", row["isMainUnit"].Equals(null) ? DBNull.Value : row["isMainUnit"]));
                paramList.Add(new SqlParameter("@changeRate", row["changeRate"].Equals(null) ? DBNull.Value : row["changeRate"]));
                paramList.Add(new SqlParameter("@isSingleUnit", row["isSingleUnit"].Equals(null) ? DBNull.Value : row["isSingleUnit"]));
                paramList.Add(new SqlParameter("@disabled", row["disabled"].Equals(null) ? DBNull.Value : row["disabled"]));
                paramList.Add(new SqlParameter("@updatedBy", row["updatedBy"].Equals(null) ? DBNull.Value : row["updatedBy"]));
                paramList.Add(new SqlParameter("@rateDescription", row["rateDescription"].Equals(null) ? DBNull.Value : row["rateDescription"]));

                //获取ID
                string idparent = string.Empty;
                idparent = SyncHelper.GetidByCodeFormOtherBook(SyncHelper.GetCodeByIDFromThisBook(row["idparent"].ToString(), "AA_InventoryClass", MainCon), PDACon, "AA_InventoryClass");
                //paramList.Add(new SqlParameter("@idparent", string.IsNullOrEmpty(idparent) ? row["idparent"] : idparent));
                paramList.Add(new SqlParameter("@isGroup", row["isGroup"].Equals(null) ? DBNull.Value : row["isGroup"]));

                paramList.Add(new SqlParameter("@idunitgroup", row["idunitgroup"].Equals(null) ? DBNull.Value : row["idunitgroup"]));
                paramList.Add(new SqlParameter("@changeType", row["changeType"].Equals(null) ? DBNull.Value : row["changeType"]));
                paramList.Add(new SqlParameter("@changeType1", row["changeType1"].Equals(null) ? DBNull.Value : row["changeType1"]));
                paramList.Add(new SqlParameter("@madeDate", row["madeDate"].Equals(null) ? DBNull.Value : row["madeDate"]));
                paramList.Add(new SqlParameter("@updated", row["updated"].Equals(null) ? DBNull.Value : row["updated"]));
                paramList.Add(new SqlParameter("@createdTime", row["createdTime"].Equals(null) ? DBNull.Value : row["createdTime"]));
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog(row["id"].ToString(), row["code"].ToString(), "AA_Unit", "Insert", "数据同步", "0",
                                     "When SyncSystem SyncUnit Do Insert,Some SqlParameter Throw Some Message,The Message Like[" + ex.InnerException + "]");
                return;
            }
            string sql = string.Empty;

            sql += "insert into AA_Unit(code,name,isMainUnit,changeRate,isSingleUnit,disabled,updatedBy,rateDescription,";
            sql += "isGroup,idunitgroup,changeType,changeType1,madeDate,updated,createdTime) values(@code, @name, @isMainUnit,";
            sql += "@changeRate, @isSingleUnit, @disabled, @updatedBy, @rateDescription, @isGroup, @idunitgroup, @changeType, @changeType1,";
            sql += "@madeDate, @updated, @createdTime)";
            try
            {
                DBAccess.ExecSql(PDACon, sql, paramList.ToArray());
                SyncHelper.UpdateSyncList(srow["BusinessID"].ToString(), srow["BusinessType"].ToString(), srow["SyncType"].ToString(), 1.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            catch (Exception ex)
            {
                SyncHelper.InsertLog(row["id"].ToString(), row["code"].ToString(), "AA_InventoryClass", "Insert", "数据同步", "0",
                                     "When SyncSystem SyncUnit Do Insert,This Sql Throw Some Message,The Message Like[" + ex.InnerException + "]");
                return;
            }
        }
コード例 #6
0
        private void DoInsert(DataRow row)
        {
            string    sql   = string.Format("select * from AA_BOM where id={0} and code='{1}'", row["BusinessID"], row["BusinessCode"]);
            DataTable dt    = MainDBAccess.QueryDataTable(sql);
            int       count = 0;

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow rows in dt.Rows)
                {
                    try
                    {
                        IList <SqlParameter> listParam = new List <SqlParameter>();
                        listParam.Add(new SqlParameter("@code", rows["code"].Equals(null) ? DBNull.Value : rows["code"]));
                        listParam.Add(new SqlParameter("@name", rows["name"].Equals(null) ? DBNull.Value : rows["name"]));
                        listParam.Add(new SqlParameter("@version", rows["version"].Equals(null) ? DBNull.Value : rows["version"]));
                        listParam.Add(new SqlParameter("@produceQuantity", rows["produceQuantity"].Equals(null) ? DBNull.Value : rows["produceQuantity"]));
                        listParam.Add(new SqlParameter("@rationWage", rows["rationWage"].Equals(null) ? DBNull.Value : rows["rationWage"]));
                        listParam.Add(new SqlParameter("@rationCharge", rows["rationCharge"].Equals(null) ? DBNull.Value : rows["rationCharge"]));
                        listParam.Add(new SqlParameter("@rationManHour", rows["rationManHour"].Equals(null) ? DBNull.Value : rows["rationManHour"]));
                        listParam.Add(new SqlParameter("@isDefaultBom", rows["isDefaultBom"].Equals(null) ? DBNull.Value : rows["isDefaultBom"]));
                        listParam.Add(new SqlParameter("@bomDepth", rows["bomDepth"].Equals(null) ? DBNull.Value : rows["bomDepth"]));
                        listParam.Add(new SqlParameter("@disabled", rows["disabled"].Equals(null) ? DBNull.Value : rows["disabled"]));
                        listParam.Add(new SqlParameter("@ts", rows["ts"].Equals(null) ? DBNull.Value : rows["ts"]));
                        listParam.Add(new SqlParameter("@updatedBy", rows["updatedBy"].Equals(null) ? DBNull.Value : rows["updatedBy"]));
                        listParam.Add(new SqlParameter("@freeItem0", rows["freeItem0"].Equals(null) ? DBNull.Value : rows["freeItem0"]));
                        listParam.Add(new SqlParameter("@freeItem1", rows["freeItem1"].Equals(null) ? DBNull.Value : rows["freeItem1"]));
                        listParam.Add(new SqlParameter("@freeItem2", rows["freeItem2"].Equals(null) ? DBNull.Value : rows["freeItem2"]));
                        listParam.Add(new SqlParameter("@freeItem3", rows["freeItem3"].Equals(null) ? DBNull.Value : rows["freeItem3"]));
                        listParam.Add(new SqlParameter("@freeItem4", rows["freeItem4"].Equals(null) ? DBNull.Value : rows["freeItem4"]));
                        listParam.Add(new SqlParameter("@freeItem5", rows["freeItem5"].Equals(null) ? DBNull.Value : rows["freeItem5"]));
                        listParam.Add(new SqlParameter("@freeItem6", rows["freeItem6"].Equals(null) ? DBNull.Value : rows["freeItem6"]));
                        listParam.Add(new SqlParameter("@freeItem7", rows["freeItem7"].Equals(null) ? DBNull.Value : rows["freeItem7"]));
                        listParam.Add(new SqlParameter("@freeItem8", rows["freeItem8"].Equals(null) ? DBNull.Value : rows["freeItem8"]));
                        listParam.Add(new SqlParameter("@freeItem9", rows["freeItem9"].Equals(null) ? DBNull.Value : rows["freeItem9"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc1", rows["priuserdefnvc1"].Equals(null) ? DBNull.Value : rows["priuserdefnvc1"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm1", rows["priuserdefdecm1"].Equals(null) ? DBNull.Value : rows["priuserdefdecm1"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc2", rows["priuserdefnvc2"].Equals(null) ? DBNull.Value : rows["priuserdefnvc2"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm2", rows["priuserdefdecm2"].Equals(null) ? DBNull.Value : rows["priuserdefdecm2"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc3", rows["priuserdefnvc3"].Equals(null) ? DBNull.Value : rows["priuserdefnvc3"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm3", rows["priuserdefdecm3"].Equals(null) ? DBNull.Value : rows["priuserdefdecm3"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc4", rows["priuserdefnvc4"].Equals(null) ? DBNull.Value : rows["priuserdefnvc4"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm4", rows["priuserdefdecm4"].Equals(null) ? DBNull.Value : rows["priuserdefdecm4"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc5", rows["priuserdefnvc5"].Equals(null) ? DBNull.Value : rows["priuserdefnvc5"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm5", rows["priuserdefdecm5"].Equals(null) ? DBNull.Value : rows["priuserdefdecm5"]));
                        listParam.Add(new SqlParameter("@producequantity2", rows["producequantity2"].Equals(null) ? DBNull.Value : rows["producequantity2"]));
                        listParam.Add(new SqlParameter("@rationcost", rows["rationcost"].Equals(null) ? DBNull.Value : rows["rationcost"]));
                        listParam.Add(new SqlParameter("@rationmaterial", rows["rationmaterial"].Equals(null) ? DBNull.Value : rows["rationmaterial"]));
                        listParam.Add(new SqlParameter("@cost", rows["cost"].Equals(null) ? DBNull.Value : rows["cost"]));
                        listParam.Add(new SqlParameter("@rateofexchange", rows["rateofexchange"].Equals(null) ? DBNull.Value : rows["rateofexchange"]));
                        listParam.Add(new SqlParameter("@yieldrate", rows["yieldrate"].Equals(null) ? DBNull.Value : rows["yieldrate"]));
                        listParam.Add(new SqlParameter("@iscostbom", rows["iscostbom"].Equals(null) ? DBNull.Value : rows["iscostbom"]));
                        listParam.Add(new SqlParameter("@idsaleorder", rows["idsaleorder"].Equals(null) ? DBNull.Value : rows["idsaleorder"]));
                        listParam.Add(new SqlParameter("@maker", rows["maker"].Equals(null) ? DBNull.Value : rows["maker"]));
                        listParam.Add(new SqlParameter("@auditor", rows["auditor"].Equals(null) ? DBNull.Value : rows["auditor"]));
                        listParam.Add(new SqlParameter("@reviser", rows["reviser"].Equals(null) ? DBNull.Value : rows["reviser"]));
                        listParam.Add(new SqlParameter("@isorderbom", rows["isorderbom"].Equals(null) ? DBNull.Value : rows["isorderbom"]));
                        listParam.Add(new SqlParameter("@customerName", rows["customerName"].Equals(null) ? DBNull.Value : rows["customerName"]));
                        listParam.Add(new SqlParameter("@customerCode", rows["customerCode"].Equals(null) ? DBNull.Value : rows["customerCode"]));
                        listParam.Add(new SqlParameter("@customerForShort", rows["customerForShort"].Equals(null) ? DBNull.Value : rows["customerForShort"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc1", rows["pubuserdefnvc1"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc1"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc2", rows["pubuserdefnvc2"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc2"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc3", rows["pubuserdefnvc3"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc3"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc4", rows["pubuserdefnvc4"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc4"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc5", rows["pubuserdefnvc5"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc5"]));
                        listParam.Add(new SqlParameter("@pubuserdefnvc6", rows["pubuserdefnvc6"].Equals(null) ? DBNull.Value : rows["pubuserdefnvc6"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm1", rows["pubuserdefdecm1"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm1"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm2", rows["pubuserdefdecm2"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm2"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm3", rows["pubuserdefdecm3"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm3"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm4", rows["pubuserdefdecm4"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm4"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm5", rows["pubuserdefdecm5"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm5"]));
                        listParam.Add(new SqlParameter("@pubuserdefdecm6", rows["pubuserdefdecm6"].Equals(null) ? DBNull.Value : rows["pubuserdefdecm6"]));
                        listParam.Add(new SqlParameter("@priuserdefdecm6", rows["priuserdefdecm6"].Equals(null) ? DBNull.Value : rows["priuserdefdecm6"]));
                        listParam.Add(new SqlParameter("@priuserdefnvc6", rows["priuserdefnvc6"].Equals(null) ? DBNull.Value : rows["priuserdefnvc6"]));
                        //listParam.Add(new SqlParameter("@id", rows["id"].Equals(null) ? DBNull.Value : rows["id"]));
                        listParam.Add(new SqlParameter("@idBomRelationDTO", rows["idBomRelationDTO"].Equals(null) ? DBNull.Value : rows["idBomRelationDTO"]));
                        listParam.Add(new SqlParameter("@idmanufactureplant", rows["idmanufactureplant"].Equals(null) ? DBNull.Value : rows["idmanufactureplant"]));
                        listParam.Add(new SqlParameter("@idinventory", rows["idinventory"].Equals(null) ? DBNull.Value : rows["idinventory"]));
                        listParam.Add(new SqlParameter("@idmechiner", rows["idmechiner"].Equals(null) ? DBNull.Value : rows["idmechiner"]));
                        listParam.Add(new SqlParameter("@idrouting", rows["idrouting"].Equals(null) ? DBNull.Value : rows["idrouting"]));
                        listParam.Add(new SqlParameter("@idunit", rows["idunit"].Equals(null) ? DBNull.Value : rows["idunit"]));
                        listParam.Add(new SqlParameter("@idunit2", rows["idunit2"].Equals(null) ? DBNull.Value : rows["idunit2"]));
                        listParam.Add(new SqlParameter("@idwarehouse", rows["idwarehouse"].Equals(null) ? DBNull.Value : rows["idwarehouse"]));
                        listParam.Add(new SqlParameter("@getbomchildunitmethod", rows["getbomchildunitmethod"].Equals(null) ? DBNull.Value : rows["getbomchildunitmethod"]));
                        listParam.Add(new SqlParameter("@produceType", rows["produceType"].Equals(null) ? DBNull.Value : rows["produceType"]));
                        listParam.Add(new SqlParameter("@voucherstate", rows["voucherstate"].Equals(null) ? DBNull.Value : rows["voucherstate"]));
                        listParam.Add(new SqlParameter("@auditorid", rows["auditorid"].Equals(null) ? DBNull.Value : rows["auditorid"]));
                        listParam.Add(new SqlParameter("@makerid", rows["makerid"].Equals(null) ? DBNull.Value : rows["makerid"]));
                        listParam.Add(new SqlParameter("@madeDate", rows["madeDate"].Equals(null) ? DBNull.Value : rows["madeDate"]));
                        listParam.Add(new SqlParameter("@updated", rows["updated"].Equals(null) ? DBNull.Value : rows["updated"]));
                        listParam.Add(new SqlParameter("@voucherdate", rows["voucherdate"].Equals(null) ? DBNull.Value : rows["voucherdate"]));
                        listParam.Add(new SqlParameter("@auditeddate", rows["auditeddate"].Equals(null) ? DBNull.Value : rows["auditeddate"]));
                        listParam.Add(new SqlParameter("@createdtime", rows["createdtime"].Equals(null) ? DBNull.Value : rows["createdtime"]));
                        listParam.Add(new SqlParameter("@reviserid", rows["reviserid"].Equals(null) ? DBNull.Value : rows["reviserid"]));
                        listParam.Add(new SqlParameter("@ReviserDate", rows["ReviserDate"].Equals(null) ? DBNull.Value : rows["ReviserDate"]));
                        string sqls = string.Empty;
                        sqls  += "insert into AA_BOM(code,name,version,produceQuantity, ";
                        sqls  += "rationWage,rationCharge,rationManHour,isDefaultBom,bomDepth,";
                        sqls  += "disabled,updatedBy,freeItem0,freeItem1,freeItem2,";
                        sqls  += "freeItem3,freeItem4,freeItem5,freeItem6,freeItem7,freeItem8,freeItem9,";
                        sqls  += "priuserdefnvc1,priuserdefdecm1,priuserdefnvc2,priuserdefdecm2,priuserdefnvc3,";
                        sqls  += "priuserdefdecm3,priuserdefnvc4,priuserdefdecm4,priuserdefnvc5,priuserdefdecm5,";
                        sqls  += "producequantity2,rationcost,rateofexchange,yieldrate,iscostbom,";
                        sqls  += "idsaleorder,maker,auditor,reviser,isorderbom,customerName,customerCode,";
                        sqls  += "customerForShort,pubuserdefnvc1,pubuserdefnvc2,pubuserdefnvc3,pubuserdefnvc4,pubuserdefnvc5,";
                        sqls  += "pubuserdefnvc6,priuserdefdecm6,priuserdefnvc6,idBomRelationDTO,idmanufactureplant,";
                        sqls  += "idinventory,idmechiner,idrouting,idunit,idunit2,";
                        sqls  += "idwarehouse,getbomchildunitmethod,produceType,voucherstate,auditorid,";
                        sqls  += "makerid,madeDate,updated,voucherdate,auditeddate,";
                        sqls  += "createdtime,reviserid,ReviserDate)";
                        sqls  += " values(@code,@name,@version,@produceQuantity,";
                        sqls  += "@rationWage,@rationCharge,@rationManHour,@isDefaultBom,@bomDepth,";
                        sqls  += "@disabled,@updatedBy,@freeItem0,@freeItem1,@freeItem2,";
                        sqls  += "@freeItem3,@freeItem4,@freeItem5,@freeItem6,@freeItem7,@freeItem8,@freeItem9,";
                        sqls  += "@priuserdefnvc1,@priuserdefdecm1,@priuserdefnvc2,@priuserdefdecm2,@priuserdefnvc3,";
                        sqls  += "@priuserdefdecm3,@priuserdefnvc4,@priuserdefdecm4,@priuserdefnvc5,@priuserdefdecm5,";
                        sqls  += "@producequantity2,@rationcost,@rateofexchange,@yieldrate,@iscostbom,";
                        sqls  += "@idsaleorder,@maker,@auditor,@reviser,@isorderbom,@customerName,@customerCode,";
                        sqls  += "@customerForShort,@pubuserdefnvc1,@pubuserdefnvc2,@pubuserdefnvc3,@pubuserdefnvc4,@pubuserdefnvc5,";
                        sqls  += "@pubuserdefnvc6,@priuserdefdecm6,@priuserdefnvc6,@idBomRelationDTO,@idmanufactureplant,";
                        sqls  += "@idinventory,@idmechiner,@idrouting,@idunit,@idunit2,";
                        sqls  += "@idwarehouse,@getbomchildunitmethod,@produceType,@voucherstate,@auditorid,";
                        sqls  += "@makerid,@madeDate,@updated,@voucherdate,@auditeddate,";
                        sqls  += "@createdtime,@reviserid,@ReviserDate)";
                        count += PDADBAccess.ExecTransSql(sqls, listParam.ToArray());
                        if (count > 0)
                        {
                            SyncHelper.UpdateSyncList(row["BusinessID"].ToString(), row["BusinessType"].ToString(), row["SyncType"].ToString(), 1.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        }
                    }
                    catch (Exception ex)
                    {
                        SyncHelper.InsertLog(row["id"].ToString(), row["code"].ToString(), "AA_Bom", "Insert", "数据同步", "0",
                                             "#" + ex.Message + "#" + ex.Source + "#" + ex.StackTrace.Trim() + "#" + ex.TargetSite);
                        return;
                    }
                }
            }
        }