Fix COnfig FIle & Sheet cleaning

This commit is contained in:
Thermo_SIM
2021-03-19 22:52:17 +01:00
parent 083be20f02
commit e098409b83
7 changed files with 30 additions and 2 deletions
+3 -1
View File
@@ -4,7 +4,7 @@
<ncVendor>S7NET</ncVendor>
<!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI/S7NET -->
<showNcHMI>false</showNcHMI>
<ncIpAddress>192.168.0.102</ncIpAddress>
<ncIpAddress>192.168.214.1</ncIpAddress>
<ncPort>102</ncPort>
<machineModel>Thermo 2020</machineModel>
<sharedPath>C:\CMS\Recipes\</sharedPath>
@@ -31,6 +31,8 @@
<CMSConnectReady>true</CMSConnectReady>
<maxAlarmsRows>50000</maxAlarmsRows>
<alarmToDelete>5000</alarmToDelete>
<maxSheetHistoryRows>10000</maxSheetHistoryRows>
<sheetHistoryToDelete>500</sheetHistoryToDelete>
</serverConfig>
<extSoftwares>
<software>
@@ -42,6 +42,8 @@
<xs:element name="MTCApplicationName" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="maxAlarmsRows" type="xs:int" minOccurs="1" maxOccurs="1"/>
<xs:element name="alarmToDelete" type="xs:int" minOccurs="1" maxOccurs="1"/>
<xs:element name="maxSheetHistoryRows" type="xs:int" minOccurs="1" maxOccurs="1"/>
<xs:element name="sheetHistoryToDelete" type="xs:int" minOccurs="1" maxOccurs="1"/>
<xs:element name="CMSConnectReady" type="xs:boolean" minOccurs="1" maxOccurs="1"/>
</xs:all>
</xs:complexType>
@@ -1033,6 +1033,8 @@ namespace Thermo.Active.Config
MTCApplicationName = x.Element("MTCApplicationName").Value,
MaxAlarmsRows = Convert.ToInt32(x.Element("maxAlarmsRows").Value),
AlarmToDelete = Convert.ToInt32(x.Element("alarmToDelete").Value),
MaxSheetHistoryRows = Convert.ToInt32(x.Element("maxSheetHistoryRows").Value),
SheetHistoryToDelete = Convert.ToInt32(x.Element("sheetHistoryToDelete").Value),
CmsConnectReady = Convert.ToBoolean(x.Element("CMSConnectReady").Value)
}).FirstOrDefault();
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Thermo.Active.Model.DatabaseModels;
using static Thermo.Active.Config.ServerConfig;
namespace Thermo.Active.Database.Controllers
{
@@ -42,6 +43,16 @@ namespace Thermo.Active.Database.Controllers
return mod;
}
public void Clean()
{
if (this.count() >= ServerStartupConfig.MaxSheetHistoryRows)
{
dbCtx.Database.ExecuteSqlCommand("DELETE FROM historysheets LIMIT {0}", ServerStartupConfig.SheetHistoryToDelete);
}
}
public List<HistorySheetModel> GetData(int start, int number)
{
// Get page numbers
@@ -18,5 +18,9 @@ namespace Thermo.Active.Model.ConfigModels
public int MaxAlarmsRows { get; set; }
public int AlarmToDelete { get; set; }
public int MaxSheetHistoryRows { get; set; }
public int SheetHistoryToDelete { get; set; }
}
}
@@ -50,7 +50,13 @@ namespace Thermo.Active.Listeners.Database
}
}
}
public static void cleanHistorySheets()
{
using (HistorySheetsController HSC = new HistorySheetsController())
{
HSC.Clean();
}
}
public static void UpdateAlarms(object alarmsObj)
{
@@ -130,6 +130,7 @@ namespace Thermo.Active.Listeners
}));
infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_PROD_INFO_DATA, (a, b) =>
{
SignalRDatabaseHandler.cleanHistorySheets();
SignalRListener.SendThermoProdInfoData(a);
}));
infos.Add(MessageServices.Current.Subscribe(SEND_THERMO_PROD_CYCLE_DATA, (a, b) =>