private void ProcessSQL() { if (parms == null) { parms = new Dictionary <string, object>(); } parms["source"] = source; try { var con = new GenConnection(GenConnection.CONNECTION_TYPE.MSSQL); con.Config(ConnString); con.ExecTimeout = timeout; con.ThrowError = true; con.ExecCommandNamedParameters(Command, parms.ToHybridDictionary(), true); Log.ApiTrace(null, operation, parms.ToArray()); } catch (Exception ex) { if ((CommandForTimeout ?? "") != "" && ex.ToString().ToLower().Contains("timeout") || ex.ToString().ToLower().Contains("limite")) { try { var con = new GenConnection(GenConnection.CONNECTION_TYPE.MSSQL); con.Config(ConnString); con.ExecTimeout = timeout; con.ThrowError = true; con.ExecCommandNamedParameters(CommandForTimeout, parms.ToHybridDictionary(), true); Log.ApiTrace(null, operation, parms.ToArray()); } catch (Exception ex1) { parms["trigger"] = true; parms["trigger_exception"] = ex1.ToString(); Log.ApiException(null, operation, ex, parms.ToArray()); throw; } } else { Log.ApiException(null, operation, ex, parms.ToArray()); } } if (Threads.Contains(this)) { try { Threads.Remove(this); } catch (Exception) { } } }
public GenRoom GetOtherRoom(GenRoomConnection connection) { GenConnection con = connection.connection; Debug.Assert(con.a != null && con.b != null, $"The room {GetHashCode()} is connected to a null room"); GenRoom result = con.a; if (con.a == this) { result = con.b; Debug.Assert(con.b != this, $"The connection is self looping to the room: {GetHashCode()}"); } else { Debug.Assert(con.b == this, $"The connection doesn't belong to the room: {GetHashCode()}"); } return(result); }
public static void GenerateImage(string pBase64File, string pExtension, string pSqlCommand, string pErrorSqlCommand, GenConnection pSqlConnection, int pWitdh = 150, int pHeight = 180, bool DeleteAfter = true) { if (!File.Exists(ExeConversion.Replace("\"", ""))) { throw new Exception("Execonversion nao existe:" + ExeConversion); } var dirbasename = TempDir + "\\" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + Guid.NewGuid().ToString().Substring(0, 5); var fdirThumb = dirbasename + "\\out"; Directory.CreateDirectory(dirbasename); Directory.CreateDirectory(fdirThumb); var fname = dirbasename + "\\" + "arquivo" + pExtension; File.WriteAllBytes(fname, Convert.FromBase64String(pBase64File)); var dosCommArg = ExeConversionParameters.Replace("{INPUT}", fname) .Replace("{OUTPUT}", fdirThumb) .Replace("{WIDTH}", pWitdh.ToString()) .Replace("{HEIGHT}", pHeight.ToString()); var co = new ConversionObject() { DosCommand = ExeConversion, DosCommandArguments = dosCommArg, InputTempDir = dirbasename, OutputTempDir = fdirThumb, sqlCommand = pSqlCommand, errorSqlCommand = pErrorSqlCommand, sqlConnection = pSqlConnection, DeleteInputAfter = DeleteAfter, inputFile = fname, Width = pWitdh, Height = pHeight }; co.RunningThread = new Thread(new ThreadStart(co.Exec)); ConversionThreads.Add(co); co.RunningThread.Start(); }