Esempio n. 1
0
    /// <summary>
    /// 通过任务编码获得任务信息
    /// </summary>
    /// <param name="missionCode"></param>
    /// <returns></returns>
    public static ZD_SyncTaskConfig GetTaskInfoByCode(string missionCode)
    {
        string sql = @"SELECT  [MissionCode]
      ,[MissionName]
      ,[SyncTime]
      ,[SyncSuccessTime]
      ,[IsAyncSuccess]
      ,[JobClassName]
      ,[State]
      ,[CronExplain],[SyncSuccessBeginTime],[HostName] FROM [H3Cloud].[dbo].[ZD_SyncTaskConfig] where MissionCode='" + missionCode + "'";

        OThinker.Data.Database.CommandFactory factory = OThinker.H3.WorkSheet.AppUtility.Engine.EngineConfig.CommandFactory;
        OThinker.Data.Database.ICommand       command = factory.CreateCommand();
        var dataTable            = command.ExecuteDataTable(sql);
        ZD_SyncTaskConfig result = new ZD_SyncTaskConfig();

        if (dataTable.Rows.Count > 0)
        {
            result.MissionCode          = missionCode;
            result.MissionName          = dataTable.Rows[0]["MissionName"] + string.Empty;
            result.SyncSuccessTime      = Convert.ToDateTime(dataTable.Rows[0]["SyncSuccessTime"]);
            result.SyncTime             = Convert.ToDateTime(dataTable.Rows[0]["SyncTime"]);
            result.SyncSuccessBeginTime = Convert.ToDateTime(dataTable.Rows[0]["SyncSuccessBeginTime"]);
            result.IsAyncSuccess        = Convert.ToInt32(dataTable.Rows[0]["IsAyncSuccess"]);
            result.State        = Convert.ToInt32(dataTable.Rows[0]["State"]);
            result.JobClassName = dataTable.Rows[0]["JobClassName"] + string.Empty;
            result.CronExplain  = dataTable.Rows[0]["CronExplain"] + string.Empty;
            result.HostName     = dataTable.Rows[0]["HostName"] + string.Empty;
        }
        else
        {
            result = null;
        }
        return(result);
    }
        public static string ExecuteDataTableSql(string connectionCode, string sql)
        {
            string rtn      = "";
            var    dbObject = OThinker.H3.Controllers.AppUtility.Engine.SettingManager.GetBizDbConnectionConfig(connectionCode);

            if (dbObject != null)
            {
                OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(dbObject.DbType, dbObject.DbConnectionString);
                var       command = factory.CreateCommand();
                DataTable dt      = command.ExecuteDataTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                        DateTimeFormat = "yyyy'-'MM'-'dd HH':'mm':'ss"
                    };
                    //JsonConvert.SerializeObject(list.Tables[0], Formatting.Indented, timeConverter);
                    rtn = Newtonsoft.Json.JsonConvert.SerializeObject(dt, Formatting.Indented, timeConverter);
                    rtn = "{ \"errcode\": \"0\", \"errmsg\": \"\", \"data\":" + rtn + "}";
                }
                else
                {
                    rtn = "{ \"errcode\": \"0\", \"errmsg\": \"数据为空\", \"data\":[]}";
                }
            }
            else
            {
                rtn = "{ \"errcode\": \"1\", \"errmsg\": \"未取到数据,connectionCode错误,请联系接口供应商\", \"data\":[]}";
            }

            return(rtn);
        }
Esempio n. 3
0
    public void ExecuteDataTableSP(string connectionCode, string sql, OThinker.Data.Database.Parameter[] par)
    {
        var dbObject = OThinker.H3.Controllers.AppUtility.Engine.SettingManager.GetBizDbConnectionConfig(connectionCode);

        if (dbObject != null)
        {
            OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(dbObject.DbType, dbObject.DbConnectionString);
            var command = factory.CreateCommand();
            command.ExecuteProcedure(sql, par);
        }
    }
        public DataTable ExecuteDataTableSql(string connectionCode, string sql)
        {
            var dbObject = OThinker.H3.Controllers.AppUtility.Engine.SettingManager.GetBizDbConnectionConfig(connectionCode);

            if (dbObject != null)
            {
                OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(dbObject.DbType, dbObject.DbConnectionString);
                var command = factory.CreateCommand();
                return(command.ExecuteDataTable(sql));
            }
            return(null);
        }
        public static object ExecuteScalar(string connectionCode, string sql)
        {
            var dbObject = AppUtility.Engine.SettingManager.GetBizDbConnectionConfig(connectionCode);

            if (dbObject != null)
            {
                OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(dbObject.DbType, dbObject.DbConnectionString);
                var command = factory.CreateCommand();
                return(command.ExecuteScalar(sql));
            }
            return(null);
        }
        public int ExecuteCountSql(string connectionCode, string sql)
        {
            var dbObject = OThinker.H3.Controllers.AppUtility.Engine.SettingManager.GetBizDbConnectionConfig(connectionCode);

            if (dbObject != null)
            {
                OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(dbObject.DbType, dbObject.DbConnectionString);
                var command = factory.CreateCommand();
                var count   = command.ExecuteScalar(sql);
                return(Convert.ToInt32(count));
            }
            return(0);
        }
        public static void ExecuteNonQuery(string connectionCode, string sql)
        {
            var dbObject = OThinker.H3.Controllers.AppUtility.Engine.SettingManager.GetBizDbConnectionConfig(connectionCode);

            if (dbObject != null)
            {
                OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(dbObject.DbType, dbObject.DbConnectionString);
                var command = factory.CreateCommand();
                var rtn     = command.ExecuteNonQuery(sql);
            }
            else
            {
                //return "{ \"errcode\": \"1\", \"errmsg\": \"未取到数据,connectionCode错误,请联系接口供应商\", \"data\":[]}";
            }
        }
        /// <summary>
        /// 返回json数据
        /// </summary>
        /// <param name="connectionCode"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static string ExecuteDataTableToJsonSql(string connectionCode, string sql)
        {
            var dbObject = OThinker.H3.Controllers.AppUtility.Engine.SettingManager.GetBizDbConnectionConfig(connectionCode);

            if (dbObject != null)
            {
                OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(dbObject.DbType, dbObject.DbConnectionString);
                var           command    = factory.CreateCommand();
                DataTable     dt         = command.ExecuteDataTable(sql);
                StringBuilder JsonString = new StringBuilder();
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        JsonString.Append("{");
                        for (int j = 0; j < dt.Columns.Count; j++)
                        {
                            if (j < dt.Columns.Count - 1)
                            {
                                JsonString.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + "\"" + (dt.Rows[i][j].ToString().Replace("\"", "\\\"")) + "\",");
                            }
                            else if (j == dt.Columns.Count - 1)
                            {
                                JsonString.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + "\"" + (dt.Rows[i][j].ToString().Replace("\"", "\\\"")) + "\"");
                            }
                        }
                        if (i == dt.Rows.Count - 1)
                        {
                            JsonString.Append("}");
                        }
                        else
                        {
                            JsonString.Append("},");
                        }
                    }
                    return("{ \"errcode\": \"0\", \"errmsg\": \"\", \"data\":[" + JsonString.ToString() + "]}");
                }
                else
                {
                    return("{ \"errcode\": \"0\", \"errmsg\": \"数据为空\", \"data\":[]}");
                }
            }
            else
            {
                return("{ \"errcode\": \"1\", \"errmsg\": \"未取到数据,connectionCode错误,请联系接口供应商\", \"data\":[]}");
            }
        }
Esempio n. 9
0
 public DataTable ExecuteDataTableSql(string connectionCode, string sql)
 {
     try
     {
         var dbObject = AppUtility.Engine.SettingManager.GetBizDbConnectionConfig(connectionCode);
         if (dbObject != null)
         {
             OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(dbObject.DbType, dbObject.DbConnectionString);
             var command = factory.CreateCommand();
             return(command.ExecuteDataTable(sql));
         }
         return(null);
     }
     catch (Exception ex)
     {
         AppUtility.Engine.LogWriter.Write("ExecuteDataTableSql Exception:connectionCode-->" + connectionCode + ",sql-->" + sql + "," + ex);
         return(null);
     }
 }
 public object ExecuteScalar(string sql)
 {
     try
     {
         string connectionCode = connecting_code;
         var    dbObject       = OThinker.H3.Controllers.AppUtility.Engine.SettingManager.GetBizDbConnectionConfig(connectionCode);
         if (dbObject != null)
         {
             OThinker.Data.Database.CommandFactory factory = new OThinker.Data.Database.CommandFactory(dbObject.DbType, dbObject.DbConnectionString);
             var command = factory.CreateCommand();
             return(command.ExecuteScalar(sql));
         }
     }
     catch
     {
         return(null);
     }
     return(null);
 }
Esempio n. 11
0
    /// <summary>
    /// 应用程序启动时从新启动已开启的任务
    /// </summary>
    public static void StartPlan()
    {
        try
        {
            string sql = @"SELECT  [MissionCode]
      ,[MissionName]
      ,[SyncTime]
      ,[SyncSuccessTime]
      ,[IsAyncSuccess]
      ,[JobClassName]
      ,[State]
      ,[CronExplain],[SyncSuccessBeginTime],[HostName] FROM [H3Cloud].[dbo].[ZD_SyncTaskConfig] where State=1 and HostName='" + Dns.GetHostName() + "'";
            OThinker.Data.Database.CommandFactory factory = OThinker.H3.WorkSheet.AppUtility.Engine.EngineConfig.CommandFactory;
            OThinker.Data.Database.ICommand       command = factory.CreateCommand();
            var dataTable = command.ExecuteDataTable(sql);

            if (dataTable.Rows.Count > 0)
            {
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    ZD_SyncTaskConfig result = new ZD_SyncTaskConfig();
                    result.MissionCode          = dataTable.Rows[i]["MissionCode"] + string.Empty;
                    result.MissionName          = dataTable.Rows[i]["MissionName"] + string.Empty;
                    result.SyncSuccessTime      = Convert.ToDateTime(dataTable.Rows[i]["SyncSuccessTime"]);
                    result.SyncTime             = Convert.ToDateTime(dataTable.Rows[i]["SyncTime"]);
                    result.SyncSuccessBeginTime = Convert.ToDateTime(dataTable.Rows[i]["SyncSuccessBeginTime"]);
                    result.IsAyncSuccess        = Convert.ToInt32(dataTable.Rows[i]["IsAyncSuccess"]);
                    result.State        = 1;
                    result.JobClassName = dataTable.Rows[i]["JobClassName"] + string.Empty;
                    result.CronExplain  = dataTable.Rows[i]["CronExplain"] + string.Empty;
                    result.HostName     = dataTable.Rows[i]["HostName"] + string.Empty;
                    OThinker.H3.Portal.JobScheduler.Start(result);
                }
            }
        }
        catch (Exception e)
        {
            _logger.InfoFormat(e.Message.ToString());
            throw;
        }
    }