public void Can_Parse_GasLog_String_Content(string contentText)
        {
            // Arrange
            var xmlDoc = XDocument.Parse(string.Format(NoteXmlTextBase, XmlNamespace, contentText));

            CurrentTime = new DateTime(2021, 10, 15);

            var gasLog = new GasLog
            {
                Date                = new DateTime(2021, 8, 15),
                Car                 = _defaultCar,
                Distance            = 300d.GetKilometer(),
                CurrentMeterReading = 13000d.GetKilometer(),
                Gas                 = 34d.GetLiter(),
                Price               = 1.34m.GetCad(),
                Station             = "Costco",
                Discounts           = new List <GasDiscountInfo>(),
                Comment             = string.Empty,
                CreateDate          = DateProvider.UtcNow
            };

            // Act
            var note = _noteSerializer.GetNote(gasLog);

            // Assert
            Assert.True(_noteSerializer.ProcessResult.Success);
            Assert.NotNull(note);
            Assert.Equal(AutomobileConstant.GasLogRecordSubject, note.Subject);
            Assert.Equal(note.Content, xmlDoc.ToString(SaveOptions.DisableFormatting));
        }
Esempio n. 2
0
        public static Seller SellerSave(Seller sellerObj)
        {
            Seller objSave = new Seller();

            try
            {
                bool esCorrecto = true;
                objSave = DataSeller.SellerSave(sellerObj);
                if (objSave.IdSegas <= 0)
                {
                    esCorrecto = false;
                }
                string Descripcion = "Registró vendedor: Usuario SEGAS:" + sellerObj.IdSegas + " PTDVF:" + sellerObj.PTDVF + " CIFVF:" + sellerObj.CIFVF + " subasta:" + sellerObj.IdSubasta + " Nombre:" + sellerObj.Nombre;
                int    TipoAccion  = (int)LogActionType.SellerSave;
                GasLog gasLogger   = GasLoggerBuilder.Build(sellerObj.User, Descripcion, TipoAccion, esCorrecto);
                DataGasLog.InsertLogGas(gasLogger);
                return(objSave);
            }
            catch (Exception ex)
            {
                GasLogB.CrearLogError(ex);
            }

            return(objSave);
        }
        public void Can_Get_Right_Xml_With_Note_Content_Contains_Invalid_Char_To_DataSource()
        {
            // Arrange - note with null content
            var xmlDoc = XDocument.Parse($"<?xml version=\"1.0\" encoding=\"utf-16\" ?><Note xmlns=\"{XmlNamespace}\"><Content><GasLog><Date>2021-10-18T00:00:00.0000000</Date><Distance><Dimension><Value>215</Value><Unit>Kilometre</Unit></Dimension></Distance><CurrentMeterReading><Dimension><Value>13000</Value><Unit>Kilometre</Unit></Dimension></CurrentMeterReading><Gas><Volume><Value>34</Value><Unit>Liter</Unit></Volume></Gas><Price><Money><Value>1.34</Value><Code>CAD</Code></Money></Price><GasStation>Costco</GasStation><Discounts></Discounts><Automobile>1</Automobile><Comment>&lt;This is a&gt; comment</Comment><CreateDate>2021-10-15T00:00:00.0000000</CreateDate></GasLog></Content></Note>");

            var gasLog = new GasLog
            {
                Car                 = _defaultCar,
                Date                = new DateTime(2021, 10, 18),
                Distance            = 215d.GetKilometer(),
                CurrentMeterReading = 13000d.GetKilometer(),
                Gas                 = 34d.GetLiter(),
                Price               = 1.34m.GetCad(),
                Station             = "Costco",
                Discounts           = new List <GasDiscountInfo>(),
                Comment             = "<This is a> comment",
                CreateDate          = new DateTime(2021, 10, 15)
            };

            // Act
            var note = _noteSerializer.GetNote(gasLog);

            // Assert
            Assert.True(_noteSerializer.ProcessResult.Success);
            Assert.NotNull(note);
            Assert.Equal(note.Content, xmlDoc.ToString(SaveOptions.DisableFormatting));
            Assert.Contains("&lt;", note.Content);
            Assert.Contains("&gt;", note.Content);
        }
Esempio n. 4
0
        public GasLog GetCurrentUser()
        {
            var    currentUser = _connectedUsers.SingleOrDefault(x => x.SessionId == Context.ConnectionId);
            GasLog Logger      = new GasLog();

            if (currentUser != null)
            {
                Logger.IdUsuario     = currentUser.IdSegas;
                Logger.NombreUsuario = currentUser.Nombre;
            }
            return(Logger);
        }
Esempio n. 5
0
 public static bool SavePurchaserUser(Purchaser purchaserObj)
 {
     try
     {
         bool   esCorrecto  = DataPurchaser.SavePurchaserUser(purchaserObj);
         string Descripcion = "Registró Comprador: Subasta:" + purchaserObj.IdSubasta + " Nombre:" + purchaserObj.Nombre + " Demanda maxima total:" + purchaserObj.DemandaMaximaTotal + " Usuario SEGAS:" + purchaserObj.IdSegas;
         int    TipoAccion  = (int)LogActionType.SavePurchaserUser;
         GasLog gasLogger   = GasLoggerBuilder.Build(purchaserObj.User, Descripcion, TipoAccion, esCorrecto);
         DataGasLog.InsertLogGas(gasLogger);
         return(true);
     }
     catch (Exception ex)
     {
         GasLogB.CrearLogError(ex);
         return(false);
     }
 }
Esempio n. 6
0
        public static void InsertLogGasError(GasLog gasobj)
        {
            int       datos;
            DataTable clientes = new DataTable();

            try
            {
                Database dbAuction = null;
                string   ConectStr = "";
                //if (gasobj.User == null)
                //{
                dbAuction = DatabaseFactory.CreateDatabase("Auction");
                //}
                //else {
                //     ConectStr = Tools.ConectionNow.BuildConection(gasobj.User);
                //    dbAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);
                //}


                //  Database dbeAuction = DatabaseFactory.CreateDatabase("Auction");
                // Crear objeto SP
                DbCommand spInsertarLog = dbAuction.GetStoredProcCommand("SP_GASLOG");

                dbAuction.AddInParameter(spInsertarLog, "@i_operation", DbType.String, "I");
                dbAuction.AddInParameter(spInsertarLog, "@i_option", DbType.String, "B");
                dbAuction.AddInParameter(spInsertarLog, "@Descripcion", DbType.String, gasobj.Descripcion);
                dbAuction.AddInParameter(spInsertarLog, "@NombreUsuario", DbType.String, gasobj.NombreUsuario);
                dbAuction.AddInParameter(spInsertarLog, "@IdUsuario", DbType.Int16, gasobj.IdUsuario);
                dbAuction.AddInParameter(spInsertarLog, "@TipoMovimiento", DbType.String, gasobj.Descripcion);
                dbAuction.AddInParameter(spInsertarLog, "@IdTipoAccion", DbType.Int16, gasobj.IdTipoAccion);
                dbAuction.AddInParameter(spInsertarLog, "@Nombre", DbType.String, gasobj.Nombre);
                dbAuction.AddInParameter(spInsertarLog, "@EstadoTrans", DbType.Boolean, gasobj.EstadoTransaccion);

                spInsertarLog.CommandTimeout = 900000000;
                datos = dbAuction.ExecuteNonQuery(spInsertarLog);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                throw new Exception("Excepcion en la funcion LogGas" + ex.StackTrace);
            }
        }
Esempio n. 7
0
 public static bool SellersSaveState(List <Seller> sellerObj)
 {
     try
     {
         foreach (Seller obj in sellerObj)
         {
             bool   esCorrecto  = DataSeller.SellersSaveState(obj);
             string Descripcion = "Actualizó estado: vendedor:" + obj.IdSegas + " Esatdo:" + obj.Estado + " subasta:" + obj.IdSubasta;
             int    TipoAccion  = (int)LogActionType.SellersSaveState;
             GasLog gasLogger   = GasLoggerBuilder.Build(obj.User, Descripcion, TipoAccion, esCorrecto);
             DataGasLog.InsertLogGas(gasLogger);
         }
         return(true);
     }
     catch (Exception ex)
     {
         GasLogB.CrearLogError(ex);
         return(false);
     }
 }
Esempio n. 8
0
 public static bool PurchasersSaveState(List <Purchaser> purchaserObj)
 {
     try
     {
         foreach (Purchaser obj in purchaserObj)
         {
             bool   esCorrecto  = DataPurchaser.PurchasersSaveState(obj);
             string Descripcion = "Registró estado comprador: Subasta:" + obj.IdSubasta + " Estado:" + obj.Estado + "  Usuario SEGAS:" + obj.IdSegas;
             int    TipoAccion  = (int)LogActionType.PurchasersSaveState;
             GasLog gasLogger   = GasLoggerBuilder.Build(obj.User, Descripcion, TipoAccion, esCorrecto);
             DataGasLog.InsertLogGas(gasLogger);
         }
         return(true);
     }
     catch (Exception ex)
     {
         GasLogB.CrearLogError(ex);
         return(false);
     }
 }
Esempio n. 9
0
 public static bool SaveParams(List <Params> listParamsObj)
 {
     try
     {
         foreach (Params objectParams in listParamsObj)
         {
             bool   esCorrecto  = DataParams.SaveParams(objectParams);
             string Descripcion = "Registro Parametro: " + objectParams.Parametro + " Nombre:" + objectParams.NombreParametro + " descripcion:" + objectParams.Texto + " Tipo:" + objectParams.Tipo + " Valor:" + objectParams.Valor;
             int    TipoAccion  = (int)LogActionType.SaveParams;
             GasLog gasLogger   = GasLoggerBuilder.Build(objectParams.User, Descripcion, TipoAccion, esCorrecto);
             DataGasLog.InsertLogGas(gasLogger);
         }
         return(true);
     }
     catch (Exception ex)
     {
         GasLogB.CrearLogError(ex);
         return(false);
     }
 }
Esempio n. 10
0
 public static void CrearLogError(Exception ex)
 {
     try
     {
         GasLog juta = new GasLog
         {
             Descripcion       = string.Concat(ex.Message, " --> ", ex.StackTrace),
             EstadoTransaccion = true,
             IdTipoAccion      = 1,
             IdUsuario         = 0,
             Nombre            = "",
             NombreUsuario     = "",
             TipoMovimiento    = "Error",
         };
         AuctionDesc.Data.Clases.DataGasLog.InsertLogGasError(juta);
     }
     catch (Exception ex2)
     {
         //  LogError(string.Concat(ex2.Message, " --> ", ex2.StackTrace, " Error original --> ", ex.Message, " --> ", ex.StackTrace));
     }
 }
Esempio n. 11
0
        public static UserAutentication ResolveUserlogin(UserAutentication userobj)
        {
            UserAutentication obj = new UserAutentication();

            try
            {
                bool esCorrecto = true;
                obj = DataUser.ValidateUser(userobj);
                if (obj.access <= 0)
                {
                    esCorrecto = false;
                }
                string Descripcion = "Ingreso de usuario";
                int    TipoAccion  = (int)LogActionType.UserLogin;
                GasLog gasLogger   = GasLoggerBuilder.Build(userobj, Descripcion, TipoAccion, esCorrecto);
                DataGasLog.InsertLogGas(gasLogger);
                return(obj);
            }
            catch (Exception ex)
            {
                GasLogB.CrearLogError(ex);
            }
            return(obj);
        }
        public static GasLog Build(UserAutentication objUser, string Descripcion, int TipoMovimiento, bool esCorrecto)
        {
            GasLog gaslogger = new GasLog();

            if (objUser != null)
            {
                gaslogger.IdUsuario     = objUser.IdSegas == null ? 0 : objUser.IdSegas;
                gaslogger.Nombre        = objUser.Nombre;
                gaslogger.NombreUsuario = objUser.username;
                gaslogger.User          = objUser;
            }
            else
            {
                gaslogger.IdUsuario     = 0;
                gaslogger.Nombre        = "Indefinido";
                gaslogger.NombreUsuario = "Indefinido";
            }
            gaslogger.Descripcion       = Descripcion;
            gaslogger.TipoMovimiento    = Descripcion;
            gaslogger.IdTipoAccion      = TipoMovimiento;
            gaslogger.EstadoTransaccion = esCorrecto;

            return(gaslogger);
        }