private void ComputeObjectsFromFolder() { if (!VerifyWebConfigVariables()) { return; } var emotionMapper = new MLMapper(); var sourceFolder = ConfigurationManager.AppSettings["SourceFolder"].ToString(); var saveFolder = ConfigurationManager.AppSettings["SaveFolder"].ToString(); var files = Directory.GetFiles(sourceFolder); foreach (var file in files) { string lastFolderName = Path.GetFileName(Path.GetDirectoryName(file)); InfoDTO dto = new InfoDTO() { Category = lastFolderName, Image = file }; Console.WriteLine(string.Format("Processing {0}", file)); Thread.Sleep(_pauseParameter); byte[] imgdata = System.IO.File.ReadAllBytes(file); ObjectInfoDTO objectsDTOs = _mlService.GetObjectsFromImage(imgdata); } }
public HttpResponseMessage CurrentLocation([FromBody] InfoDTO info) { if (info.SecretCode == ConnectData.SecretCode && info.CheckNull()) { var item = TrackDataService.GetLastedLocationByImei(info.ID); if (item != null) { RequestInfo returnInfo = new RequestInfo(); returnInfo.MREF = info.MREF; returnInfo.Seqno = info.Seqno; returnInfo.ID = info.ID; returnInfo.Time = item.TransmitTime.ToString("HH:mm:ss"); returnInfo.State = "A"; returnInfo.Latitude = item.Latitude; returnInfo.ExpSN = item.DirectionSN; returnInfo.Longitude = item.Longitude; returnInfo.ExpEW = item.DirectionEW; returnInfo.Speed = item.Speed < 3 ? 0: (Math.Round((item.Speed * 0.53996) * 10) / 10); returnInfo.DIR = ""; returnInfo.Date = item.TransmitTime.ToString("dd/MM/yyyy"); return(Request.CreateResponse(HttpStatusCode.OK, returnInfo)); } return(Request.CreateResponse(HttpStatusCode.BadRequest, "Không tìm thấy thiết bị")); } return(Request.CreateResponse(HttpStatusCode.BadRequest, "SecretCode không chính xác")); }
private void ComputeEmotionsFromLink() { if (!VerifyWebConfigVariables()) { return; } var imageLink = ConfigurationManager.AppSettings["ImageLink"].ToString(); var saveFolder = ConfigurationManager.AppSettings["SaveFolder"].ToString(); Uri uri = new Uri(imageLink); string file = System.IO.Path.GetFileName(uri.AbsolutePath); Console.WriteLine(string.Format("Processing {0}", imageLink)); var jsonPost = "{ \"url\": \"" + imageLink + "\" }"; FaceEmotionDTO[] emotionDTOs = _mlService.GetEmotionsFromLink(jsonPost); InfoDTO dto = new InfoDTO() { Category = "Web", Image = file }; if (emotionDTOs != null) { dto.Emotions = emotionDTOs; _emotionService.AddEmotion(dto); } }
public IEnumerable <UserDTO> FindUserByInfo(InfoDTO info) { Info insideInfo = new Info() { City = info.City }; List <UserDTO> output = new List <UserDTO>(); IEnumerable <User> users = Database.Users.GetAll().Where(u => u.Info.Equals(insideInfo)); foreach (var item in users) { var udto = new UserDTO() { Id = item.Id, Name = item.Name, Phone = item.Phone, Info = item.Info.Id //Role = item.Roles.ToArray(). } }; udto.Role = new int[item.Roles.Count]; for (int i = 0; i < udto.Role.Length; i++) { udto.Role[i] = item.Roles.ToArray()[i].Id; } output.Add(udto); } return(output); //throw new NotImplementedException(); }
private async Task Vote(bool up, InfoDTO info) { ServiceRepository serviceRepository = new ServiceRepository(); page.upvote.IsTapEnabled = false; page.downvote.IsTapEnabled = false; page.upvote.Opacity = 0.4; page.downvote.Opacity = 0.4; RateInfoPostDTO rip = new RateInfoPostDTO() { infoId = info.Id, userId = SessionManager.SessionID, score = up }; bool result = await serviceRepository.setVoteInfo(rip); if (result) { int factor = 1; if (!up) { factor = -1; } page.likesCount.Text = (int.Parse(page.likesCount.Text) + factor).ToString(); } page.upvote.IsTapEnabled = true; page.downvote.IsTapEnabled = true; page.upvote.Opacity = 1; page.downvote.Opacity = 1; }
public IActionResult Update(InfoDTO infoDTO) { if (!_infoModel.UpdateDTO(1, infoDTO)) { return(Problem(statusCode: 500, detail: "Can't update data")); } _cache.DataUpdated(Helper.CacheKey.INFO); return(Ok()); }
/// <summary> /// Мапим в наше DTO /// </summary> private InfoDTO mappingToEntity(OpenweatherDTO openweatherDTO, string lang) { //строка с фразой для ксюхи string phraze = string.Empty; InfoDTO dto = new InfoDTO() { dayInfo = new List <InfoPartDTO>(), weekInfo = new List <InfoPartDTO>() }; foreach (var item in openweatherDTO.hourly) { DateTime date = UnixTimeStampToDateTime(item.dt).ToLocalTime(); if (date.Day == DateTime.Today.Day && date.Hour > DateTime.Now.Hour) { //добавление фразы Ксюхи для дня phraze = SendPhraze(lang, item.clouds, item.temp); InfoPartDTO day = new InfoPartDTO(); day.dateTime = item.dt; day.clouds = item.clouds; day.description = item.weather[0].description; day.temperature = item.temp; day.wind = item.wind_speed; day.feels_like = item.feels_like; day.icon = item.weather[0].icon; day.textFromKsu = phraze; dto.dayInfo.Add(day); } } foreach (var item in openweatherDTO.daily) { DateTime date = UnixTimeStampToDateTime(item.dt).ToLocalTime(); if (date.Day > DateTime.Now.Day) { //добавление фразы Ксюхи для недели phraze = SendPhraze(lang, item.clouds, item.temp.day); InfoPartDTO week = new InfoPartDTO(); week.dateTime = item.dt; week.clouds = item.clouds; week.description = item.weather[0].description; week.temperature = item.temp.day; week.wind = item.wind_speed; week.textFromKsu = phraze; week.feels_like = item.feels_like.day; week.icon = item.weather[0].icon; dto.weekInfo.Add(week); } } return(dto); }
public async Task <IActionResult> Info(InfoDTO info) { if (TryValidateModel(info)) { var nfo = Mapper.Map <Info>(info); var result = await common.addInfo(nfo); } _toastNotification.AddSuccessToastMessage("Your Info have been submitted"); return(View("Contact")); }
public async Task <IHttpActionResult> GetInfo() { InfoDTO infoDto = await service.GetInfo(); InfoModel info = mapper.Map <InfoDTO, InfoModel>(infoDto); if (info != null) { return(Ok(new ResponseSheme(info, "EverythingOk", 200))); } return(BadRequest()); }
public void AddInfo(UserDTO user, InfoDTO info) { User u = Database.Users.Get(user.Id); //if (u.Info == null) return; u.Info = new Info() { City = info.City, User = u }; Database.Infos.Create(u.Info); Database.Save(); }
public bool EmotionAllreadyComputed(InfoDTO infoDTO) { var saveFolder = ConfigurationManager.AppSettings["SaveFolder"].ToString(); var folder = Path.Combine(saveFolder, infoDTO.Category); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var filename = Path.Combine(folder, Path.GetFileName(infoDTO.Image)) + ".txt"; return(File.Exists(filename)); }
public void AddEmotion(InfoDTO infoDTO) { var saveFolder = ConfigurationManager.AppSettings["SaveFolder"].ToString(); var folder = Path.Combine(saveFolder, infoDTO.Category); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var filename = Path.Combine(folder, Path.GetFileName(infoDTO.Image)) + ".txt"; var emotionStr = JsonConvert.SerializeObject(infoDTO); File.WriteAllText(filename, emotionStr); }
public Info(int Id) { List <InfoDTO> InfoList = new List <InfoDTO>(); IInfoRepository infoRepository = new InfoRepositorySqlServer(); InfoList = infoRepository.Infos(Id); InfoDTO i = InfoList[0]; this.Name = i.Name; this.Key = i.Key; this.Value = i.Value; this.Url = i.Url; this.iDate = i.iDate; this.Id = Id; }
public HttpResponseMessage SetUpDelay([FromBody] InfoDTO info) { if (info.SecretCode == ConnectData.SecretCode && info.CheckNullDelay()) { if (AdminService.CheckDeviceExist(null, info.ID) == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new { MREF = info.MREF, Seqno = info.Seqno, ID = info.ID, Result = "Không tìm thấy thiết bị" })); } if (InfoService.AddInfoDelay(info) == 1 && InfoService.GetInfoDelay(info.ID).Time == info.Time) { return(Request.CreateResponse(HttpStatusCode.OK, new { MREF = info.MREF, Seqno = info.Seqno, ID = info.ID, Result = "OK" })); } return(Request.CreateResponse(HttpStatusCode.BadRequest, new { MREF = info.MREF, Seqno = info.Seqno, ID = info.ID, Result = "Fail" })); } return(Request.CreateResponse(HttpStatusCode.BadRequest, new { MREF = info.MREF, Seqno = info.Seqno, ID = info.ID, Result = "SecretCode không đúng" })); }
public static List <InfoDTO> GetAllDelayInfo() { using (SqlDataReader reader = SqlHelper.ExecuteReader(ConnectData.ConnectionString, "sp_GetAllDelayInfo")) { List <InfoDTO> data = new List <InfoDTO>(); if (reader.HasRows) { while (reader.Read()) { InfoDTO dt = new InfoDTO(); dt.ID = reader["DeviceImei"].ToString(); dt.Time = Convert.ToInt32(reader["Time"]); dt.LastSend = Convert.ToDateTime(reader["LastSend"]); data.Add(dt); } return(data); } return(null); } }
public static InfoDTO GetInfoDelay(string ID) { using (SqlDataReader reader = SqlHelper.ExecuteReader(ConnectData.ConnectionString, "sp_GetInfoDelay", ID)) { if (reader.HasRows) { while (reader.Read()) { InfoDTO res = new InfoDTO(); res.MREF = reader["MREF"].ToString(); res.ID = reader["ID"].ToString(); res.Seqno = reader["Seqno"].ToString(); res.SecretCode = reader["SecretCode"].ToString(); res.Time = Convert.ToInt32(reader["Time"]); return(res); } } return(null); } }
/// <summary> /// Update an existing information /// </summary> /// <param name="item"></param> /// <returns></returns> public bool Update(InfoDTO item) { if (item == null) { throw new ArgumentException("item missing"); } // dbo.pInfoUpdate @id=1, @name='test', @key='key', @Value='Value', @Url='Url' using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[ConfigurationManager.AppSettings["connection"]].ConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("dbo.pInfoUpdate", conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Id", item.Id)); cmd.Parameters.Add(new SqlParameter("@Name", item.Name)); cmd.Parameters.Add(new SqlParameter("@Key", item.Key)); cmd.Parameters.Add(new SqlParameter("@Value", item.Value)); cmd.Parameters.Add(new SqlParameter("@Url", item.Url)); cmd.ExecuteNonQuery(); } } return(true); }
private void ComputeEmotionsFromFolder() { if (!VerifyWebConfigVariables()) { return; } var emotionMapper = new MLMapper(); var sourceFolder = ConfigurationManager.AppSettings["SourceFolder"].ToString(); var saveFolder = ConfigurationManager.AppSettings["SaveFolder"].ToString(); var files = Directory.GetFiles(sourceFolder); foreach (var file in files) { string lastFolderName = Path.GetFileName(Path.GetDirectoryName(file)); InfoDTO dto = new InfoDTO() { Category = lastFolderName, Image = file }; Console.WriteLine(string.Format("Processing {0}", file)); if (!_emotionService.EmotionAllreadyComputed(dto)) { Thread.Sleep(_pauseParameter); byte[] imgdata = System.IO.File.ReadAllBytes(file); FaceEmotionDTO[] emotionDTOs = _mlService.GetEmotionsFromImage(imgdata); if (emotionDTOs != null) { dto.Emotions = emotionDTOs.ToArray(); _emotionService.AddEmotion(dto); } } } }
// public List<MyInfo.DTO.InfoDTO> InfoList { get; set; } /// <summary> /// Persist the new task in the repository /// </summary> public int Save() { // create new object and send to the repository InfoDTO td = new InfoDTO(); td.Name = this.Name; td.Key = this.Key; td.Value = this.Value; IInfoRepository infoRepository = new InfoRepositorySqlServer(); if (this.Id == 0) { // add the item in the repository and return the provided generated information id return(infoRepository.Add(td)); } else { // Id exist: update existing item td.Id = this.Id; infoRepository.Update(td); return(0); } }
public HttpResponseMessage Communication([FromBody] InfoDTO rq) { switch (rq.MREF) { case "IMG": { Lib.Service.TrackDataService.AddMessage(rq.ID, rq.Message); return(Request.CreateResponse(HttpStatusCode.OK)); } case "2": var rs = Lib.Service.TrackDataService.GetLastedLocation(int.Parse(rq.ID)); if (rs != null) { return(Request.CreateResponse(HttpStatusCode.OK, new { rq.MREF, rq.Seqno, rq.ID, Time = rs.TransmitTime.ToString("hhMMss"), State = rs.State, rs.Latitude, rs.Longitude, rs.Speed, Date = rs.TransmitTime.ToString("ddmmyyyy") })); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); case "6": var val = Lib.Service.TrackDataService.AddConfigTime(rq.ID, rq.OpCode, rq.Time); return(Request.CreateResponse(HttpStatusCode.OK, new { Results = val > 0 ? "OK" : "Fail" })); } return(Request.CreateResponse(HttpStatusCode.OK)); }
private void InitComments(InfoDTO info) { page.CommentListbox.Items.Clear(); var comments = info.comments.Reverse(); //comments foreach (var comment in comments) { StackPanel commentPanel = new StackPanel() { Orientation = Orientation.Horizontal }; StackPanel votePanel = new StackPanel() { Orientation = Orientation.Vertical }; StackPanel commentTextPanel = new StackPanel() { Orientation = Orientation.Vertical }; commentPanel.Children.Add(votePanel); commentPanel.Children.Add(commentTextPanel); TextBlock scoreText = new TextBlock() { Text = comment.reputation.ToString(), Foreground = new SolidColorBrush(Windows.UI.Colors.White), TextAlignment = Windows.UI.Xaml.TextAlignment.Center, FontSize = 18 }; Image upvote = new Image() { Width = 50, Height = 25, Source = new BitmapImage(new Uri("ms-appx:///Assets/upvote.png")), }; Image downvote = new Image() { Width = 50, Height = 25, Source = new BitmapImage(new Uri("ms-appx:///Assets/downvote.png")), }; upvote.Tapped += new TappedEventHandler(async delegate(object o, TappedRoutedEventArgs e) { await VoteComment(true, comment, upvote, downvote, scoreText); } ); downvote.Tapped += new TappedEventHandler(async delegate(object o, TappedRoutedEventArgs e) { await VoteComment(false, comment, upvote, downvote, scoreText); } ); votePanel.Children.Add(upvote); votePanel.Children.Add(scoreText); votePanel.Children.Add(downvote); TextBlock posterName = new TextBlock() { Text = comment.user, Foreground = new SolidColorBrush(Windows.UI.Colors.White), FontSize = 18 }; TextBlock commentText = new TextBlock() { Text = comment.content, Foreground = new SolidColorBrush(Windows.UI.Colors.White), FontSize = 22 }; commentTextPanel.Children.Add(posterName); commentTextPanel.Children.Add(commentText); page.CommentListbox.Items.Add(commentPanel); } }
private async Task <Document> AddElementToDocumentDb(string databaseName, string collectionName, InfoDTO emotions) { DocumentClient client; client = new DocumentClient(new Uri(_endpointUri), _primaryKey); var result = await client.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), emotions); var document = result.Resource; return(result); }
public void InitInformation(InfoDTO info) { ServiceRepository serviceRepository = new ServiceRepository(); page.placeName.Text = info.place; page.vrijemeOd.Text = "Od: " + info.startTime.ToString(); page.vrijemeDo.Text = "Do: " + info.endTime.ToString(); page.opis.Text = info.content; page.likesCount.Text = info.reputation.ToString(); page.upvote.Tapped += new TappedEventHandler(async delegate(object o, TappedRoutedEventArgs e) { await Vote(true, info); } ); page.downvote.Tapped += new TappedEventHandler(async delegate(object o, TappedRoutedEventArgs e) { await Vote(false, info); } ); page.commentButton.Click += new RoutedEventHandler(async delegate(object o, RoutedEventArgs e) { page.commentButton.IsEnabled = false; page.commentTextbox.IsEnabled = false; CommentPostDTO comment = new CommentPostDTO() { userId = SessionManager.SessionID, content = page.commentTextbox.Text, contentInfoId = info.Id, time = DateTime.Now }; int?id = await serviceRepository.setComment(comment); if (id != null) { List <CommentDTO> tempList = new List <CommentDTO>(info.comments); tempList.Add(new CommentDTO() { Id = (int)id, content = comment.content, user = "******", reputation = 0, time = comment.time }); info.comments = tempList; } InitComments(info); page.commentButton.IsEnabled = true; page.commentTextbox.IsEnabled = true; } ); InitComments(info); }
public void AddEmotion(InfoDTO infoDTO) { var repo = new MDRepository <InfoDTO>(); repo.InsertOne(infoDTO); }
public bool EmotionAllreadyComputed(InfoDTO infoDTO) { throw new NotImplementedException(); }
public IActionResult Index(InfoDTO info = null) { ViewBag.Info = info; return(View()); }
public static int AddInfoDelay(InfoDTO info) { return(SqlHelper.ExecuteNonQuery(ConnectData.ConnectionString, "sp_AddInfoDelay", info.MREF, info.ID, info.Seqno, info.SecretCode, info.OpCode, info.Time)); }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { infoDTO = (InfoDTO)e.Parameter; }