public RecipePage BuildRecipePage(string recipeKey, int pageNo) { Recipe r = BuildRecipe(recipeKey); RecipePage p = new RecipePage(r.Title, pageNo, r.Id); PageBuilder.RegisterInstance(p); PageRepository.Add(p); return(p); }
private void OnScanComplete(object sender, PageEventArgs e) { foreach (var page in e.Pages) { var result = page.DetectDocument(true); Console.WriteLine("Attempted document detection on imported page: " + result.Status); } PageRepository.Add(e.Pages); OpenImageListController(); }
public JsonResult AddPage(int id) { var newPage = new Page(); newPage.ReportId = id; pageRepository.Add(newPage); var json = JsonConvert.SerializeObject(newPage.Id); return(Json(json, JsonRequestBehavior.AllowGet)); }
public static void CreateViews(DbContext context) { var userManager = HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>(); var admin = userManager.FindByName("Admin"); if (admin == null) { throw new InvalidOperationException("Admin doesnt exist in Database"); } PageRepository pageRepository = new PageRepository(context); List <PageBase> pages = new List <PageBase>(); pages.Add(new HomePage() { PageName = "Home", StartActionName = "Index", ControllerName = "Home", ApplicationUser = admin, ApplicationUserId = admin.Id }); pages.Add(new SqlDashBoardPage() { PageName = "SqlDashBoard", StartActionName = "Index", ControllerName = "SqlDashBoard", ApplicationUser = admin, ApplicationUserId = admin.Id }); foreach (var createdPage in pages) { //find page type in database var databasePages = pageRepository.GetQueryable() .Where(x => x.ControllerName == createdPage.ControllerName).ToList(); //iterate those pages foreach (var databasePage in databasePages) { //if that is main page,change properties ,except controllername due to identification of this page //that must not be changed! if (databasePage.ApplicationUser == null) { databasePage.PageName = createdPage.PageName; databasePage.StartActionName = createdPage.StartActionName; } pageRepository.Update(databasePage); } //if it is new page in the system, add it to database if (!databasePages.Any()) { pageRepository.Add(createdPage, x => new { x.ApplicationUser }); } pageRepository.Save(); } }
private void ImageImported(object sender, UIImagePickerMediaPickedEventArgs e) { ImagePicker.Instance.Dismiss(); ImagePicker.Instance.Controller.FinishedPickingMedia -= ImageImported; var page = PageRepository.Add(e.OriginalImage, new SBSDKPolygon()); var result = page.DetectDocument(true); Console.WriteLine("Attempted document detection on imported page: " + result.Status); OpenImageListController(); }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == Result.Ok && requestCode == CAMERA_ACTIVITY) { var pages = data.GetParcelableArrayExtra(DocumentScannerActivity.SnappedPageExtra).Cast <Page>().ToList(); PageRepository.Add(pages); } adapter.SetItems(PageRepository.Pages); adapter.NotifyDataSetChanged(); UpdateVisibility(); }
public ActionResult Create(PageViewModel page) { var access = _accessRepository.GetByToken(HttpContext.Request.Headers["Authorization"]); page.OwnerId = access.UserId; var pagina = _pageRepository.Add(_mapper.Map <Page>(page)); if (pagina == null) { return(BadRequest()); } return(Ok(_mapper.Map <UserViewModel>(pagina))); }
private static void export() { System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); TextureRepository texturesRepository = new TextureRepository(); texturesRepository.FromJSON(File.ReadAllText( URLManager.CombinePath( Application.streamingAssetsPath, AssetPath.DEFAULT_REPOSITORY_IN_SA, URLManager.DEFAULT_TEXTURE_REPOSITORY_FILENAME) )); PageRepository pagesRepository = new PageRepository(); pagesRepository.FromJSON(File.ReadAllText( URLManager.CombinePath( Application.streamingAssetsPath, AssetPath.DEFAULT_REPOSITORY_IN_SA, URLManager.DEFAULT_PAGE_REPOSITORY_FILENAME) )); lastUsedAssetPath = AssetPath.CreateAssetPath(AssetPath.DEFAULT_RESOURCES_PATH, wizard.Folder) + "/" + PAGE_PREFIX + wizard.Name + ".asset"; ImageData data = exportMeshData(); AssetDatabase.CreateAsset(data, lastUsedAssetPath); AssetImporter asset = AssetImporter.GetAtPath(lastUsedAssetPath); string bundleName = wizard.Folder + ".unity3d"; asset.SetAssetBundleNameAndVariant(bundleName, ""); AssetDatabase.SaveAssets(); // Модификация реестра страниц string previewPath = AssetDatabase.GetAssetPath(wizard.PreviewTexture); uint textureID = texturesRepository.Find(t => t.Location.ResourceName == previewPath).ID; List <uint> allPagesIDs = pagesRepository.FindAll(p => true).Select(p => p.ID).ToList(); uint maxPageID = 0; allPagesIDs.ForEach(id => maxPageID = (id > maxPageID) ? id : maxPageID); Page oldPage = pagesRepository.Find(p => p.Location.ResourceName == lastUsedAssetPath); if (oldPage == null) { pagesRepository.Add(new Page( maxPageID + 1, lastUsedAssetPath, bundleName, textureID )); } else { pagesRepository.Storage[oldPage.ID].TextureID = textureID; // = new Page( // oldPage.ID, // oldPage.Location.ResourceName, // bundleName, // textureID // ); } File.WriteAllText(URLManager.CombinePath( Application.streamingAssetsPath, AssetPath.DEFAULT_REPOSITORY_IN_SA, URLManager.DEFAULT_PAGE_REPOSITORY_FILENAME), pagesRepository.ToJSON()); sw.Stop(); Debug.Log(string.Format("Import completed. Time elapsed: {0}ms", sw.ElapsedMilliseconds)); }