Commit f450c7581ae99cb0c625e39d42b16a7f1a08b207
1 parent
5449f858
v1.31.2.0
- Multirun script paraméterek között a DAYSBACK és a LIMITDATE összeolvasztása
Showing
2 changed files
with
45 additions
and
46 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs
... | ... | @@ -1942,43 +1942,44 @@ GO |
1942 | 1942 | { |
1943 | 1943 | DBKEY,DATABASE,DATASOURCE,DBOTYPE,DBONAME,DBDATAGROUP,BACKUPTS,SHRINKOPTION,SHRINKFREESPACEPERCENT, |
1944 | 1944 | } |
1945 | - #endregion DBSubstitution | |
1945 | + #endregion DBSubstitution | |
1946 | 1946 | |
1947 | - #region ExecuteSQLScriptWithMultipleRuns | |
1948 | - /// <summary> | |
1949 | - /// Executes a multirun script. Its parameters are in the <Script Parameters=> attribute, as list of KEY=VALUE; pairs. | |
1950 | - /// Keys: | |
1951 | - /// DAYSBACK (C# int value) or LIMITDATE (C# DateTime value): how many days from now, or from when the older rows should be deleted | |
1952 | - /// NUMOFDAYSINONERUN (C# int value): how many days are deleted in one run | |
1953 | - /// DELAYBETWEENRUNS (C# TimeSpan value): how much delay will be between runs | |
1954 | - /// TESTMODE (C# bool value): if testmode, no delete takes place | |
1955 | - /// </summary> | |
1956 | - /// <param name="sqlc">connectionstring az sql server-hez</param> | |
1957 | - /// <param name="sqlscript">az sql script (multirun interfész szerint!!!) | |
1958 | - /// this should be used in the script in the following way: | |
1959 | - /// DECLARE @RUNNINGMODE AS varchar(20) = '{RUNNINGMODE}' | |
1960 | - /// IF @RUNNINGMODE = 'GETTOTALRECORDS' | |
1961 | - /// THEN | |
1962 | - /// -- this part of the script should count the number of the rows of the dab, that will decrease after each run | |
1963 | - /// SELECT @RV, @RM -- @RV:0, @RM:the number of rows | |
1964 | - /// END | |
1965 | - /// ELSE IF @RUNNINGMODE = 'GETMINDATE' | |
1966 | - /// THEN | |
1967 | - /// -- this part of the script should return a DateTime value, that is the oldest date in the database | |
1968 | - /// SELECT @RV, @RM -- @RV:0, @RM:the Date, that is considered the oldest; no rows will be deleted before this | |
1969 | - /// END | |
1970 | - /// ELSE IF @RUNNINGMODE = 'ONERUN' | |
1971 | - /// THEN | |
1972 | - /// -- this part of the script deletes some rows from the database, older then a limitdate(parameter) | |
1973 | - /// -- parameter usage: DECLARE @RUNDELETEBEFOREDATE AS DATE = '{RUNDELETEBEFOREDATE}' | |
1974 | - /// SELECT @RV, @RM -- @RV:(0=OK, otherwise NOK), @RM:message with the result description | |
1975 | - /// END | |
1976 | - /// </param> | |
1977 | - /// <param name="ExitAtThisPoint">az a függvény, ami minde run után végrehajtásra kerül; | |
1978 | - /// bemenő paramétere az előző run eredménye, | |
1979 | - /// kimenő paramétere pedig igaz, ha ki kell lépni a végrehajtásból. | |
1980 | - /// </param> | |
1981 | - /// <returns></returns> | |
1947 | + #region ExecuteSQLScriptWithMultipleRuns | |
1948 | + /// <summary> | |
1949 | + /// Executes a multirun script. Its parameters are in the <Script Parameters=> attribute, as list of KEY=VALUE; pairs. | |
1950 | + /// Keys: | |
1951 | + /// LIMITDATE yyyy-MM-dd hh:mm:ss (yyyy-MM-dd hh:mm:ss is C# DateTime value) from when the older rows should be deleted (LIMITDATE 2024-12-31) | |
1952 | + /// LIMITDATE NNdays (NN is C# int value): how many days from now the older rows should be deleted (LIMITDATE 90days) | |
1953 | + /// NUMOFDAYSINONERUN (C# int value): how many days are deleted in one run | |
1954 | + /// DELAYBETWEENRUNS (C# TimeSpan value): how much delay will be between runs | |
1955 | + /// TESTMODE (C# bool value): if testmode, no delete takes place | |
1956 | + /// </summary> | |
1957 | + /// <param name="sqlc">connectionstring az sql server-hez</param> | |
1958 | + /// <param name="sqlscript">az sql script (multirun interfész szerint!!!) | |
1959 | + /// this should be used in the script in the following way: | |
1960 | + /// DECLARE @RUNNINGMODE AS varchar(20) = '{RUNNINGMODE}' | |
1961 | + /// IF @RUNNINGMODE = 'GETTOTALRECORDS' | |
1962 | + /// THEN | |
1963 | + /// -- this part of the script should count the number of the rows of the dab, that will decrease after each run | |
1964 | + /// SELECT @RV, @RM -- @RV:0, @RM:the number of rows | |
1965 | + /// END | |
1966 | + /// ELSE IF @RUNNINGMODE = 'GETMINDATE' | |
1967 | + /// THEN | |
1968 | + /// -- this part of the script should return a DateTime value, that is the oldest date in the database | |
1969 | + /// SELECT @RV, @RM -- @RV:0, @RM:the Date, that is considered the oldest; no rows will be deleted before this | |
1970 | + /// END | |
1971 | + /// ELSE IF @RUNNINGMODE = 'ONERUN' | |
1972 | + /// THEN | |
1973 | + /// -- this part of the script deletes some rows from the database, older then a limitdate(parameter) | |
1974 | + /// -- parameter usage: DECLARE @RUNDELETEBEFOREDATE AS DATE = '{RUNDELETEBEFOREDATE}' | |
1975 | + /// SELECT @RV, @RM -- @RV:(0=OK, otherwise NOK), @RM:message with the result description | |
1976 | + /// END | |
1977 | + /// </param> | |
1978 | + /// <param name="ExitAtThisPoint">az a függvény, ami minde run után végrehajtásra kerül; | |
1979 | + /// bemenő paramétere az előző run eredménye, | |
1980 | + /// kimenő paramétere pedig igaz, ha ki kell lépni a végrehajtásból. | |
1981 | + /// </param> | |
1982 | + /// <returns></returns> | |
1982 | 1983 | |
1983 | 1984 | public static ReturnInfoJSON ExecuteMultirunSQLScript(SqlConnection sqlc, SQLDataBase.SQLScript sqlscript, Func<ReturnInfoJSON,TimeSpan?, bool> ExitAtThisPoint=null) |
1984 | 1985 | { |
... | ... | @@ -2086,18 +2087,17 @@ GO |
2086 | 2087 | var testmodestring = argkvplist.GetValue(XMLPAR_TESTMODE, "false"); |
2087 | 2088 | if (!bool.TryParse(testmodestring, out par_testmode)) { Add(multirunresult, "Result", $"Parameter error:{XMLPAR_TESTMODE}"); return null; } |
2088 | 2089 | |
2089 | - var daysbackstring = argkvplist.GetValue(XMLPAR_DAYSBACK, null); | |
2090 | - var limitdatestring = argkvplist.GetValue(XMLPAR_LIMITDATE, null); | |
2091 | - if (daysbackstring == null && limitdatestring == null) { par_limitdays = 90; par_limitdate = DateTime.Now.Subtract(new TimeSpan(par_limitdays, 0, 0, 0)); } | |
2092 | - else if (!string.IsNullOrEmpty(daysbackstring) && !string.IsNullOrEmpty(limitdatestring)) { Add(multirunresult, "Result", $"Parameter error:{XMLPAR_DAYSBACK} and {XMLPAR_LIMITDATE} are both defined."); return null; } | |
2093 | - else if (!string.IsNullOrEmpty(limitdatestring)) | |
2090 | + string limitdatestring = argkvplist.GetValue(XMLPAR_LIMITDATE, null); string daysbackstring = null; | |
2091 | + if (limitdatestring == null) { limitdatestring="90days"; } | |
2092 | + if (limitdatestring.EndsWith("days")) { daysbackstring = limitdatestring.Replace("days", "").Replace(" ", ""); limitdatestring = null; } | |
2093 | + if (!string.IsNullOrEmpty(limitdatestring)) | |
2094 | 2094 | { |
2095 | - if (!DateTime.TryParse(limitdatestring, out par_limitdate)) { Add(multirunresult, "Result", $"Parameter error:" + XMLPAR_LIMITDATE); return null; } | |
2095 | + if (!DateTime.TryParse(limitdatestring, out par_limitdate)) { Add(multirunresult, "Result", $"Parameter error:{XMLPAR_LIMITDATE}"); return null; } | |
2096 | 2096 | par_limitdays = (int)DateTime.Now.Subtract(par_limitdate).TotalDays; |
2097 | 2097 | } |
2098 | 2098 | else /*if (!string.IsNullOrEmpty(daysbackstring)) */ |
2099 | 2099 | { |
2100 | - if (!int.TryParse(daysbackstring, out par_limitdays)) { Add(multirunresult, "Result", $"Parameter error:" + XMLPAR_DAYSBACK); return null; } | |
2100 | + if (!int.TryParse(daysbackstring, out par_limitdays)) { Add(multirunresult, "Result", $"Parameter error:{XMLPAR_LIMITDATE}(days)"); return null; } | |
2101 | 2101 | par_limitdate = DateTime.Now.Subtract(new TimeSpan(par_limitdays, 0, 0, 0)); |
2102 | 2102 | } |
2103 | 2103 | |
... | ... | @@ -2138,7 +2138,6 @@ GO |
2138 | 2138 | const string XMLPAR_NUMOFDAYSINONERUN = "NUMOFDAYSINONERUN"; |
2139 | 2139 | const string XMLPAR_DELAYBETWEENRUNS = "DELAYBETWEENRUNS"; |
2140 | 2140 | const string XMLPAR_TESTMODE = "TESTMODE"; |
2141 | - const string XMLPAR_DAYSBACK = "DAYSBACK"; | |
2142 | 2141 | const string XMLPAR_LIMITDATE = "LIMITDATE"; |
2143 | 2142 | |
2144 | 2143 | const string ERRMSG_NOTHINGTOEXECUTE = "FAILURE! Nothing to execute! Check script definition entry!"; | ... | ... |
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
... | ... | @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; |
32 | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
33 | 33 | // by using the '*' as shown below: |
34 | 34 | // [assembly: AssemblyVersion("1.0.*")] |
35 | -[assembly: AssemblyVersion("1.31.1.0")] | |
36 | -[assembly: AssemblyFileVersion("1.31.1.0")] | |
35 | +[assembly: AssemblyVersion("1.31.2.0")] | |
36 | +[assembly: AssemblyFileVersion("1.31.2.0")] | ... | ... |