Example #1
0
        static public void saveEvent(UniversalFrameProvider processed)
        {
            try
            {
                if (LogTramas != null)
                {
                    string   strDate = LogTramas.getFileName().Mid("Tramas".Length + 1, 10).Replace("-", "");
                    DateTime date    = DateTime.ParseExact(strDate, "yyyyMMdd", CultureInfo.InvariantCulture);
                    if (date != DateTime.Today)
                    {
                        LogTramas = null;
                    }
                }

                if (LogTramas == null)
                {
                    LogTramas = new XmlLogger("Tramas", ShiolConfiguration.Instance.Config.LogDirectory);
                }

                LogTramas.saveEvent(processed);
            }
            catch (Exception ex)
            {
                EventLog ev = new EventLog();
                ev.WriteEntry(ex.Message, EventLogEntryType.Error);
            }
        }
Example #2
0
        private void GetShiolInfo(UniversalFrameProvider uFrameProvider)
        {
            vPrecioVenta        = 0;
            vcodigosTelefonicos = "";
            vProductoId         = 0;
            vPrecioCosto        = 0;
            vMonedaID           = 0;

            AD.ADTelefonos objTelefono = new AD.ADTelefonos();

            string primer_caracter_discado          = uFrameProvider.DialedNumber.Left(1);
            string primeros_dos_caracteres_discados = uFrameProvider.DialedNumber.Left(1);

            DataTable telefonos;

            if (primer_caracter_discado == "0" && primer_caracter_discado.Trim().Length > 0)
            {
                telefonos = objTelefono.telefonos(primeros_dos_caracteres_discados);
            }
            else
            {
                telefonos = objTelefono.telefonos(primer_caracter_discado);
            }

            string vDiscado = uFrameProvider.DialedNumber;

            for (Int32 iX = 0; iX < vDiscado.Length + 1; iX++)
            {
                String discado_parcial = discado_parcial = vDiscado.Mid(0, vDiscado.Length - iX);
                foreach (DataRow filaTabla in telefonos.Rows)
                {
                    if (Convert.ToString(filaTabla["codigostelefonicos"]) == discado_parcial)
                    {
                        DataRow filaTel = filaTabla;
                        vPrecioVenta        = Convert.ToDecimal(filaTel["PrecioVenta"]);
                        vcodigosTelefonicos = Convert.ToString(filaTel["codigosTelefonicos"]);

                        vProductoId     = Convert.ToInt32(filaTel["ProductoId"]);
                        vPrecioCosto    = Convert.ToDecimal(filaTel["preciocosto"]);
                        vMonedaID       = Convert.ToInt32(filaTel["MonedaID"]);
                        vTiempoSegundos = Convert.ToInt32(filaTel["TiempoSegundos"]);
                        vCollect        = Convert.ToInt32(filaTel["Collect"]);
                        vFamiliaID      = Convert.ToInt32(filaTel["FamiliaID"]);
                        vAfectoIGV      = Convert.ToInt32(filaTel["AfectoIGv"]);
                        vAfectoServicio = Convert.ToInt32(filaTel["afectoservicio"]);
                        break;
                    }
                }
            }
        }
Example #3
0
        public static void Main(string[] args)
        {
            UniversalFrameProvider uFrame = new UniversalFrameProvider();

            uFrame.Data = "20/01/18 08:29PM   106 28 <I>12793301               0'03 00:00'54     ";
            uFrame.Process();
            LogFile.saveEvent(uFrame);

            /*
             *
             * XmlValidatingReader vr =  new XmlValidatingReader(new XmlTextReader("logfile.xml"));
             * vr.ValidationType = ValidationType.None;
             * vr.EntityHandling = EntityHandling.ExpandEntities;
             *
             * XmlDocument doc = new XmlDocument();
             * doc.Load(vr);
             *
             * foreach (XmlElement element in doc.SelectNodes("//Event"))
             * {
             *  string file = element.ChildNodes[0].InnerText;
             * // string date = element.ChildNodes[1].InnerText;
             *
             *
             *  Console.WriteLine("{0}", file);
             *
             *  XmlNode element1 = element["Processed"];
             *
             *  Console.WriteLine("{0}-{1} ", element1["Date"].Name, element1["Date"].InnerText);
             *  Console.WriteLine("{0}-{1} ", element1["Time"].Name, element1["Time"].InnerText);
             *  Console.WriteLine("{0}-{1} ", element1["Anexo"].Name, element1["Anexo"].InnerText);
             *  Console.WriteLine("{0}-{1} ", element1["DialedNumber"].Name, element1["DialedNumber"].InnerText);
             *  Console.WriteLine("{0}-{1} ", element1["UserID"].Name, element1["UserID"].InnerText);
             *  Console.WriteLine("{0}-{1} ", element1["Duration"].Name, element1["Duration"].InnerText);
             *
             *
             *  foreach (XmlNode element2 in element["Processed"])
             *  {
             *      Console.WriteLine("{0}-{1} ", element2.Name, element2.InnerText);
             *
             *  }
             *
             *
             * }
             *
             */
            Console.ReadKey();
        }
Example #4
0
        public void saveEvent(UniversalFrameProvider processed)
        {
            try
            {
                if (!File.Exists(_filepath))
                {
                    Directory.CreateDirectory(_directorypath);
                }

                StreamWriter sw = File.AppendText(_filepath);

                using (xw = new XmlTextWriter(sw))
                {
                    //XmlTextWriter xtw = new XmlTextWriter(sw);
                    xw.WriteStartElement("Event");
                    xw.WriteStartElement("Received");
                    xw.WriteElementString("Data", processed.Data.Replace("<", "&lt;").Replace(">", "&gt;"));
                    xw.WriteElementString("Date", $"{DateTime.Now}");
                    xw.WriteEndElement();

                    xw.WriteStartElement("Processed");
                    xw.WriteElementString("Date", processed.Date.ToString("dd-MM-yyyy"));
                    xw.WriteElementString("Time", processed.Time.ToString("hh:mm tt"));
                    xw.WriteElementString("Duration", UniversalFrameProvider.SecondsToDurationFormat(processed.Duration));
                    xw.WriteElementString("Anexo", processed.Anexo.ToString());
                    xw.WriteElementString("DialedNumber", processed.DialedNumber);
                    xw.WriteElementString("UserID", processed.User);
                    xw.WriteElementString("Shiol", processed.Shiol);

                    xw.WriteEndElement();
                    xw.WriteRaw("\n");

                    xw.Close();
                }
            }
            catch (Exception ex)
            {
                EventLog ev = new EventLog();
                ev.WriteEntry(ex.Message, EventLogEntryType.Error);
            }
        }
Example #5
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;
        }