예제 #1
0
 public int ProcessInsertData(int areaCode, string targetDbName)
 {
     try
     {
         var sList = new TUserDAL(areaCode.ToString()).GetModelList(c => c.sysFlag == 0).ToList();
         sList.ForEach(s =>
         {
             s.areaCode = areaCode;
             s.areaId   = s.ID;
         });
         var dal  = new TUserDAL(targetDbName);
         var odal = new TUserDAL(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);
     }
 }
예제 #2
0
 public int ProcessUpdateData(int areaCode, string targetDbName)
 {
     try
     {
         var sdal  = new TUserDAL(areaCode.ToString());
         var tdal  = new TUserDAL(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);
     }
 }