Exemple #1
0
        public int GetNextPort()
        {
            var lastPort = new PortEntity();
            var nextPort = new PortEntity();

            lastPort =
                _uow.PortRepository.GetFirstOrDefault(orderBy: q => q.OrderByDescending(p => p.Id));

            if (lastPort == null)
            {
                nextPort.Number = Convert.ToInt32(SettingServices.GetSettingValue(SettingStrings.StartPort));
            }
            else if (nextPort.Number >= Convert.ToInt32(SettingServices.GetSettingValue(SettingStrings.EndPort)))
            {
                nextPort.Number = Convert.ToInt32(SettingServices.GetSettingValue(SettingStrings.StartPort));
            }
            else
            {
                nextPort.Number = lastPort.Number + 2;
            }

            AddPort(nextPort);

            return(nextPort.Number);
        }
Exemple #2
0
        protected void btnUpdateSettings_OnClick(object sender, EventArgs e)
        {
            RequiresAuthorization(AuthorizationStrings.UpdateAdmin);
            if (ValidateSettings())
            {
                var listSettings = new List <SettingEntity>
                {
                    new SettingEntity
                    {
                        Name  = "Sender Args",
                        Value = txtSenderArgs.Text,
                        Id    = Call.SettingApi.GetSetting("Sender Args").Id
                    },
                    new SettingEntity
                    {
                        Name  = "Udpcast Start Port",
                        Value = txtStartPort.Text,
                        Id    = Call.SettingApi.GetSetting("Udpcast Start Port").Id
                    },
                    new SettingEntity
                    {
                        Name  = "Udpcast End Port",
                        Value = txtEndPort.Text,
                        Id    = Call.SettingApi.GetSetting("Udpcast End Port").Id
                    },
                    new SettingEntity
                    {
                        Name  = "Client Receiver Args",
                        Value = txtRecClientArgs.Text,
                        Id    = Call.SettingApi.GetSetting("Client Receiver Args").Id
                    },
                    new SettingEntity
                    {
                        Name  = "Multicast Decompression",
                        Value = ddlDecompress.Text,
                        Id    = Call.SettingApi.GetSetting("Multicast Decompression").Id
                    }
                };

                if (Call.SettingApi.UpdateSettings(listSettings))
                {
                    EndUserMessage = "Successfully Updated Settings";
                    if ((string)ViewState["startPort"] != txtStartPort.Text)
                    {
                        var startPort = Convert.ToInt32(txtStartPort.Text);
                        startPort = startPort - 2;
                        var port = new PortEntity {
                            Number = startPort
                        };
                        Call.PortApi.Post(port);
                    }
                }
                else
                {
                    EndUserMessage = "Could Not Update Settings";
                }
            }
        }
Exemple #3
0
        public ActionResultDTO Post(PortEntity tObject)
        {
            Request.Method = Method.POST;
            Request.AddJsonBody(tObject);
            Request.Resource = string.Format("api/{0}/Post/", Resource);
            var response = _apiRequest.Execute <ActionResultDTO>(Request);

            if (response.Id == 0)
            {
                response.Success = false;
            }
            return(response);
        }
Exemple #4
0
        public static IPort GetPort(int portId, char isActiveOnly)
        {
            string strExecution = "[common].[uspGetPort]";
            IPort  port         = null;

            using (DbQuery oDq = new DbQuery(strExecution))
            {
                oDq.AddIntegerParam("@PortId", portId);
                oDq.AddCharParam("@IsActiveOnly", 1, isActiveOnly);
                DataTableReader reader = oDq.GetTableReader();

                while (reader.Read())
                {
                    port = new PortEntity(reader);
                }

                reader.Close();
            }

            return(port);
        }
Exemple #5
0
        public static List <IPort> GetPort(char isActiveOnly)
        {
            string       strExecution = "[common].[uspGetPort]";
            List <IPort> lstPort      = new List <IPort>();

            using (DbQuery oDq = new DbQuery(strExecution))
            {
                oDq.AddCharParam("@IsActiveOnly", 1, isActiveOnly);
                DataTableReader reader = oDq.GetTableReader();

                while (reader.Read())
                {
                    IPort port = new PortEntity(reader);
                    lstPort.Add(port);
                }

                reader.Close();
            }

            return(lstPort);
        }
Exemple #6
0
 public bool AddPort(PortEntity port)
 {
     _uow.PortRepository.Insert(port);
     _uow.Save();
     return(true);
 }
Exemple #7
0
 public ApiBoolResponseDTO Post(PortEntity port)
 {
     return(new ApiBoolResponseDTO {
         Value = _portServices.AddPort(port)
     });
 }