Exemple #1
0
 static private void SupportSitesUpdateSite(HydroService.HydroServiceClient theHydro, int theType)
 {
     try
     {
         foreach (var site in theHydro.GetSiteList(theType))
         {
             HydroDataCenterEntity.Models.Site theSite = null;
             int site_code = Convert.ToInt32(site.SiteCode);
             theSite = Site.GetByCode(site_code, site.Type.Id);
             if (theSite == null)
             {
                 theSite = new Site();
             }
             theSite.Code          = Convert.ToInt32(site.SiteCode);
             theSite.Name          = site.Name;
             theSite.ExtID         = site.SiteId;
             theSite.TypeID        = site.Type.Id;
             theSite.TypeName      = site.Type.Name;
             theSite.TypeNameShort = site.Type.ShortName;
             if (theSite.ID == 0)
             {
                 theSite.Save();
             }
             else
             {
                 theSite.Update();
             }
         }
     }
     catch (Exception ex)
     {
         string err = ex.Message;
         if (ex.InnerException != null)
         {
             err += "\n\r" + ex.InnerException.Message;
         }
         Console.WriteLine(err);
     }
 }