public IList <Employee> GetAllEmployees()
        {
            string _mess = "working";

            CustomLogging.LogMessage(CustomLogging.Trace.INFO, _mess);
            return(_employeeBusiness.GetEmployeeList());
        }
Beispiel #2
0
        public IHttpActionResult Post(string link)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(link))
                {
                    return(Content(HttpStatusCode.BadRequest, "Url must have value"));
                }

                bool urlExist = CheckUrlIsExist(link);

                if (urlExist)
                {
                    var token = _appService.AddUrl(link);
                    return(Content(HttpStatusCode.OK, token));
                }
                else
                {
                    return(Content(HttpStatusCode.NotFound, "Url does not exist"));
                }
            }
            catch (Exception ex)
            {
                CustomLogging.LogMessage(TracingLevel.ERROR, ex.Message);
                return(Content(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Beispiel #3
0
        public dynamic GetLocationsFromClocksList(ADLocationsModel storeLocations)
        {
            try
            {
                var result = dbContext.ClocksList.Where(cl => cl.IsActive).OrderBy(loc => loc.Location.Length).ThenBy(loc => loc.Location).ToList();

                //creating dicrionary to improve performance of location filling
                var locDic = storeLocations.Locations.ToDictionary(p => p.Location.TrimStart('0'), q => q.Label);

                //Filling location name
                foreach (var locs in result)
                {
                    locs.SecurityCode = Util.DecodeSecurityCode(locs.EncodedSecurityCode);
                    if (locDic.ContainsKey(locs.Location.TrimStart('0')))
                    {
                        locs.LocationName = locDic[locs.Location.TrimStart('0')];
                    }
                    else
                    {
                        locs.LocationName = locs.Location;
                    }
                }
                if (result != null && result.Count() > 0)
                {
                    return(result);
                }
                return(null);
            }
            catch (Exception ex)
            {
                CustomLogging.ErrorLog(ex);
                return(null);
            }
        }
Beispiel #4
0
        public dynamic GetLocationsWithClocks(ADLocationsModel storeLocations)
        {
            try
            {
                var result = dbContext.ClocksList.Where(loc => loc.IsActive).OrderBy(loc => loc.Location.Length).ThenBy(loc => loc.Location).Select(x => new ClocksListDTO {
                    Value    = x.Location,
                    Location = x.Location
                }).ToArray();
                //creating dicrionary to improve performance of location filling
                var locDic = storeLocations.Locations.ToDictionary(p => p.Location.TrimStart('0'), q => q.Label);
                //Filling location name
                foreach (var locs in result)
                {
                    if (locDic.ContainsKey(locs.Location.TrimStart('0')))
                    {
                        locs.Label = locDic[locs.Location.TrimStart('0')];
                    }
                    else
                    {
                        locs.Label = locs.Location;
                    }
                }

                if (result != null)
                {
                    return(result);
                }
                return(null);
            }
            catch (Exception ex)
            {
                CustomLogging.ErrorLog(ex);
                return(null);
            }
        }
Beispiel #5
0
        public ActionResult GenerateClock(string location)
        {
            try
            {
                location = location.Trim();
                ClockGenerator generatorObj = new ClockGenerator(_context);
                ClockURL       clockDTO     = generatorObj.GenerateClock(location);
                //setting Redirection Clock
                string redirectionType = dbService.GetConfigurationProperties("WebClockType");
                if (redirectionType.ToUpper() == "WEB")
                {
                    clockDTO.RedirectURL = clockDTO.SilverLighClockURL;
                }
                else if (redirectionType.ToUpper() == "HTML")
                {
                    clockDTO.RedirectURL = clockDTO.HTMLClockURL;
                }

                var result = Json(clockDTO);
                return(result);
            }
            catch (Exception ex)
            {
                CustomLogging.ErrorLog(ex);
                return(Json(false));
            }
        }
Beispiel #6
0
 public bool ValidateClock(string locationId)
 {
     try
     {
         int  loc        = 0;
         bool isLocation = int.TryParse(locationId, out loc);
         List <ClocksList> result;
         if (isLocation)
         {
             result = dbContext.ClocksList.Where(cl => cl.IsActive && cl.Location.Trim().ToUpper().TrimStart('0') == locationId.Trim().ToUpper().TrimStart('0')).ToList();
         }
         else
         {
             result = dbContext.ClocksList.Where(cl => cl.IsActive && cl.ClockName.Trim().ToUpper() == locationId.Trim().ToUpper()).ToList();
         }
         if (result != null && result.Count() > 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         CustomLogging.ErrorLog(ex);
         return(false);
     }
 }
Beispiel #7
0
        internal static void OnCustomLogging(LoggerArgs e)
        {
            CustomLogging?.Invoke(e);

            // Try sending it to the simpler WriteLine event
            OnWriteLine(e);
        }
Beispiel #8
0
        public int SaveOrder(OrderInformation orderInformation)
        {
            int orderNumber = new Random().Next(1, 10000);

            try
            {
                using (_context)
                {
                    Order order = new Order()
                    {
                        OrderId = orderNumber, Date = DateTime.Now
                    };
                    order.UserName = orderInformation.Email;
                    foreach (OrderDetail orderDetail in orderInformation.OrderDetails)
                    {
                        orderDetail.OrderId = orderNumber;
                    }
                    orderInformation.BillingContact.OrderId = orderInformation.ShippingContact.OrderId = orderNumber;

                    order.OrderDetails          = orderInformation.OrderDetails;
                    order.OrderShippingContacts = orderInformation.ShippingContact;
                    order.OrderBillingContacts  = orderInformation.BillingContact;
                    _context.Orders.Add(order);
                    _context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                orderNumber = -1;
                CustomLogging.LogMessage(TracingLevel.ERROR, new Exception("Error saving order information", ex));
            }
            return(orderNumber);
        }
Beispiel #9
0
        public dynamic AddClock(string location, string clockName, string locationName, string encodedSecurityCode, string clockType, string locType)
        {
            try
            {
                List <ClocksList> checkLocation = dbContext.ClocksList.Where(cl => cl.Location.Trim().TrimStart('0') == location.Trim().TrimStart('0')).ToList();
                if (checkLocation.Count() > 0)
                {
                    return(false);
                }

                ClocksList addObj = new ClocksList();
                addObj.Location            = location.Trim();
                addObj.ClockName           = clockName.Trim();
                addObj.EncodedSecurityCode = encodedSecurityCode.Trim();
                addObj.LocationType        = locType;
                addObj.ClockType           = clockType.Trim();
                dbContext.ClocksList.Add(addObj);
                dbContext.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                CustomLogging.ErrorLog(ex);
                return(false);
            }
        }
Beispiel #10
0
 public void Set <T>(string key, T value, TimeSpan timeout)
 {
     using (RedisClient client = new RedisClient(_endPoint))
     {
         client.As <T>().SetValue(key, value, timeout);
         CustomLogging.LogMessage(CustomLogging.TracingLevel.CACHE, key + "from redis");
     }
 }
        public T Get <T>(string key)
        {
            var cache = (T)HttpRuntime.Cache.Get(key);

            CustomLogging.LogMessage(CustomLogging.TracingLevel.CACHE, key + "from webCache");

            return(cache);
        }
Beispiel #12
0
        public OrderInformation RetrieveOrder(int orderId, string email)
        {
            OrderInformation orderInformation = null;

            using (_context)
            {
                try
                {
                    var order = (from o in _context.Orders
                                 where o.OrderId == orderId &&
                                 o.UserName == email
                                 select o).FirstOrDefault();

                    orderInformation = new OrderInformation()
                    {
                        BillingContact = new OrderBillingContact()
                        {
                            Address     = order.OrderBillingContacts.Address,
                            Apt         = order.OrderBillingContacts.Apt,
                            City        = order.OrderBillingContacts.City,
                            FirstName   = order.OrderBillingContacts.FirstName,
                            LastName    = order.OrderBillingContacts.LastName,
                            PhoneNumber = order.OrderBillingContacts.PhoneNumber,
                            State       = order.OrderBillingContacts.State,
                            ZipCode     = order.OrderBillingContacts.ZipCode
                        },

                        ShippingContact = new OrderShippingContact()
                        {
                            Address     = order.OrderShippingContacts.Address,
                            Apt         = order.OrderShippingContacts.Apt,
                            City        = order.OrderShippingContacts.City,
                            FirstName   = order.OrderShippingContacts.FirstName,
                            LastName    = order.OrderShippingContacts.LastName,
                            PhoneNumber = order.OrderShippingContacts.PhoneNumber,
                            State       = order.OrderShippingContacts.State,
                            ZipCode     = order.OrderShippingContacts.ZipCode
                        }
                    };

                    orderInformation.OrderDetails = new List <OrderDetail>();
                    foreach (var orderDetail in order.OrderDetails)
                    {
                        orderInformation.OrderDetails.Add(new OrderDetail()
                        {
                            ItemId     = orderDetail.ItemId,
                            ItemAmount = orderDetail.ItemAmount,
                            ItemTotal  = orderDetail.ItemTotal
                        });
                    }
                }
                catch (Exception ex)
                {
                    CustomLogging.LogMessage(TracingLevel.ERROR, new Exception("Error retrieving order", ex));
                }
                return(orderInformation);
            }
        }
Beispiel #13
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            CustomLogging.Initialize(Server.MapPath("~"));
        }
Beispiel #14
0
        public ActionResult GetClockURL(int number)
        {
            try
            {
                UserInfo userInfo = new UserInfo(_context, HttpContext, User);
                bool     isAdmin  = userInfo.isAdmin();
                if (isAdmin) //If user is admin, show admin panel to user by setting is admin property to true
                {
                    ClockURL dto = new ClockURL();
                    dto.IsAdmin = isAdmin;
                    return(Json(dto));
                }
                else
                {
                    //If user is not admin, try to find location of user from user info.
                    string locationID  = "";
                    var    userDetails = userInfo.GetUserInfo();
                    CustomLogging.InfoLog("UserInfo details: empID=" + userDetails.empID + "; locationID=" + userDetails.locationID +
                                          "; jobCode=" + userDetails.jobCode + "; dept=" + userDetails.dept);
                    locationID = userDetails.locationID;
                    //IF location is not recieived from user info, try to find it from user agent string
                    if (locationID == "0" || locationID == null)
                    {
                        var userAgent = Request.Headers["User-Agent"].ToString();
                        locationID = Util.GetStoreFromUserAgent(userAgent);
                    }
                    //If location is not present in user agent string, show dropdown to user by sending empty object
                    if (locationID == "0" || String.IsNullOrEmpty(locationID))
                    {
                        ClockURL dtObject = new ClockURL();
                        return(Json(dtObject));
                    }
                    // Now if location is present, generate URL's
                    ClockGenerator generatorObj = new ClockGenerator(_context);
                    ClockURL       clockDTO     = generatorObj.GetClockURLObject(locationID);

                    //setting Redirection Clock
                    string redirectionType = dbService.GetConfigurationProperties("WebClockType");
                    if (redirectionType.ToUpper() == "WEB")
                    {
                        clockDTO.RedirectURL = clockDTO.SilverLighClockURL;
                    }
                    else if (redirectionType.ToUpper() == "HTML")
                    {
                        clockDTO.RedirectURL = clockDTO.HTMLClockURL;
                    }
                    var result = Json(clockDTO);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                CustomLogging.ErrorLog(ex);
                return(Json(false));
            }
        }
 public IHttpActionResult RegisterUser([FromBody] User user)
 {
     if (!ModelState.IsValid)
     {
         CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, CustomLogging.ModelStatusConverter(ModelState));
         return(BadRequest(ModelState));
     }
     _accountService.RegisterUser(user);
     return(Ok(user));
 }
Beispiel #16
0
        public IHttpActionResult GetReleaseByIDs(int detaineeID, int detentionID)
        {
            var release = _releaseService.GetReleaseByIDs(detaineeID, detentionID);

            if (release == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Не существует доставки с таким номером");
                return(NotFound());
            }
            return(Ok(release));
        }
        public IHttpActionResult InsertDetainee([FromBody] Detainee detainee)
        {
            if (!ModelState.IsValid)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, CustomLogging.ModelStatusConverter(ModelState));
                return(BadRequest(ModelState));
            }

            detainee.DetaineeID = _detaineeService.InsertDetainee(detainee);
            return(Ok(detainee));
        }
Beispiel #18
0
        public IHttpActionResult GetDeliveries()
        {
            var deliveriesList = _deliveryService.GetDeliveries();

            if (deliveriesList == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Не существует доставки с таким номером");
                return(NotFound());
            }
            return(Ok(deliveriesList));
        }
Beispiel #19
0
        public IHttpActionResult GetSmartDeliveryByIDs(int detaineeID, int detentionID)
        {
            var delivery = _deliveryService.GetSmartDeliveryByIDs(detaineeID, detentionID);

            if (delivery == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Не существует доставки с таким номером");
                return(NotFound());
            }
            return(Ok(delivery));
        }
Beispiel #20
0
        public IHttpActionResult GetSmartReleasesByDate([FromBody] DateTime date)
        {
            var releasesList = _releaseService.GetSmartReleasesByDate(date);

            if (releasesList == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Нет доставок");
                return(NotFound());
            }
            return(Ok(releasesList));
        }
Beispiel #21
0
        public IHttpActionResult GetRelease(int id)
        {
            var release = _releaseService.GetReleaseByID(id);

            if (release == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Нет освобождения с таким номером");
                return(NotFound());
            }
            return(Ok(release));
        }
Beispiel #22
0
        public IHttpActionResult GetDetentionsByPlace([FromBody] string place)
        {
            var detentionsList = _detentionService.GetDetentionsByPlace(place);

            if (detentionsList == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Не таких задержания");
                return(NotFound());
            }
            return(Ok(detentionsList));
        }
Beispiel #23
0
        public IHttpActionResult GetEmployee(int id)
        {
            var employee = _employeeService.GetEmployeeByID(id);

            if (employee == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Нет такого сотрудника");
                return(NotFound());
            }
            return(Ok(employee));
        }
        public IHttpActionResult GetUsers()
        {
            var users_list = _accountService.GetUsers();

            if (users_list == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Не существует доставки с таким номером");
                return(NotFound());
            }
            return(Ok(users_list));
        }
Beispiel #25
0
        public IHttpActionResult GetDetention(int id)
        {
            var detention = _detentionService.GetDetentionByID(id);

            if (detention == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Не такого задержания");
                return(NotFound());
            }
            return(Ok(detention));
        }
        public IHttpActionResult GetUser(int id)
        {
            var user = _accountService.GetUserByID(id);

            if (user == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Нет такого пользователя");
                return(NotFound());
            }
            return(Ok(user));
        }
Beispiel #27
0
 public string GetConfigurationProperties(string key)
 {
     try
     {
         return(dbService.GetConfigurationProperties(key));
     }
     catch (Exception ex)
     {
         CustomLogging.ErrorLog(ex);
         return("");
     }
 }
Beispiel #28
0
        public IHttpActionResult DeleteDelivery(int id)
        {
            var delivery = _deliveryService.GetDeliveryByID(id);

            if (delivery == null)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, "Не существует доставки с таким номером");
                return(NotFound());
            }
            _deliveryService.DeleteDelivery(id);
            return(Ok(delivery));
        }
        public IHttpActionResult UpdateDetainee(int id, [FromBody] Detainee detainee)
        {
            if (!ModelState.IsValid)
            {
                CustomLogging.LogMessage(CustomLogging.TracingLevel.INFO, CustomLogging.ModelStatusConverter(ModelState));
                return(BadRequest(ModelState));
            }

            _detaineeService.UpdateDetainee(id, detainee);
            _detaineeCachingService.Update(detainee);
            return(Ok(detainee));
        }
Beispiel #30
0
 public ActionResult checkAdmin()
 {
     try
     {
         UserInfo userInfo = new UserInfo(_context, HttpContext, User);
         return(Json(userInfo.isAdmin().ToString()));
     }
     catch (Exception ex)
     {
         CustomLogging.ErrorLog(ex);
         return(Json(false));
     }
 }