Example #1
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 #2
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;
        }