Beispiel #1
0
        public void PropertyTest_FillAll_ReadAll()
        {
            SystemSettings sys = new SystemSettings();
            sys.AssignmentsBasePath = "a";
            sys.NunitAssemblyPath = "b";
            sys.CscPath = "c";

            Assert.AreEqual("a", sys.AssignmentsBasePath);
            Assert.AreEqual("b", sys.NunitAssemblyPath);
            Assert.AreEqual("c", sys.CscPath);
        }
Beispiel #2
0
        public UCSmsSetting()
        {
            InitializeComponent();

            SetIcons();

            CheckSessionAccessList();

            DataLayer.BeginTransaction();
            this.Disposed += (x, y) => DataLayer.EndTransaction();

            _systemSettings = DataLayer.GetSystemSettings();
            srcItem.DataSource = _systemSettings;
        }
Beispiel #3
0
        /////////////////////////////////////////

        public static void EngineApp_AppCreateBefore()
        {
            //register [EngineConfig] fields, properties
            EngineConfig.RegisterClassParameters(typeof(SimulationApp));

            //creation settings

            if (!Fullscreen)
            {
                EngineApp.InitSettings.CreateWindowFullscreen = false;
            }
            if (VideoMode != Vector2I.Zero && (SystemSettings.VideoModeExists(VideoMode) || !Fullscreen))
            {
                EngineApp.InitSettings.CreateWindowSize = VideoMode;
                if (!Fullscreen)
                {
                    EngineApp.InitSettings.CreateWindowState = EngineApp.WindowStateEnum.Normal;
                }
            }
            if (!VerticalSync)
            {
                EngineSettings.Init.SimulationVSync = false;
            }

            //get from project settings
            {
                var windowStateString = ProjectSettings.ReadParameterFromFile("WindowState");
                if (!string.IsNullOrEmpty(windowStateString))
                {
                    if (Enum.TryParse <Component_ProjectSettings.WindowStateEnum>(windowStateString, out var windowState))
                    {
                        if (windowState != Component_ProjectSettings.WindowStateEnum.Auto)
                        {
                            switch (windowState)
                            {
                            case Component_ProjectSettings.WindowStateEnum.Normal:
                            {
                                EngineApp.InitSettings.CreateWindowFullscreen = false;
                                EngineApp.InitSettings.CreateWindowState      = EngineApp.WindowStateEnum.Normal;

                                var windowSizeString = ProjectSettings.ReadParameterFromFile("WindowSize", Component_ProjectSettings.WindowSizeDefault.ToString());
                                if (!string.IsNullOrEmpty(windowSizeString))
                                {
                                    try
                                    {
                                        EngineApp.InitSettings.CreateWindowSize = Vector2I.Parse(windowSizeString);
                                    }
                                    catch { }
                                }
                            }
                            break;

                            case Component_ProjectSettings.WindowStateEnum.Minimized:
                                EngineApp.InitSettings.CreateWindowFullscreen = false;
                                EngineApp.InitSettings.CreateWindowState      = EngineApp.WindowStateEnum.Minimized;
                                break;

                            case Component_ProjectSettings.WindowStateEnum.Maximized:
                                EngineApp.InitSettings.CreateWindowFullscreen = false;
                                EngineApp.InitSettings.CreateWindowState      = EngineApp.WindowStateEnum.Maximized;
                                break;

                            case Component_ProjectSettings.WindowStateEnum.Fullscreen:
                                EngineApp.InitSettings.CreateWindowFullscreen = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
        private static void CopyFiles(Assignment assignment, Submit submit, string teamSubmitDirName, SystemSettings systemSettings)
        {
            MoCS.BuildService.Business.FileSystemWrapper fileSystem = new Business.FileSystemWrapper();

            // Copy nunit.framework.dll to this directory
            fileSystem.FileCopy(Path.Combine(systemSettings.NunitAssemblyPath, "nunit.framework.dll"),
                                Path.Combine(teamSubmitDirName, "nunit.framework.dll"), true);

            //copy the file to this directory
            using (Stream target = fileSystem.FileOpenWrite(Path.Combine(teamSubmitDirName, submit.FileName)))
            {
                try
                {
                    target.Write(submit.Data, 0, submit.Data.Length);
                }
                finally
                {
                    target.Flush();
                }
            }


            // Copy the interface file
            //delete the file if it existed already
            AssignmentFile interfaceFile = assignment.AssignmentFiles.Find(af => af.Name == "InterfaceFile");

            fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, interfaceFile.FileName));

            fileSystem.FileCopy(Path.Combine(assignment.Path, interfaceFile.FileName),
                                Path.Combine(teamSubmitDirName, interfaceFile.FileName));

            //copy the server testfile
            //delete the file if it existed already
            AssignmentFile serverTestFile = assignment.AssignmentFiles.Find(af => af.Name == "NunitTestFileServer");

            fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, serverTestFile.FileName));

            fileSystem.FileCopy(Path.Combine(assignment.Path, serverTestFile.FileName),
                                Path.Combine(teamSubmitDirName, serverTestFile.FileName));

            //copy additional serverfiles
            List <AssignmentFile> serverFilesToCopy = assignment.AssignmentFiles.FindAll(af => af.Name == "ServerFileToCopy");

            foreach (AssignmentFile serverFileToCopy in serverFilesToCopy)
            {
                fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, serverFileToCopy.FileName));

                fileSystem.FileCopy(Path.Combine(assignment.Path, serverFileToCopy.FileName),
                                    Path.Combine(teamSubmitDirName, serverFileToCopy.FileName));
            }

            //copy the client testfile
            AssignmentFile clientTestFile = assignment.AssignmentFiles.Find(af => af.Name == "NunitTestFileClient");

            //delete the file if it existed already
            fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, clientTestFile.FileName));

            fileSystem.FileCopy(Path.Combine(assignment.Path, clientTestFile.FileName),
                                Path.Combine(teamSubmitDirName, clientTestFile.FileName));
        }
        public void ProcessPatches()
        {
            using (SecurityContext.OpenSystemScope())
            {
                var entMan = new EntityManager();
                var relMan = new EntityRelationManager();
                var recMan = new RecordManager();
                var storeSystemSettings = DbContext.Current.SettingsRepository.Read();
                var systemSettings      = new SystemSettings(storeSystemSettings);

                //Create transaction
                using (var connection = DbContext.Current.CreateConnection())
                {
                    try
                    {
                        connection.BeginTransaction();

                        //Here we need to initialize or update the environment based on the plugin requirements.
                        //The default place for the plugin data is the "plugin_data" entity -> the "data" text field, which is used to store stringified JSON
                        //containing the plugin settings or version

                        //TODO: Develop a way to check for installed plugins
                        #region << 1.Get the current ERP database version and checks for other plugin dependencies >>

                        if (systemSettings.Version > 0)
                        {
                            //Do something if database version is not what you expect
                        }

                        #endregion

                        #region << 2.Get the current plugin settings from the database >>

                        var currentPluginSettings = new PluginSettings()
                        {
                            Version = WEBVELLA_PROJECT_INIT_VERSION
                        };
                        string jsonData = GetPluginData();
                        if (!string.IsNullOrWhiteSpace(jsonData))
                        {
                            currentPluginSettings = JsonConvert.DeserializeObject <PluginSettings>(jsonData);
                        }

                        #endregion

                        #region << 3. Run methods based on the current installed version of the plugin >>

                        //Patch 20190203
                        {
                            var patchVersion = 20190203;
                            if (currentPluginSettings.Version < patchVersion)
                            {
                                try
                                {
                                    currentPluginSettings.Version = patchVersion;
                                    Patch20190203(entMan, relMan, recMan);
                                }
                                catch (ValidationException ex)
                                {
                                    var exception = ex;
                                    throw ex;
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }

                        //Patch 20190205
                        {
                            var patchVersion = 20190205;
                            if (currentPluginSettings.Version < patchVersion)
                            {
                                try
                                {
                                    currentPluginSettings.Version = patchVersion;
                                    Patch20190205(entMan, relMan, recMan);
                                }
                                catch (ValidationException ex)
                                {
                                    var exception = ex;
                                    throw ex;
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }

                        //Patch 20190206
                        {
                            var patchVersion = 20190206;
                            if (currentPluginSettings.Version < patchVersion)
                            {
                                try
                                {
                                    currentPluginSettings.Version = patchVersion;
                                    Patch20190206(entMan, relMan, recMan);
                                }
                                catch (ValidationException ex)
                                {
                                    var exception = ex;
                                    throw ex;
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }

                        //Patch 20190207
                        {
                            var patchVersion = 20190207;
                            if (currentPluginSettings.Version < patchVersion)
                            {
                                try
                                {
                                    currentPluginSettings.Version = patchVersion;
                                    Patch20190207(entMan, relMan, recMan);
                                }
                                catch (ValidationException ex)
                                {
                                    var exception = ex;
                                    throw ex;
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }

                        //Patch 20190208
                        {
                            var patchVersion = 20190208;
                            if (currentPluginSettings.Version < patchVersion)
                            {
                                try
                                {
                                    currentPluginSettings.Version = patchVersion;
                                    Patch20190208(entMan, relMan, recMan);
                                }
                                catch (ValidationException ex)
                                {
                                    var exception = ex;
                                    throw ex;
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }

                        //Patch 20190222
                        {
                            var patchVersion = 20190222;
                            if (currentPluginSettings.Version < patchVersion)
                            {
                                try
                                {
                                    currentPluginSettings.Version = patchVersion;
                                    Patch20190222(entMan, relMan, recMan);
                                }
                                catch (ValidationException ex)
                                {
                                    var exception = ex;
                                    throw ex;
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                        //Patch 20211012
                        {
                            var patchVersion = 20211012;
                            if (currentPluginSettings.Version < patchVersion)
                            {
                                try
                                {
                                    currentPluginSettings.Version = patchVersion;
                                    Patch20211012(entMan, relMan, recMan);
                                }
                                catch (ValidationException ex)
                                {
                                    var exception = ex;
                                    throw ex;
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                        //Patch 20211013
                        {
                            var patchVersion = 20211013;
                            if (currentPluginSettings.Version < patchVersion)
                            {
                                try
                                {
                                    currentPluginSettings.Version = patchVersion;
                                    Patch20211013(entMan, relMan, recMan);
                                }
                                catch (ValidationException ex)
                                {
                                    var exception = ex;
                                    throw ex;
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                        #endregion


                        SavePluginData(JsonConvert.SerializeObject(currentPluginSettings));

                        connection.CommitTransaction();
                        //connection.RollbackTransaction();
                    }
                    catch (ValidationException ex)
                    {
                        connection.RollbackTransaction();
                        throw ex;
                    }
                    catch (Exception)
                    {
                        connection.RollbackTransaction();
                        throw;
                    }
                }
            }
        }
 public Task SetSystemSettingsAsync(SystemSettings settings, UserCredentials userCredentials = null)
 {
     throw new NotImplementedException();
 }
 public CxWSBasicRepsonse SetSystemSettings(string sessionID, SystemSettings settings) {
     object[] results = this.Invoke("SetSystemSettings", new object[] {
                 sessionID,
                 settings});
     return ((CxWSBasicRepsonse)(results[0]));
 }
Beispiel #8
0
 public void ParseSystem(SystemSettings ss)
 {
     ss.Logging = (bool?) statedyn["system"]["logging"] ?? false;
 }
        static IEnumerable <ServerDataDataModel> MakeServerData(this ServerInfo info, SystemSettings settings)
        {
            Func <string, object, ServerDataDataModel> getModel = (name, value) =>
            {
                if (value == null)
                {
                    return(null);
                }

                return(new ServerDataDataModel()
                {
                    Identifier = Guid.NewGuid(),
                    DataKey = name,
                    Data = JsonConvert.SerializeObject(value),
                });
            };

            var serviceInfo = info.Services?.Where(s => settings.MonitoredServices.Contains(s.Name)).ToList();

            yield return(getModel("DetailedInfo", info.DetailedInfo));

            yield return(getModel("DiskInfo", info.DiskInfo));

            yield return(getModel("DriveInfo", info.DriveInfo));

            yield return(getModel("NetworkInfo", info.NetworkInfo));

            yield return(getModel("TopCpuProcesses", info.TopCpuProcesses));

            yield return(getModel("TopMemoryProcesses", info.TopMemoryProcesses));

            yield return(getModel("WebsiteInfo", info.WebsiteInfo));

            yield return(getModel("AppPoolInfo", info.AppPoolInfo));

            yield return(getModel("SqlServerInfo", info.SqlServerInfo));

            yield return(getModel("SqlDatabaseInfo", info.SqlDatabaseInfo));

            yield return(getModel("ServiceInfo", serviceInfo));

            yield return(getModel("PendingUpdateInfo", info.PendingUpdates));
        }
 public CxWSBasicRepsonse SetSystemSettings(string sessionID, SystemSettings settings)
 {
     CxWSBasicRepsonse result = _web_Service.SetSystemSettings(sessionID, settings);
     return result;
 }
 private void InitializeData()
 {
     DataLayer.BeginTransaction();
             _systemSettings = DataLayer.GetSystemSettings();
             srcItem.DataSource = _systemSettings;
 }
	// Use this for initialization
	void Start () {
		if (SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11")
				|| SystemInfo.operatingSystem.Contains("Mac"))
		{
			DeviceSupportsSharedTextures = true;
		}

		if (m_UISystem == null)
		{
			m_SystemListener = (SystemListenerFactoryFunc != null)? SystemListenerFactoryFunc(this.OnSystemReady) : new SystemListener(this.OnSystemReady);
			m_LogHandler = new UnityLogHandler();
			if (FileHandlerFactoryFunc != null)
			{
				m_FileHandler = FileHandlerFactoryFunc();
			}
			#if !UNITY_ANDROID || UNITY_EDITOR

			if (m_FileHandler == null)
			{
				Debug.LogWarning("Unable to create file handler using factory function! Falling back to default handler.");
				m_FileHandler = new UnityFileHandler();
			}
			#endif

			#if COHERENT_UNITY_STANDALONE || COHERENT_UNITY_UNSUPPORTED_PLATFORM
			SystemSettings settings = new SystemSettings() {
				HostDirectory = Path.Combine(Application.dataPath, this.HostDirectory),
				EnableProxy = this.EnableProxy,
				AllowCookies = this.AllowCookies,
				CookiesResource = "file:///" + Application.persistentDataPath + '/' + this.CookiesResource,
				CachePath = Path.Combine(Application.temporaryCachePath, this.CachePath),
				HTML5LocalStoragePath = Path.Combine(Application.temporaryCachePath, this.HTML5LocalStoragePath),
				ForceDisablePluginFullscreen = this.ForceDisablePluginFullscreen,
				DisableWebSecurity = this.DisableWebSecutiry,
				DebuggerPort = this.DebuggerPort,
			};
			int sdkVersion = Coherent.UI.Versioning.SDKVersion;
			#elif UNITY_IPHONE || UNITY_ANDROID
			SystemSettings settings = new SystemSettings() {
				iOS_UseURLCache = m_UseURLCache,
				iOS_URLMemoryCacheSize = (uint)m_MemoryCacheSize,
				iOS_URLDiskCacheSize = (uint)m_DiskCacheSize,
			};
			int sdkVersion = Coherent.UI.Mobile.Versioning.SDKVersion;
			#endif

			m_UISystem = CoherentUI_Native.InitializeUISystem(sdkVersion, Coherent.UI.License.COHERENT_KEY, settings, m_SystemListener, Severity.Info, m_LogHandler, m_FileHandler);
			if (m_UISystem == null)
			{
				throw new System.ApplicationException("UI System initialization failed!");
			}
			Debug.Log ("Coherent UI system initialized..");
			#if COHERENT_UNITY_STANDALONE
			CoherentUIViewRenderer.WakeRenderer();
			#endif
		}
		m_StartTime = Time.realtimeSinceStartup;

		DontDestroyOnLoad(this.gameObject);
	}
        /// <summary>
        /// Check the device temperatures against the threshold. 
        /// Send a warning email if temperature is too high.
        /// </summary>
        /// <param name="romID"></param>
        /// <param name="temperatureCelsius"></param>
        private bool TemperatureHasExceededThreshold(decimal temperatureCelsius, string romID)
        {
            decimal temperatureThreshold;
            bool result;

            // get the temperature threshold
            SystemSettings systemSettings = new SystemSettings(true);

            //Dictionary<string, DeviceSettings> deviceSettingsDictionary = systemSettings.DeviceSettingsDictionary;
            temperatureThreshold = systemSettings.GetDeviceSettingsByRomID(romID).TemperatureThreshold;

            result = temperatureCelsius > temperatureThreshold;

            return result;
        }
        /// <inheritdoc />      
        public SystemSettings SendSystemSettingsToUserInterface()
        {
            SystemSettings systemSettings = new SystemSettings(true);

            return systemSettings;
        }
 public override void WriteString(string key, string value)
 {
     SystemSettings.WriteString(LoginUser, key, value);
 }
 public Task SetSystemSettingsAsync(SystemSettings settings, UserCredentials userCredentials = null)
 {
     return AppendToStreamAsync(SystemStreams.SettingsStream, ExpectedVersion.Any, GetUserCredentials(_settings, userCredentials),
         new EventData(Guid.NewGuid(), SystemEventTypes.Settings, true, settings.ToJsonBytes(), null));
 }
 public static IEnumerable <ServerDataAgregateDataModel> ToServerAggregateData(this ServerInfo info, SystemSettings settings, DateTime nowUtc)
 {
     return(info.MakeServerAggregateData(settings, nowUtc).Where(s => s != null));
 }
Beispiel #18
0
 public void SetSystemSettings(SystemSettings systemSettings)
 {
     _systemSettings = systemSettings;
 }
        static IEnumerable <ServerDataAgregateDataModel> MakeServerAggregateData(this ServerInfo info, SystemSettings settings, DateTime nowUtc)
        {
            Func <string, string, ServerDataAgregateDataModel> getModel = (name, value) =>
            {
                if (value == null)
                {
                    return(null);
                }

                return(new ServerDataAgregateDataModel()
                {
                    Identifier = Guid.NewGuid(),
                    DataKey = name,
                    Data = value,
                });
            };


            if (info.DiskInfo != null)
            {
                yield return(getModel(
                                 "DiskInfo",
                                 info.DiskInfo.Any(di => di.PercentFree < 15) ? "Warning" : "OK"
                                 ));
            }

            if (info.DriveInfo != null)
            {
                yield return(getModel(
                                 "DriveInfo",
                                 info.DriveInfo.Any(di => !di.Status.Equals(DriveStatus.OK)) ? "Warning" : "OK"
                                 ));
            }

            if (info.WebsiteInfo != null)
            {
                yield return(getModel(
                                 "WebsiteCount",
                                 info.WebsiteInfo.Count.ToString()
                                 ));
            }

            if (info.WebsiteInfo != null)
            {
                yield return(getModel(
                                 "WebsiteStatus",
                                 info.WebsiteInfo.Where(wsi => wsi != null && String.Equals(wsi.State, "Started", StringComparison.InvariantCultureIgnoreCase)).Count() == info.WebsiteInfo.Where((wsi) => wsi != null).Count() ? "OK" : "Warning"
                                 ));
            }

            if (info.SqlServerInfo != null)
            {
                yield return(getModel(
                                 "SqlServerInfoStatus",
                                 info.SqlServerInfo.Where(ssi => ssi != null && ssi.Status == "OK").Count() == info.SqlServerInfo.Where(ssi => ssi != null).Count() ? "OK" : "Warning"
                                 ));
            }

            // TODO check if this should be utc? it just used "Now" in the original version
            if (info.SqlDatabaseInfo != null)
            {
                yield return(getModel(
                                 "SqlDatabaseInfoStatus",
                                 info.SqlDatabaseInfo.Where(sdi => sdi != null && !sdi.IsSystemObject && (nowUtc - sdi.LastBackupDate).TotalHours < 48).Count() == info.SqlDatabaseInfo.Where(sdi => sdi != null).Count() ? "OK" : "Warning"
                                 ));
            }

            if (info.Services != null)
            {
                yield return(getModel(
                                 "ServiceStatus",
                                 info.Services.Any(si => settings.MonitoredServices.Contains(si.Name) && si.State != "Running")
                   ? "Error"
                   : info.Services.Where(si => si != null && si.Status == "OK").Count() == info.Services.Where(si => si != null).Count()
                        ? "OK" : "Warning"
                                 ));
            }

            if (info.PendingUpdates != null)
            {
                yield return(getModel(
                                 "PendingUpdateCount",
                                 info.PendingUpdates.Count.ToString()
                                 ));
            }
        }
 /// <remarks/>
 public void SetSystemSettingsAsync(string sessionID, SystemSettings settings) {
     this.SetSystemSettingsAsync(sessionID, settings, null);
 }
        public ActionResult AddDocument(OrganisationViewModel ViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var          form = ViewModel.OrganisationDocumentForm;
                    Organisation o    = db.Organisations.Find(form.OrganisationId);
                    if (null == o)
                    {
                        ControllerMessage.Error(this, "Invalid form!");
                        return(RedirectToAction("index"));
                    }

                    DocumentType type = db.DocumentTypes.Find(form.DocumentType);
                    if (null == type)
                    {
                        ControllerMessage.Error(this, "Invalid form!");
                        return(RedirectToAction("index"));
                    }

                    string fileExtension = Path.GetExtension(form.File.FileName);
                    string fileName      = Utility.GenerateRandomString(DateTime.Now.Ticks.ToString()) + fileExtension;
                    // Check the extension to ensure compartibility
                    if (!type.DocumentFormat.Name.Equals(fileExtension.ToLower()))
                    {
                        ControllerMessage.Error(this, "Invalid file type! Please upload a document with " + type.DocumentFormat.Name + " format");
                        return(RedirectToAction("details", new { Id = form.OrganisationId }));
                    }

                    if (type.UploadSize < form.File.ContentLength)
                    {
                        ControllerMessage.Error(this, "The file should be less than " + type.UploadSize + "kb");
                        return(RedirectToAction("details", new { Id = form.OrganisationId }));
                    }

                    // Save the file to a location
                    var uploadPath = Server.MapPath(SystemSettings.GetStringValue("DocumentPath"));
                    form.File.SaveAs(uploadPath + fileName);

                    Document document = new Document
                    {
                        Id          = Guid.NewGuid(),
                        TypeId      = type.Id,
                        Name        = fileName,
                        Path        = fileName,
                        Size        = form.File.ContentLength,
                        CreatedBy   = User.Identity.Name,
                        CreatedDate = DateTime.Now
                    };

                    db.Documents.Add(document);
                    o.Documents.Add(document);

                    db.SaveChanges();
                    ControllerMessage.Success(this, "Document uploaded!");
                    return(RedirectToAction("details", new { Id = o.Id }));
                }

                ControllerMessage.Error(this, "Fill form properly!");
                return(RedirectToAction("details", new { Id = ViewModel.OrganisationDocumentForm.OrganisationId }));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                ControllerMessage.Error(this, "System Error");
                return(RedirectToAction("index"));
            }
        }
        /// <inheritdoc />              
        public SimpleHttpResponseMessage ReceiveSystemSettingsFromUserInterface(Stream postData)
        {
            string romId, friendlyName, username, password;
            int temperatureThreshold, counter;
            NameValueCollection postKeyValuePairs;
            SimpleHttpResponseMessage result;

            // assume that the save will be succesful, for now
            result = new SimpleHttpResponseMessage();
            result.Message = "success";

            // parse the application/x-www-form-urlencoded POST data into a collection
            postKeyValuePairs = ConvertPostStreamIntoNameValueCollection(postData);

            username = GetValueFromNameValueCollectionAndThenRemoveItToo(postKeyValuePairs, "username");
            password = GetValueFromNameValueCollectionAndThenRemoveItToo(postKeyValuePairs, "password");
            if (!UsernameAndPasswordAreCorrect(username, password))
            {
                result.Message = "unauthorized";
                return result;
            }

            // save the system wide settings, of which there are two
            SystemSettings systemSettings = new SystemSettings();
            systemSettings.DataStoreDurationInDays = Convert.ToInt32(GetValueFromNameValueCollectionAndThenRemoveItToo(postKeyValuePairs, "data-store-duration-in-days"));
            systemSettings.HoursThatMustPassBetweenSendingDeviceSpecificWarningEmails = Convert.ToInt32(GetValueFromNameValueCollectionAndThenRemoveItToo(postKeyValuePairs, "max-email-freq-in-hours"));
            systemSettings.WarningEmailRecipientsInCsv = GetValueFromNameValueCollectionAndThenRemoveItToo(postKeyValuePairs, "warning-email-recipients-csv");

            // instantiate empty variables in preparation for saving device specific settings
            romId = String.Empty;
            friendlyName = String.Empty;
            temperatureThreshold = Int32.MaxValue;

            // save the device specific settings, of which there are two for each device
            // a romId is the key for each device
            counter = 0;
            foreach (string key in postKeyValuePairs.AllKeys)
            {
                if (key.ToLowerInvariant().Contains("rom-id"))
                {
                    counter = 0;
                    romId = postKeyValuePairs[key];
                }
                else if (key.ToLowerInvariant().Contains("friendly-name"))
                {
                    ++counter;
                    friendlyName = postKeyValuePairs[key];
                }
                else if (key.ToLowerInvariant().Contains("temp-threshold"))
                {
                    ++counter;
                    temperatureThreshold = Convert.ToInt32(postKeyValuePairs[key]);
                }
                if (counter > 0 && counter % DeviceSettings.SYSTEM_SETTINGS_DEVICE_DATA_COUNT == 0)
                {
                    DeviceSettings deviceSettings = new DeviceSettings() { FriendlyName = friendlyName, TemperatureThreshold = temperatureThreshold };
                    if (systemSettings.DeviceSettingsDictionary.ContainsKey(romId))
                    {
                        systemSettings.DeviceSettingsDictionary[romId] = deviceSettings;
                    }
                    else
                    {
                        systemSettings.DeviceSettingsDictionary.Add(romId, new DeviceSettings() { FriendlyName = friendlyName, TemperatureThreshold = temperatureThreshold });
                    }
                }
            }

            systemSettings.Save();
            return result;
        }
        public string GetPendoOptions()
        {
            LoginUser    loginUser = TSAuthentication.GetLoginUser();
            User         user      = Users.GetUser(loginUser, TSAuthentication.UserID);
            Organization org       = Organizations.GetOrganization(loginUser, TSAuthentication.OrganizationID);
            SqlCommand   command;
            DataTable    table;

            dynamic result = new ExpandoObject();

            result.apiKey              = SystemSettings.ReadString(loginUser, "PendoKey", "NO API IN SYSTEMSETTINGS");
            result.usePendoAgentAPI    = false;
            result.visitor             = new ExpandoObject();
            result.visitor.id          = user.UserID;
            result.visitor.email       = user.Email;
            result.visitor.role        = user.Title;
            result.visitor.name        = user.FirstLastName;
            result.visitor.dateCreated = user.DateCreated;
            //result.visitor.lastLogin =
            result.visitor.isAdmin = user.IsSystemAdmin;

            command = new SqlCommand("SELECT COUNT(*) FROM Tickets WHERE OrganizationID = @OrganizationID AND UserID = @UserID");
            command.Parameters.AddWithValue("UserID", user.UserID);
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            result.visitor.assignedTickets = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            command = new SqlCommand("SELECT COUNT(*) FROM Tickets WHERE OrganizationID = @OrganizationID AND CreatorID = @UserID");
            command.Parameters.AddWithValue("UserID", user.UserID);
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            result.visitor.ticketsCreated = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            command = new SqlCommand("SELECT COUNT(*) FROM Actions WHERE CreatorID = @UserID");
            command.Parameters.AddWithValue("UserID", user.UserID);
            //result.visitor.actionsCreated = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            //result.visitor.groups =
            result.visitor.isChatUser = user.IsChatUser;

            result.account              = new ExpandoObject();
            result.account.id           = org.OrganizationID;
            result.account.name         = org.Name;
            result.account.planLevel    = org.UserSeats == 100 ? "Trial" : "Paying";
            result.account.creationDate = org.DateCreated;
            result.account.isActive     = org.IsActive;
            //result.account.lastLogin =
            result.account.seatCount  = org.UserSeats;
            result.account.apiEnabled = org.IsApiEnabled;
            command = new SqlCommand(
                @"SELECT COUNT(*) AS Cnt, TicketSource FROM Tickets 
                WHERE OrganizationID = @OrganizationID
                AND TicketSource IS NOT NULL
                AND TicketSource <> ''
                GROUP BY TicketSource
                ");
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            table = SqlExecutor.ExecuteQuery(loginUser, command);
            result.account.ticketsCreatedByEmail       = 0;
            result.account.ticketsCreatedByFaceBook    = 0;
            result.account.ticketsCreatedByAgent       = 0;
            result.account.ticketsCreatedByForum       = 0;
            result.account.ticketsCreatedByWeb         = 0;
            result.account.ticketsCreatedByChatOffline = 0;
            result.account.ticketsCreatedByMobile      = 0;
            result.account.ticketsCreatedByChat        = 0;

            foreach (DataRow row in table.Rows)
            {
                try
                {
                    switch (row[1].ToString().ToLower())
                    {
                    case "forum": result.account.ticketsCreatedByForum = (int)row[0]; break;

                    case "agent": result.account.ticketsCreatedByAgent = (int)row[0]; break;

                    case "web": result.account.ticketsCreatedByWeb = (int)row[0]; break;

                    case "facebook": result.account.ticketsCreatedByFaceBook = (int)row[0]; break;

                    case "chatoffline": result.account.ticketsCreatedByChatOffline = (int)row[0]; break;

                    case "mobile": result.account.ticketsCreatedByMobile = (int)row[0]; break;

                    case "email": result.account.ticketsCreatedByEmail = (int)row[0]; break;

                    case "chat": result.account.ticketsCreatedByChat = (int)row[0]; break;

                    default:
                        break;
                    }
                }
                catch (Exception)
                {
                }
            }

            command = new SqlCommand("SELECT COUNT(*) FROM Tickets WHERE OrganizationID = @OrganizationID AND IsKnowledgeBase = 1");
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            result.account.kbCount = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            command = new SqlCommand("SELECT COUNT(*) FROM Tickets WHERE OrganizationID = @OrganizationID");
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            result.account.ticketCount = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            command = new SqlCommand("SELECT COUNT(*) FROM Organizations WHERE ParentID = @OrganizationID");
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            result.account.customerCount = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            command = new SqlCommand("SELECT COUNT(*) FROM CustomFields WHERE OrganizationID = @OrganizationID");
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            result.account.customFieldCount = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            command = new SqlCommand("SELECT COUNT(*) FROM Users WHERE OrganizationID = @OrganizationID AND MarkDeleted = 0");
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            result.account.actualUsers = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            command = new SqlCommand("SELECT COUNT(*) FROM Users WHERE OrganizationID = @OrganizationID AND IsSystemAdmin = 1 AND MarkDeleted = 0");
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            result.account.adminCount = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            command = new SqlCommand("SELECT COUNT(*) FROM Imports WHERE OrganizationID = @OrganizationID");
            command.Parameters.AddWithValue("OrganizationID", org.OrganizationID);
            result.account.importCount = (int)SqlExecutor.ExecuteScalar(loginUser, command);

            result.account.podName     = SystemSettings.GetPodName();
            result.account.productType = org.ProductType.ToString();
            return(JsonConvert.SerializeObject(result));
        }
Beispiel #24
0
 public FilmeController(MemoryCacheWrapper memoryCache, IOptions <SystemSettings> systemSettings, IFilmeServico filmeDominio)
 {
     _memoryCache    = memoryCache;
     _systemSettings = systemSettings.Value;
     _filmeServico   = filmeDominio;
 }
Beispiel #25
0
        /// <summary>
        /// Handles the Click event of the btnDefault control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnDefault_Click(object sender, EventArgs e)
        {
            var bioBlock = BlockCache.Get(Rock.SystemGuid.Block.BIO.AsGuid());

            // Record an exception if the stock Bio block has been deleted but continue processing
            // the remaining settings.
            if (bioBlock == null)
            {
                var errorMessage = string.Format("Stock Bio block ({0}) is missing.", Rock.SystemGuid.Block.BIO);
                ExceptionLogService.LogException(new Exception(errorMessage));
            }
            else
            {
                List <Guid> workflowActionGuidList = bioBlock.GetAttributeValues("WorkflowActions").AsGuidList();
                if (workflowActionGuidList == null || workflowActionGuidList.Count == 0)
                {
                    // Add to Bio Workflow Actions
                    bioBlock.SetAttributeValue("WorkflowActions", Rock.SystemGuid.WorkflowType.PROTECTMYMINISTRY);
                    ///BackgroundCheckContainer.Instance.Components
                }
                else
                {
                    //var workflowActionValues = workflowActionValue.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ).ToList();
                    Guid guid = Rock.SystemGuid.WorkflowType.PROTECTMYMINISTRY.AsGuid();
                    if (!workflowActionGuidList.Any(w => w == guid))
                    {
                        // Add Checkr to Bio Workflow Actions
                        workflowActionGuidList.Add(guid);
                    }

                    // Remove PMM from Bio Workflow Actions
                    guid = CheckrSystemGuid.CHECKR_WORKFLOW_TYPE.AsGuid();
                    workflowActionGuidList.RemoveAll(w => w == guid);
                    bioBlock.SetAttributeValue("WorkflowActions", workflowActionGuidList.AsDelimited(","));
                }

                bioBlock.SaveAttributeValue("WorkflowActions");
            }

            string pmmTypeName  = (typeof(Rock.Security.BackgroundCheck.ProtectMyMinistry)).FullName;
            var    pmmComponent = BackgroundCheckContainer.Instance.Components.Values.FirstOrDefault(c => c.Value.TypeName == pmmTypeName);

            pmmComponent.Value.SetAttributeValue("Active", "True");
            pmmComponent.Value.SaveAttributeValue("Active");
            // Set as the default provider in the system setting
            SystemSettings.SetValue(Rock.SystemKey.SystemSetting.DEFAULT_BACKGROUND_CHECK_PROVIDER, pmmTypeName);

            using (var rockContext = new RockContext())
            {
                WorkflowTypeService workflowTypeService = new WorkflowTypeService(rockContext);
                // Rename PMM Workflow
                var pmmWorkflowAction = workflowTypeService.Get(Rock.SystemGuid.WorkflowType.PROTECTMYMINISTRY.AsGuid());
                pmmWorkflowAction.Name = "Background Check";

                var checkrWorkflowAction = workflowTypeService.Get(CheckrSystemGuid.CHECKR_WORKFLOW_TYPE.AsGuid());
                // Rename Checkr Workflow
                checkrWorkflowAction.Name = CheckrConstants.CHECKR_WORKFLOW_TYPE_NAME;

                rockContext.SaveChanges();

                // Enable PMM packages and disable Checkr packages
                DefinedValueService definedValueService = new DefinedValueService(rockContext);
                var packages = definedValueService
                               .GetByDefinedTypeGuid(Rock.SystemGuid.DefinedType.BACKGROUND_CHECK_TYPES.AsGuid())
                               .ToList();

                foreach (var package in packages)
                {
                    package.IsActive = package.ForeignId == 1;
                }

                rockContext.SaveChanges();
            }

            ShowDetail();
        }
Beispiel #26
0
 public DateTimeHelper(IDbService <EntityAttribute, EntityAttributeQuery> entityAttributeService, IDbSettingsService <SystemSettings> systemSettingsService, IWorkContext workContext, SystemSettings systemSettings)
 {
     _entityAttributeService = entityAttributeService;
     _systemSettingsService  = systemSettingsService;
     _workContext            = workContext;
     _systemSettings         = systemSettings;
 }
Beispiel #27
0
 public SudoerTemplate(SystemSettings sSettings, AppSettings settings) : base(sSettings, settings)
 {
 }
Beispiel #28
0
        public void Start(PluginStartArguments pluginStartArgs)
        {
            //initialize static context
            StaticContext.Initialize(pluginStartArgs.Plugin, pluginStartArgs.ServiceProvider);

            var entMan = new EntityManager();
            var relMan = new EntityRelationManager();
            var recMan = new RecordManager();
            var storeSystemSettings = DbContext.Current.SettingsRepository.Read();
            var systemSettings      = new SystemSettings(storeSystemSettings);

            using (SecurityContext.OpenSystemScope())
            {
                //Create transaction
                using (var connection = DbContext.Current.CreateConnection())
                {
                    try
                    {
                        connection.BeginTransaction();

                        //Here we need to initialize or update the environment based on the plugin requirements.
                        //The default place for the plugin data is the "plugin_data" entity -> the "data" text field, which is used to store stringified JSON
                        //containing the plugin settings or version

                        #region << 1.Get the current ERP database version and checks for other plugin dependencies >>
                        if (systemSettings.Version > 0)
                        {
                            //Do something if database version is not what you expect
                        }

                        //This plugin needs the webvella-crm plugin to be installed, so we will check this here
                        var installedPlugins = new PluginService().Plugins;
                        var crmPluginFound   = false;
                        foreach (var plugin in installedPlugins)
                        {
                            switch (plugin.Name)
                            {
                            case "webvella-crm":
                                crmPluginFound = true;
                                break;

                            default:
                                break;
                            }
                        }

                        if (!crmPluginFound)
                        {
                            throw new Exception("'webvella-crm' plugin is required for the 'webvella-project' to operate");
                        }

                        #endregion

                        #region << 2.Get the current plugin settings from the database >>
                        var         currentPluginSettings   = new PluginSettings();
                        QueryObject pluginDataQueryObject   = EntityQuery.QueryEQ("name", WEBVELLA_PROJECT_PLUGIN_NAME);
                        var         pluginDataQuery         = new EntityQuery("plugin_data", "*", pluginDataQueryObject);
                        var         pluginDataQueryResponse = recMan.Find(pluginDataQuery);
                        if (!pluginDataQueryResponse.Success)
                        {
                            throw new Exception("plugin 'webvella-project' failed to get its settings due to: " + pluginDataQueryResponse.Message);
                        }

                        if (pluginDataQueryResponse.Object == null || !pluginDataQueryResponse.Object.Data.Any() || pluginDataQueryResponse.Object.Data[0]["data"] == DBNull.Value)
                        {
                            //plugin was not installed
                            currentPluginSettings.Version = 20160429;
                            {
                                string json = JsonConvert.SerializeObject(currentPluginSettings);
                                var    settingsEntityRecord = new EntityRecord();
                                settingsEntityRecord["id"]   = WEBVELLA_PROJECT_PLUGIN_ID;
                                settingsEntityRecord["name"] = WEBVELLA_PROJECT_PLUGIN_NAME;
                                settingsEntityRecord["data"] = json;
                                var settingsSaveReponse = recMan.CreateRecord("plugin_data", settingsEntityRecord);
                                if (!settingsSaveReponse.Success)
                                {
                                    throw new Exception("plugin 'webvella-project' failed to save its settings in the database due to: " + pluginDataQueryResponse.Message);
                                }
                            }
                        }
                        else
                        {
                            string json = (string)((List <EntityRecord>)pluginDataQueryResponse.Object.Data)[0]["data"];
                            currentPluginSettings = JsonConvert.DeserializeObject <PluginSettings>(json);
                        }
                        #endregion

                        #region << 3. Run methods based on the current installed version of the plugin >>
                        if (currentPluginSettings.Version < 20160430)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160430;
                                Patch160430(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20160610)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160610;
                                Patch160610(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20160613)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160613;
                                Patch160613(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20160627)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160627;
                                Patch160627(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20160707)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160707;
                                Patch160707(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20161118)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20161118;
                                Patch161118(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20161119)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20161119;
                                Patch161119(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20170119)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20170119;
                                Patch170119(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20170328)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20170328;
                                Patch170328(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20170502)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20170502;
                                Patch20170502(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20180912)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20180912;
                                Patch20180912(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20180913)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20180913;
                                Patch20180913(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }

                        #endregion

                        #region << 4. Save needed changes to the plugin setting data >>
                        {
                            string json = JsonConvert.SerializeObject(currentPluginSettings);
                            var    settingsEntityRecord = new EntityRecord();
                            settingsEntityRecord["id"]   = WEBVELLA_PROJECT_PLUGIN_ID;
                            settingsEntityRecord["name"] = WEBVELLA_PROJECT_PLUGIN_NAME;
                            settingsEntityRecord["data"] = json;
                            var settingsUpdateReponse = recMan.UpdateRecord("plugin_data", settingsEntityRecord);
                            if (!settingsUpdateReponse.Success)
                            {
                                throw new Exception("plugin 'webvella-project' failed to update its settings in the database due to: " + pluginDataQueryResponse.Message);
                            }
                        }
                        #endregion


                        connection.CommitTransaction();
                    }
                    catch (Exception ex)
                    {
                        connection.RollbackTransaction();
                        throw ex;
                    }
                }

                StartupExtensions.SetSchedulePlans();
            }
        }
Beispiel #29
0
    public CxWSBasicRepsonse SetSystemSettings(string sessionID, SystemSettings settings)
    {
        CxWSBasicRepsonse result = _web_Service.SetSystemSettings(sessionID, settings);

        return(result);
    }
 public override string ReadString(string key, string defaultValue)
 {
     return(SystemSettings.ReadString(LoginUser, key, defaultValue));
 }
 private bool Equals(SystemSettings other)
 => Equals(UserStreamAcl, other.UserStreamAcl) && Equals(SystemStreamAcl, other.SystemStreamAcl);
 private void IsTemplate()
 {
     if (objOffer.IsTemplate && !DisabledAttribute)
     {
         RewardTemplateFieldContainer rc = ucTemplateLockableFields.RewardTemplateFieldSource;
         if (rc != null)
         {
             foreach (CMS.AMS.Models.TemplateField temp in rc.TemplateFieldList)
             {
                 if (temp.Tiered)
                 {
                     for (int i = 0, j = 0; i < objOffer.NumbersOfTier; i++)
                     {
                         if (temp.FieldName == "Message")
                         {
                             List <Language> lang = SystemSettings.GetAllActiveLanguages((Engines)objOffer.EngineID);
                             var             k    = 0;
                             foreach (Language lan in lang)
                             {
                                 var tt = (HtmlControl)this.FindControl(repProximityMsg.ID + "$ctl0" + j + "$" + "repProximityMsgDesc" + "$ctl0" + k + "$" + temp.ControlName);
                                 if (rc.DisallowEdit == true && temp.Editable)
                                 {
                                     tt.Style.Add("background", "#bfffff");
                                 }
                                 else if (!rc.DisallowEdit && !temp.Editable)
                                 {
                                     tt.Style.Add("background", "#ffdddd");
                                 }
                                 k++;
                             }
                         }
                         else
                         {
                             var t = (WebControl)this.FindControl(repProximityMsg.ID + "$ctl0" + j + "$" + temp.ControlName);
                             if (rc.DisallowEdit == true && temp.Editable)
                             {
                                 t.Style.Add("background-color", "#bfffff");
                             }
                             else if (!rc.DisallowEdit && !temp.Editable)
                             {
                                 t.Style.Add("background-color", "#ffdddd");
                             }
                         }
                         j += 1;
                     }
                 }
                 else
                 {
                     var t = (WebControl)this.FindControl(temp.ControlName);
                     if (rc.DisallowEdit == true && temp.Editable)
                     {
                         t.Style.Add("background-color", "#bfffff");
                     }
                     else if (!rc.DisallowEdit && !temp.Editable)
                     {
                         t.Style.Add("background-color", "#ffdddd");
                     }
                 }
             }
         }
     }
 }
 internal ServerReturnMessages(SystemSettings sysSettings, ServerReturnMessage delayedDeliveryWarning, ServerReturnMessage undelivered)
 {
     this.m_pSysSettings            = sysSettings;
     this.m_pDelayedDeliveryWarning = delayedDeliveryWarning;
     this.m_pUndelivered            = undelivered;
 }
Beispiel #34
0
        public void ProcessPatches()
        {
            using (SecurityContext.OpenSystemScope())
            {
                var entMan = new EntityManager();
                var relMan = new EntityRelationManager();
                var recMan = new RecordManager();
                var storeSystemSettings = DbContext.Current.SettingsRepository.Read();
                var systemSettings      = new SystemSettings(storeSystemSettings);

                //Create transaction
                using (var connection = DbContext.Current.CreateConnection())
                {
                    try
                    {
                        connection.BeginTransaction();

                        //Here we need to initialize or update the environment based on the plugin requirements.
                        //The default place for the plugin data is the "plugin_data" entity -> the "data" text field, which is used to store stringified JSON
                        //containing the plugin settings or version

                        //TODO: Develop a way to check for installed plugins
                        #region << 1.Get the current ERP database version and checks for other plugin dependencies >>

                        if (systemSettings.Version > 0)
                        {
                            //Do something if database version is not what you expect
                        }

                        //This plugin needs the webvella-sdk plugin to be installed, so we will check this here
                        //var installedPlugins = new PluginService().Plugins;
                        //var corePluginFound = false;
                        //foreach (var plugin in installedPlugins)
                        //{
                        //	if (plugin.Name == "webvella-core")
                        //	{
                        //		corePluginFound = true;
                        //		break;
                        //	}
                        //}

                        //if (!corePluginFound)
                        //	throw new Exception("'webvella-sdk' plugin is required for the 'webvella-sdk' to operate");

                        #endregion

                        #region << 2.Get the current plugin settings from the database >>

                        var currentPluginSettings = new PluginSettings()
                        {
                            Version = WEBVELLA_SDK_INIT_VERSION
                        };
                        string jsonData = GetPluginData();
                        if (!string.IsNullOrWhiteSpace(jsonData))
                        {
                            currentPluginSettings = JsonConvert.DeserializeObject <PluginSettings>(jsonData);
                        }

                        #endregion

                        #region << 3. Run methods based on the current installed version of the plugin >>

                        //this patch creates SDK application
                        //duplicate this IF for next patches
                        if (currentPluginSettings.Version < 20181215)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20181215;
                                Patch20181215(entMan, relMan, recMan);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        //this patch creates SDK application
                        //duplicate this IF for next patches
                        if (currentPluginSettings.Version < 20190227)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20190227;
                                Patch20190227(entMan, relMan, recMan);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20200610)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20200610;
                                Patch20200610(entMan, relMan, recMan);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        #endregion


                        SavePluginData(JsonConvert.SerializeObject(currentPluginSettings));

                        connection.CommitTransaction();
                        //connection.RollbackTransaction();
                    }
                    catch (Exception ex)
                    {
                        connection.RollbackTransaction();
                        throw ex;
                    }
                }
            }
        }
Beispiel #35
0
 /// <summary>
 /// Determines whether this instance is enabled.
 /// </summary>
 /// <returns>
 ///   <c>true</c> if this instance is enabled; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsEnabled()
 {
     return
         (SystemSettings.GetValue(SystemSetting.WEBFARM_IS_ENABLED).AsBooleanOrNull() ??
          DefaultValue.IsWebFarmEnabled);
 }
Beispiel #36
0
 public Task SetSystemSettingsAsync(SystemSettings settings, UserCredentials userCredentials = null)
 {
     return(AppendToStreamAsync(SystemStreams.SettingsStream, ExpectedVersion.Any, GetUserCredentials(_settings, userCredentials),
                                new EventData(Guid.NewGuid(), SystemEventTypes.Settings, true, settings.ToJsonBytes(), null)));
 }
 public StandardProductUsageServices(IConfigurationServices configurationServices)
 {
     ConfigurationServices = configurationServices;
     _userSettings         = ConfigurationServices.UserSettings.Get <UserSettings>();
     _systemSettings       = ConfigurationServices.SystemSettings.Get <SystemSettings>();
 }
Beispiel #38
0
 public DeleteGuestsScheduleTask(ICustomerService customerService, SystemSettings systemSettings)
 {
     _customerService = customerService;
     _systemSettings  = systemSettings;
 }
Beispiel #39
0
 private void WriteSystemSettings(XmlWriter w, SystemSettings s)
 {
     w.WriteElementString("drawerFont", s.drawerFont);
     w.WriteElementString("drawerDisableAntialiasing", (s.drawerDisableAntialiasing ? 1 : 0).ToString());
     w.WriteElementString("wavePartialCount", s.wavePartialCount.ToString());
 }
 /// <remarks/>
 public System.IAsyncResult BeginSetSystemSettings(string sessionID, SystemSettings settings, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("SetSystemSettings", new object[] {
                 sessionID,
                 settings}, callback, asyncState);
 }
Beispiel #41
0
        /// <summary>
        /// Processes the file at the given path.
        /// </summary>
        /// <param name="fileGroupID">The identifier for the file group to be processed.</param>
        /// <returns>False if the file was not able to be processed and needs to be processed again later.</returns>
        public bool ProcessFileGroup(int fileGroupID)
        {
            SystemSettings systemSettings;

            FileGroup fileGroup;
            DataFile  dataFile = null;

            List <MeterDataSet> meterDataSets;

            try
            {
                systemSettings = new SystemSettings(m_connectionString);

                using (AdoDataConnection connection = new AdoDataConnection("systemSettings"))
                {
                    // Create a file group for this file in the database
                    fileGroup = LoadFileGroup(connection, fileGroupID);

                    if ((object)fileGroup == null)
                    {
                        return(true);
                    }

                    dataFile = (new TableOperations <DataFile>(connection)).QueryRecordWhere("FileGroupID = {0}", fileGroupID);

                    if ((object)dataFile == null)
                    {
                        return(true);
                    }

                    // Parse the file
                    meterDataSets = LoadMeterDataSets(connection, fileGroup);

                    // Set properties on each of the meter data sets
                    foreach (MeterDataSet meterDataSet in meterDataSets)
                    {
                        meterDataSet.ConnectionString = m_connectionString;
                        meterDataSet.FilePath         = dataFile.FilePath;
                        meterDataSet.FileGroup        = fileGroup;
                    }

                    // Process meter data sets
                    OnStatusMessage("Processing meter data from file \"{0}\"...", dataFile.FilePath);
                    ProcessMeterDataSets(meterDataSets, systemSettings, connection);
                    OnStatusMessage("Finished processing data from file \"{0}\".", dataFile.FilePath);
                }
            }
            catch (Exception ex)
            {
                string message;

                if ((object)dataFile != null)
                {
                    message = string.Format("Failed to process file \"{0}\" due to exception: {1}", dataFile.FilePath, ex.Message);
                }
                else
                {
                    message = string.Format("Failed to process file group \"{0}\" due to exception: {1}", fileGroupID, ex.Message);
                }

                OnHandleException(new InvalidOperationException(message, ex));
            }

            return(true);
        }
 /// <remarks/>
 public void SetSystemSettingsAsync(string sessionID, SystemSettings settings, object userState) {
     if ((this.SetSystemSettingsOperationCompleted == null)) {
         this.SetSystemSettingsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetSystemSettingsOperationCompleted);
     }
     this.InvokeAsync("SetSystemSettings", new object[] {
                 sessionID,
                 settings}, this.SetSystemSettingsOperationCompleted, userState);
 }
Beispiel #43
0
 public void OnGet()
 {
     SystemSettings = _dataContext.Settings.Result;
 }
	// Use this for initialization
	void Start () {
		
		if(SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 11") || SystemInfo.operatingSystem.Contains("Mac"))
		{
			DeviceSupportsSharedTextures = true;
		}
		
		if (m_UISystem == null)
		{
			m_SystemListener = (SystemListenerFactoryFunc != null)? SystemListenerFactoryFunc(this.OnSystemReady) : new SystemListener(this.OnSystemReady);
			m_LogHandler = new UnityLogHandler();
			if (FileHandlerFactoryFunc != null)
			{
				m_FileHandler = FileHandlerFactoryFunc();
			}
			if (m_FileHandler == null)
			{
				Debug.LogWarning("Unable to create file handler using factory function! Falling back to default handler.");
				m_FileHandler = new UnityFileHandler();
			}
			
			#if UNITY_EDITOR || COHERENT_UNITY_STANDALONE
			SystemSettings settings = new SystemSettings() { 
				HostDirectory = Path.Combine(Application.dataPath, this.HostDirectory),
				EnableProxy = this.EnableProxy,
				AllowCookies = this.AllowCookies,
				CookiesResource = "file:///" + Application.persistentDataPath + '/' + this.CookiesResource,
				CachePath = Path.Combine(Application.temporaryCachePath, this.CachePath),
				HTML5LocalStoragePath = Path.Combine(Application.temporaryCachePath, this.HTML5LocalStoragePath),
				ForceDisablePluginFullscreen = this.ForceDisablePluginFullscreen,
				DisableWebSecurity = this.DisableWebSecutiry,
				DebuggerPort = this.DebuggerPort,
			};
			#elif UNITY_IPHONE
			SystemSettings settings = new SystemSettings() {
				
			};
			#endif
			if (string.IsNullOrEmpty(Coherent.UI.License.COHERENT_KEY))
			{
				throw new System.ApplicationException("You must supply a license key to start Coherent UI! Follow the instructions in the manual for editing the License.cs file.");
			}
			m_UISystem = CoherentUI_Native.InitializeUISystem(Coherent.UI.License.COHERENT_KEY, settings, m_SystemListener, Severity.Warning, m_LogHandler, m_FileHandler);
			if (m_UISystem == null)
			{
				throw new System.ApplicationException("UI System initialization failed!");
			}
			Debug.Log ("Coherent UI system initialized..");
		}
		
		DontDestroyOnLoad(this.gameObject);
	}
 public string GetMobileURL(int userID)
 {
     return(JsonConvert.SerializeObject(SystemSettings.GetMobileURL()));
 }