private List <MarketplaceOrder> getMarketplaceOrdersData(List <string> orderIds) { var context = new ApiContext(); var results = new List <MarketplaceOrder>(); try { // let's set the credentials for our eBay API service context.ApiCredential = _apiCredential; context.SoapApiServerUrl = _apiServiceUrl; // init the GetOrdersCall var apiCall = new GetOrdersCall(context); apiCall.DetailLevelList = new DetailLevelCodeTypeCollection(); apiCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); apiCall.OrderRole = TradingRoleCodeType.Seller; apiCall.OrderStatus = OrderStatusCodeType.Completed; apiCall.Site = SiteCodeType.US; apiCall.OrderIDList = new StringCollection(orderIds.ToArray()); apiCall.Execute(); // check if the call is not success if (apiCall.ApiResponse.Ack != AckCodeType.Success) { _logger.Add(LogEntrySeverity.Error, LogEntryType.eBayOrders, string.Format("{0} - Error in retrieving orders for eBay. Error message: {1}", apiCall.ApiResponse.Errors[0].LongMessage), apiCall.ApiResponse.Errors.ToString()); return(null); } var ordersResult = apiCall.ApiResponse.OrderArray; if (ordersResult.Count == 0) { return(null); } // parsed the orders results foreach (OrderType item in ordersResult) { results.Add(parsedMarketplaceOrder(item)); } return(results); } catch (Exception ex) { _logger.LogError(LogEntryType.AmazonOrdersProvider, string.Format("{0} - Error in getting latest order data for Order Id: {1}. Error Message: {2}", ChannelName, string.Join(",", orderIds), EisHelper.GetExceptionMessage(ex)), ex.StackTrace); return(null); } }
public void ToLogDTo(string username, string message, LogTypeHelper logTypeHelper) { LogDTO logDTO = new LogDTO(); logDTO.UserName = username; logDTO.Type = logTypeHelper.Value; logDTO.Message = message; logDTO.IPAddress = ""; logDTO.CreationDate = DateTime.Now; _logService.Add(logDTO); }
public async Task <ActionResult> Create([Bind(Include = "Id,Date,Title,Note,FurtherNote,Category")] LogModel log) { log.Date = DateTime.UtcNow; if (ModelState.IsValid) { await _logService.Add(log); return(RedirectToAction("Index")); } return(View(log)); }
private void btnGuncelle_Click(object sender, EventArgs e) { try { _logService.Add(new Log { KullaniciID = _kullanici.ID, Aciklama = _kullanici.KullaniciAdi + ", " + _hisseSenedi.HisseSahibi.ToString() + " kişisine ait " + _hisseSenedi.ID.ToString() + " ID sine sahip hisseyi günelledi." + _hisseSenedi.HisseDegeri.ToString() + "-" + nudHSDeger.Value.ToString() + " ; " + _hisseSenedi.HisseYili.ToString() + "-" + nudSene.Value.ToString() + " ; " + _hisseSenedi.HisseTertipNo.ToString() + "-" + nudTertip.Value.ToString() + " ; " + _hisseSenedi.HisseNo.ToString() + "-" + nudHisseNo.Value.ToString() + " ; " + _hisseSenedi.isGecerli.ToString() + "-" + cbxBlokaj.Checked.ToString() }); HisseSenedi hsen = _hisseSenediService.Get(_hisseSenedi.ID); //_hisseSenediService.Update(new HisseSenedi //{ // ID = _hisseSenedi.ID, // HisseSahibiID = _hisseSenedi.HisseSahibi.ID, // HisseDegeri = nudHSDeger.Value, // HisseYili = (int)nudSene.Value, // HisseTertipNo = (int)nudTertip.Value, // HisseNo = (int)nudHisseNo.Value, // isGecerli = cbxBlokaj.Checked, //});; hsen.HisseDegeri = nudHSDeger.Value; hsen.HisseYili = (int)nudSene.Value; hsen.HisseTertipNo = (int)nudTertip.Value; hsen.HisseNo = (int)nudHisseNo.Value; hsen.isGecerli = cbxBlokaj.Checked; _hisseSenediService.Update(hsen); MessageBox.Show("Güncelleme Başarılı"); } catch (Exception) { MessageBox.Show("Güncelleme Başarısız"); } }
public async Task <IActionResult> Login([FromBody] UserRequestModel userParam) { try { var user = await _userService.Authenticate(userParam.Email, userParam.Password); if (user == null) { return(BadRequest(new { status = HttpStatusCode.InternalServerError, valid = false, msg = "Username or Password is incorrect" })); } var UserDtos = _mapper.Map <UserResponseModel>(user); var claims = new Claim[] { new Claim(JwtRegisteredClaimNames.Sub, user.Email), new Claim(JwtRegisteredClaimNames.Email, user.Email), new Claim("UserId", user.Id), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) }; string refreshToken = tokenGenerators.GenerateRefreshToken(); string jwtRoken = tokenGenerators.GenerateJwtToken(claims, config); await logService.DeleteAll(UserDtos.Id); await logService.Add(CreateLog(UserDtos.Id, refreshToken)); var result = new { UserDtos.FullName, Token = jwtRoken, RefreshToken = refreshToken }; return(Ok(new { status = HttpStatusCode.OK, valid = true, msg = "You have been logged successfully!", response = result })); } catch (Exception ex) { return(BadRequest(new { status = HttpStatusCode.InternalServerError, valid = false, msg = ex.Message + ex.InnerException?.Message })); } }
private void btnKullaniciIslemleri_Click(object sender, EventArgs e) { if (_kullanici.Role == Roles.admin) { KullaniciIslemleri kullaniciIslemleriForm = new KullaniciIslemleri(_kullanici, this); kullaniciIslemleriForm.Show(); this.Hide(); _logService.Add(new Log { KullaniciID = _kullanici.ID, Aciklama = _kullanici.KullaniciAdi + " kullanıcısı kullanıcı işlemlerine giriş yaptı." }); } }
public void Convert() { var observations = observationService.Get(); var continents = locationService.Get(); foreach (var observation in observations) { observation.Continent = continents.SingleOrDefault(c => c.Country == observation.Country)?.Continent; logService.Add(observation); progress?.Report(observation); } }
public IHttpActionResult PostSum([FromUri] string sum) { try { var log = new Log(FindIPAddress()); _logService.Add(log); var result = _calcService.Calculate(sum); return(Ok(result)); } catch (Exception) { return(BadRequest("Error In Calculation")); } }
public ActionResult addLog(string data) { var username = User.Identity.Name; Log log = new Log(); log.Content = username + data; log.CreatedBy = userService.FindAll().Where(x => x.Username == username).FirstOrDefault().ID; log.CreateAt = DateTime.Now; log.Status = true; bool status = logService.Add(log); logService.Save(); return(Json(status, JsonRequestBehavior.AllowGet)); }
public IActionResult Index() { //throw new Exception(); //var au1 = HttpContext.RequestServices.GetService(typeof(IAdminUserService)) as IAdminUserService; //_cache.Set("k1", "v1:" + DateTime.Now.ToString(), TimeSpan.FromSeconds(5)); log.Add("add log"); //return Content(person.Dance() + user.Dance()+au.GetPwd("username")+","+ au1.GetPwd("au1")); return(View()); //string contentPath = hostingEnvironment.ContentRootPath; //string wwwPath = hostingEnvironment.WebRootPath; //string appSettingPath = Path.Combine(contentPath, wwwPath); //var env = hostingEnvironment.IsDevelopment(); //return Content(env + contentPath + "," + wwwPath + "," + appSettingPath); }
private void LogError(Exception ex) { try { Log log = new Log(); log.CreatedDate = DateTime.Now; log.Message = ex.Message; log.StackTrace = ex.StackTrace; _errorService.Add(log); _errorService.SaveChanges(); } catch { } }
public async Task <GoogleResponseObject> GetRecaptchaScore(string googleClientToken) { using (var httpClient = new HttpClient()) { var secret = _config.GetSection("SiteConfiguration")["RecaptchaSiteSecret"]; var response = httpClient.GetAsync($"https://www.google.com/recaptcha/api/siteverify?response={googleClientToken}&secret={secret}").Result; var jsonString = await response.Content.ReadAsStringAsync(); var log = _logService.Get(0); log.Date = DateTime.Now; log.LogType = "Error"; log.Summary = $"Recaptcha Response: {jsonString}"; _logService.Add(log); return(JsonConvert.DeserializeObject <GoogleResponseObject>(jsonString)); } }
public void Run() { Task.Run(() => { var dc = new DomainConfiguration(_config); try { new SelfHost(new ApiCompositionRoot(dc), _logger) .Run(dc.ListenUri); } catch (Exception e) { _logger.Add(e.Message); } }); }
public IActionResult Post([FromBody] LogViewModel logViewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Request.Headers.TryGetValue("Authorization", out StringValues token); var log = _service.Add(logViewModel, token.ToString()); if (log is null) { return(NoContent()); } return(CreatedAtAction(nameof(Get), new { log.Id }, log)); }
public async Task <IActionResult> Get([FromQuery] string companyCode) { if (string.IsNullOrWhiteSpace(companyCode)) { return(NotFound()); } var company = await _companyService.GetByCompanyCodeAsync(companyCode); await _logService.Add(Request.Method, Request.Path, Request.QueryString.Value, Request.Headers["User-Agent"], Request.Headers["Accept-Language"], Request.Headers["Host"], Request.Headers["Origin"]); if (company == null) { return(NotFound()); } return(Json(company)); }
public ActionResult <IEnumerable <LogDTO> > Post([FromBody] LogAddDTO log) { try { if (!ModelState.IsValid) { throw new Exception("Fail on model validation"); } _app.Add(log); return(_app.SelectAll()); } catch (Exception ex) { _err.Add(ex, HttpContext.User.Identity.Name); return(BadRequest(ex.Message)); } }
public void DeleteShipStationOrder(string orderId) { //delete order from ship station try { var shipStationService = new ShipStationService(); var shipStationTask = shipStationService.DeleteOrderByOrderNumber(orderId); shipStationTask.Wait(); } catch (Exception ex) { var description = string.Format("{0} - Error in submitting delete order feed to Shipstation with OrderId: {1}. \nError Message: {2}", ChannelName, orderId, (ex.InnerException != null ? string.Format("{0} <br/>Inner Message: {1}", ex.Message, ex.InnerException.Message) : ex.Message)); _logger.Add(LogEntrySeverity.Error, LogEntryType.EshopoOrders, description, ex.StackTrace); _emailService.SendEmailAdminException(subject: "Eshopo - Delete ShipStation Order Error", exParam: ex, useDefaultTemplate: true, url: "/orders", userName: String.Format("Order Id: {0}", orderId)); } }
public IActionResult Post([FromBody] Log body) { var entity = _manager.Add(body); return(ResponseJson(entity)); }
private void HandleMetricsChanged(string message) { _log.Add($"HandleMetricsChanged({message.Replace("\n", "")})"); }
public void SubmitProductsListingFeed(List <MarketplaceProductFeedDto> productPostFeeds, string submittedBy) { try { // take out the products which has no product type id or no information for Amazon var invalidProducts = productPostFeeds .Where(x => x.IsBlacklisted || x.AmazonProductFeed == null || x.ProductTypeId == null) .ToList(); if (invalidProducts.Any()) { _logger.Add(LogEntrySeverity.Warning, LogEntryType.AmazonListing, string.Format("{0}/{1} EIS products which will not be included to Amazon product listing feed due to no product type ID or no Amazon information or black listed.", invalidProducts.Count, productPostFeeds.Count)); productPostFeeds.RemoveAll(x => x.IsBlacklisted || x.AmazonProductFeed == null || x.ProductTypeId == null); } // create the Amazon envelope for the products var envelope = RequestHelper.CreateProductsFeedEnvelope(productPostFeeds, AmazonEnvelopeMessageOperationType.Update); // parse the envelope into file var xmlFullName = XmlParser.WriteXmlToFile(envelope, "AmazonProductsListingFeed"); var submitFeedController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy); var streamResponse = submitFeedController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_PRODUCT_DATA_); parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.Product, submittedBy); _logger.LogInfo(LogEntryType.AmazonListing, string.Format("{0} - Successfully posted product listing feed for {1} product items. \nRequested by: {2}", ChannelName, productPostFeeds.Count, submittedBy)); } catch (Exception ex) { var description = string.Format("{0} - Error in submitting product listing feed for {3} items. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, productPostFeeds.Count); _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonListing, description, ex.StackTrace); } }
public void Post([FromBody] string value) { _logService.Add(log); _logService.Save(); }
private Task HandleExceptionAsync(HttpContext context, Exception exception) { context.Response.ContentType = "application/json"; context.Response.StatusCode = (int)HttpStatusCode.Forbidden; var message = string.Empty; Enums.LogType logType = Enums.LogType.Error; if (exception is FoundSameObjectException) { logType = Enums.LogType.SameObject; message = ResponseMessage.SAME_OBJECT.ToString(); } else if (exception is NotFoundException) { logType = Enums.LogType.NotFound; message = ResponseMessage.NOT_FOUND.ToString(); } else if (exception is ExistDependencyException) { logType = Enums.LogType.Error; message = ResponseMessage.EXIST_DEPENDENCY_OBJECTS.ToString(); } else if (exception is NotFoundDependencyObjectException) { logType = Enums.LogType.NotFound; message = ResponseMessage.NOT_FOUND_DEPENDENCY_OBJECT.ToString(); } else if (exception is RoleManagerException) { logType = Enums.LogType.Error; message = ResponseMessage.ERROR.ToString(); } else if (exception is UserManagerException) { logType = Enums.LogType.Error; message = ResponseMessage.ERROR.ToString(); } else if (exception is UnavailableOperationException) { logType = Enums.LogType.NoAccess; message = ResponseMessage.NO_ACCESS.ToString(); } else if (exception is AppUnauthorizedAccessException) { logType = Enums.LogType.Error; context.Response.StatusCode = (int)HttpStatusCode.Unauthorized; var ex = exception as AppUnauthorizedAccessException; if (ex.UnautorizedType == UnautorizedType.NOT_FOUND) { if (ex.ObjectType == ObjectType.USER) { message = ResponseMessage.NOT_FOUND_USER.ToString(); } else if (ex.ObjectType == ObjectType.ROLE) { message = ResponseMessage.NOT_FOUND_ROLE.ToString(); } } else if (ex.UnautorizedType == UnautorizedType.SAME_OBJECT) { if (ex.ObjectType == ObjectType.USER) { message = ResponseMessage.SAME_USER.ToString(); } else if (ex.ObjectType == ObjectType.ROLE) { message = ResponseMessage.SAME_ROLE.ToString(); } } } else { logType = Enums.LogType.Error; context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; } _logService.Add(logType, exception.Message); return(context.Response.WriteAsync(message)); }
public void OnException(ExceptionContext context) { logService.Add("Exception"); }
public void SubmitSingleProductListingFeed(MarketplaceProductFeedDto productFeed, string submittedBy) { if (productFeed.eBayProductFeed == null || productFeed.eBayProductFeed.CategoryId == null) { _logger.LogWarning(LogEntryType.eBayProductListing, string.Format("Unable to create listing for this product - {0} due to no eBay details or category id.", productFeed.EisSKU)); return; } if (!string.IsNullOrEmpty(productFeed.eBayProductFeed.ItemId)) { _logger.LogWarning(LogEntryType.eBayProductListing, string.Format("The EIS product {0} is already listed in eBay. Please do the product revise feed instead!", productFeed.EisSKU)); return; } try { // set the log file name _context.ApiLogManager.ApiLoggerList.Add(new FileLogger(string.Format(_logDirectory, MethodBase.GetCurrentMethod().Name), false, true, true)); var apiCall = new AddItemCall(_context); // parse the product feed for eBay item var itemType = RequestHelper.CreateItemType(productFeed, _credential.eBayDescriptionTemplate); // send the request and get the fee collection var fees = apiCall.AddItem(itemType); var container = new ItemContainer { EisSKU = productFeed.EisSKU, ItemId = itemType.ItemID }; foreach (FeeType fee in fees) { if (fee.Fee.Value <= 0) { continue; } container.Fees.Add(new Fee { Name = fee.Name, Amount = fee.Fee.Value, CurrencyCode = fee.Fee.currencyID.ToString(), ActionFeedType = eBayConstants.ITEM_ADDED }); } logAndUpdateProductItemId(new List <ItemContainer> { container }, LogEntryType.eBayProductListing); } catch (Exception ex) { var description = string.Format("Error in submitting single product feed for {0} - {3}. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, productFeed.EisSKU); _logger.Add(LogEntrySeverity.Error, LogEntryType.eBayProductListing, description, ex.StackTrace); } }
public int Add(Log log) { return(_logService.Add(log)); }
public void NotifyConnectionChanged(string message) { _logger.Add($"NotifyConnectionChanged({message})"); ConnectionChanged?.Invoke(message); }
public ActionResult Login(LoginViewModel model, string returnUrl = "") { HttpCookie cookie = new HttpCookie("User"); //ViewBag.show = "false"; //if there are no any model errors exists, allows user to login to the system if (ModelState.IsValid) { //Encripted password assign to a string variable string encryptedPw = _userService.Encrypt(model.password.TrimEnd()); User user = null; //Validated user assign to a variable var isValidUser = _userService.ValidateUser(model.username.TrimEnd(), encryptedPw); //If user is exists, the user lastlogin will update in the database if (isValidUser) { user = _userService.UserList.FirstOrDefault(a => a.username.Equals(model.username.TrimEnd())); if (user != null) { user.lastLogin = DateTime.Now; } _userService.Save(user); } if (user != null) { //If user is exists, The ticket is passed as the value of the forms authentication cookie with // each request and is used by forms authentication on the server to identify an authenticated user. FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, user.username, DateTime.Now, DateTime.Now.AddMinutes(30), model.RememberMe, ""); string encToken = FormsAuthentication.Encrypt(ticket); HttpCookie authoCookies = new HttpCookie(FormsAuthentication.FormsCookieName, encToken); //Set the coockie expire time cookie.Expires = DateTime.Now.AddDays(2); Response.Cookies.Add(authoCookies); Logs logIn = new Logs(); logIn.userId = user.userId; logIn.loggedTime = DateTime.Now; logService.Add(logIn); //Session Management Session["lUser"] = user; TempData["LoginMessage"] = "<script>alert('You have successfully loggedin!!!')</script>"; return(RedirectToAction("Index", "Post")); //the user will be redirected to the all post lists } //if the username and password correct, validation message will be showed else { ModelState.AddModelError("", "Sorry, You have enterd the incorrect username or password"); ModelState.Remove("Password"); return(View()); } } return(View(model)); }
public bool ConfirmOrderShimpmentDetails(MarketplaceOrderFulfillment marketplaceOrder, string submittedBy) { if (!marketplaceOrder.OrderItems.Any()) { return(false); } // create configuratin to use US marketplace var config = new MarketplaceWebServiceConfig { ServiceURL = RequestHelper.ServiceUrl }; config.SetUserAgentHeader(_ApplicationName, _Version, "C#"); _amazonClient = new MarketplaceWebServiceClient(_credential.AccessKeyId, _credential.SecretKey, config); try { // create fulfillment item list from the order items var fulfillmentItems = new List <OrderFulfillmentItem>(); foreach (var item in marketplaceOrder.OrderItems) { fulfillmentItems.Add(new OrderFulfillmentItem { Item = item.OrderItemId, Quantity = item.Quantity.ToString() }); } // create the order fulfillment information var fulfillment = new OrderFulfillment { Item = marketplaceOrder.OrderId, FulfillmentDate = marketplaceOrder.FulfillmentDate, FulfillmentData = new OrderFulfillmentFulfillmentData { Item = marketplaceOrder.Carrier.Code, ShippingMethod = marketplaceOrder.ShippingMethod, ShipperTrackingNumber = marketplaceOrder.ShipperTrackingNumber }, Item1 = fulfillmentItems.ToArray() }; // create Amazon envelope object var amazonEnvelope = new AmazonEnvelope { Header = new Header { DocumentVersion = "1.01", MerchantIdentifier = _credential.MerchantId }, MessageType = AmazonEnvelopeMessageType.OrderFulfillment, Message = new AmazonEnvelopeMessage[] { new AmazonEnvelopeMessage { MessageID = "1", Item = fulfillment } } }; // parse the envelope into file var xmlFullName = XmlParser.WriteXmlToFile(amazonEnvelope, "OrderFulfillment"); var submitController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy); var streamResponse = submitController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_ORDER_FULFILLMENT_DATA_); parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.OrderFulfillment, submittedBy); _logger.Add(LogEntrySeverity.Information, LogEntryType.AmazonOrdersProvider, string.Format("{0} - Successfully sent confirming order shipment for Order ID \'{1}\'", ChannelName, marketplaceOrder.OrderId)); return(true); } catch (Exception ex) { _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonOrdersProvider, string.Format("{0} - Error in confirming order shipment for OrderId: {3}. <br/>Error Message: {1} <br/> Access Key: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), _credential.AccessKeyId, marketplaceOrder.OrderId), ex.StackTrace); return(false); } }
public void WriteReport(string report) { _logService.Add(report); _logService.Save(); }
protected void AddLog(LogType logType, string message) { _logService.Add(logType, message); }