/// <summary> /// Starts saving mission, metadata and thumbnail. Called from the previous function and from the update after a tablet that didn't press "done mapping" receives a done mapping message /// </summary> void SaveAndGoToPlanSelectionv2() { done = true; //Remove frames form the queue as there are some residues MapperModule.DequeuePCLFrame(); MapperModule.DequeuePCLFrame(); MapperModule.DequeuePCLFrame(); //If the map hasn't been downloaded yet, continue in this loop while (MapLoader.mapDownloaded == false) { //do nothing } MapLoader.mapDownloaded = false; //If the info panel is activated, the metadata needs to be written before coming back to Plan if (mapInfoPanel.activeSelf) { fileSize = new System.IO.FileInfo(Application.persistentDataPath + "/PersistentData/Maps/" + MissionManager.guid + ".dpl.map").Length; fileSizeText.GetComponent <Text>().text = fileSize.ToString(); boundingBoxText.GetComponent <Text>().text = new Vector3(maxX, maxY, maxZ).ToString(); dateText.GetComponent <Text>().text = "" + DateTime.Now.Day + '/' + DateTime.Now.Month + '/' + DateTime.Now.Year; return; } SceneManager.LoadScene("General"); //StartCoroutine(RenderTexture()); }
public string postComment(CommentPostViewModel postComment) { if (this.User.Identity.IsAuthenticated) { if (ModelState.IsValid) { this.User.Identity.GetUserId(); CommentDTO commentDTO = MapperModule.CommentPostViewModel_To_CommentDTO(postComment); commentDTO.userID = this.User.Identity.GetUserId(); try { logger.Info("User try add comment"); commentService.PostComment(commentDTO); logger.Info("Comment succesfully added"); } catch (DbEntityValidationException ex) { logger.Error(ex, "Comment not saved to the Database validation of entities fails"); return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = ex.Message })); } catch (DbUpdateException ex) { logger.Error(ex, "Comment not saved to the Database"); return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = ex.Message })); } catch (DataException ex) { logger.Error(ex, "Comment not saved to the Database"); return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = ex.Message })); } catch (SystemException ex) { logger.Error(ex, "Exeption occured when user post new comment"); return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = ex.Message })); } return(JsonConvert.SerializeObject(new { postComment.content, postComment.parent, success = true })); } return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = "Send data is't valid" })); } return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = "Login please" })); }
/// <summary> /// Creates <see cref="IRickAndMortyService"/> interface instance. /// </summary> /// <returns></returns> public static IRickAndMortyService Create() { var mapper = MapperModule.Resolve(); var service = new RickAndMortyService(mapper); return(service); }
public string editComment(CommentEditViewModel commentEditViewModel) { commentEditViewModel.modified = DateTime.Now; EditCommentDTO editCommentDTO = MapperModule.CommentEditViewModel_To_EditCommentDTO(commentEditViewModel); commentService.EditComment(editCommentDTO); return(JsonConvert.SerializeObject(new { id = commentEditViewModel.id, content = commentEditViewModel.content, modified = commentEditViewModel.modified })); }
private static void InitializeBindings(IKernel kernel) { var mapperConfiguration = MapperModule.Configure(); kernel.Bind <MapperConfiguration>().ToConstant(mapperConfiguration).InSingletonScope(); kernel.Bind <IMapper>().ToMethod(ctx => new Mapper(mapperConfiguration, type => ctx.Kernel.Get(type))); BLDependencyResolver.Initialize(kernel); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); MapperModule.Initialize(); GlobalConfiguration.Configure(WebApiConfig.Register); InitializeContainer(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
protected override void Load(ContainerBuilder builder) { builder.RegisterType <RickAndMortyService>() .AsImplementedInterfaces() .SingleInstance(); builder.Register(ctx => MapperModule.Resolve()) .As <IRickAndMortyMapper>() .SingleInstance(); }
/// <summary> /// Creates <see cref="IRickAndMortyService"/> interface instance. /// </summary> /// <param name="url">URL to service.</param> /// <returns></returns> public static IRickAndMortyService Create(string url) { Ensure.Bool.IsFalse(String.IsNullOrEmpty(url)); var mapper = MapperModule.Resolve(); var service = new RickAndMortyService(mapper, url); return(service); }
public void PostComment(CommentDTO commentDTO) { CommentEntity commentEntity = MapperModule.CommentDTO_To_CommentEntity(commentDTO); Comment comment = MapperModule.CommentDTO_To_Comment(commentDTO); comment.commentEntity = commentEntity; Database.Comments.Create(comment); Database.Save(); }
public async Task <string> getComments(int entityType, int entityID) { try { string userID = this.User.Identity.GetUserId(); IEnumerable <GetCommentsDTO> commentsDTO = await commentService.GetCommentsAsync(entityType, entityID, userID); //IEnumerable<GetCommentsDTO> commentsDTO = commentService.GetComments(entityType, entityID, userID); IEnumerable <CommentsGetViewModel> commentsGetViewModel = MapperModule.GetCommentsDTO_To_CommentsGetViewModel(commentsDTO); return(JsonConvert.SerializeObject(new { commentsGetViewModel, success = true })); } catch (DataException ex) { logger.Error(ex, "Comments data cannot be retrieved from the database"); return(JsonConvert.SerializeObject(new { success = false, message = ex.Message })); } }
public List <Models.Vegetable> GetVegetables(Dictionary <int, string> ingredients) { var storage = _unitOfWork.VegetableStorage.GetAll().ToList(); foreach (var ing in ingredients) { var foundVegetables = storage.Find(item => item.Vegetable.Name == ing.Value); if (foundVegetables == null) { throw new NotFoundIngredientException(""); } if (foundVegetables.VegetableStock < ing.Key) { throw new NoAmountNeededProductException(ing.ToString()); } var vegetable = MapperModule.EFVegetable_To_Vegetable(foundVegetables.Vegetable); vegetable.Weight = ing.Key; Vegetables.Add(vegetable); } return(Vegetables); }
public IServiceProvider ConfigureServices(IServiceCollection services) { var connection = _configuration.GetConnectionString("Connection"); services.AddDbContext <DvorContext>(options => options.UseSqlServer(connection)); var apiAuthSettings = AuthOperator.AddApiAuthSettings(_configuration, services); var cookieAuthSettings = AuthOperator.AddCookieAuthSettings(_configuration, services); services .AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddCookie(options => { options.SlidingExpiration = true; options.LoginPath = "/Account/Login"; options.AccessDeniedPath = "/Account/AccessDenied"; options.ExpireTimeSpan = TimeSpan.FromSeconds(cookieAuthSettings.ExpirationTimeInSeconds); }) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.TokenValidationParameters = new TokenValidationParameters { RequireExpirationTime = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(apiAuthSettings.Secret)), ValidIssuer = apiAuthSettings.Issuer, ValidateIssuer = true, ValidateAudience = false }; }); services.AddAuthorization(); MapperModule.Configure(services); services.AddLocalization(options => options.ResourcesPath = "App_LocalResources"); services.AddMvc() .AddViewLocalization() .AddJsonOptions(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore); services.Configure <RequestLocalizationOptions>(options => { var supportedCultures = new[] { new CultureInfo("en"), new CultureInfo("ru") }; options.DefaultRequestCulture = new RequestCulture("en"); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; }); var builder = new ContainerBuilder(); builder.RegisterModule <DIModule>(); builder.Populate(services); var container = builder.Build(); return(new AutofacServiceProvider(container)); }
void Update() { //If the app didn't click and a done mapping arrived, go to save plan if (done != true && MapperModule.state == MapperModule.MapperState.DONE) { MapperModule.state = MapperModule.MapperState.IDLE; SaveAndGoToPlanSelectionv2(); } else if (done) { return; } //If a last PC deleted arrived, enter here if (MapperModule.lastPointCloudDeletedBool) { //If this is the app that deleted the PC, exit if (lastPCDeleted) { lastPCDeleted = false; } else { if (savedPointCloud.PointCloud.Count > 0) { Destroy(this.transform.GetChild(this.transform.childCount - 1).gameObject); PointCloudID pointCloudToDelete = savedPointCloud.PointCloud[savedPointCloud.PointCloud.Count - 1].pointCloudID; savedPointCloud.PointCloud.RemoveAt(savedPointCloud.PointCloud.Count - 1); numAdded--; } } MapperModule.lastPointCloudDeletedBool = false; } //Same as above but for every PC if (MapperModule.allPointCloudsDeletedBool) { if (allPointCloudDeleted) { allPointCloudDeleted = false; } else { for (int i = 0; i < savedPointCloud.PointCloud.Count; i++) { Destroy(this.transform.GetChild(i).gameObject); } savedPointCloud.PointCloud.Clear(); numAdded = 0; } MapperModule.allPointCloudsDeletedBool = false; } //We obtain the message of the pointcloud with the structure that contains the points, rotation and ID PCLMsg pclmsg = MapperModule.DequeuePCLFrame(); if (pclmsg != null) { //PCLMsg pclmsg = queue.Dequeue(); //If there are too many pointclouds, delete the last from local. In our tests the app didn't seem to reach a limit. if (numDrawn > (CLOUDS_TO_RENDER - 1)) { Destroy(GameObject.Find("cloudgo" + (numDrawn - CLOUDS_TO_RENDER))); } //Gets the points and rotation PCLMesh cm = pclmsg.getCloudMesh(); // Instantiate pointclouds in gameobjects GameObject instance = GameObject.Instantiate(prefab_cloud_go, this.transform, true); instance.name = "cloudgo" + numDrawn.ToString(); instance.GetComponent <MeshFilter>().sharedMesh = new Mesh(); instance.GetComponent <MeshFilter>().sharedMesh.name = "cmesh" + numDrawn.ToString(); /* * instance.GetComponent<MeshFilter>().sharedMesh.vertices = cm.points; * instance.GetComponent<MeshFilter>().sharedMesh.SetIndices(cm.indices, MeshTopology.Points, 0, true); * instance.GetComponent<MeshFilter>().sharedMesh.normals = cm.normals; * instance.GetComponent<MeshFilter>().sharedMesh.colors = cm.colors; */ //UnityEngine.Debug.Log("Puntets: " + cm.points[0]); //Executes the compute shader that turns the points in triangles runComputeShader(ref cm.points, ref cm.normals); Triangle[] result = new Triangle[cm.points.Length]; triangles.GetData(result); //GPU-> CPU releaseCSBuffers(); // It is necessary to release compute buffers after using them // insert the compute shader results in vectors // TODO: from compute shader write directly in a buffer[numpoints*3] instead of buffer.p1, buffer.p2, buffer.3 Vector3[] allVertices = new Vector3[cm.points.Length * 3]; Vector3[] allNormals = new Vector3[cm.points.Length * 3]; Color[] allColors = new Color[cm.points.Length * 3]; int[] allIndices = new int[cm.points.Length * 3]; //After obtaining the vertex from gpu, the mesh is created for (int i = 0, j = 0; i < cm.points.Length * 3; i += 3, j++) { allVertices[i] = result[j].p1; allVertices[i + 1] = result[j].p2; allVertices[i + 2] = result[j].p3; CalculateBounds(allVertices[i], allVertices[i + 1], allVertices[i + 2]); allIndices[i] = i; allIndices[i + 1] = i + 1; allIndices[i + 2] = i + 2; allNormals[i] = cm.normals[j]; allNormals[i + 1] = cm.normals[j]; allNormals[i + 2] = cm.normals[j]; allColors[i] = cm.colors[j]; allColors[i + 1] = cm.colors[j]; allColors[i + 2] = cm.colors[j]; } //TODO: replace de loop above by using Graphics.DrawProceduralIndirect (on a Camera script) and an appendBuffer in other CompShader (consumer). Tried it but didn't work. Didn't have much time to seriously try //https://www.digital-dust.com/single-post/2017/07/10/Marching-cubes-on-the-GPU-in-Unity // attach vertices, colors, and normals to the mesh instance.GetComponent <MeshFilter>().sharedMesh.vertices = allVertices; instance.GetComponent <MeshFilter>().sharedMesh.SetIndices(allIndices, MeshTopology.Triangles, 0, true); instance.GetComponent <MeshFilter>().sharedMesh.normals = allNormals; instance.GetComponent <MeshFilter>().sharedMesh.colors = allColors; instance.GetComponent <MeshFilter>().sharedMesh.RecalculateBounds(); #if POZYX_TRANSFORM_COORDS // Converting coords from Pozyx to Unity, mm to meters, and angles from right-handed to left-handed Matrix4x4 toUnityCoordsMat = Matrix4x4.TRS(new Vector3(pclmsg.hdr.x * 0.001f, pclmsg.hdr.z * 0.001f, pclmsg.hdr.y * 0.001f), Quaternion.Euler(pclmsg.hdr.pitch * -180f / 3.141592f, pclmsg.hdr.yaw * -180f / 3.141592f, pclmsg.hdr.roll * -180f / 3.141592f), new Vector3(1, 1, 1)); instance.transform.rotation = toUnityCoordsMat.rotation; instance.transform.position = new Vector3(toUnityCoordsMat.m03, toUnityCoordsMat.m13, toUnityCoordsMat.m23); //instance.transform.RotateAround(drone.transform.position, new Vector3(1, 0, 0), toUnityCoordsMat.rotation.eulerAngles.x); //instance.transform.RotateAround(drone.transform.position, new Vector3(0, 1, 0), -toUnityCoordsMat.rotation.eulerAngles.y); //instance.transform.RotateAround(drone.transform.position, new Vector3(0, 0, 1), toUnityCoordsMat.rotation.eulerAngles.z); //UnityEngine.Debug.Log(toUnityCoordsMat); //instance.transform.localScale = new Vector3(-1 * instance.transform.localScale.x, instance.transform.localScale.y, instance.transform.localScale.z); #endif //The loop that checks if a pointcloud needs to be substitutedw numDrawn++; int posOfOldPointCloud = savedPointCloud.isTheCloudAlreadyIn(pclmsg.hdr.pointCloudID); if (posOfOldPointCloud != -1) { GameObject aux = GameObject.Find("cloudgo" + pclmsg.hdr.pointCloudID.i + "" + pclmsg.hdr.pointCloudID.j + "" + pclmsg.hdr.pointCloudID.k + "" + pclmsg.hdr.pointCloudID.heading); if (aux != null) { //Destroying the gameobject Destroy(aux); //UnityEngine.Debug.Log("Destroyed"); } else { //search on saved DISK } //UnityEngine.Debug.Log("Removed"); //And remove it from the array savedPointCloud.PointCloud.RemoveAt(posOfOldPointCloud); } //Renaming the pointcloud to manage it better instance.name = "cloudgo" + pclmsg.hdr.pointCloudID.i + "" + pclmsg.hdr.pointCloudID.j + "" + pclmsg.hdr.pointCloudID.k + "" + pclmsg.hdr.pointCloudID.heading; //savedPointCloud.PointCloud.Add(new SavedMeshPointCloud(allVertices, allColors, Matrix4x4.TRS(new Vector3(pclmsg.hdr.x * 0.001f, pclmsg.hdr.z * 0.001f, pclmsg.hdr.y * 0.001f), // Quaternion.Euler(pclmsg.hdr.pitch * -180f / 3.141592f, pclmsg.hdr.yaw * -180f / 3.141592f, pclmsg.hdr.roll * -180f / 3.141592f), new Vector3(1, 1, 1)), new Vector3(pclmsg.hdr.pointCloudID.i, pclmsg.hdr.pointCloudID.j, pclmsg.hdr.pointCloudID.k), pclmsg.hdr.pointCloudID.heading)); //Adding the pointcloud to the array savedPointCloud.PointCloud.Add(new SavedMeshPointCloud(new Vector3(pclmsg.hdr.pointCloudID.i, pclmsg.hdr.pointCloudID.j, pclmsg.hdr.pointCloudID.k), pclmsg.hdr.pointCloudID.heading)); } //LoadFile(); // Código a ejecutar cuando ya hemos pintado la nube de puntos entera //if (numDrawn == NUMCLOUDFILES) //{ // // Ajustamos todos los parámetros de las cámaras para centrarlas sobre la nube de puntos y tratar de abarcarla entera // AdjustCameras(); // // canvas.SetActive(true); // // numDrawn++; //} }
public string postImageComment(CommentImagePostViewModel postImageComment) { var file = this.Request.Files[0]; if (file.ContentType == "image/jpeg" || file.ContentType == "image/png") { if (file.ContentLength <= Int32.Parse(ConfigurationManager.AppSettings["MaxFileSize"])) { CommentImageDTO commentImageDTO = MapperModule.CommentImagePostViewModel_To_CommentImageDTO(postImageComment); commentImageDTO.userID = this.User.Identity.GetUserId(); commentImageDTO.contentLength = file.ContentLength; commentImageDTO.contentType = file.ContentType; commentImageDTO.fileName = file.FileName; byte[] data = new byte[file.ContentLength]; file.InputStream.Read(data, 0, file.ContentLength); commentImageDTO.data = data; try { commentService.PostImageComment(commentImageDTO); } catch (DbEntityValidationException ex) { logger.Error(ex, "Comment not saved to the Database validation of entities fails"); return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = ex.Message })); } catch (DbUpdateException ex) { logger.Error(ex, "Comment not saved to the Database"); return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = ex.Message })); } catch (DataException ex) { logger.Error(ex, "Comment not saved to the Database"); return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = ex.Message })); } catch (SystemException ex) { logger.Error(ex, "Exeption occured when user post new comment"); return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = ex.Message })); } string imageBase64Data = Convert.ToBase64String(data); string imageDataURL = string.Format("data:{0};base64,{1}", file.ContentType, imageBase64Data); return(JsonConvert.SerializeObject(new { id = 10, content = "", file_url = imageDataURL, file_mime_type = file.ContentType })); } else { return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = "File is too big, you can attach file whith size less than 5000 bytes" })); } } else { return(JsonConvert.SerializeObject(new ErrorResponse { success = false, message = "You can attach only photo in jpeg and png" })); } }
// Use this for initialization void Awake() { //If clientunity object is already present on the scene, the new one gets destroyed if (FindObjectsOfType(GetType()).Length > 1) { Destroy(gameObject); return; } //The first ClientUnity is common for every scene DontDestroyOnLoad(gameObject); //FileInfo fileInfo = new System.IO.FileInfo(Application.dataPath + "/Resources/Update/airt-project-0.1.1-.deb"); //FileStream fs = File.OpenRead(Application.dataPath + "/Resources/Update/airt-project-0.1.1-.deb"); //ulong fileSize = (ulong)fileInfo.Length; //UnityEngine.Debug.Log("File size: " + fileSize); //byte[] fileBytes = new byte[4096]; // //BinaryReader br = new BinaryReader(fs); // // //ulong bytesRead = 0; //while (bytesRead < fileSize) //{ // int readCount = br.Read(fileBytes, (int)0, 4096); // bytesRead += 4096; // UnityEngine.Debug.Log("READING"); //} //UnityEngine.Debug.Log("END"); //Drone ip if (GlobalSettings.Instance.getIP() == "") { //GlobalSettings.Instance.setIP("10.42.0.101"); GlobalSettings.Instance.setIP("192.168.8.1"); } //GlobalSettings.Instance.setIP("192.168.8.205"); //GlobalSettings.Instance.setIP("158.42.154.131"); //Every module client = new Client(); stdManager = new StandardModule(); atreyuManager = new AtreyuModule(); osManager = new OSModule(FileManager.debFilePath, FileManager.debFileName + ".deb"); fpvManager = new FPVModule(); FCS_Module = new FCSModule(); libraryManager = new LibraryModule(); missionExecutorManager = new MissionExecutorModule(); pozyxManager = new PozyxModule(); pointCloudManager = new MapperModule(); droneManager = new DroneModule(); recCamModule = new RecCamModule(); //mhandlers.Add(new MsgHandler((byte)Modules.POINTCLOUD_MODULE, (byte)PointcloudNotificationType.PCL_SINGLE, onPclData)); // data cli_thread = new Thread(() => client.run(mhandlers)); cli_thread.Start(); //We start quering atreyu state to see if the app should jump to mapping or recording, as the drone can't do anything other than mapping or recording if it is //is those states if (client.isConnected) { tryReconnect = false; client.SendCommand((byte)Modules.ATREYU_MODULE, (byte)AtreyuCommandType.ATREYU_QUERY_SYSTEM_STATE); } else { tryReconnect = true; } //client.sendCommand((byte)Modules.ATREYU_MODULE, (byte)AtreyuCommandType.ATREYU_QUERY_SERVER_VERSION); }