public override void DoWork() { try { var portallist = DnnUtils.GetAllPortals(); foreach (var portal in portallist) { // clear down NBStore temp folder var storeSettings = new StoreSettings(portal.PortalID); if (Directory.Exists(storeSettings.FolderTempMapPath)) { string[] files = Directory.GetFiles(storeSettings.FolderTempMapPath); foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.LastAccessTime < DateTime.Now.AddHours(-3)) fi.Delete(); } // DO Scheduler Jobs var pluginData = new PluginData(portal.PortalID); var l = pluginData.GetSchedulerProviders(); foreach (var p in l) { var prov = p.Value; ObjectHandle handle = null; handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass")); if (handle != null) { var objProvider = (SchedulerInterface)handle.Unwrap(); var strMsg = objProvider.DoWork(portal.PortalID); if (strMsg != "") { this.ScheduleHistoryItem.AddLogNote(strMsg); } } } } } this.ScheduleHistoryItem.Succeeded = true; } catch (Exception Ex) { //--intimate the schedule mechanism to write log note in schedule history this.ScheduleHistoryItem.Succeeded = false; this.ScheduleHistoryItem.AddLogNote("NBS Service Start. Failed. " + Ex.ToString()); this.Errored(ref Ex); } }
public override void DoWork() { try { var portallist = DnnUtils.GetAllPortals(); foreach (var portal in portallist) { // clear down NBStore temp folder var storeSettings = new StoreSettings(portal.PortalID); if (Directory.Exists(storeSettings.FolderTempMapPath)) { string[] files = Directory.GetFiles(storeSettings.FolderTempMapPath); foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.LastAccessTime < DateTime.Now.AddHours(-3)) { fi.Delete(); } } // DO Scheduler Jobs var pluginData = new PluginData(portal.PortalID); var l = pluginData.GetSchedulerProviders(); foreach (var p in l) { var prov = p.Value; ObjectHandle handle = null; handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass")); if (handle != null) { var objProvider = (SchedulerInterface)handle.Unwrap(); var strMsg = objProvider.DoWork(portal.PortalID); if (strMsg != "") { this.ScheduleHistoryItem.AddLogNote(strMsg); } } } } } this.ScheduleHistoryItem.Succeeded = true; } catch (Exception Ex) { //--intimate the schedule mechanism to write log note in schedule history this.ScheduleHistoryItem.Succeeded = false; this.ScheduleHistoryItem.AddLogNote("NBS Service Start. Failed. " + Ex.ToString()); this.Errored(ref Ex); } }
public override void DoWork() { try { var portallist = DnnUtils.GetAllPortals(); foreach (var portal in portallist) { var storeSettings = new StoreSettings(portal.PortalID); if (Directory.Exists(storeSettings.FolderTempMapPath)) { // clear old carts var objCtrl = new NBrightBuyController(); var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier; var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner; var days = 60; var d = DateTime.Now.AddDays(days * -1); var strDate = d.ToString("s"); var stmt = ""; stmt = "delete from " + dbOwner + "[" + objQual + "NBrightBuy] where PortalId = " + portal.PortalID.ToString("") + " and typecode = 'CART' and ModifiedDate < '" + strDate + "' "; objCtrl.ExecSql(stmt); // clear down NBStore temp folder string[] files = Directory.GetFiles(storeSettings.FolderTempMapPath); foreach (string file in files) { FileInfo fi = new FileInfo(file); if (fi.LastAccessTime < DateTime.Now.AddHours(-1)) { fi.Delete(); } } // DO Scheduler Jobs var pluginData = new PluginData(portal.PortalID); var l = pluginData.GetSchedulerProviders(); foreach (var p in l) { var prov = p.Value; ObjectHandle handle = null; handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass")); if (handle != null) { var objProvider = (SchedulerInterface)handle.Unwrap(); var strMsg = objProvider.DoWork(portal.PortalID); if (strMsg != "") { this.ScheduleHistoryItem.AddLogNote(strMsg); } } } } } this.ScheduleHistoryItem.Succeeded = true; } catch (Exception Ex) { //--intimate the schedule mechanism to write log note in schedule history this.ScheduleHistoryItem.Succeeded = false; this.ScheduleHistoryItem.AddLogNote("NBS Service Start. Failed. " + Ex.ToString()); this.Errored(ref Ex); } }