public static bool InsertTaskTree(PTR3Core core, IDatabase dbPTRConfig, DelGetConfig getXmlDynamicConfig , int rootTaskRunningId, bool parallel, int taskToInsertId, ref int prevTaskRunningId, out string message) { return InsertTaskTree(core, dbPTRConfig, getXmlDynamicConfig , rootTaskRunningId, parallel, taskToInsertId, ref prevTaskRunningId, out message, MsgStatusEnum.MS_Deb1); }
public static int GetRunningTaskId(PTR3Core core) { return Convert.ToInt32(ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, "task-running-instance-id")); }
public static int GetTaskId(PTR3Core core) { return Convert.ToInt32(ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, "taks:task-id")); }
public static String GetDBConvertersConnectionString(PTR3Core core, out string log) { String databaseName = "database-converters"; String server = ConfigXmlReader.XmlGetConfigParam(core, databaseName + ":address"); String database = ConfigXmlReader.XmlGetConfigParam(core, databaseName + ":name"); String user = ConfigXmlReader.XmlGetConfigParam(core, databaseName + ":user"); String password = PasswordEncoder.PtrDecryptText(ConfigXmlReader.XmlGetConfigParam(core, databaseName + ":password")); log = String.Format("server: {0}, user: {1}, password: {2}, database: {3}", server, user, password, database); string connectionString = String.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Connection Timeout={4};Asynchronous Processing=true;MultipleActiveResultSets=true;Persist Security Info=True;", server, database, user, password, 3600); return connectionString; }
public static int GetProcessId(PTR3Core core) { return Convert.ToInt32(ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, "process:process-id")); }
public static void UpdateProcessConfigXml(PTR3Core core, String converterName, String processConfigurationXml) { String ptrServer = ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, "data-base:address"); String ptrDatabase = ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, "data-base:name"); String ptrUser = ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, "data-base:user"); String ptrPassword = PasswordEncoder.PtrDecryptText(ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, "data-base:password")); // Zapis xml do bazy danych. PTR3Core.LOG.Log(MsgStatusEnum.MS_Deb1, "Create connection with PTR DB"); SqlDatabase ptrDb = new SqlDatabase(ptrServer, ptrDatabase, ptrUser, ptrPassword); if(ptrDb == null) { throw new Exception("Connection with PTR database failed"); } SqlDatabase ptrConfModDb = new SqlDatabase(ptrServer, ptrDatabase, ptrUser, ptrPassword); if(ptrConfModDb == null) { throw new Exception("Connection with PTR database failed"); } try { PTR3Core.LOG.Log(MsgStatusEnum.MS_Deb1, "Lock " + converterName + " Resources"); string machineName = ""; string processDescr = ""; string lockResource = String.Format("{0}:{1}:{2}", ptrServer, ptrDatabase, converterName); DateTime lockTime = DateTime.MinValue; if(!core.LockResource(ptrDb, lockResource, 60, out machineName, out processDescr, out lockTime)) { throw new Exception(String.Format("Resource: {0} was blocked by another process [Machine name: {1}, Process descr: {2}, at: {3}]", lockResource, machineName, processDescr, lockTime)); } ptrConfModDb.BeginTransaction(); core.UpdateProcessConfiguration(ptrConfModDb, processConfigurationXml); ptrConfModDb.CommitTransaction(); } catch(Exception ex) { if(ptrDb != null) { ptrDb.RollbackTransaction(); } if(ptrConfModDb != null) { ptrConfModDb.RollbackTransaction(); } throw ex; } finally { if(ptrDb != null) { ptrDb.Close(); ptrDb = null; } if(ptrConfModDb != null) { ptrConfModDb.Close(); ptrConfModDb = null; } } }
public static String GetDBConvertersConnectionString(PTR3Core core) { string log = ""; return GetDBConvertersConnectionString(core, out log); }
public static SqlDatabase GetDBConfig(PTR3Core core, bool logToPtr, MsgStatusEnum logStatus) { String databaseName = "data-base"; String server = ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, databaseName + ":address"); String database = ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, databaseName + ":name"); String user = ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, databaseName + ":user"); String password = PasswordEncoder.PtrDecryptText(ConfigXmlReader.XmlGetConfigParam(core.OptionalConfigurationXml, databaseName + ":password")); if(logToPtr) PTR3Core.LOG.Log(logStatus, "Connecting to PTRConfig database (server: {0}, user: {1}, password: {2}, database: {3}) ...", server, user, password, database); SqlDatabase result = new SqlDatabase(server, database, user, password); if(logToPtr) PTR3Core.LOG.Log(logStatus, "Connection to PTRConfig database established."); return result; }
public static SqlDatabase GetDBConverters(PTR3Core core) { return GetDBConverters(core, true, MsgStatusEnum.MS_Deb1); }
public static String GetAcceleratedDBConvertersUser(PTR3Core core) { String databaseName = "accelerated-database-converters"; return ConfigXmlReader.XmlGetConfigParam(core, databaseName + ":user"); }
public static int GetConfigLogLevel(PTR3Core core) { return Convert.ToInt32(ConfigXmlReader.XmlGetConfigParam(core, "log-level")); }
public static String GetAcceleratedDBConvertersConnectionString(PTR3Core core, out string log) { String hosts = GetAcceleratedDBConvertersHosts(core); String user = GetAcceleratedDBConvertersUser(core); String password = GetAcceleratedDBConvertersPassword(core); log = String.Format("hosts: {0}, user: {1}, encrypted password: {2}", hosts, user, password); return "hosts=" + hosts + ";user="******";pass=" + PasswordEncoder.PtrDecryptText(password); }
/// <summary> /// Zapis konfiguracji dynamicznej wysyłania maili /// </summary> /// <param name="core"></param> /// <param name="errorMessage"></param> public void Serialize(PTR3Core core, ref string errorMessage) { string serializedMailConfig = new Serializer<XmlDynamicConfEmailMessage>().Serialize(this, ref message); if (!core.DynamicConfigurationXmlHelper.UpdateValue("email-message-config", serializedMailConfig)) core.DynamicConfigurationXmlHelper.AddConfigItem("email-message-config", serializedMailConfig, ""); }
public static XmlDynamicConfEmailMessage Deserialize(PTR3Core core, ref string errorMessage) { XmlDocument xmlConfig = new XmlDocument(); string triId = ""; string priId = ""; XmlNodeList nodesCfg = ConfigXmlReader.XmlGetConfigParamList(core.DynamicConfigurationXmlHelper.Xml, "email-message-config"); if (nodesCfg.Count > 0) { XmlDynamicConfEmailMessage result = new XmlDynamicConfEmailMessage(); result.Attachments = new List<XmlDynamicConfAttachment>(); string xmlCfg = ConfigXmlReader.XmlGetConfigParamValue(nodesCfg[0], out triId, out priId); result = new Serializer<XmlDynamicConfEmailMessage>().Deserialize(xmlCfg, ref errorMessage); core.DynamicConfigurationXmlHelper.RemoveValue("email-message-config", triId, priId); return result; } return null; }
public static bool InsertTaskTree(PTR3Core core, IDatabase dbPTRConfig, DelGetConfig getXmlDynamicConfig , int rootTaskRunningId, bool parallel, int taskToInsertId, ref int lastInsertedTaskRunningId , out string message, MsgStatusEnum logStatus) { message = ""; dbPTRConfig.BeginTransaction(); try { // wstaw do konfiguracji dynamicznej i dodaj graf procesow do running tasks DbParameter OUT_INSERTED_TASK_RI_ID = dbPTRConfig.GetIntParamOut("@OUT_INSERTED_TASK_RI_ID"); DbParameter OUT_LAST_INSERTED_TASK_RI_ID = dbPTRConfig.GetIntParamOut("@OUT_LAST_INSERTED_TASK_RI_ID"); int prevTaskId = (parallel ? rootTaskRunningId : lastInsertedTaskRunningId); PTR3Core.LOG.Log(logStatus, "Dynamic tasks graph inserting (root running task id: {0}, preview running task id: {1}, task to insert id {2}) ..." , rootTaskRunningId, prevTaskId, taskToInsertId); dbPTRConfig.ExecuteSp("SP_INSERT_TASK_TREE", dbPTRConfig.GetIntParamIn("@IN_ROOF_TASK_RI_ID", rootTaskRunningId), dbPTRConfig.GetIntParamIn("@IN_PREV_TASK_RI_ID", prevTaskId), dbPTRConfig.GetIntParamIn("@IN_TASK_ID", taskToInsertId), OUT_INSERTED_TASK_RI_ID, OUT_LAST_INSERTED_TASK_RI_ID); int firstInsertedTaskRunningId = (int)OUT_INSERTED_TASK_RI_ID.Value; lastInsertedTaskRunningId = (int)OUT_LAST_INSERTED_TASK_RI_ID.Value; core.UpdateTaskDynamicConfiguration(dbPTRConfig, getXmlDynamicConfig(firstInsertedTaskRunningId)); dbPTRConfig.CommitTransaction(); return true; } catch(Exception ex) { dbPTRConfig.RollbackTransaction(); message = "Error while dynamic task graph inserting: " + ex.Message + "\r\n" + ex.StackTrace + "."; return false; } }
public static SqlDatabase GetDBConverters(PTR3Core core, bool logToPtr, MsgStatusEnum logStatus) { string log = ""; string connectionString = GetDBConvertersConnectionString(core, out log); if(logToPtr) PTR3Core.LOG.Log(logStatus, "Connecting to PTRConvert database ({0}) ...", log); SqlDatabase dbConverters = new SqlDatabase(connectionString); dbConverters.CommandTimeout = 3600; if(logToPtr) PTR3Core.LOG.Log(logStatus, "Connection to PTRConvert database established."); return dbConverters; }
static void Main(string[] args) { PTR3Core core = null; try { core = new PTR3Core(); core.Converter = new BMRetransfer("BMRetransfer"); core.InstallConfigXmlHelper.Name = "BMRetransfer.exe"; core.InstallConfigXmlHelper.Description = "BMRetransfer Convert"; core.InstallConfigXmlHelper.TypeOf = "1"; // 1 - offline, 2 - online // Wartoci nadpisywane przez dodatkowy XML core.InstallConfigXmlHelper.InterfaceId = "1"; // Id interfejsu konfiguracyjnego core.InstallConfigXmlHelper.ConfigXmlVersion = "1.0.0.3"; // Wersja konfiguracji konwertera core.InstallConfigXmlHelper.SchemaXmlVersion = "1.0.0.0"; // Wersja interfejsu konfiguracyjnego core.InstallConfigXmlHelper.EfficiencyClassId = "20"; // Id zarejestrowanej klasy wydajnociowej core.InstallConfigXmlHelper.CobEfficiencyClassId = ""; // Id zarejestrowanej klasy wydajnociowej konwertera pracującego w trybie COB core.ParseCommandline(args); core.Init(MsgStatusEnum.MS_Deb3, 3600000, 1000, 0); if (String.IsNullOrEmpty(ConfigXmlReader.XmlGetConfigParam(core, "log-level")) == false) { PTR3Core.LOG.SetLogLevel(LoggerTypeEnum.RTf, Convert.ToInt32(ConfigXmlReader.XmlGetConfigParam(core, "log-level"))); } core.Process(); } catch (Exception ex) { PTR3Core.LOG.Log(MsgStatusEnum.MS_Error, ex, ""); } //---------------------------------------------------------------------------------------- }
static void Main(string[] args) { PTR3Core core = null; try { core = new PTR3Core(); //core.InitialLogLevel = MsgStatusEnum.MS_Deb3; core.Converter = new ITNWebServiceMain("ITNWebService"); // Parametry konwertera // Wartości niezmieniane przez dodatkowy XML // Mogą zostać nadpisane tutaj core.InstallConfigXmlHelper.Name = "ITNWebService.exe"; // Domyślna nazwa konwertera //core.InstallConfigXmlHelper.Version = ""; // Domyślnie wersja pliku core.InstallConfigXmlHelper.Description = "ITNWebService"; core.InstallConfigXmlHelper.TypeOf = "2"; // 1 - offline, 2 - online // Wartości nadpisywane przez dodatkowy XML core.InstallConfigXmlHelper.InterfaceId = "210"; // Id interfejsu konfiguracyjnego core.InstallConfigXmlHelper.ConfigXmlVersion = "1.0.0.0"; // Wersja konfiguracji konwertera core.InstallConfigXmlHelper.SchemaXmlVersion = "1.0.0.0"; // Wersja interfejsu konfiguracyjnego core.InstallConfigXmlHelper.EfficiencyClassId = "20"; // Id zarejestrowanej klasy wydajnościowej //core.InstallConfigXmlHelper.CobEfficiencyClassId = ""; // Opcjonalne id zarejestrowanej klasy wydajnościowej konwertera pracującego w trybie COB core.InstallConfigXmlHelper.EmptyConfigXml = "1"; core.ParseCommandline(args); core.Init(MsgStatusEnum.MS_Deb3, 35000, 5000, 0); core.Process(); } catch (Exception ex) { PTR3Core.LOG.Log(MsgStatusEnum.MS_Error, ex, ""); } }