Пример #1
0
 public static void WritToDB(object state)
 {
     try
     {
         List <XElement>    list    = XElement.Load(AppDomain.CurrentDomain.BaseDirectory + "AppSettings.config").Elements("add").ToList <XElement>();
         BasicConfigService service = new BasicConfigService();
         foreach (XElement element in list)
         {
             string      name   = element.Attribute("key").Value;
             string      str3   = element.Attribute("value").Value;
             BasicConfig byName = service.GetByName(name);
             if (byName != null)
             {
                 byName.ParaValue = str3;
                 service.Update(byName);
             }
             else
             {
                 byName = new BasicConfig {
                     Id        = Guid.NewGuid().ToString(),
                     ParaName  = name,
                     ParaValue = str3
                 };
                 service.Add(byName);
             }
         }
     }
     catch
     {
     }
 }
Пример #2
0
 public static void ClearPTPrjInfo(object o)
 {
     try
     {
         Log4netHelper.Error(new Exception("ClearPTPrjInfo 开始执行"), "ClearPTPrjInfo", "bery");
         BasicConfigService service = new BasicConfigService();
         BasicConfig        byName  = service.GetByName("IsClearPTPrjInfo");
         if (byName == null)
         {
             byName = new BasicConfig {
                 Id        = Guid.NewGuid().ToString(),
                 ParaName  = "IsClearPTPrjInfo",
                 ParaValue = "0",
                 Note      = "是否已经把PT_PrjInfo_ZTB表的数据导入PT_PrjInfo表中"
             };
             service.Add(byName);
         }
         if (byName.ParaValue != "1")
         {
             string cmdText = "SELECT PrjGuid FROM PT_PrjInfo_ZTB WHERE PrjGuid Not IN (SELECT PrjGuid FROM PT_PrjInfo)";
             foreach (DataRow row in SqlHelper.ExecuteQuery(CommandType.Text, cmdText, new SqlParameter[0]).Rows)
             {
                 Guid id = new Guid(row[0].ToString());
                 PTPrjInfoZTBService service2 = new PTPrjInfoZTBService();
                 PTPrjInfoService    service3 = new PTPrjInfoService();
                 PTPrjInfoZTB        byId     = service2.GetById(id);
                 service3.ChangePrjInfo(byId, 2, 1);
             }
             byName.ParaValue = "1";
             service.Update(byName);
         }
     }
     catch (Exception exception)
     {
         Log4netHelper.Error(exception, "ClearPTPrjInfo", "bery");
     }
 }