Example #1
0
        public async Task <int> RegistrationUser(RegistrationTeamModal user)
        {
            try
            {
                var spFinalString = StringGenerator.GetProcedureParameter(user, SPConstants.spRegistrationUser);

                var res = await _connectContext.spCustomerRegistration
                          .FromSqlRaw(string.Format(spFinalString,
                                                    user.Action,
                                                    user.ULA_UID_UserId,
                                                    user.ULA_Roll,
                                                    user.ULA_LoginId,
                                                    user.ULA_FirstName,
                                                    user.ULA_LastName
                                                    )).ToListAsync()
                ;

                return(res.FirstOrDefault().Result);
            }
            catch (Exception ex)
            {
                _ILogger.Log(LogLevel.Critical, "Exception while calling SpCustomerRegistration ", ex);
                return(1);
            }
        }
Example #2
0
        public async Task <List <spGetIndent_Result> > GetIndent(IndentModel obj)
        {
            try
            {
                var sp     = Helpers.StringGenerator.GetProcedureParameter(obj, SPConstants.spGetIndent);
                var result = await _connectContext.spGetIndent
                             .FromSqlRaw(sp, obj.UID_UserId_Owner, obj.LoginId, obj.Roll, obj.SBK_MNS_Id, obj.SBK_SaleType)
                             .ToListAsync();

                return(result);
            }
            catch (Exception ex)
            {
                _ILogger.Log(LogLevel.Critical, "Exception while calling SpRegistrationTeam ", ex);
                return(new List <spGetIndent_Result>());
            }
        }
Example #3
0
        public async Task <int> SetDailyUpdateFuelPrice(FuelPriceModel fuelPrice)
        {
            try
            {
                var sp     = StringGenerator.GetProcedureParameter(fuelPrice, SPConstants.spSetDailyUpdateFuelPrice);
                var result = await _connectContext.spSetDailyUpdateFuelPrice
                             .FromSqlRaw(sp, fuelPrice.PRD_Id, fuelPrice.PRD_UID_UserId, fuelPrice.PRD_Mrp)
                             .ToListAsync();

                return(result.FirstOrDefault().Result);
            }
            catch (Exception ex)
            {
                _ILogger.Log(LogLevel.Critical, "Exception while calling SpRegistrationTeam ", ex);
                return(0);
            }
        }
Example #4
0
        public async Task <int> SetTankRegistration(TankRegistrationModel obj)
        {
            try
            {
                var sp  = StringGenerator.GetProcedureParameter(obj, SPConstants.spSetTankRegistration);
                var res = await _connectContext.spSetTankRegistration
                          .FromSqlRaw(sp, obj.Action, obj.TNK_Id, obj.TNK_UID_UserId, obj.TNK_Name, obj.TNK_FuelType, obj.TNK_Capacity, obj.TNK_IsActive)
                          .ToListAsync();

                return(res.FirstOrDefault().Result);
            }
            catch (Exception ex)
            {
                _ILogger.Log(LogLevel.Critical, "Exception while calling SetTankRegistration ", ex);
                return(0);
            }
        }
Example #5
0
        public async Task <object> SetMappingNozzleShift(NozzleMappingModel obj)
        {
            try
            {
                var sp = PetroConnect.API.Helpers.StringGenerator.GetProcedureParameter(obj, SPConstants.spSetMappingNozzleShift);

                var res = await _connectContext.SetMappingNozzleShift
                          .FromSqlRaw(sp, obj.Action, obj.MNS_Id, obj.MNS_UID_UserId, obj.MNS_NZL_Id, obj.MNS_SSH_Id, obj.MNS_IsActive)
                          .ToListAsync();

                return(res.FirstOrDefault().Result);
            }
            catch (Exception ex)
            {
                _ILogger.Log(LogLevel.Critical, "Exception while calling SetMappingNozzleShift ", ex);
                return(false);
            }
        }
Example #6
0
 public async Task <List <CityModel> > GetCity(long CTM_STM_StateID)
 {
     try
     {
         var spString = StringGenerator.GetProcedureParameter(SPConstants.spGetCityList);
         return(await _connectContext.spGetCity
                .FromSqlRaw(spString + " " + CTM_STM_StateID)
                .Select(x => new PetroConnect.API.Models.CityModel
         {
             CTM_CityCode = x.CTM_CityCode,
             CTM_Name = x.CTM_Name,
             CTM_STM_StateID = x.CTM_STM_StateID
         }).ToListAsync());
     }
     catch (Exception ex)
     {
         _ILogger.Log(LogLevel.Critical, "Exception while calling GetCity", ex);
         return(new List <CityModel>());
     }
 }
Example #7
0
        public bool Start(HostControl control, IDbLogger connection)
        {
            if (!bool.Parse(ConfigurationManager.AppSettings["automaticUpdate"]))
            {
                return(true);
            }

            var fileVersionString = File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), ".semver"));

            _currentVersion = new SemVerReader(fileVersionString).GetVersion();

            bool isProcessing = false;

            _disposable = Observable.Interval(TimeSpan.FromMinutes(1)).
                          SkipWhile(l => isProcessing).
                          Subscribe(l =>
            {
                isProcessing = true;
                try
                {
                    var client        = new WebClient();
                    var versionString = client.DownloadString(ConfigurationManager.AppSettings["versionFileAddress"]);
                    var newVersion    = new SemVerReader(versionString).GetVersion();

                    if (newVersion > _currentVersion)
                    {
                        connection.Log(new Event
                        {
                            Date          = _time.Now,
                            EventId       = 5384,
                            EventRecordId = 5384,
                            LogName       = "Application",
                            Message       = string.Format("Upgrading from {0} to {1}...", _currentVersion, newVersion),
                            Source        = "Nosey",
                            MachineName   = Environment.MachineName,
                            Level         = "Information"
                        });

                        var updatePackage = new UpdatePackage(newVersion);
                        updatePackage.GetAndUnpackLatestVersion();
                        updatePackage.ReplaceUpdateScript();
                        updatePackage.RunUpdateScript();
                        StopServiceForUpdating(control);
                    }
                }
                catch (Exception)
                {
                    isProcessing = false;
                }
            });

            return(true);
        }
Example #8
0
 public async Task <object> GetTeams(long UID_UserId_Owner)
 {
     try
     {
         var sp = StringGenerator.GetProcedureParameter(1, SPConstants.spGetTeamDetails);
         return(await _connectContext.spGetTeamDetails.FromSqlRaw(sp, UID_UserId_Owner).Select(x => new TeamsModel
         {
             ULA_FirstName = x.ULA_FirstName,
             ULA_LastName = x.ULA_LastName,
             ULA_LoginId = x.ULA_LoginId,
             ULA_Photo = x.ULA_Photo,
             ULA_Roll = x.ULA_Roll,
             ULA_IsActive = x.ULA_IsActive
         }).ToListAsync());
     }
     catch (Exception ex)
     {
         _ILogger.Log(LogLevel.Critical, "Exception while calling GetCustomerList ", ex);
         return(0);
     }
 }
Example #9
0
        public bool Start(HostControl control, IDbLogger connection)
        {
            if (!bool.Parse(ConfigurationManager.AppSettings["automaticUpdate"]))
            {
                return true;
            }

            var fileVersionString = File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), ".semver"));
            _currentVersion = new SemVerReader(fileVersionString).GetVersion();

            bool isProcessing = false;

            _disposable = Observable.Interval(TimeSpan.FromMinutes(1)).
                SkipWhile(l => isProcessing).
                Subscribe(l =>
                {
                    isProcessing = true;
                    try
                    {
                        var client = new WebClient();
                        var versionString = client.DownloadString(ConfigurationManager.AppSettings["versionFileAddress"]);
                        var newVersion = new SemVerReader(versionString).GetVersion();

                        if (newVersion > _currentVersion)
                        {
                            connection.Log(new Event
                                {
                                    Date = _time.Now,
                                    EventId = 5384,
                                    EventRecordId = 5384,
                                    LogName = "Application",
                                    Message = string.Format("Upgrading from {0} to {1}...", _currentVersion, newVersion),
                                    Source = "Nosey",
                                    MachineName = Environment.MachineName,
                                    Level = "Information"
                                });

                            var updatePackage = new UpdatePackage(newVersion);
                            updatePackage.GetAndUnpackLatestVersion();
                            updatePackage.ReplaceUpdateScript();
                            updatePackage.RunUpdateScript();
                            StopServiceForUpdating(control);
                        }
                    }
                    catch (Exception)
                    {
                        isProcessing = false;
                    }
                });

            return true;
        }
Example #10
0
        public async Task <int> AddUpdateUserRegistrationAsync(UserRegistrationModel obj)
        {
            try
            {
                var spString = StringGenerator.GetProcedureParameter(obj, SPConstants.spRegistrationUser);
                var res      = await _connectContext.spCustomerRegistration
                               .FromSqlRaw(
                    spString,
                    obj.Action,
                    obj.UID_UserId,
                    obj.UID_CompanyName,
                    obj.UID_PumpRegNumber,
                    obj.UID_OilCompany,
                    obj.UID_Address,
                    obj.UID_STM_StateId,
                    obj.UID_CTM_CityCode,
                    obj.UID_Pin,
                    obj.UID_UserType,
                    obj.UID_MobileNumber,
                    obj.UID_eMail,
                    obj.UID_GSTIN,
                    obj.UID_PAN,
                    obj.UID_TIN,
                    obj.UID_CIN,
                    obj.UID_ValidFrom,
                    obj.UID_ValidThru,
                    obj.ULA_FirstName,
                    obj.ULA_LastName,
                    obj.ULA_Photo
                    ).ToListAsync();

                return(res.FirstOrDefault().Result);
            }
            catch (Exception ex)
            {
                _ILogger.Log(LogLevel.Critical, "Exception while calling SpUserRegistration", ex);
                return(0);
            }
        }
Example #11
0
        public async Task <int> SetProductDetailOwner(ProductDetailOwner pro)
        {
            try
            {
                var sp     = StringGenerator.GetProcedureParameter(pro, SPConstants.spSetProductDetailOwner);
                var result = await _connectContext.spSetProductDetailOwner
                             .FromSqlRaw(sp, pro.Action, pro.PRD_Id, pro.PRD_UID_UserId, pro.PRD_PRDG_Id, pro.PRD_GST, pro.PRD_Mrp, pro.PRD_Discount, pro.PRD_IsActive)
                             .ToListAsync();

                return(result.FirstOrDefault().Result);
            }
            catch (Exception ex)
            {
                _ILogger.Log(LogLevel.Critical, "Exception while calling SpRegistrationTeam ", ex);
                return(0);
            }
        }
        public void EventLogEventRead(object obj, EventRecordWrittenEventArgs arg)
        {
            if (arg.EventRecord != null)
            {
                var xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(arg.EventRecord.ToXml());

                var @event = new Event
                {
                    EventId       = arg.EventRecord.Id,
                    EventRecordId = arg.EventRecord.RecordId,
                    LogName       = arg.EventRecord.LogName,
                    Message       = string.Join(Environment.NewLine, arg.EventRecord.Properties.Select(property => property.Value.ToString())),
                    Source        = arg.EventRecord.ProviderName,
                    Date          = arg.EventRecord.TimeCreated.Value.ToUniversalTime().ToString(_time.Format),
                    Level         = arg.EventRecord.LevelDisplayName,
                    MachineName   = Environment.MachineName
                };

                _connection.Log(@event);
            }
        }
Example #13
0
 public async Task Log(string vaultId, string accessType, string message)
 {
     _dbLogger.VaultId   = vaultId;
     _dbLogger.EventType = accessType;
     await _dbLogger.Log(message);
 }