public static int getMinimumLength()
        {
            int minimum = 0;

            if (minimum < ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.Date))
            {
                minimum = ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.Date);
            }
            if (minimum < ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.Time))
            {
                minimum = ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.Time);
            }
            if (minimum < ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.DialedNumber))
            {
                minimum = ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.DialedNumber);
            }
            if (minimum < ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.Anexo))
            {
                minimum = ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.Anexo);
            }
            if (minimum < ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.UserID))
            {
                minimum = ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.UserID);
            }
            if (minimum < ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.Duration))
            {
                minimum = ShiolExtension.getOffset(ShiolConfiguration.Instance.Config.DataFrames[0].Structure.Duration);
            }


            return(minimum);
        }
        public static string Purify(this string val)
        {
            if (val == null)
            {
                return(null);
            }

            val = val.Replace('\n', ' ').TrimStart();

            if (string.IsNullOrEmpty(val))
            {
                throw new ArgumentNullException("val");
            }

            if (val.Length < ShiolExtension.getMinimumLength())  //ShiolConfiguration.Instance.Config.MinLengthFrame)
            {
                LogFile.saveRegistro($"Trama ({val.Length})debe ser más grande que el tamaño mínimo = {ShiolExtension.getMinimumLength()}", levels.error);
                return(null);
            }



            return(val);
        }
        public static string Purify(this string val)
        {
            if (val == null)
            {
                return(null);
            }

            val = val.Replace('\n', ' ').TrimStart();

            if (string.IsNullOrEmpty(val))
            {
                throw new ArgumentNullException("val");
            }

            String[] strList = ShiolConfiguration.Instance.Config.ExcludedStrings.Split(',');

            foreach (var str in strList)
            {
                if (val.IndexOf(str) > -1)
                {
                    Console.WriteLine("Excluding string: >>" + str + "<<");
                    return(null);
                }
            }


            if (val.Length < ShiolExtension.getMinimumLength())  //ShiolConfiguration.Instance.Config.MinLengthFrame)
            {
                LogFile.saveRegistro($"Trama ({val.Length})debe ser más grande que el tamaño mínimo = {ShiolExtension.getMinimumLength()}", levels.error);
                return(null);
            }



            return(val);
        }
Ejemplo n.º 4
0
        public void Save(ref UniversalFrameProvider uFrameProvider)
        {
            AD.Conexion.SqlConnectionString = ShiolConfiguration.Instance.Config.SqlServerConnection.ConnectionString;

            if (uFrameProvider.DialedNumber.ToString().Trim() == "")
            {
                return;
            }

            try
            {
                GetShiolInfo(uFrameProvider);

                /*String anexo,
                 * string discado,
                 * DateTime fecha,
                 * DateTime hora,
                 * string tiempo,
                 * string codigo,
                 * decimal precioventa,
                 * decimal preciocosto,
                 * int productoId,
                 * int monedaId,
                 * int usuarioID,
                 * int minutos,
                 * string anexoregistro,
                 * decimal descuento,
                 * int tipo,
                 * int troncalid*/

                if (ShiolConfiguration.Instance.Config.SqlServerConnection.Connection)
                {
                    if (uFrameProvider.Duration < ShiolConfiguration.Instance.Config.MinCallDuration)
                    {
                        if (ShiolConfiguration.Instance.Config.SaveAllCalls)
                        {
                            uFrameProvider.Shiol = $"OK  {uFrameProvider.Duration} < {ShiolConfiguration.Instance.Config.MinCallDuration} config.";
                        }
                        else
                        {
                            uFrameProvider.Shiol = $"NO  {uFrameProvider.Duration} < {ShiolConfiguration.Instance.Config.MinCallDuration} config.";
                            return;
                        }
                    }
                    else
                    {
                        uFrameProvider.Shiol = "OK";
                    }
                }
                else
                {
                    uFrameProvider.Shiol = "Shiol disabled";
                    return;
                }

                AD.ADCentrales sqlObject = new ADCentrales();

                //objCentral.saveLlamada(vanexo, vDiscado, vfecha, vhora, vtiempo,
                //vusuario, vPrecioVenta, vPrecioCosto, vProductoId, vMonedaID, 0, vMinutos, "", 0, vTipo, 0) == true)

                sqlObject.saveLlamada(uFrameProvider.Anexo,
                                      uFrameProvider.DialedNumber,
                                      uFrameProvider.Date,
                                      uFrameProvider.Time,
                                      UniversalFrameProvider.SecondsToDurationFormat(uFrameProvider.Duration), uFrameProvider.Anexo,
                                      vPrecioVenta, vPrecioCosto, vProductoId, vMonedaID,
                                      0,
                                      ShiolExtension.SecondsToMinutes(uFrameProvider.Duration),
                                      "", 0, uFrameProvider.Type, 0);
            }
            catch (Exception ex)
            {
                LogFile.saveRegistro("Shiol Sql Server Saving: " + ex.Message, levels.error);
                uFrameProvider.Shiol = "Sql Server Error";
            }

            return;
        }