Пример #1
0
        /// <summary>
        ///
        /// </summary>
        public Models.Configuration CreateConfigurationData()
        {
            var result = new Models.Configuration();

            result.SearchPaths.AddRange(EphemerisPath.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
            return(result);
        }
        //
        // GET: /Configuration/
        public ActionResult Index()
        {
            var config = new Models.Configuration();
            var GeneralModel = new Models.ConfigurationModels.GeneralConfiguration();
            GeneralModel.EpgUpdateHour = config.EpgUpdateHour;
            GeneralModel.UpdateDvbEpgDuringLiveTv = config.UpdateDvbEpgDuringLiveTv;
            GeneralModel.LiveTvBufferDirectory = config.LiveTvBufferDirectory;
            GeneralModel.EnableUserSupport = config.EnableUserSupport;
            GeneralModel.UserBaseRecordingDirectory = config.UserBaseRecordingDirectory;

            var RecordingModel = new Models.ConfigurationModels.RecordingConfiguration();
            RecordingModel.AvoidDuplicateRecordings = config.AvoidDuplicateRecordings;
            RecordingModel.BlockShutDownWhileRecording = config.BlockShutDownWhileRecording;
            RecordingModel.PostPadding = config.PostPadding;
            RecordingModel.PrePadding = config.PrePadding;
            RecordingModel.RecurringMatch = config.RecurringMatch;
            RecordingModel.RecordingDirectories = Models.RecordingDirectory.LoadForUser(Globals.SHARED_USER_OID);

            var DevicesModel = new Models.ConfigurationModels.DevicesConfiguration();
            DevicesModel.Devices = Models.Device.LoadAll();
            DevicesModel.UseReverseOrderForLiveTv = config.UseReverseOrderForLiveTv;

            ViewBag.GeneralModel = GeneralModel;
            ViewBag.RecordingModel = RecordingModel;
            ViewBag.DevicesModel = DevicesModel;
            ViewBag.ChannelGroups = Models.ChannelGroup.LoadAll(Globals.SHARED_USER_OID, true);
            ViewBag.Channels = Models.Channel.LoadAll(Globals.SHARED_USER_OID, true);
            return View();
        }
Пример #3
0
        private void cbMpago_SelectedIndexChanged(object sender, EventArgs e)
        {
            Models.Configuration configuracion = new Models.Configuration();
            using (configuracion)
            {
                List <Models.Configuration> config = configuracion.getConfiguration();
                switch (cbMpago.Text)
                {
                case "Tarjeta de Debito":
                    double nuevo_total = deberia_ser + ((deberia_ser / 100) * config[0].Debito);
                    lbCobrar.Text = string.Format("{0:#,0.00}", nuevo_total);
                    calcula();
                    break;

                case "Tarjeta de Credito":

                    double nuevo_total2 = deberia_ser + ((deberia_ser / 100) * config[0].Credito);
                    lbCobrar.Text = string.Format("{0:#,0.00}", nuevo_total2);
                    calcula();
                    break;

                default:
                    lbCobrar.Text = string.Format("{0:#,0.00}", deberia_ser);
                    calcula();
                    break;
                }
            }
        }
Пример #4
0
 public static string GetConfigValueByKey(string keyName)
 {
     Models.Configuration config = SessionManager.CurrentSite.Configs.Where(_ => _.Key == keyName).FirstOrDefault();
     if (config != null)
     {
         return(config.Value);
     }
     return(string.Empty);
 }
Пример #5
0
 private void timbrar()
 {
     Models.Configuration configuracion = new Models.Configuration();
     using (configuracion)
     {
         List <Models.Configuration> config = configuracion.getConfiguration();
         //Instancias del timbrado
         Timbrado.StampSOAP selloSOAP = new Timbrado.StampSOAP();
         stamp         oStamp         = new stamp();
         stampResponse selloResponse  = new stampResponse();
         //Cargas tu archivo xml
         XmlDocument xmlDocument = new XmlDocument();
         xmlDocument.Load(config[0].Ruta_factura + txtFolio.Text + ".xml");
         //xmlDocument.Load(config[0].Ruta_factura + txtFolio.Text + ".xml");
         //Conviertes el archivo en byte
         byte[] byteXmlDocument = Encoding.UTF8.GetBytes(xmlDocument.OuterXml);
         //Conviertes el byte resultado en base64
         string stringByteXmlDocument = Convert.ToBase64String(byteXmlDocument);
         //Convirtes el resultado nuevamente a byte
         byteXmlDocument = Convert.FromBase64String(stringByteXmlDocument);
         //Timbras el archivo
         oStamp.xml      = byteXmlDocument;
         oStamp.username = "******";
         oStamp.password = "******";
         //Generamos request
         String usuario;
         usuario = Environment.UserName;
         String        url  = config[0].Ruta_factura;
         StreamWriter  XML  = new StreamWriter(url + "SOAP_Request.xml");             //Direccion donde guardaremos el SOAP Envelope
         XmlSerializer soap = new XmlSerializer(oStamp.GetType());                    //Obtenemos los datos del objeto oStamp que contiene los parámetros de envió y es de tipo stamp()
         soap.Serialize(XML, oStamp);
         XML.Close();
         //Recibes la respuesta de timbrado
         selloResponse = selloSOAP.stamp(oStamp);
         try
         {
             MessageBox.Show("No se timbro el XML" + "\nCódigo de error: " + selloResponse.stampResult.Incidencias[0].CodigoError.ToString() + "\nMensaje: " + selloResponse.stampResult.Incidencias[0].MensajeIncidencia);
         }
         catch (Exception)
         {
             MessageBox.Show(selloResponse.stampResult.CodEstatus.ToString());
             Models.Facturas factura = new Models.Facturas();
             using (factura)
             {
                 factura.Uuid  = selloResponse.stampResult.UUID.ToString();
                 factura.Folio = Convert.ToInt32(txtFolio.Text);
                 factura.Xml   = selloResponse.stampResult.xml.ToString();
                 factura.update_uuid();
             }
             StreamWriter XMLL = new StreamWriter(url + txtFolio.Text + ".xml");
             XMLL.Write(selloResponse.stampResult.xml);
             XMLL.Close();
             File.Delete(url + "SOAP_Request.xml");
         }
     }
 }
 public ActionResult Index(string SearchText)
 {
     var config = new Models.Configuration();
     var user = this.GetUser();
     ViewBag.UserOid = user.Oid;
     ViewBag.PrePadding = config.PrePadding;
     ViewBag.PostPadding = config.PostPadding;
     List<Models.SearchResult> results = Models.EpgListing.Search(user.Oid, SearchText);
     return View(results);
 }
Пример #7
0
 private void button12_Click(object sender, EventArgs e)
 {
     Models.Configuration configuracion = new Models.Configuration();
     using (configuracion)
     {
         configuracion.Id           = Id;
         configuracion.Iva_incluido = chkIva.Checked;
         configuracion.update_iva();
     }
     MessageBox.Show("Actualizacion exitosa");
 }
Пример #8
0
 private void button3_Click(object sender, EventArgs e)
 {
     Models.Configuration config = new Models.Configuration();
     using (config)
     {
         List <Models.Configuration> configuracion = config.getConfiguration();
         DataTable         dtbl = maketable();
         Models.Export_pdf pdf  = new Models.Export_pdf();
         pdf.ExportDatatablePdf(dtbl, configuracion[0].Ruta_reportes + "/Ganancias.pdf", "Ganancias");
         MessageBox.Show("Terminado");
     }
 }
Пример #9
0
        public IActionResult Index()
        {
            var resultado     = this.ConsumeService(null, "configuration", HttpMethod.Get);
            var configuration = new Models.Configuration();

            if (resultado.Response.IsSuccessStatusCode)
            {
                configuration = JsonConvert.DeserializeObject <Models.Configuration>(resultado.Result);
            }

            return(View(configuration));
        }
Пример #10
0
 private void button2_Click(object sender, EventArgs e)
 {
     Models.Configuration config = new Models.Configuration();
     using (config)
     {
         List <Models.Configuration> configuracion = config.getConfiguration();
         DataTable           dtbl  = maketable();
         Models.Export_excel excel = new Models.Export_excel();
         excel.ExportToExcel(dtbl, configuracion[0].Ruta_reportes + "/Ganancias");
         MessageBox.Show("Terminado");
     }
 }
Пример #11
0
 private void button4_Click(object sender, EventArgs e)
 {
     Models.Configuration config = new Models.Configuration();
     using (config)
     {
         List <Models.Configuration> configuracion = config.getConfiguration();
         DataTable           dtbl  = inventario_para();
         Models.Export_excel excel = new Models.Export_excel();
         excel.ExportToExcel(dtbl, configuracion[0].Ruta_reportes + "inv");
         MessageBox.Show("Terminado");
         OpenMicrosoftExcel(configuracion[0].Ruta_reportes + "inv.xlsx");
     }
 }
Пример #12
0
        public ImageWeb()
        {
            webClient = Communication.Client.GetInstance;
            webClient.RecivedMessageFromServer();
            Config1      = Configuration.GetInstance;
            NumberOfImgs = NumberOfImages();
            CommandRecievedEventArgs commanToSent = new CommandRecievedEventArgs((int)CommandStateEnum.GET_APP_CONFIG, new string[5], "");

            webClient.SendCommandToServer(commanToSent);
            List <Creator> student = InizilaizedCreator();

            Students = student;
        }
Пример #13
0
 public ActionResult EditConfiguration(Models.Configuration config)
 {
     if (ModelState.IsValid)
     {
         using (var db = new Models.LoJackal())
         {
             db.Entry(config).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Configurations"));
         }
     }
     return(View(config));
 }
Пример #14
0
        //
        // GET: /Guide/
        public ActionResult Index()
        {
            var config = new Models.Configuration();
            var user = this.GetUser();
            ViewBag.UserOid = user.Oid;

            ViewBag.RecordingDirectories = Models.RecordingDirectory.LoadForUser(user.Oid, true);
            ViewBag.Groups = Models.ChannelGroup.LoadAll(user.Oid).Where(x => x.Enabled).ToList();
            ViewBag.PrePadding = config.PrePadding;
            ViewBag.PostPadding = config.PostPadding;

            return View();
        }
Пример #15
0
        public ActionResult Index()
        {
            bool firstRun = false;
            try
            {
                firstRun = new Models.Configuration().FirstRun;
            }
            catch (Exception) { firstRun = true; }
            if (!firstRun)
                return RedirectToAction("Login", "Account");

            return View();
        }
Пример #16
0
        private void button11_Click(object sender, EventArgs e)
        {
            Models.Configuration configuracion = new Models.Configuration();
            using (configuracion)
            {
                configuracion.Id      = Id;
                configuracion.Credito = Convert.ToDouble(txtCredito.Text);
                configuracion.Debito  = Convert.ToDouble(txtDebito.Text);
                configuracion.updatecomisiones();
            }

            MessageBox.Show("Actualizacion exitosa");
        }
Пример #17
0
        public async Task SetInstrumentationApproval(bool accepted)
        {
            var acceptanceConfig = new Models.Configuration("Instrumentation", "UserApproved", "Approval", accepted);
            var foundConfig      = await this.configurationRepository.GetAsync(acceptanceConfig.Namespace, acceptanceConfig.Key);

            if (foundConfig != null)
            {
                await this.configurationRepository.UpdateAsync(acceptanceConfig.Namespace, acceptanceConfig.Key, acceptanceConfig);
            }
            else
            {
                await this.configurationRepository.AddAsync(acceptanceConfig);
            }
        }
Пример #18
0
 private void button4_Click(object sender, EventArgs e)
 {
     Models.Configuration config = new Models.Configuration();
     using (config)
     {
         config.Id    = Id;
         config.Serie = txtSerie.Text;
         config.Folio = Convert.ToInt16(txtFolio.Text);
         string ruta = txtRuta.Text;
         config.Ruta_factura = ruta.Replace("\\", "/");
         config.updateFactura();
     }
     MessageBox.Show("Actualización exitosa");
 }
        public CaptchaDialog(HttpHandler httpHandler, Action <string> updateStatus, Models.Configuration config)
        {
            Logger.Debug("Init. solving captcha...");

            Solution = new CaptchaSolution(false, "Something went wrong...", config.Captcha);

            _httpHandler = httpHandler;

            InitializeComponent();

            Config       = config;
            UpdateStatus = updateStatus;

            LoadCaptcha();
        }
Пример #20
0
        private void button8_Click(object sender, EventArgs e)
        {
            Models.Configuration config = new Models.Configuration();
            using (config)
            {
                config.Id                 = Id;
                config.Tipo_Impre         = Convert.ToInt16(chkticket.Checked);
                config.Impresora          = cbImpresora.SelectedValue.ToString();
                config.Impresora_reportes = cbImpreReportes.SelectedValue.ToString();
                config.Pie_ticket         = txtPieTicket.Text;
                config.updateImpresoras();
            }

            MessageBox.Show("Actualización exitosa");
        }
Пример #21
0
        private void button5_Click(object sender, EventArgs e)
        {
            Models.Configuration config = new Models.Configuration();
            using (config)
            {
                config.Id = Id;
                string logo        = txtLogo.Text;
                string logo_ticket = txtLogoTicket.Text;
                config.Logo        = logo.Replace("\\", "/");
                config.Logo_ticket = logo_ticket.Replace("\\", "/");
                config.updateLogo();
            }

            MessageBox.Show("Actualización exitosa");
        }
Пример #22
0
        public ActionResult UpdateGeneralSettings(Models.ConfigurationModels.GeneralSystem GeneralModel)
        {
            try
            {
                if (!ModelState.IsValid)
                    throw new ArgumentException();

                var config = new Models.Configuration();
                config.WebsiteAddress = GeneralModel.WebsiteAddress;
                config.Save();
                return Json(new { success = true });
            }
            catch (Exception ex)
            {
                return Json(new { _error = true, message = ex.Message });
            }
        }
Пример #23
0
        public async Task CanUpdateConfiguration()
        {
            var configurationEndpoint = new SezzleSharp.Endpoints.Configuration(SezzleConfig, AuthResponse);

            var configuration = new Models.Configuration()
            {
                WebhookUrl = "https://test.sezzle.com/orders-webhook"
            };

            var configurationResponse = await configurationEndpoint.Post(configuration);

            Assert.IsNotNull(configurationResponse);

            Console.WriteLine(JsonConvert.SerializeObject(configurationResponse, Formatting.Indented));

            Assert.AreEqual(HttpStatusCode.OK, configurationResponse.HttpStatusCode);
        }
Пример #24
0
        public ActionResult UpdateSmtpSettings(Models.ConfigurationModels.SmtpConfiguration Model)
        {
            if (!ModelState.IsValid)
                throw new ArgumentException();

            var config = new Models.Configuration();
            config.SmtpServer = Model.Server;
            config.SmtpPort = Model.Port;
            config.SmtpUsername = Model.Username;
            if(Model.Password != DummyPassword) // only update it if its not the dummy
                config.SmtpPassword = Helpers.Encrypter.Encrypt(Model.Password, Helpers.Encrypter.GetCpuId()); // TODO encrypt this
            config.SmtpUseSsl = Model.UseSsl;
            config.SmtpSender = Model.Sender;
            config.Save();

            return Json(new { success = true });
        }
Пример #25
0
 private void button3_Click(object sender, EventArgs e)
 {
     Models.Configuration config = new Models.Configuration(
         Id,
         txtRazon.Text,
         txtComercial.Text,
         txtRFC.Text,
         txtTelefono.Text,
         txtCalle.Text,
         txtExterior.Text,
         txtInterior.Text,
         txtColonia.Text,
         txtEstado.Text,
         txtPoblacion.Text,
         txtPais.Text,
         txtRegimen.Text,
         txtCp.Text,
         "",
         "",
         "",
         "",
         "",
         "",
         "",
         "",
         0,
         0,
         "",
         "",
         "",
         0,
         "",
         "",
         "",
         0,
         "",
         "",
         0, 0,
         true
         );
     using (config)
     {
         config.updateEmpresa();
     }
     MessageBox.Show("Actualización exitosa");
 }
Пример #26
0
        private void button6_Click(object sender, EventArgs e)
        {
            string strkey = txtKey.Text;
            string strcer = txtCer.Text;

            Models.Configuration config = new Models.Configuration();
            using (config)
            {
                config.Id   = Id;
                config.Key  = strkey.Replace("\\", "/");
                config.Cer  = strcer.Replace("\\", "/");
                config.Pass = txtContra.Text;
                config.updateCertified();
            }

            MessageBox.Show("Actualización exitosa");
        }
Пример #27
0
        public ActionResult Index()
        {
            var config = new Models.Configuration();
            var SmtpModel = new Models.ConfigurationModels.SmtpConfiguration();
            SmtpModel.Username = config.SmtpUsername;
            SmtpModel.Password = !String.IsNullOrWhiteSpace(config.SmtpPassword) ? DummyPassword : "";
            SmtpModel.Port = config.SmtpPort;
            SmtpModel.Server = config.SmtpServer;
            SmtpModel.UseSsl = config.SmtpUseSsl;
            SmtpModel.Sender = config.SmtpSender;
            ViewBag.SmtpModel = SmtpModel;

            var GeneralModel = new Models.ConfigurationModels.GeneralSystem();
            GeneralModel.WebsiteAddress = config.WebsiteAddress;
            ViewBag.GeneralModel = GeneralModel;

            return View();
        }
Пример #28
0
        private void button7_Click(object sender, EventArgs e)
        {
            Models.Configuration config = new Models.Configuration();
            using (config)
            {
                config.Id           = Id;
                config.Email        = txtEmail.Text;
                config.Contra_smtp  = txtPassEmail.Text;
                config.Proveedor    = cbProveedor.SelectedValue.ToString();
                config.Ssl          = Convert.ToInt16(chkSsl.Checked);
                config.Smtp_serv    = txtSmtp.Text;
                config.Smtp_Port    = Convert.ToInt16(txtSmtpPort.Text);
                config.Cuerpo_email = txtCuerpo.Text;
                config.updateEmail();
            }

            MessageBox.Show("Actualización exitosa");
        }
Пример #29
0
        /// <summary>
        /// At this time, Sezzle only allows configuration of the URL that we send our webhooks to.
        /// </summary>
        /// <remarks>
        ///     https://gateway.sezzle.com/v1/configuration
        /// </remarks>
        /// <returns></returns>
        public Task <ConfigurationResponse> Post(Models.Configuration configuration)
        {
            AssertIsAuthenticated();

            // TODO: In the event that a token is expired, we want to refresh the token
            AssertTokenExpired();

            var request = Request("", HttpMethod.Post);

            // TODO: Abstract the string payload convert into StringContent to an extension method
            var stringPayload = JsonConvert.SerializeObject(configuration, SezzleConfig.DefaultSerializerSettings);

            var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");

            request.Content = httpContent;

            return(Client.ExecuteAsync <ConfigurationResponse>(request));
        }
Пример #30
0
        private void button10_Click(object sender, EventArgs e)
        {
            if (txtRutas.Text != "")
            {
                Models.Configuration config = new Models.Configuration();
                using (config)
                {
                    config.Id = Id;
                    string ruta = txtRutas.Text;
                    config.Ruta_reportes = ruta.Replace("\\", "/");
                    config.update_reportes();
                }

                MessageBox.Show("Actualización exitosa");
            }
            else
            {
                MessageBox.Show("no puede guardar un campo vacio");
            }
        }
        public static TConfigs GetConfigs <TConfigs>()
            where TConfigs : ConfigSection
        {
            Models.Configuration cnfgEntity = null;
            var key = typeof(TConfigs).Name;

            using (var dbContext = new AARPDbContext())
            {
                cnfgEntity = dbContext.Configurations.FirstOrDefault(cfg => cfg.Key == key);
            }

            if (cnfgEntity != null)
            {
                return(JsonConvert.DeserializeObject <TConfigs>(cnfgEntity.Value));
            }
            else
            {
                return(Activator.CreateInstance <TConfigs>());
            }
        }
Пример #32
0
        private void imprimir()
        {
            printDocument1 = new PrintDocument();
            Models.Configuration configuracion = new Models.Configuration();
            int cuantos   = dtProductos.RowCount;
            int faltantes = 0;
            int valor;

            using (configuracion)
            {
                faltantes = cuantos - 1;
                valor     = 110 * faltantes;
                valor     = valor + 1150;
                PaperSize ps = new PaperSize("Custom", 300, valor);
                List <Models.Configuration> config = configuracion.getConfiguration();
                printDocument1.DefaultPageSettings.PaperSize = ps;
                printDocument1.PrinterSettings.PrinterName   = config[0].Impresora;
                printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
                printDocument1.Print();
            }
        }
Пример #33
0
        public ReCaptchaDialog(Models.Configuration configuration, Models.ProxyItem proxy)
        {
            Configuration = configuration;
            Solution      = new CaptchaSolution(false, Solution.Message, configuration.Captcha);
            InitializeComponent();

            if ((proxy?.Enabled ?? false))
            {
                GeckoPreferences.Default["network.proxy.type"] = 1;

                // clear proxies
                GeckoSetProxy(Enums.ProxyType.Http, "", 0);
                GeckoSetProxy(Enums.ProxyType.Socks4, "", 0);

                GeckoSetProxy(proxy.ProxyType, proxy.Host, proxy.Port);
            }
            else
            {
                GeckoPreferences.Default["network.proxy.type"] = 0;
            }
        }
Пример #34
0
        public IEnumerable<Models.DriveUsage> GetDriveStatistics()
        {
            var config = new Models.Configuration();

            Dictionary<char, Models.DriveUsage> drives = new Dictionary<char, Models.DriveUsage>();

            // add live tv buffer
            string liveTvBufferDir = config.LiveTvBufferDirectory;
            var liveTvDriveInfo = new System.IO.DriveInfo(liveTvBufferDir.Substring(0, 1));
            drives.Add((char)1, new Models.DriveUsage()
            {
                Name = "Live TV Buffer",
                Size = liveTvDriveInfo.TotalSize,
                FreeSpace = liveTvDriveInfo.TotalFreeSpace,
                Used = liveTvDriveInfo.TotalSize - liveTvDriveInfo.TotalFreeSpace,
                RecordingsSize = Size(new System.IO.DirectoryInfo(liveTvBufferDir))
            });

            foreach (var rd in Models.RecordingDirectory.LoadForUser(GetUser().Oid, true))
            {
                if (Regex.IsMatch(rd.Path, @"^[c-zC-Z]:\\"))
                {
                    char drive = rd.Path[0];
                    if (!drives.ContainsKey(drive))
                    {
                        var driveInfo = new System.IO.DriveInfo(drive.ToString());
                        drives.Add(drive, new Models.DriveUsage()
                        {
                            Name = drive.ToString().ToUpper() + " Drive Recordings",
                            Size = driveInfo.TotalSize,
                            FreeSpace = driveInfo.TotalFreeSpace,
                            Used = driveInfo.TotalSize - driveInfo.TotalFreeSpace
                        });
                    }
                    drives[drive].RecordingsSize += Size(new System.IO.DirectoryInfo(rd.Path));
                }
            }
            return drives.Values;
        }
Пример #35
0
        public Models.EpgListing EpgListing(int Oid)
        {
            var user = this.GetUser();
            var epgEvent = NUtility.EPGEvent.LoadByOID(Oid);
            var channel = Models.Channel.Load(epgEvent.ChannelOID, user.Oid);
            var config = new Models.Configuration();

            var eventEpgRecodingData = Models.EpgRecordingData.LoadForEpgEventOid(user.Oid, Oid);

            return new Models.EpgListing(epgEvent)
            {
                ChannelName = channel.Name,
                ChannelNumber = channel.Number,
                PrePadding = eventEpgRecodingData == null ? config.PrePadding : eventEpgRecodingData.PrePadding,
                PostPadding = eventEpgRecodingData == null ? config.PostPadding : eventEpgRecodingData.PostPadding,
                RecordingDirectoryId = eventEpgRecodingData == null ? user.DefaultRecordingDirectoryDirectoryId : eventEpgRecodingData.RecordingDirectoryId,
                IsRecurring = eventEpgRecodingData != null && eventEpgRecodingData.IsRecurring,
                IsRecording = eventEpgRecodingData != null && eventEpgRecodingData.RecordingOid > 0,
                RecordingOid = eventEpgRecodingData != null ? eventEpgRecodingData.RecordingOid : 0,
                RecurrenceOid = eventEpgRecodingData != null ? eventEpgRecodingData.RecurrenceOid : 0
            };
        }
        public async Task <Models.Configuration> Get()
        {
            var    items = new Models.Configuration();
            string uri   = "http://" + PATHSERVER + "/tshirt/Configuration/GetAll";

            try
            {
                var result = await client.GetAsync(uri);

                if (result.IsSuccessStatusCode)
                {
                    var content = await result.Content.ReadAsStringAsync();

                    items = JsonConvert.DeserializeObject <Models.Configuration>(content);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
            }
            return(items);
        }
Пример #37
0
 public ConfigurationManager()
 {
     Current = new Models.Configuration()
     {
         StreamReadConfigurations = new ObservableCollection <StreamReadConfig>()
         {
             new StreamReadConfig()
             {
                 Stream = MavLink.MavDataStream.ExtendedStatus, UpdateHz = 2
             },
             new StreamReadConfig()
             {
                 Stream = MavLink.MavDataStream.Position, UpdateHz = 2
             },
             new StreamReadConfig()
             {
                 Stream = MavLink.MavDataStream.Extra1, UpdateHz = 4
             },
             new StreamReadConfig()
             {
                 Stream = MavLink.MavDataStream.Extra2, UpdateHz = 4
             },
             new StreamReadConfig()
             {
                 Stream = MavLink.MavDataStream.Extra3, UpdateHz = 4
             },
             new StreamReadConfig()
             {
                 Stream = MavLink.MavDataStream.RawSensors, UpdateHz = 4
             },
             new StreamReadConfig()
             {
                 Stream = MavLink.MavDataStream.RcChannels, UpdateHz = 2
             },
         }
     };
 }
Пример #38
0
        protected override async Task OnInitializedAsync()
        {
            _config = await manageConfig.GetConfigAsync();

            head.Title = "Configuration | Administration";
        }
Пример #39
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!Data.Utilities.Questions.ContainsKey(Account.Question))
            {
                return(RedirectToPage("Error"));
            }

            if (await _context.Accounts.FirstOrDefaultAsync(x => x.Email == Account.Email) != null)
            {
                ModelState.AddModelError("Account.Email", "An account with this email already exists.");
            }

            if (!ModelState.IsValid)
            {
                Configuration = await _context.Configurations.FirstOrDefaultAsync(x => x.Id == 1);

                return(Page());
            }

            byte[] salt = new byte[128 / 8];

            using (RandomNumberGenerator random = RandomNumberGenerator.Create())
            {
                random.GetBytes(salt);
            }

            byte[] password = KeyDerivation.Pbkdf2(
                password: Account.Password,
                salt: salt,
                prf: KeyDerivationPrf.HMACSHA1,
                iterationCount: 10000,
                numBytesRequested: 256 / 8
                );

            byte[] answer = KeyDerivation.Pbkdf2(
                password: Account.Answer,
                salt: salt,
                prf: KeyDerivationPrf.HMACSHA1,
                iterationCount: 10000,
                numBytesRequested: 256 / 8
                );

            if (HttpContext.Session.Get("isAdmin") == null || !BitConverter.ToBoolean(HttpContext.Session.Get("isAdmin")))
            {
                Account.IsAdmin = false;
            }

            Models.Account account = new Models.Account()
            {
                Email    = Account.Email,
                Password = Convert.ToBase64String(password),
                Question = Account.Question,
                Answer   = Convert.ToBase64String(answer),
                Salt     = Convert.ToBase64String(salt),
                IsAdmin  = Account.IsAdmin,
                Date     = DateTime.Now
            };

            _context.Accounts.Add(account);
            await _context.SaveChangesAsync();

            if (HttpContext.Session.Get("isAdmin") != null && BitConverter.ToBoolean(HttpContext.Session.Get("isAdmin")))
            {
                return(RedirectToPage("Accounts"));
            }

            HttpContext.Session.SetInt32("id", account.Id);
            HttpContext.Session.Set("isAdmin", BitConverter.GetBytes(account.IsAdmin));
            return(RedirectToPage("Index"));
        }
        private ActionResult SaveConfig(object PartialModel)
        {
            if (!ModelState.IsValid)
            {
                List<string> errors = new List<string>();
                foreach (var t in ModelState.Values)
                    errors.AddRange(t.Errors.Where(x => !String.IsNullOrWhiteSpace(x.ErrorMessage)).Select(x => x.ErrorMessage));
                throw new HttpException((int)HttpStatusCode.BadRequest, String.Join(Environment.NewLine, errors.ToArray()));
            }

            var config = new Models.Configuration();
            foreach(var property in PartialModel.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.SetProperty))
            {
                var configProperty = config.GetType().GetProperty(property.Name);
                if(configProperty != null)
                    configProperty.SetValue(config, property.GetValue(PartialModel, null), null);
            }
            config.Save();

            return Json(new { success = true });
        }
        public ActionResult UpdateRecording(Models.ConfigurationModels.RecordingConfiguration ModelRecording)
        {
            try
            {
                // save recording directories
                if (ModelRecording.RecordingDirectories == null || ModelRecording.RecordingDirectories.Count == 0)
                    throw new Exception("At least one recording directory is required.");

                // check base user recording directory isnt in a shared directory
                var config = new Models.Configuration();
                if (!String.IsNullOrWhiteSpace(config.UserBaseRecordingDirectory))
                {
                    string basePath = config.UserBaseRecordingDirectory.ToLower();
                    if (basePath.EndsWith(@"\"))
                        basePath = basePath.Substring(0, basePath.Length - 1);
                    foreach (var rd in ModelRecording.RecordingDirectories)
                    {
                        string rdPath = rd.Path.ToLower();
                        if (rdPath.EndsWith(@"\"))
                            rdPath = rdPath.Substring(0, rdPath.Length - 1);

                        if (basePath.StartsWith(rdPath))
                            throw new Exception("Cannot crete a Shared Recording Directory that contains the User Recording Directory.");
                    }
                }

                if (ModelState.IsValid && !Models.RecordingDirectory.SaveForUser(Globals.SHARED_USER_OID, ModelRecording.RecordingDirectories))
                    throw new Exception("Failed to save recording directories.");
                return SaveConfig(ModelRecording);
            }
            catch (Exception ex)
            {
                return Json(new { _error = true, message = ex.Message });
            }
        }
        internal bool Save(int UserOid)
        {
            var original = NUtility.RecurringRecording.LoadByOID(this.Oid);

            var config = new Models.Configuration();
            if (config.EnableUserSupport)
            {
                var recordingDirectories = RecordingDirectory.LoadForUserAsDictionaryIndexedByDirectoryId(UserOid, true);
                // make sure this user has access to the original
                if (!String.IsNullOrWhiteSpace(original.RecordingDirectoryID) && !recordingDirectories.ContainsKey(original.RecordingDirectoryID))
                    throw new UnauthorizedAccessException();
            }

            original.PostPadding = this.PostPadding;
            original.PrePadding = this.PrePadding;
            original.RecordingDirectoryID = this.RecordingDirectoryId;
            original.Keep = this.Keep;
            switch (this.Type)
            {
                case RecordingType.Record_Season_New_This_Channel:
                    {
                        original.OnlyNewEpisodes = true;
                        original.Timeslot = false;
                        original.DayMask = NUtility.DayMask.ANY;
                    }
                    break;
                case RecordingType.Record_Season_All_This_Channel:
                    {
                        original.OnlyNewEpisodes = false;
                        original.Timeslot = false;
                        original.DayMask = NUtility.DayMask.ANY;
                    }
                    break;
                case RecordingType.Record_Season_Daily_This_Timeslot:
                    {
                        original.OnlyNewEpisodes = false;
                        original.Timeslot = true;
                        original.DayMask = NUtility.DayMask.ANY;
                    }
                    break;
                case RecordingType.Record_Season_Weekly_This_Timeslot:
                    {
                        original.OnlyNewEpisodes = false;
                        original.Timeslot = true;
                        // need to work out day its on...
                        switch (StartTime.DayOfWeek)
                        {
                            case DayOfWeek.Sunday: original.DayMask = NUtility.DayMask.SUNDAY; break;
                            case DayOfWeek.Monday: original.DayMask = NUtility.DayMask.MONDAY; break;
                            case DayOfWeek.Tuesday: original.DayMask = NUtility.DayMask.TUESDAY; break;
                            case DayOfWeek.Wednesday: original.DayMask = NUtility.DayMask.WEDNESDAY; break;
                            case DayOfWeek.Thursday: original.DayMask = NUtility.DayMask.THURSDAY; break;
                            case DayOfWeek.Friday: original.DayMask = NUtility.DayMask.FRIDAY; break;
                            case DayOfWeek.Saturday: original.DayMask = NUtility.DayMask.SATURDAY; break;
                        }
                    }
                    break;
                case RecordingType.Record_Season_Weekdays_This_Timeslot:
                    {
                        original.OnlyNewEpisodes = false;
                        original.Timeslot = true;
                        original.DayMask = NUtility.DayMask.MONDAY | NUtility.DayMask.TUESDAY | NUtility.DayMask.WEDNESDAY | NUtility.DayMask.THURSDAY | NUtility.DayMask.FRIDAY;
                    }
                    break;
                case RecordingType.Record_Season_Weekends_This_Timeslot:
                    {
                        original.OnlyNewEpisodes = false;
                        original.Timeslot = true;
                        original.DayMask = NUtility.DayMask.SATURDAY | NUtility.DayMask.SUNDAY;
                    }
                    break;
                case RecordingType.Record_Season_All_Episodes_All_Channels:
                    {
                        original.OnlyNewEpisodes = false;
                        original.Timeslot = false;
                        original.DayMask = NUtility.DayMask.ANY;
                        original.Channel = null;
                    }
                    break;
            }

            original.Save();
            return true;
        }
 public override void Startup()
 {
     base.Startup();
     NextPvrWebConsole.Models.Configuration config = new Models.Configuration();
     config.UserBaseRecordingDirectory = @"C:\temp";
     config.Save();
 }
Пример #44
0
        public static bool DeleteByOid(int UserOid, int Oid)
        {
            var recording = Helpers.NpvrCoreHelper.ScheduledRecordingLoadByOID(Oid);
            if (recording == null)
                throw new Exception("Failed to locate recording.");

            var config = new Models.Configuration();
            if (config.EnableUserSupport)
            {
                // check they have access to delete this
                bool canDelete = true;
                var recordingDirectories = Models.RecordingDirectory.LoadForUserAsDictionaryIndexedByDirectoryId(UserOid, true);
                if (!String.IsNullOrWhiteSpace(recording.Filename))
                {
                    string path = new System.IO.FileInfo(recording.Filename).Directory.Parent.FullName.ToLower();
                    if (recordingDirectories.ContainsKey(path))
                        canDelete = false;
                }
                else
                {
                    // check for a recurring instance
                    if (recording.RecurrenceOID == 0)
                        canDelete = true; // this means a future recording that will be in the default directory (i.e. the master shared directory everyone can access)
                    else
                    {
                        var recurrenceDirs = Models.RecordingDirectory.LoadForUserAsDictionaryIndexedByDirectoryId(UserOid, true);
                        var recurrence = NUtility.RecurringRecording.LoadByOID(recording.RecurrenceOID);
                        if (!String.IsNullOrWhiteSpace(recurrence.RecordingDirectoryID) && !recurrenceDirs.ContainsKey(recurrence.RecordingDirectoryID))
                            canDelete = false;
                    }
                }

                if (!canDelete)
                    throw new UnauthorizedAccessException();
            }

            Helpers.NpvrCoreHelper.DeleteRecording(recording);
            Hubs.NextPvrEventHub.Clients_ShowInfoMessage("Deleted recording: " + recording.Name, "Recording Deleted");

            return true;
        }