public void Start() { DataConvert DICG = D_DICG(); //文件拼接 string fileData = DICG.file_sb.ToString(); //脚本拼接 string sql = DICG.upLinks_sql.ToString(); if (string.IsNullOrEmpty(sql)) { MainFile.WriteFile(filePath, fileName, fileData); return; } SqlCommand cmd = SQLHelper.GetTransactionSqlCommand(connStr); SQLHelper.ExecuteNonQuery(ref cmd, sql); if (MainFile.WriteFile(filePath, fileName, fileData)) { cmd.Transaction.Commit(); } else { cmd.Transaction.Rollback(); } cmd.Connection.Close(); }
public void Start() { FKTZS_ZF fktzs_zf = D_FKTZS_ZF(); FKTZS_ZSK fktzs_zsk = D_FKTZS_ZSK(); ZSK zsk = D_ZSK(); //文件拼接 string fileData = fktzs_zf.file_sb.ToString() + fktzs_zsk.file_sb.ToString() + zsk.file_sb.ToString(); //脚本拼接 string sql = fktzs_zf.upLinks_sql.ToString() + fktzs_zsk.upLinks_sql.ToString() + zsk.upLinks_sql.ToString(); if (string.IsNullOrEmpty(sql)) { MainFile.WriteFile(filePath, fileName, fileData); return; } SqlCommand cmd = SQLHelper.GetTransactionSqlCommand(connStr); SQLHelper.ExecuteNonQuery(ref cmd, sql); if (MainFile.WriteFile(filePath, fileName, fileData)) { cmd.Transaction.Commit(); } else { cmd.Transaction.Rollback(); } cmd.Connection.Close(); }
protected void SaveToKPSQ(string sql, string saleData, string purchaseData) { DateTime time = DateTime.Now; //string saleFileName = string.Format("{0}_{1}_{2}{3}", SalePrefix, sap_cd, time, FileSuffix); //string purchaseFileName = string.Format("{0}_{1}_{2}{3}", PurchasePrefix, sap_cd, time, FileSuffix); string saleFileName = GetSaleFileName(time); string purchaseFileName = GetPurchaseFileName(time); if (string.IsNullOrEmpty(sql)) { MainFile.WriteFile(FilePath, saleFileName, saleData, Encoding.Default); MainFile.WriteFile(FilePath, purchaseFileName, purchaseData); } else { SqlCommand cmd = SQLHelper.GetTransactionSqlCommand(context.connStr); try { SQLHelper.ExecuteNonQuery(ref cmd, sql); cmd.Transaction.Commit(); MainFile.WriteFile(FilePath, saleFileName, saleData, Encoding.Default); MainFile.WriteFile(FilePath, purchaseFileName, purchaseData); } catch (Exception ex) { cmd.Transaction.Rollback(); throw ex; } finally { cmd.Connection.Close(); } } }
public override void DoSave() { linksQueueConnection.Open(); linksQueueConnection.ExecuteQuery(); try { foreach (SapSaveFileInfo sapSaveFileInfo in sapSaveFileInfos) { MainFile.WriteFile(sapSaveFileInfo.SaveFilePath, sapSaveFileInfo.SaveFileName, sapSaveFileInfo.SaveFileStream.ToString(), sapSaveFileInfo.Encoding); } linksQueueConnection.Commit(); } catch (Exception ex) { linksQueueConnection.Rollback(); throw ex; } }
protected void FileAndDB(string sql, string fileData) { if (string.IsNullOrEmpty(sql)) { MainFile.WriteFile(filePath, fileName, fileData); return; } System.Data.SqlClient.SqlCommand cmd = SQLHelper.GetTransactionSqlCommand(connStr); SQLHelper.ExecuteNonQuery(ref cmd, sql); if (MainFile.WriteFile(filePath, fileName, fileData)) { cmd.Transaction.Commit(); } else { cmd.Transaction.Rollback(); } cmd.Connection.Close(); }
/// <summary> /// 保存文件 /// </summary> /// <param name="saveFileEntity"></param> /// <returns></returns> private bool SaveFile(SaveFileEntity saveFileEntity) { return(MainFile.WriteFile(saveFileEntity.FilePath, saveFileEntity.FileFullName, saveFileEntity.Content, saveFileEntity.ContentEncoding)); }