public ActionResult Edit(Guid?id) { if (id == null) { GetAlert(Danger, "ID cannot be null!"); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var user = TheUserManager.GetUserById(id); if (user == null) { GetAlert(Danger, "User cannot be found!"); return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var model = new UserVm.Edit() { UserId = user.UserId, UserName = user.Name, UserEnabled = user.Enabled, UserLocked = user.Locked }; var userRoles = TheUserManager.GetRolesForUser(id); var roles = TheRoleManager.GetAllRoles(); var roleDetail = roles.Select(rd => new CheckBoxListItem() { Id = rd.RoleId, Display = rd.Name, IsChecked = userRoles.Any(ur => ur.RoleId == rd.RoleId) }).ToList(); model.Roles = roleDetail; return(View("Edit", model)); }
public ActionResult Detail(Guid?id) { if (id == null) { GetAlert(Danger, "ID cannot e null!"); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var user = TheUserManager.GetUserById(id); if (user == null) { GetAlert(Danger, "User cannot be found!"); return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var model = new UserVm.Detail() { UserId = user.UserId, UserName = user.Name, UserEnabled = user.Enabled, UserLocked = user.Locked }; var userRoles = TheUserManager.GetRolesForUser(id); var roleDetail = userRoles.Select(rd => new UserVm.UserRolesDetail() { RoleId = rd.RoleId, RoleName = rd.Role.Name }).ToList(); model.UserRolesDetail = roleDetail; return(View("Detail", model)); }
public ActionResult Delete(UserVm.Delete model) { if (ModelState.IsValid) { TheUserManager.DeleteUser(model.UserId); GetAlert(Success, "User deleted!"); return(RedirectToAction("Index")); } GetAlert(Danger, "Error!"); return(View("Delete", model)); }
public ActionResult Edit(UserVm.Edit model) { if (ModelState.IsValid) { var rolesToAdd = model.Roles.Where(x => x.IsChecked).Select(x => x.Id).ToList(); TheUserManager.UpdateUser(model.UserId, model.UserName, model.UserEnabled, model.UserLocked, rolesToAdd); GetAlert(Success, "Role updated!"); return(RedirectToAction("Index")); } GetAlert(Danger, "Error!"); return(View("Edit", model)); }
public ActionResult Create(UserVm.Create model) { if (ModelState.IsValid) { var rolesToAdd = model.Roles.Where(r => r.IsChecked).Select(r => r.Id).ToList(); TheUserManager.CreateUser(model.UserName, rolesToAdd); GetAlert(Success, "Role created!"); return(RedirectToAction("Index")); } GetAlert(Danger, "Error!"); return(View("Create", model)); }
/// <summary> /// This event is fired when the scope was changed /// </summary> public virtual void EventScopeChanged(bool SetReq) { if (TheBaseAssets.MyApplication != null && TheBaseAssets.MyApplication.MyCommonDisco != null) { TheBaseAssets.MyApplication.MyCommonDisco.UpdateContextID(); } TheQueuedSenderRegistry.UpdateLocalHostScope(); if (TheBaseAssets.MyServiceHostInfo.AreAllEnginesStarted) { TheQueuedSenderRegistry.ReinitCloudRoutes(); TheUserManager.ResetUserScopes(true); } }
internal void sinkExpired(TheSessionState pState) { if (pState != null) { if (pState.CID != Guid.Empty) { TheUserManager.RemoveTempUser(pState.CID); } TheQueuedSender tQSend = TheQueuedSenderRegistry.GetSenderBySEID(pState.cdeMID); if (tQSend != null) { tQSend.FireSenderProblem(new TheRequestData() { ErrorDescription = "1500:Session for this QSender expired" }); } } }
public ActionResult Index(string term, int?page) { var model = TheUserManager.GetAllRoles().Select(x => new UserVm.Index() { UserId = x.UserId, UserName = x.Name, UserRoleCount = x.UserRoles.Count, UserLocked = x.Locked, UserEnabled = x.Enabled }); if (!string.IsNullOrEmpty(term)) { model = model.Where(s => s.UserName.Contains(term)); } var pageNo = page ?? 1; var pagedData = model.ToPagedList(pageNo, AppConfig.PageSize); ViewBag.Data = pagedData; return(View("Index", pagedData)); }
public ActionResult Delete(Guid?id) { if (id == null) { GetAlert(Danger, "ID cannot be null!"); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var user = TheUserManager.GetUserById(id); if (user == null) { GetAlert(Danger, "User cannot be found!"); return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var model = new UserVm.Delete() { UserId = user.UserId, UserName = user.Name, UserEnabled = user.Enabled, UserLocked = user.Locked }; return(View("Delete", model)); }
internal static TheScreenInfo GenerateLiveScreen(Guid pScreenId, TheClientInfo tClientInfo) // Guid pUserGuid, int lcid, int pFlag) { if (TheCDEngines.MyNMIService == null) { return(null); } TheScreenInfo tInfo = new TheScreenInfo { cdeMID = pScreenId, MyDashboard = null, MyStorageInfo = new List <TheFormInfo>(), MyStorageMeta = new cdeConcurrentDictionary <string, TheFormInfo>(), MyStorageMirror = new List <object>(), MyDashPanels = new List <TheDashPanelInfo>() }; TheThing tLiveForm = TheThingRegistry.GetThingByMID("*", pScreenId); if (tLiveForm == null || !TheUserManager.HasUserAccess(tClientInfo.UserID, tLiveForm.cdeA)) { return(null); //V3.1: BUG 126 - could lead to racing condition. TODO: Revisit later //TheFormInfo tI = new TheFormInfo(tLiveForm) { FormTitle = (tLiveForm == null ? "Form not Found!" : "Access Denied!") }; //tI.TargetElement = pScreenId.ToString(); //tI.AssociatedClassName = pScreenId.ToString(); //tInfo.MyStorageInfo.Add(tI); //tI.FormFields = new List<TheFieldInfo>(); //TheFieldInfo tFldInfo = new TheFieldInfo(null, null, 10, 0, 0); //tFldInfo.Type = eFieldType.SmartLabel; //tFldInfo.Header = (tLiveForm == null ? "This Form was defined but has not Meta-Data associated with it." : "You do not have the required access permissions!"); //tI.FormFields.Add(tFldInfo); //return tInfo; } string tFormName = TheThing.GetSafePropertyString(tLiveForm, "FriendlyName"); List <TheThing> tFields = TheThingRegistry.GetThingsByFunc("*", s => s.cdeO == TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID && TheThing.GetSafePropertyString(s, "FormName") == tFormName && TheThing.GetSafePropertyBool(s, "IsLiveTag") && (s.UID == Guid.Empty || s.UID == tClientInfo.UserID)); if (tFields != null && tFields.Any()) { string tFormTitle = TheThing.GetSafePropertyString(tLiveForm, "FormTitle"); if (string.IsNullOrEmpty(tFormTitle)) { tFormTitle = tFormName; } TheFormInfo tI = new TheFormInfo(tLiveForm) { FormTitle = tFormTitle, TargetElement = pScreenId.ToString(), DefaultView = eDefaultView.Form, TileWidth = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tLiveForm, "TileWidth")), TileHeight = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tLiveForm, "TileHeight")), IsUsingAbsolute = TheThing.GetSafePropertyBool(tLiveForm, "IsAbsolute"), AssociatedClassName = pScreenId.ToString() }; tInfo.MyStorageInfo.Add(tI); tI.FormFields = new List <TheFieldInfo>(); int fldNo = 10; foreach (TheThing tTh in tFields) { int tfldNo = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "FldOrder")); if (tfldNo == 0) { tfldNo = fldNo; } int tFlags = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "Flags")); cdeP ValProp = tTh.GetProperty("Value"); bool IsNewFld = true; TheFieldInfo tFldInfo = TheNMIEngine.GetFieldById(TheThing.GetSafePropertyGuid(tTh, "FldID")); if (tFldInfo == null) { tFldInfo = new TheFieldInfo(tTh, "Value", tfldNo, tFlags & 0xFFBF, tTh.GetBaseThing().cdeA); } else { tFldInfo.FldOrder = tfldNo; tFldInfo.Flags = tFlags; IsNewFld = false; } if (tFldInfo.PropertyBag == null) { tFldInfo.PropertyBag = new ThePropertyBag(); } ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, "IsOnTheFly", "=", "True"); ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, "UXID", "=", $"{tTh.cdeMID}"); tFldInfo.Header = tTh.FriendlyName; RegisterNMISubscription(tClientInfo, "Value", tFldInfo); string tControlType = TheThing.GetSafePropertyString(tTh, "ControlType"); if (TheCommonUtils.CInt(tControlType) == 0 && !TheCommonUtils.IsNullOrWhiteSpace(tControlType)) { tFldInfo.Type = eFieldType.UserControl; RegisterFieldEvents(tTh, ValProp, IsNewFld, tFldInfo, tControlType); } else { tFldInfo.Type = (eFieldType)TheCommonUtils.CInt(tControlType); } tFldInfo.DefaultValue = ValProp?.ToString(); tFldInfo.TileWidth = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "TileWidth")); tFldInfo.TileHeight = TheCommonUtils.CInt(TheThing.GetSafePropertyNumber(tTh, "TileHeight")); foreach (cdeP prop in tTh.GetNMIProperties()) { ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, prop.Name, "=", prop.ToString()); } if (tFldInfo.Type == eFieldType.TileButton) { tTh.DeclareNMIProperty("IsDown", ePropertyTypes.TBoolean); ThePropertyBag.PropBagUpdateValue(tFldInfo.PropertyBag, "EnableTap", "=", "True"); tFldInfo.RegisterUXEvent(tTh, eUXEvents.OnPropertyChanged, "IsDown", (pThing, pObj) => { if (!(pObj is TheProcessMessage pMsg) || pMsg.Message == null) { return; } TheThing.SetSafePropertyBool(pThing, "IsDown", TheCommonUtils.CBool(pMsg.Message.PLS)); });
internal static List <TheFieldInfo> GetPermittedFields(Guid FormId, TheClientInfo pClientInfo, TheFOR tso, bool UpdateSubs) { List <TheFieldInfo> tReturnLst = new List <TheFieldInfo>(); try { Func <TheFieldInfo, bool> pSelector = (s => TheUserManager.HasUserAccess(pClientInfo.UserID, s.cdeA) && ((s.Flags & 4) == 0 || !pClientInfo.IsMobile) && ((s.Flags & 128) == 0 || pClientInfo.IsFirstNode || pClientInfo.IsUserTrusted)); //NEW3.105: Only Show from First node is set IEnumerable <TheFieldInfo> FormFields = TheNMIEngine.GetFieldsByFunc(s => s.FormID == FormId).Where(pSelector).OrderBy(s => s.FldOrder); //NMI-REDO: this is the main bottleneck Function if (FormFields != null) { foreach (var tField in FormFields) { if (CheckHidePersmission(tField.PlatBag, pClientInfo)) { TheFieldInfo tFld = tField.Clone(); if (tFld.PlatBag.ContainsKey(eWebPlatform.Any)) { tFld.PropertyBag.MergeBag(tFld.PlatBag[eWebPlatform.Any], true, false); } if (tFld.PlatBag.ContainsKey(pClientInfo.WebPlatform)) { tFld.PropertyBag.MergeBag(tFld.PlatBag[pClientInfo.WebPlatform], true, false); } bool DeleteFld = false; if (tso != null) { var tfo = tso.Flds.Where(s => s.FldOrder == tFld.FldOrder); if (tfo != null && tfo.Count() > 0) { foreach (TheFLDOR tF in tfo) { if (tF.PO != null) { tFld.PropertyBag = tF.PO; } if (tF.NewFldOrder > 0) { tFld.FldOrder = tF.NewFldOrder; } else if (tF.NewFldOrder < 0) { DeleteFld = true; } } } } if (!DeleteFld) { tReturnLst.Add(tFld); //NEW in 4.1: All subscriptiosn here if (UpdateSubs) { var tThing = RegisterNMISubscription(pClientInfo, tFld.DataItem, tFld); if (tThing != null && (tFld.Type == eFieldType.FacePlate || tFld.Type == eFieldType.TileButton)) { var tsuc = TheNMIEngine.ParseFacePlateUrlInternal(tThing, ThePropertyBag.PropBagGetValue(tFld.PropertyBag, "HTMLUrl", "="), false, pClientInfo.NodeID); if (!tsuc) { TheNMIEngine.ParseFacePlateInternal(tThing, ThePropertyBag.PropBagGetValue(tFld.PropertyBag, "HTML", "="), pClientInfo.NodeID); } } } } } } } } catch (Exception e) { TheBaseAssets.MySYSLOG.WriteToLog(777, new TSM(eEngineName.NMIService, "Get Permitted fields failed", eMsgLevel.l1_Error, e.ToString())); } return(tReturnLst); }
public bool Init() { if (mIsInitCalled) { return(false); } mIsInitCalled = true; MyBaseThing.RegisterEvent(eEngineEvents.IncomingMessage, HandleMessage); if (TheThing.GetSafePropertyString(MyBaseThing, "VisitorCount") == "") { VisitorCount = 0; } MyNodePrintsName = $"NodePrints{TheThing.GetSafeThingGuid(MyBaseThing, "NodePrints")}"; TheBaseEngine.WaitForStorageReadiness(OnStorageReady, true); MyBaseThing.SetPublishThrottle(15000); TheCommCore.RegisterRelayEvents(null, null, sinkNewConnection); if (MyVisitorLog == null) { MyVisitorLog = new TheVisitorLog(MyBaseThing); } TheQueuedSenderRegistry.RegisterHealthTimer(GetSystemInfo); TheCDEngines.MyNMIService.RegisterEvent("NMI_MY_LOCATION", (sender2, para) => { var t = para as TheNMILocationInfo; if (t != null) { var NewEntry = new TheVisitorLogData { cdeN = t.cdeN, latitude = t.Latitude, longitude = t.Longitude, ip = t.ClientInfo?.UserID.ToString(), LastVisit = DateTimeOffset.Now, Description = t.ClientInfo != null && t.ClientInfo.UserID != Guid.Empty ? TheUserManager.GetUserFullName(t.ClientInfo.UserID) : "Unknown user" }; MyVisitorLog.LogVisitor(NewEntry); myGoogleMap?.SetUXProperty(Guid.Empty, $"AddMarker={TheCommonUtils.SerializeObjectToJSONString(NewEntry)}"); } }); TheCommCore.MyHttpService.RegisterHttpInterceptorB4("/cdemeshinfo.aspx", sinkRequestMeshInfo); MyBaseEngine.ProcessInitialized(); MyBaseEngine.SetEngineReadiness(true, null); MyBaseEngine.SetStatusLevel(1); mIsInitialized = true; return(true); }
internal TheUserDetails CloneToUser(Guid pUserID) { TheUserDetails tMinUser = TheUserManager.GetUserByID(pUserID); if (tMinUser == null) { return(null); } Guid pSessionID = tMinUser.CurrentSessionID; TheUserDetails tU = new TheUserDetails { ApplicationName = ApplicationName, AssignedEasyScope = AssignedEasyScope, //OK cdeAVA = cdeAVA, cdeCTIM = cdeCTIM, cdeMID = cdeMID, cdePRI = cdePRI, cdeO = cdeO, EMail = EMail, Name = Name, AccessMask = -1, HomeScreen = HomeScreen, IsReadOnly = IsReadOnly, LoginGesture = LoginGesture, HomeNode = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID, PrimaryDeviceID = PrimaryDeviceID, PrimaryRole = PrimaryRole, ThemeName = ThemeName, UserName = UserName, TeTo = TeTo, LCID = LCID, ShowClassic = ShowClassic, ShowToolTipsInTable = ShowToolTipsInTable, SpeakToasts = SpeakToasts, HomeNodeName = HomeNodeName }; if (string.IsNullOrEmpty(NodeScope) || NodeScope.ToUpper() == "THIS") { NodeScope = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID.ToString(); } tU.NodeScope = NodeScope; if (string.IsNullOrEmpty(HomeNodeName)) { HomeNodeName = TheBaseAssets.MyServiceHostInfo.MyStationName; } if (!string.IsNullOrEmpty(SecToken)) { string[] tSec = TheCommonUtils.cdeSplit(TheCommonUtils.cdeRSADecrypt(pSessionID, SecToken), ";:;", false, false); if ("CDE!" == tSec[0]) { for (int i = 1; i < tSec.Length; i++) { int tPos = tSec[i].IndexOf('='); if (tPos < 0) { continue; } int tFldNo = TheCommonUtils.CInt(tSec[i].Substring(0, tPos)); string tPara = tSec[i].Substring(tPos + 1); if (TheCommonUtils.IsNullOrWhiteSpace(tPara) || tPara == "null") { continue; } switch (tFldNo) { case 40: tU.EMail = tPara; break; case 20: //Name of User tU.Name = tPara; break; case 50: //Password tU.Password = TheBaseAssets.MySecrets.CreatePasswordHash(tPara); //PW-SECURITY-REVIEW: Create Hash Here break; case 56: //Pin if (string.IsNullOrEmpty(tU.TeTo)) { tU.TeTo = TheBaseAssets.MyScopeManager.GenerateCode(8); } tU.PinHash = TheBaseAssets.MySecrets.CreatePasswordHash($"{tU.TeTo.ToUpper()}@@{tPara}"); break; case 120: //HomeScreen if (tU.PrimaryRole != "NMIADMIN") //not allowed to set a HomeScreen for NMIAdmin { tU.HomeScreen = tPara; } break; case 110: //Language ID tU.LCID = TheCommonUtils.CInt(tPara); break; case 6: //Node Scope tU.NodeScope = tPara; break; case 70: //AccessMask tU.AccessMask = TheCommonUtils.CInt(tPara); break; } } } else { //Should no come here //tU.Password = tSec[0]; //PW-SECURITY-REVIEW: should contain hash // if (tSec.Length > 1) // tU.AssignedEasyScope = tSec[1]; //ok - not used at this point //if (tSec.Length > 2) // tU.AccessMask = TheCommonUtils.CInt(tSec[2]); } } else { tU.Password = TheBaseAssets.MySecrets.CreatePasswordHash(Password); //PW-SECURITY-REVIEW: should contain hash tU.AccessMask = AccessMask; } tU.SecToken = TheCommonUtils.cdeEncrypt(tU.Password + ";:;" + tU.AssignedEasyScope + ";:;" + tU.AccessMask, TheBaseAssets.MySecrets.GetAI()); //AES OK ; PW Should be Hash return(tU); }
/// <summary> /// Override to initalize the app with custom values but still call the base! /// </summary> /// <param name="pPlugInLst">List if ICDEPlugin instances</param> /// <param name="ArgList">Additional Parameters of the Application</param> /// <returns>True if all went well during startup</returns> public virtual bool StartBaseApplication2(List <ICDEPlugin> pPlugInLst, IDictionary <string, string> ArgList) { if (TheBaseAssets.MasterSwitch) { return(false); //SECURITY REVIEW: do not allow to call StartBaseApplication twice } TheBaseAssets.MasterSwitch = true; if (TheBaseAssets.MyServiceHostInfo == null) { TheBaseAssets.MasterSwitch = false; TheSystemMessageLog.ToCo("MyServiceHostInfo is not set! Exiting..."); //Will becalled because if MyServiceHostInfo==null TOCO will be called return(false); } if (TheBaseAssets.CryptoLoadMessage != null) { TheBaseAssets.MasterSwitch = false; TheSystemMessageLog.ToCo($"Security initialization failed with {TheBaseAssets.CryptoLoadMessage}. Exiting..."); return(false); } try { TheBaseAssets.IsStarting = true; //AppDomain.CurrentDomain.UnhandledException += MyUnhandledExceptionHandler; if (ArgList == null) { ArgList = new Dictionary <string, string>(); //DIC-Allowed! } if (!TheBaseAssets.MySettings.ReadAllAppSettings(ref ArgList)) { TheSystemMessageLog.ToCo("Not reading app.config: not supported by platform."); //Will never be called! } if (!TheBaseAssets.MasterSwitch) { return(false); } TheBaseAssets.MyCmdArgs = ArgList; //MyCmdArgs ONLY contains "public" settings coming from app.config or via the host MyUserManager = new TheUserManager(); TheBaseAssets.InitAssets(this); if (!TheBaseAssets.MasterSwitch) { return(false); } TheBaseAssets.MyScopeManager.RegisterScopeChanged(EventScopeChanged); TheBaseAssets.MySYSLOG.WriteToLog(4140, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("TheBaseApplication", "Assets and SystemLog Initialized", eMsgLevel.l3_ImportantMessage)); int minWorker = -1, minCompletionPort = -1, maxWorker = -1, maxCompletionPort = -1; try { System.Threading.ThreadPool.GetMinThreads(out minWorker, out minCompletionPort); System.Threading.ThreadPool.GetMaxThreads(out maxWorker, out maxCompletionPort); } catch { }; #if CDE_STANDARD var largeObjectHeapCompactionMode = System.Runtime.GCSettings.LargeObjectHeapCompactionMode; #else const string largeObjectHeapCompactionMode = "n/a"; #endif TheBaseAssets.MySYSLOG.WriteToLog(4144, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(eEngineName.ContentService, $"CLR Info", eMsgLevel.l4_Message, $"Server GC: {System.Runtime.GCSettings.IsServerGC}. GC Latency Mode: {System.Runtime.GCSettings.LatencyMode}. LOHC Mode: {largeObjectHeapCompactionMode}. Bitness: {System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr)) * 8}. Threads Min W/CP, Max W/CP: {minWorker}/{minCompletionPort},{maxWorker}/{maxCompletionPort}. GC TotalMemory: {GC.GetTotalMemory(false)}")); if (!TheBaseAssets.MyActivationManager.InitializeLicenses()) { Shutdown(true); TheBaseAssets.MySYSLOG.WriteToLog(4145, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("TheBaseApplication", "Licensing error", eMsgLevel.l3_ImportantMessage)); return(false); } //4.304: Workitem #2289 - Removed from OSS Release (as CheckLicense is always returning true in the CoreCrypto Lib if (!TheBaseAssets.MyActivationManager.CheckLicense(new Guid("{5737240C-AA66-417C-9B66-3919E18F9F4A}"), "", null, 1, false)) { if (TheBaseAssets.MyServiceHostInfo.ShutdownOnLicenseFailure) { TheBaseAssets.MySYSLOG.WriteToLog(4146, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("TheBaseApplication", "Licensing error: no activated license for Thing Service. Shutting down immediately as configured.", eMsgLevel.l2_Warning)); return(false); } else { TheBaseAssets.MySYSLOG.WriteToLog(4147, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("TheBaseApplication", "Licensing error: no activated license for Thing Service. Will shut down in 60 minutes if not activated.", eMsgLevel.l2_Warning)); TheCommonUtils.cdeRunAsync("LicenseCheck", true, (o) => { TheCommonUtils.TaskDelayOneEye(60 * 60 * 1000, 100).ContinueWith((t) => { if (TheBaseAssets.MasterSwitch) { if (!TheBaseAssets.MyActivationManager.CheckLicense(new Guid("{5737240C-AA66-417C-9B66-3919E18F9F4A}"), "", null, 1, false)) { TheBaseAssets.MySYSLOG.WriteToLog(4148, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("TheBaseApplication", "Licensing error: no activated license for Thing Service. Shutting down.", eMsgLevel.l1_Error)); if (TheBaseAssets.IsInAgentStartup) { MyISMRoot?.Restart(true); } else { Shutdown(true); } } } }); }); } } TheCommCore.MyHttpService = new TheHttpService(); TheBaseAssets.MySYSLOG.WriteToLog(4141, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("TheBaseApplication", "HttpService created", eMsgLevel.l3_ImportantMessage)); if (TheBaseAssets.MyServiceHostInfo.StartISM && MyISMRoot == null && !string.IsNullOrEmpty(TheBaseAssets.MyServiceHostInfo.BaseDirectory)) { MyISMRoot = new TheISMManager { eventShutdownRequired = sinkAppShutdown }; MyISMRoot.InitISM("", "", "", TheBaseAssets.MyServiceHostInfo.CurrentVersion, TheBaseAssets.MyServiceHostInfo.ISMScanForUpdatesOnUSB, TheBaseAssets.MyServiceHostInfo.ISMScanOnStartup); TheBaseAssets.MySYSLOG.WriteToLog(4142, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("TheBaseApplication", "ISM Started", eMsgLevel.l3_ImportantMessage)); } else { TheBaseAssets.MyServiceHostInfo.StartISM = false; } if (!TheBaseAssets.MasterSwitch) { return(false); } if (MyCommonDisco == null) { if (!TheBaseAssets.MyServiceHostInfo.IsIsolated && (TheCommonUtils.IsHostADevice() || TheBaseAssets.MyServiceHostInfo.cdeNodeType == cdeNodeType.Active)) { TheBaseAssets.MySettings.SetSetting("DISCO_IsClientOnly", "True"); } MyCommonDisco = new TheCommonDisco(); // Initialized the Discovery Service } TheCDEngines.eventAllEnginesStarted += sinkEnginesStarted; if (!TheCDEngines.StartEngines(pPlugInLst, null)) //Starts all SubEngines and Plugins. MyCmdArgs is a copy of the tParas sent to the Init Assets Function and can be used to set parameters for each engine during startup { Shutdown(true); TheBaseAssets.MySYSLOG.WriteToLog(4149, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("TheBaseApplication", "Failed to start engines", eMsgLevel.l3_ImportantMessage)); return(false); } return(true); } finally { TheBaseAssets.IsStarting = false; } }
public override bool Init() { if (mIsInitCalled) { return(false); } mIsInitCalled = true; MyBaseThing.StatusLevel = 4; string temp; TheBaseAssets.MyCmdArgs.TryGetValue("IsHealthCollectionOff", out temp); if (!string.IsNullOrEmpty(temp)) { IsHealthCollectionOff = TheCommonUtils.CBool(temp); } if (HealthCollectionCycle == 0) { TheBaseAssets.MyCmdArgs.TryGetValue("HealthCollectionCycle", out temp); if (!string.IsNullOrEmpty(temp)) { HealthCollectionCycle = TheCommonUtils.CInt(temp); } if (HealthCollectionCycle == 0) { HealthCollectionCycle = 15; } } if (SensorDelay == 0) { TheBaseAssets.MyCmdArgs.TryGetValue("SensorDelay", out temp); if (!string.IsNullOrEmpty(temp)) { SensorDelay = TheCommonUtils.CInt(temp); } if (SensorDelay == 0) { SensorDelay = 500; } } if (SensorAccelDeadband < 1) { TheBaseAssets.MyCmdArgs.TryGetValue("SensorAccelDeadband", out temp); if (!string.IsNullOrEmpty(temp)) { SensorAccelDeadband = TheCommonUtils.CDbl(temp); } if (SensorAccelDeadband < 0.1) { SensorAccelDeadband = 3.0; } } int tBS = (int)TheThing.GetSafePropertyNumber(MyBaseThing, "ChartValues"); if (tBS < 10) { tBS = 1000; TheThing.SetSafePropertyNumber(MyBaseThing, "ChartValues", tBS); } tBS = (int)TheThing.GetSafePropertyNumber(MyBaseThing, "ChartSize"); if (tBS < 6) { tBS = 18; TheThing.SetSafePropertyNumber(MyBaseThing, "ChartSize", tBS); } TheUserManager.RegisterNewRole(new TheUserRole(new Guid("{0A254170-D4D4-4B2D-9E05-D471729BE739}"), "ComputerManager", 1, new Guid("{3FB56264-9AA8-4AC9-9208-A01F1142B153}"), true, "Person allowed to view Computer Details")); MyBaseThing.RegisterEvent(eEngineEvents.IncomingMessage, HandleMessage); //Event when C-DEngine has new Telegram for this service as a subscriber (Client Side) MyBaseThing.RegisterEvent("FileReceived", sinkFileReceived); MyBaseThing.RegisterEvent(eEngineEvents.ShutdownEvent, sinkEngineShutdown); StartEngineServices(); if (MyBaseThing.StatusLevel == 4) { MyBaseThing.StatusLevel = 1; } mIsInitialized = true; return(true); }