receiver, string message, strin
public static void SendBookingNotification(BookingAction bookingAction, BookingEventModel model)
{
//get receiver and sender from the settings file
- var receiver = Modules.RBM.UI.Helper.Settings.get("BookingMailReceiver").ToString().Split(',').ToList();
- var receiverCC = Modules.RBM.UI.Helper.Settings.get("BookingMailReceiverCC").ToString().Split(',').ToList();
- var receiverBCC = Modules.RBM.UI.Helper.Settings.get("BookingMailReceiverBCC").ToString().Split(',').ToList();
+ var settings = ModuleManager.GetModuleSettings("rbm");
+ var receiver = settings.GetValueByKey("BookingMailReceiver").ToString().Split(',').ToList();
+ var receiverCC = settings.GetValueByKey("BookingMailReceiverCC").ToString().Split(',').ToList();
+ var receiverBCC = settings.GetValueByKey("BookingMailReceiverBCC").ToString().Split(',').ToList();
- var sender = Modules.RBM.UI.Helper.Settings.get("BookingMailSender").ToString();
+ //var sender = Modules.RBM.UI.Helper.Settings.get("BookingMailSender").ToString();
- var subject = Modules.RBM.UI.Helper.Settings.get("BookingMailSubject").ToString() + ": " + bookingAction;
+ var subject = settings.GetValueByKey("BookingMailSubject").ToString() + ": " + bookingAction;
string message = "";
message += "The following booking has been " + bookingAction + "
";
@@ -56,7 +67,9 @@ public static void SendBookingNotification(BookingAction bookingAction, BookingE
if (!String.IsNullOrEmpty(model.Description))
message += "Booking description: " + model.Description + "";
message += "Booked Resources:
";
- using (var userManager = new UserManager())
+
+ var userManager = IoCFactory.Container.Resolve();
+
using (var partyManager = new PartyManager())
{
foreach (ScheduleEventModel schedule in model.Schedules)
@@ -76,7 +89,9 @@ public static void SendBookingNotification(BookingAction bookingAction, BookingE
else
message += person.UserFullName + ", ";
- var user = userManager.FindByIdAsync(person.UserId).Result;
+ var userTask = userManager.FindByIdAsync(person.UserId);
+ userTask.Wait();
+ var user = userTask.Result;
if (user != null)
{
@@ -92,14 +107,16 @@ public static void SendBookingNotification(BookingAction bookingAction, BookingE
receiverBCC.Add(ConfigurationManager.AppSettings["SystemEmail"].ToString()); // Allways send BCC to SystemEmail
- var emailService = new EmailService();
- emailService.Send(
- subject,
- message,
- receiver.Distinct().ToList(),
- receiverCC,
- receiverBCC
- );
+ using (var emailService = new EmailService())
+ {
+ emailService.Send(
+ subject,
+ message,
+ receiver.Distinct().ToList(),
+ receiverCC,
+ receiverBCC
+ );
+ }
}
}
diff --git a/Helper/Settings.cs b/Helper/Settings.cs
deleted file mode 100644
index 65b74bd..0000000
--- a/Helper/Settings.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Web;
-using System.Xml;
-using System.Xml.Linq;
-using Vaiona.Utils.Cfg;
-
-namespace BExIS.Modules.RBM.UI.Helper
-{
- static class Settings
- {
-
- private static String filePath = Path.Combine(AppConfiguration.GetModuleWorkspacePath("RBM"), "Rbm.settings.xml");
- private static Dictionary settings = new Dictionary();
-
- ///
- /// setup settings model
- /// * load settings from settings.xml
- ///
- static Settings()
- {
- // intial loading of settings
- reloadSettings();
-
- // set up file watcher to listen for changes
- using (FileSystemWatcher fw = new FileSystemWatcher())
- {
- fw.Path = Path.GetDirectoryName(filePath);
- fw.Filter = Path.GetFileName(filePath);
- fw.Changed += new FileSystemEventHandler(fw_Changed);
- fw.EnableRaisingEvents = true;
- }
-
- }
-
- ///
- /// retrieve a value from the settings file
- ///
- /// the key for the parameter
- /// the respective value
- public static object get(String key)
- {
- if (settings.ContainsKey(key))
- {
- return settings[key];
- }
- else
- {
- return null;
- }
- }
-
- ///
- /// add or change an entry in the settings
- /// TODO persist changes in workflow file
- ///
- ///
- ///
- public static void set(String key, object value)
- {
- if (settings.ContainsKey(key))
- {
- settings[key] = value;
- }
- else
- {
- settings.Add(key, value);
- }
- }
-
- ///
- /// Handler to listen for changes in settings file
- ///
- ///
- ///
- private static void fw_Changed(object sender, FileSystemEventArgs e)
- {
- reloadSettings();
- }
-
- ///
- /// load settings anew from settings.xml
- ///
- private static void reloadSettings()
- {
- // get XML data
- XDocument xDoc = XDocument.Load(filePath);
- XmlDocument xmlDoc = new XmlDocument();
- xmlDoc.Load(xDoc.CreateReader());
-
- // empty old settings list
- settings.Clear();
-
- // parse values
- foreach (XmlNode node in xmlDoc.SelectNodes("//settings/entry"))
- {
- // shortcuts
- var key = node.Attributes["key"] != null ? node.Attributes["key"].Value : null;
- var value = node.Attributes["value"] != null ? node.Attributes["value"].Value : null;
- var type = node.Attributes["type"] != null ? node.Attributes["type"].Value : null;
-
- // only parse valid entries
- if ((null == key) || (null == value))
- {
- continue;
- }
-
- // convert types
- switch (type)
- {
- case "int":
- int intVal;
- if (Int32.TryParse(value, out intVal))
- {
- settings.Add(key, intVal);
- }
- else
- {
- settings.Add(key, value);
- }
- break;
-
- // default is string
- default:
- settings.Add(key, value);
- break;
- }
- }
- }
-
- }
-}
\ No newline at end of file
diff --git a/Helper/UserHelper.cs b/Helper/UserHelper.cs
index 37322ff..8e52115 100644
--- a/Helper/UserHelper.cs
+++ b/Helper/UserHelper.cs
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
+using Vaiona.IoC;
namespace BExIS.Modules.RBM.UI.Helper
{
@@ -12,18 +13,14 @@ public static class UserHelper
{
public static long GetUserId(string userName)
{
- using (UserManager userManager = new UserManager())
- {
- return userManager.FindByNameAsync(userName).Result.Id;
- }
+ var userManager = IoCFactory.Container.Resolve();
+ return userManager.FindByNameAsync(userName).Result.Id;
}
public static Security.Entities.Subjects.User GetUser(string userName)
{
- using (UserManager userManager = new UserManager())
- {
- return userManager.FindByNameAsync(userName).Result;
- }
+ var userManager = IoCFactory.Container.Resolve();
+ return userManager.FindByNameAsync(userName).Result;
}
diff --git a/Models/Booking/BookingEventModel.cs b/Models/Booking/BookingEventModel.cs
index 3f734a4..e4a830b 100644
--- a/Models/Booking/BookingEventModel.cs
+++ b/Models/Booking/BookingEventModel.cs
@@ -1,29 +1,32 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
-using R = BExIS.Rbm.Entities.Resource;
-using E = BExIS.Rbm.Entities.Booking;
+using BExIS.Dlm.Entities.DataStructure;
+using BExIS.Dlm.Entities.Party;
+using BExIS.Dlm.Services.Party;
using BExIS.Rbm.Entities.Booking;
-using BExIS.Rbm.Services.Booking;
-using BExIS.Web.Shell.Areas.RBM.Models.Resource;
-using BExIS.Web.Shell.Areas.RBM.Models.ResourceStructure;
+using BExIS.Rbm.Entities.BookingManagementTime;
+using BExIS.Rbm.Entities.Resource;
using BExIS.Rbm.Entities.ResourceStructure;
-using BExIS.Dlm.Entities.DataStructure;
+using BExIS.Rbm.Services.Booking;
using BExIS.Rbm.Services.Resource;
-using BExIS.Rbm.Entities.Resource;
using BExIS.Security.Entities.Subjects;
using BExIS.Security.Services.Subjects;
+using BExIS.Web.Shell.Areas.RBM.Models.Resource;
+using BExIS.Web.Shell.Areas.RBM.Models.ResourceStructure;
+using Microsoft.AspNet.Identity;
+using System;
+using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using BExIS.Rbm.Entities.BookingManagementTime;
-using BExIS.Dlm.Services.Party;
-using BExIS.Dlm.Entities.Party;
+using System.Linq;
+using System.Web;
+using Vaiona.IoC;
using Vaiona.Persistence.Api;
+using E = BExIS.Rbm.Entities.Booking;
+using R = BExIS.Rbm.Entities.Resource;
namespace BExIS.Web.Shell.Areas.RBM.Models.Booking
{
public class BookingEventModel
{
+
public DateTime startDate;
public DateTime endDate;
@@ -58,7 +61,7 @@ public BookingEventModel()
public BookingEventModel(List cart)
{
- using (var userManager = new UserManager())
+ var userManager = IoCFactory.Container.Resolve();
using (var rManager = new ResourceManager())
{
Schedules = new List();
@@ -80,9 +83,7 @@ public BookingEventModel(List cart)
//add as default resvered by user as reserved for user
- var userTask = userManager.FindByIdAsync(rc.ByPersonUserId);
- userTask.Wait();
- var user = userTask.Result;
+ var user = userManager.FindByIdAsync(rc.ByPersonUserId).Result;
PersonInSchedule byPerson = new PersonInSchedule(0, user, false);
byPerson.IsContactPerson = true;
diff --git a/Properties/PublishProfiles/BexisServer_BE_DevSite.pubxml b/Properties/PublishProfiles/BexisServer_BE_DevSite.pubxml
new file mode 100644
index 0000000..16989e4
--- /dev/null
+++ b/Properties/PublishProfiles/BexisServer_BE_DevSite.pubxml
@@ -0,0 +1,18 @@
+
+
+
+
+ FileSystem
+ FileSystem
+ Release
+ Any CPU
+
+ True
+ False
+ C:\inetpub\wwwroot\BE_DevSite\Site\Areas\RBM
+ False
+
+
\ No newline at end of file
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 15bc822..783c503 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace BExIS.Modules.RBM.UI.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.2.0.0")]
public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
diff --git a/Rbm.Settings.json b/Rbm.Settings.json
new file mode 100644
index 0000000..1dc3971
--- /dev/null
+++ b/Rbm.Settings.json
@@ -0,0 +1,78 @@
+{
+ "id": "rbm",
+ "name": "Resource Booking",
+ "description": "...",
+ "entries": [
+ {
+ "key": "help",
+ "title": "Help URL",
+ "value": "",
+ "type": "String",
+ "description": "URL to the manual. If empty, it links to the latest manual from BEXIS2"
+ },
+ {
+ "key": "BookingMailReceiver",
+ "title": "Booking Mail Receiver",
+ "value": "",
+ "description": "",
+ "type": "String",
+ "options": []
+ },
+ {
+ "key": "BookingMailReceiverCC",
+ "title": "Booking Mail Receiver CC",
+ "value": "",
+ "description": "",
+ "type": "String",
+ "options": []
+ },
+ {
+ "key": "BookingMailReceiverBCC",
+ "title": "Booking Mail Receiver BCC",
+ "value": "",
+ "description": "",
+ "type": "String",
+ "options": []
+ },
+ {
+ "key": "BookingMailSubject",
+ "title": "Booking Mail Subject",
+ "value": "Fieldbook reservation",
+ "description": "",
+ "type": "String",
+ "options": []
+ },
+ {
+ "key": "AlumniGroup",
+ "title": "Alumni group",
+ "value": "alumni",
+ "description": "",
+ "type": "String",
+ "options": []
+ },
+ {
+ "key": "AccountPartyTypes",
+ "title": "Account party type",
+ "value": "Person",
+ "description": "Setting to define party type name",
+ "type": "String",
+ "options": []
+ },
+ {
+ "key": "EventAdminGroups",
+ "title": "Event admin groups",
+ "value": "FB_Edit_HAI:Hainich-Dün,FB_Edit_SCH:Schorfheide-Chorin,FB_Edit_ALB:Schwäbische Alb",
+ "description": "Setting admin group to edit and delete events and schedules, Groupname:resource attribute value so you are able to give different rights to group depending on the classification with resource attribute value",
+ "type": "String",
+ "options": []
+ },
+ {
+ "key": "OverNightResource",
+ "title": "Over night resource",
+ "value": "Sleeping place",
+ "description": "Setting to specify resource for specific validation.",
+ "type": "String",
+ "options": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/web.config b/web.config
index dac6552..e02c24c 100644
--- a/web.config
+++ b/web.config
@@ -1,130 +1,84 @@
-
+
-
+
-
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
+
+
-
-
-
+
-
-
-
-
+
+
+
+
-
+
+
\ No newline at end of file