Esempio n. 1
0
 public int ProcessInsertData(int areaCode, string targetDbName)
 {
     try
     {
         var sList = new TBusinessAttributeDAL(areaCode.ToString()).GetModelList(c => c.sysFlag == 0).ToList();
         sList.ForEach(s =>
         {
             s.areaCode = areaCode;
             s.areaId   = s.id;
         });
         var dal  = new TBusinessAttributeDAL(targetDbName);
         var odal = new TBusinessAttributeDAL(areaCode.ToString());
         foreach (var s in sList)
         {
             dal.Insert(s);
             s.id      = s.areaId;
             s.sysFlag = 2;
             odal.Update(s);
         }
         return(sList.Count);
     }
     catch
     {
         return(-1);
     }
 }
Esempio n. 2
0
 public int ProcessUpdateData(int areaCode, string targetDbName)
 {
     try
     {
         var sdal  = new TBusinessAttributeDAL(areaCode.ToString());
         var tdal  = new TBusinessAttributeDAL(targetDbName);
         var sList = sdal.GetModelList(p => p.sysFlag == 1);
         foreach (var s in sList)
         {
             var id    = s.id;
             var nData = tdal.GetModelList(p => p.areaCode == areaCode && p.areaId == s.id).FirstOrDefault();
             if (nData == null)
             {
                 s.areaCode = areaCode;
                 s.areaId   = s.id;
                 tdal.Insert(s);
                 s.id      = s.areaId;
                 s.sysFlag = 2;
                 sdal.Update(s);
             }
             else
             {
                 var data = s;
                 data.id       = nData.id;
                 data.areaCode = nData.areaCode;
                 data.areaId   = nData.areaId;
                 tdal.Update(data);
                 s.sysFlag = 2;
                 s.id      = id;
                 sdal.Update(s);
             }
         }
         return(sList.Count);
     }
     catch
     {
         return(-1);
     }
 }