Beispiel #1
0
        internal void UpdateProperties(HomeProperties theProperties)
        {
            bool RestartHostAPd = false;

            IEnumerable <PropertyInfo> Properties = typeof(HomeProperties).GetProperties().Where(Property => Property.IsDefined(typeof(Models.Attributes.FileName), false));

            foreach (PropertyInfo Property in Properties)
            {
                Models.Attributes.FileName FileNameAttribute = Property.GetCustomAttribute <Models.Attributes.FileName>();
                if (FileNameAttribute != null)
                {
                    string Old = Property.GetValue(this) as string;
                    string New = Property.GetValue(theProperties) as string;

                    if ((Old == null && New != null) || (!Old.Equals(New, StringComparison.Ordinal)))
                    {
                        Property.SetValue(this, New);
                        RestartHostAPd = true;
                    }
                }
            }

            Save();

            if (m_RunningLinux && HostAPdEnabled != theProperties.HostAPdEnabled)
            {
                Task <ProcessResult> StartHostAPd   = null;
                Task <ProcessResult> DisableHostAPd = null;

                if (theProperties.HostAPdEnabled)
                {
                    Task <ProcessResult> EnableHostAPd = ProcessRunner.GetProcessResultAsync(c_LinuxSystemControlCommand, "enable " + c_HostAPdCommand);
                    EnableHostAPd.Wait();

                    if (EnableHostAPd.Result.Okay())
                    {
                        StartHostAPd = ProcessRunner.GetProcessResultAsync(c_LinuxSystemControlCommand, "start " + c_HostAPdCommand);
                        StartHostAPd.Wait();
                    }
                }
                else
                {
                    Task <ProcessResult> StopTimesyncd = ProcessRunner.GetProcessResultAsync(c_LinuxSystemControlCommand, "stop " + c_HostAPdCommand);
                    StopTimesyncd.Wait();

                    if (StopTimesyncd.Result.Okay())
                    {
                        DisableHostAPd = ProcessRunner.GetProcessResultAsync(c_LinuxSystemControlCommand, "disable " + c_HostAPdCommand);
                        DisableHostAPd.Wait();
                    }
                }
            }
            else if (m_RunningLinux && HostAPdEnabled && RestartHostAPd)
            {
                Task <ProcessResult> Restart = ProcessRunner.GetProcessResultAsync(c_LinuxSystemControlCommand, "restart " + c_HostAPdCommand);
                Restart.Wait();
            }
        }
Beispiel #2
0
        public Response Post(HomeProperties thePostProperties)
        {
            Core.Instance.Home.UpdateProperties(thePostProperties);

            var Response = Get();

            Response.StatusCode = System.Net.HttpStatusCode.Created;

            return(Response);
        }