public static bool DoFileIsExcute(string clientUser) { try { lock (upLocker) { //获取数据处理的状态 DBOracle dboracle = new DBOracle(); //CLCXZT 处理程序状态 1停止 2运行中 DataTable dt = dboracle.ExcuteDataTable_oracle("select * from T_JK_CXZT where CLCXZT='2' "); if (dt != null && dt.Rows.Count > 0) { TxtLogger.Debug(string.Format("{0}:[{1}{2}]", "DoFileIsExcute", clientUser, "程序已经启动")); //程序正在执行中 return(true); } else { //处理程序没有执行,启动处理程序 string sql_Insert = string.Format("insert into T_JK_CXZT(CLCXBM,CLCXSM,CLCXZT,CZY,KSSJ)values('{0}','{1}','{2}','{3}','{4}') ", clientUser, clientUser, "2", clientUser, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")); //从数据库中获取数据状态 //DBOracle dboracle = new DBOracle(); int insertResult = dboracle.ExecuteNonQuery_oracle(sql_Insert); TxtLogger.Debug(string.Format("{0}:[{1}{2}]", "DoFileIsExcute", clientUser, "程序正常启动")); return(false); } } } catch (Exception ex) { TxtLogger.Error(string.Format("{0}:[{1}{2}]:[{3}]", "DoFileIsExcute", clientUser, "设定程序启动状态错误", ex.Message)); throw new Exception(string.Format("DoFileIsExcute:设定程序启动状态错误:{0}", ex.Message)); } }
public static int ChangeExcuteStatus() { string sql_update = string.Format("update T_JK_CXZT set CLCXZT='1' ,KSSJ='{0}' where CLCXZT='2' ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")); //更新数据库中数据状态 DBOracle dboracle = new DBOracle(); return(dboracle.ExecuteNonQuery_oracle(sql_update)); }
public static void Insert(LoggerInfo info) { ArrayList sqlList = new ArrayList(); string sql = string.Format("insert into T_JK_CLIENTUPLOADINFOS(ip,czy,info,createdate,guid,status) " + "values('{0}','{1}','{2}','{3}','{4}',{5})", info.IP, info.Czy, info.Info, info.CreateDate, info.GUID, info.Status); sqlList.Add(sql); DBOracle db = new DBOracle(); db.ExecuteNonQuery_oracle(sqlList); }
/// <summary> /// 执行文件的处理 /// </summary> /// <param name="threadid"></param> public void DoFile(string clientUser, string GuidStr, string yljgbm) { TxtLogger.Debug(string.Format("{0}:[{1}]:[{2}]", "DoFile", clientUser, "文件处理开始")); //取得本地的保存文件地址 fileDirAddress = ConfigurationManager.AppSettings["ExcelUpFile"]; string filePathAll = string.Format("{0}{1}", fileDirAddress, "upLoade"); string filePathAllTo = string.Format("{0}{1}", fileDirAddress, "excute"); try { //文件处理 if (copyDirectory(filePathAll, filePathAllTo) == true) { //将文件内容保存到数据库中 DoFileToDb(filePathAllTo, GuidStr, yljgbm, clientUser); //处理完当前数据后再次扫描是否存在需要处理的文件 DoFile(clientUser, GuidStr, yljgbm); } else { //调用存储过程将临时表中的数据处理到正式表中 //ExecuteProCreateData(clientUser, GuidStr, yljgbm); //ExecuteProCreateData(clientUser, GuidStr, yljgbm); ////处理程序执行结束,关闭处理程序 //string sql_update = string.Format("update T_JK_CXZT set CLCXZT='1' ,KSSJ='{0}' where CLCXZT='2' ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")); ////更新数据库中数据状态 //DBOracle dboracle = new DBOracle(); //int insertResult = dboracle.ExecuteNonQuery_oracle(sql_update); //return; } logger.Debug(string.Format("{0}:[{1}]:[{2}]", "DoFile", clientUser, "文件处理结束")); DBLogger.Insert(new LoggerInfo(clientUser, "DoFile 文件处理结束", 1)); } catch (Exception ex) { logger.Error(string.Format("{0}:[{1}]:[{2}]:[{3}]", "DoFile", clientUser, "文件处理异常", ex.Message)); DBLogger.Insert(new LoggerInfo(clientUser, string.Format("DoFile文件处理异常,{0}", ex.Message), 0)); throw ex; //出错时增加错误处理 ////处理程序执行结束,关闭处理程序 //string sql_update = string.Format("insert into ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")); ////更新数据库中数据状态 //DBOracle dboracle = new DBOracle(); //int insertResult = dboracle.ExecuteNonQuery_oracle(sql_update); //throw new Exception(string.Format("DoFile文件处理异常:{0}", ex.Message)); } finally { //处理程序执行结束,关闭处理程序 string sql_update = string.Format("update T_JK_CXZT set CLCXZT='1' ,KSSJ='{0}' where CLCXZT='2' ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")); //更新数据库中数据状态 DBOracle dboracle = new DBOracle(); int insertResult = dboracle.ExecuteNonQuery_oracle(sql_update); } return; }