public void RejectWRO(Guid wroId) { using (var context = new SCMSEntities()) { using (TransactionScope scope = new TransactionScope()) { try { var wrnItems = context.WarehouseReleaseItems.Where(w => w.WarehouseReleaseId == wroId).ToList(); foreach (var wrnItem in wrnItems) { string itemCategory = context.Inventories.FirstOrDefault(p => p.Id == wrnItem.InventoryId).Item.ItemCategory.CategoryCode; if (itemCategory.Equals("A")) { wrnItem.Quantity = 1; Model.Asset ass = context.Assets.FirstOrDefault(p => p.Id == wrnItem.AssetId); ass.IsReleased = false; ass.CurrentOwnerId = null; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(ass, System.Data.EntityState.Modified); } Model.Inventory inv = context.Inventories.First(p => p.Id == wrnItem.InventoryId); inv.Quantity += (Int64)wrnItem.Quantity; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(inv, System.Data.EntityState.Modified); } context.SaveChanges(); SessionData.CurrentSession.ReleaseOrderList = null; SessionData.CurrentSession.ReleaseOrderItemList = null; SessionData.CurrentSession.AssetList = null; SessionData.CurrentSession.InventoryList = null; scope.Complete(); } catch (Exception ex) { scope.Dispose(); throw ex; } } } }
public bool IsROrderDeleted(Guid ROId) { using (var context = new SCMSEntities()) { var RO = context.WarehouseReleases.FirstOrDefault(p => p.Id == ROId); foreach (var item in RO.WarehouseReleaseItems) { string itemCategory = context.Inventories.FirstOrDefault(p => p.Id == item.InventoryId).Item.ItemCategory.CategoryCode; if (itemCategory.Equals("A")) { item.Quantity = 1; Model.Asset ass = context.Assets.FirstOrDefault(p => p.Id == item.AssetId); ass.IsReleased = false; ass.CurrentOwnerId = null; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(ass, System.Data.EntityState.Modified); } Model.Inventory inv = context.Inventories.First(p => p.Id == item.InventoryId); inv.Quantity += (Int64)item.Quantity; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(inv, System.Data.EntityState.Modified); } context.WarehouseReleases.Remove(RO); int affectedRecords = context.SaveChanges(); SessionData.CurrentSession.ReleaseOrderList = null; SessionData.CurrentSession.ReleaseOrderItemList = null; SessionData.CurrentSession.AssetList = null; SessionData.CurrentSession.InventoryList = null; return(affectedRecords > 0 ? true : false); } }
public string GenerateAssetNo(Model.GoodsReceivedNoteItem GRNItem) { string code = GRNItem.PurchaseOrderItem.ProjectDonor.Donor.ShortName + "/"; code += GRNItem.PurchaseOrderItem.ProjectDonor.Project.ShortName + "/"; long count = 1; Model.Asset m = SessionData.CurrentSession.AssetList.OrderByDescending(p => p.Index).FirstOrDefault(); if (m != null) { count = m.Index + 1; } if (count < 10000) { if (count < 10) { return(code + "0000" + count); } if (count < 100 & count >= 10) { return(code + "000" + count); } if (count < 1000 & count >= 100) { return(code + "00" + count); } if (count < 10000 & count >= 1000) { return(code + "0" + count); } } return(code + count); }
public void Execute() { if (!Check()) { return; } Model.Asset asset = form.project.Assets[form.listAssets.SelectedIndices[0]]; if (asset.Atlas == null) { return; } var dlg = new SaveFileDialog() { Filter = "png files|*png", }; DialogResult result = dlg.ShowDialog(); if (result == DialogResult.OK) { string savename = dlg.FileName; if (System.IO.Path.HasExtension(savename)) { savename = System.IO.Path.ChangeExtension(savename, ""); } else { savename += "."; } asset.Atlas.SaveImage(savename + "png"); asset.Atlas.SavePlist(savename + "plist"); } }
public ActionResult RegsiterItem(Guid id, Model.Asset model) { model.GoodsReceivedNoteItemId = id; model.CountryProgramId = countryProg.Id; //check for uploaded image if (UserSession.CurrentSession.UploadedFile != null) { model.Image = UserSession.CurrentSession.UploadedFile; } var grnItm = SessionData.CurrentSession.GoodsReceivedNoteItemList.FirstOrDefault(p => p.Id == id); model.ItemId = grnItm.PurchaseOrderItem.Item.Id; model.PurchaseValue = grnItm.PurchaseOrderItem.UnitPrice; model.AcquisionDate = (DateTime)grnItm.GoodsReceivedNote.ApprovedOn; model.OriginalProjectId = model.CurrentProjectDonorId; gRNService.IsAssetRegistered(model); SessionData.CurrentSession.AssetList = null; int totalItems, currentItemcount; totalItems = (Int32)grnItm.QuantityDelivered; currentItemcount = SessionData.CurrentSession.AssetList.Count(p => p.GoodsReceivedNoteItemId == id); //clear session image variable to allow for more uploads UserSession.CurrentSession.UploadedFile = null; SessionData.CurrentSession.InventoryList = null; SessionData.CurrentSession.GoodsReceivedNoteItemList = null; if (currentItemcount == totalItems) { return(ViewUnregisteredAssets()); } else { ModelState.Clear(); return(RegisterAsset(id)); } }
private void asset_listview_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListView Item = (ListView)sender; Model.Asset asset = (Model.Asset)Item.SelectedItem; this.NavigationService.Navigate(new AssetDetailPage(asset)); }
public bool IsWRNItemDeleted(Guid wrnItemId) { using (var context = new SCMSEntities()) { Model.WarehouseReleaseItem wrnitm = context.WarehouseReleaseItems.FirstOrDefault(p => p.Id == wrnItemId); string itemCategory = context.Inventories.FirstOrDefault(p => p.Id == wrnitm.InventoryId).Item.ItemCategory.CategoryCode; if (itemCategory.Equals("A")) { wrnitm.Quantity = 1; Model.Asset ass = context.Assets.FirstOrDefault(p => p.Id == wrnitm.AssetId); ass.IsReleased = false; ass.CurrentOwnerId = null; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(ass, System.Data.EntityState.Modified); } Model.Inventory inv = context.Inventories.First(p => p.Id == wrnitm.InventoryId); inv.Quantity += (Int64)wrnitm.Quantity; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(inv, System.Data.EntityState.Modified); context.WarehouseReleaseItems.Remove(wrnitm); int affectedColumns = context.SaveChanges(); SessionData.CurrentSession.ReleaseOrderList = null; SessionData.CurrentSession.ReleaseOrderItemList = null; SessionData.CurrentSession.AssetList = null; SessionData.CurrentSession.InventoryList = null; return(affectedColumns > 0 ? true : false); } }
public ActionResult DisposeAsset(Model.Asset model) { if (gRNService.IsAssetDisposed(model)) { SessionData.CurrentSession.AssetList = null; } return(AssetManagement()); }
public bool IsAssetRegistered(Model.Asset assetEntity) { using (var context = new SCMSEntities()) { using (TransactionScope scope = new TransactionScope()) { try { assetEntity.IsAssigned = false; assetEntity.Id = Guid.NewGuid(); //if (assetEntity.UseLifeSpan) // assetEntity.DepreciationType = "Straight Line"; context.Assets.Add(assetEntity); if (context.Inventories.Count(p => p.ItemId == assetEntity.ItemId && p.WareHouseId == assetEntity.CurrentWareHouseId) > 0) { Model.Inventory invt = context.Inventories.FirstOrDefault(p => p.ItemId == assetEntity.ItemId && p.WareHouseId == assetEntity.CurrentWareHouseId); invt.Quantity += 1; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(invt, System.Data.EntityState.Modified); } else { Model.Inventory newinvetoryEntity = new Model.Inventory() { Id = Guid.NewGuid(), ItemId = (Guid)assetEntity.ItemId, Quantity = 1, CountryProgrammeId = assetEntity.CountryProgramId, WareHouseId = (Guid)assetEntity.CurrentWareHouseId }; context.Inventories.Add(newinvetoryEntity); } if (assetEntity.IsFleet) { SessionData.CurrentSession.FleetDetailsList = null; context.FleetDetails.Add(new FleetDetail() { Id = Guid.NewGuid(), CountryProgrammeId = assetEntity.CountryProgramId, AssetId = assetEntity.Id, IssueDate = DateTime.Now }); } if (assetEntity.DepreciationType == "Zero Percentage") { if (!(context.SaveChanges() > 0)) { scope.Dispose(); return(false); } else { scope.Complete(); return(true); } } else { assetEntity.DepreciationPeriods = assetEntity.Lifespan * 12; } return(this.IsDepreciationComputed(context, scope, assetEntity)); } catch (Exception ex) { scope.Dispose(); throw ex; } } } }
public AssetDetailPage(Model.Asset asset) { InitializeComponent(); this.asset = asset; setController(new AssetController(this)); InitUIBuilders(); InitUIElements(); ShowAsset(); }
public ActionResult LoadEditAsset(Guid assetId) { Model.Asset model = inventoryService.GetAssetInventoryList(AssetId: assetId).FirstOrDefault(); model.Projects = new SelectList(SessionData.CurrentSession.ProjectDonorList, "Id", "ProjectNumber"); model.Warehouses = new SelectList(SessionData.CurrentSession.WarehouseList, "Id", "Name"); model.Staffs = new SelectList(SessionData.CurrentSession.StaffList, "Id", "StaffName"); model.SalvageValue = Math.Round(model.SalvageValue, 2); ViewBag.CurrentProject = inventoryService.GetAssetCurrentProjetNoByAssetId(assetId); return(View(model)); }
public bool InsertAsset(Model.Asset asset) { try { asset.CreationTime = asset.UpdateTime = DateTime.Now; Instance.Connection.Insert(asset); } catch (SQLiteException ex) { Log.Info("SQLiteEx", ex.Message); return(false); } return(true); }
public bool IsAssetDisposed(Model.Asset AssetEntity) { using (var context = new SCMSEntities()) { Model.Asset aset = context.Assets.FirstOrDefault(p => p.Id == AssetEntity.Id); aset.IsDesposed = true; aset.ActionType = AssetEntity.ActionType; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(aset, System.Data.EntityState.Modified); Model.Inventory inv = context.Inventories.FirstOrDefault(p => p.ItemId == aset.ItemId & p.WareHouseId == aset.CurrentWareHouseId); inv.Quantity -= 1; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(inv, System.Data.EntityState.Modified); return(context.SaveChanges() > 0 ? true : false); } }
public ActionResult EditAssetDetails(Model.Asset assetModel) { //check for uploaded image if (UserSession.CurrentSession.UploadedFile != null) { assetModel.Image = UserSession.CurrentSession.UploadedFile; } assetModel.IsReleased = assetModel.CurrentOwnerId.HasValue; if (inventoryService.IsAssetEdited(assetModel)) { SessionData.CurrentSession.AssetList = null; } //clear uploaded image UserSession.CurrentSession.UploadedFile = null; return(View("AssetInventoryPopUp", inventoryService.GetAssetInventoryList(AssetId: assetModel.Id).FirstOrDefault())); }
public bool IsAssetStateChanged(Model.AssetManagment Entity) { using (var context = new SCMSEntities()) { context.AssetManagments.Add(Entity); Model.Asset aset = context.Assets.FirstOrDefault(p => p.Id == Entity.AssetId); aset.IsAssetStateChanged = true; if (Entity.currentProjectId != null) { aset.CurrentProjectDonorId = Entity.currentProjectId; } ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(aset, System.Data.EntityState.Modified); return(context.SaveChanges() > 0 ? true : false); } }
Database() { try { connection = new SQLiteConnection(Path.Combine(path, Constants.DatabaseFileName)); connection.CreateTable <Model.Asset>(); connection.CreateTable <Model.AssetType>(); if (connection.Table <Model.AssetType>().Count() == 0) { var assetType = new Model.AssetType { Name = "Ingatlan" }; connection.Insert(assetType); assetType.Name = "Autó"; connection.Insert(assetType); } if (connection.Table <Model.Asset>().Count() == 0) { var asset = new Model.Asset { Name = "Ház", EstimatedValue = 15000000, AssetTypeId = 1, AssetStatusId = 1 }; connection.Insert(asset); asset.Name = "Autó"; asset.EstimatedValue = 1000000; asset.AssetTypeId = 2; } UpgradeDatabaseIfNecessary(); } catch (SQLiteException ex) { Log.Info("SQLiteEx", ex.Message); } }
public void OnClickUpdateButton() { string name = assetTextBox.getText(); string quantity = quantityTextBox.getText(); if (name == "" || quantity == "") { MessageBox.Show("Please fill all the fields", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } else { Model.Asset newAsset = new Model.Asset(); newAsset.Id = asset.Id; newAsset.Name = name; newAsset.Quantity = Int32.Parse(quantity); getController().callMethod("UpdateAsset", newAsset, myFile); } }
private bool AddItems(Model.WarehouseRelease wrEntity, Model.WarehouseReleaseItem entity, SCMSEntities context, TransactionScope scope, bool sendmail = false) { string itemCategory = context.Inventories.FirstOrDefault(p => p.Id == entity.InventoryId).Item.ItemCategory.CategoryCode; if (wrEntity == null) { wrEntity = context.WarehouseReleases.FirstOrDefault(w => w.Id == entity.WarehouseReleaseId); } entity.Id = Guid.NewGuid(); if (itemCategory.Equals("C")) { entity.AssetId = Guid.Empty; context.WarehouseReleaseItems.Add(entity); } else { entity.Quantity = 1; Model.Asset ass = context.Assets.FirstOrDefault(p => p.Id == entity.AssetId); ass.IsReleased = true; ass.CurrentOwnerId = wrEntity.ReceivedBy; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(ass, System.Data.EntityState.Modified); context.WarehouseReleaseItems.Add(entity); } Model.Inventory inv = context.Inventories.First(p => p.Id == entity.InventoryId); inv.Quantity -= (Int64)entity.Quantity; ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(inv, System.Data.EntityState.Modified); if ((context.SaveChanges() > 0)) { SessionData.CurrentSession.ReleaseOrderList = null; SessionData.CurrentSession.ReleaseOrderItemList = null; SessionData.CurrentSession.AssetList = null; SessionData.CurrentSession.InventoryList = null; if (sendmail) { NotificationServicee.SendNotification(NotificationServicee.GetApproverEmailAddress(1, NotificationHelper.wrnCode), NotificationHelper.wrnMsgBody, NotificationHelper.wrnsubject); } scope.Complete(); return(true); } else { scope.Dispose(); return(false); } }
public bool IsAssetEdited(Model.Asset entity) { using (var context = new SCMSEntities()) { if (entity.IsFleet) { if (context.FleetDetails.FirstOrDefault(p => p.AssetId == entity.Id) == null) { context.FleetDetails.Add(new FleetDetail() { Id = Guid.NewGuid(), CountryProgrammeId = entity.CountryProgramId, AssetId = entity.Id, IssueDate = DateTime.Now }); } } context.Assets.Attach(entity); ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Modified); return((context.SaveChanges() > 0) ? true : false); } }
public bool UpdateAsset(Model.Asset asset) { try { asset.UpdateTime = DateTime.Now; Instance.Connection.Query <Model.Asset>( "UPDATE Asset set Name=?, UpdateTime=?, StartTime=?, Endtime=?, EstimatedValue=?, AssetTypeId=?, AssetStatusId=?", asset.Name, asset.UpdateTime, asset.StartTime, asset.EndTime, asset.EstimatedValue, asset.AssetTypeId, asset.AssetStatusId); return(true); } catch (SQLiteException ex) { Log.Info("SQLiteEx", ex.Message); return(false); } }
public string GetAssetCurrentProjetNoByAssetId(Guid assetId) { Model.Asset aset = SessionData.CurrentSession.AssetList.FirstOrDefault(p => p.Id == assetId); if (!aset.IsAssetStateChanged) { return(aset.ProjectDonor.ProjectNumber); } else { var asetmgt = aset.AssetManagments.Where(p => p.AssetId == assetId).OrderByDescending(p => p.IssueDate).FirstOrDefault(); if (asetmgt.currentProjectId != null) { return(asetmgt.ProjectDonor.ProjectNumber); } else { return(asetmgt.PartnerName); } } }
public void Execute() { if (!Check()) { return; } Model.Asset asset = form.project.Assets[form.listAssets.SelectedIndices[0]]; if (asset.Atlas == null) { return; } AnimationForm aniForm = new AnimationForm(); aniForm.SetData(form.project, asset); aniForm.ShowDialog(); form.dirty = true; form.UpdateTitle(); }
public string GetAssetCurrentProject(Model.Asset asset) { string currentProject; if (!asset.IsAssetStateChanged) { currentProject = asset.ProjectDonor.ProjectNumber + " (" + asset.ProjectDonor.Donor.ShortName + ")"; } else { var asetmgt = asset.AssetManagments.OrderByDescending(p => p.IssueDate).FirstOrDefault(); if (asetmgt.currentProjectId != null) { currentProject = asetmgt.ProjectDonor.ProjectNumber + " (" + asetmgt.ProjectDonor.Donor.ShortName + ")"; } else { currentProject = asetmgt.PartnerName; } } return(currentProject); }
public static ViewWayBill prepareWB(Guid wbId) { using (var db = new SCMSEntities()) { WayBill entitymodel = db.WayBills.First(p => p.Id == wbId); ViewWayBill model = new ViewWayBill(); model.EntityWBill = entitymodel; WarehouseRelease wrn = model.EntityWBill.WarehouseRelease; model.issuer = db.VStaffDetails.FirstOrDefault(p => p.StaffID == entitymodel.PreparedBy); model.consignee = db.VStaffDetails.FirstOrDefault(p => p.StaffID == entitymodel.Consignee); model.ReceivedBy = db.VStaffDetails.FirstOrDefault(p => p.StaffID == entitymodel.ReceivedBy); model.OrrignWH = db.WareHouses.FirstOrDefault(p => p.Id == entitymodel.IssuerWarehouse); model.destinationWH = db.WareHouses.FirstOrDefault(p => p.Id == entitymodel.DestinationWarehouse); model.DestnationOfiice = db.CountrySubOffices.FirstOrDefault(p => p.Id == entitymodel.DestinationOffice); Model.Location loc = model.destinationWH.Location; Model.CountrySubOffice cso = model.destinationWH.CountrySubOffice; model.OrignSOfiice = db.CountrySubOffices.First(p => p.Id == entitymodel.IssuingOffice); Model.Location l = model.OrignSOfiice.Location; Model.Location lok = model.DestnationOfiice.Location; List <WarehouseReleaseItem> writems = entitymodel.WarehouseRelease.WarehouseReleaseItems.ToList(); foreach (WarehouseReleaseItem item in writems) { Model.Inventory inv = item.Inventory; Model.Item it = inv.Item; Model.ItemCategory ic = it.ItemCategory; Model.UnitOfMeasure u = it.UnitOfMeasure; Model.Asset ast = item.Asset; } model.WRItems = writems; //dummies var person = entitymodel.Staff.Person; if (entitymodel.Staff1 != null) { person = entitymodel.Staff1.Person; } return(model); } }
public ActionResult WBReceive() { using (var db = new SCMSEntities()) { WarehouseRelease wrn = db.WarehouseReleases.FirstOrDefault <WarehouseRelease>(); List <WarehouseReleaseItem> itmz = wrn != null?wrn.WarehouseReleaseItems.ToList() : new List <WarehouseReleaseItem>(); foreach (WarehouseReleaseItem item in itmz) { Model.Inventory iv = item.Inventory; Model.Item it = iv.Item; Model.ItemCategory itc = it.ItemCategory; Model.Asset ast = item.Asset; Model.UnitOfMeasure u = it.UnitOfMeasure; } //Use this to populate items on load for any changes in the stolen code //WayBill wb = db.WayBills.First(p => p.Id == new Guid("0D88562F-BBEC-4722-941B-91FC4D82BB1C")); //List<WarehouseReleaseItem> wrnn = db.WarehouseReleases.FirstOrDefault(p => p.Id == wb.WRNId).WarehouseReleaseItems.ToList(); //foreach (WarehouseReleaseItem item in wrnn) //{ // Model.Asset ass = item.Asset; // Model.Inventory iv = item.Inventory; // Model.Item it = iv.Item; // Model.ItemCategory ic = it.ItemCategory; // Model.UnitOfMeasure u = it.UnitOfMeasure; //} var model = new ReceiveWB() { EntityWBill = new WayBill(), IssuingOffice = new SelectList(WBService.GetSubOffices(countryProg.Id), "Id", "Name"), WBlist = new SelectList(WBService.GetWayBillsNotReceived(countryProg.Id), "Id", "RefNumber"), WRItems = new List <WarehouseReleaseItem>()//wrnn }; return(View(model)); } }
public void Execute() { if (!Check()) { return; } if (form.listAssets.SelectedIndices.Count == 0) { return; } Model.Asset asset = form.project.Assets[form.listAssets.SelectedIndices[0]]; SpriteForm spriteForm = new SpriteForm() { Atlas = asset.Atlas }; spriteForm.UpdateList(); spriteForm.ShowDialog(form); form.dirty = true; form.UpdateTitle(); }
public string GenerateAssetNo(Guid ProjectDId) { using (var dbContext = new SCMSEntities()) { Model.ProjectDonor pd = dbContext.ProjectDonors.FirstOrDefault(p => p.Id == ProjectDId); string code = pd.Donor.ShortName + "/"; code += pd.Project.ShortName + "/"; long count = 1; Model.Asset m = dbContext.Assets.OrderByDescending(p => p.Index).FirstOrDefault(); if (m != null) { count = m.Index + 1; } if (count < 10000) { if (count < 10) { return(code + "0000" + count); } if (count < 100 & count >= 10) { return(code + "000" + count); } if (count < 1000 & count >= 100) { return(code + "00" + count); } if (count < 10000 & count >= 1000) { return(code + "0" + count); } } return(code + count); } }
public async void UpdateAsset(Model.Asset newAsset, MyFile myFile) { var client = new ApiClient(API.URL); var requestBuilder = new ApiRequestBuilder(); client.setAuthorizationToken(File.ReadAllText("jwt.txt")); var formContent = new MultipartFormDataContent(); formContent.Add(new StringContent(newAsset.Name), "name"); formContent.Add(new StringContent(newAsset.Quantity.ToString()), "quantity"); if (myFile != null) { formContent.Add(new StreamContent(new MemoryStream(myFile.byteArray)), "image", myFile.fullFileName); } var request = requestBuilder .buildMultipartRequest(new MultiPartContent(formContent)) .setEndpoint(API.assetId.Replace("{id}", newAsset.Id)) .setRequestMethod(HttpMethod.Post); client.setOnFailedRequest(CallbackOperationFailed); client.setOnSuccessRequest(CallbackOperationSuccess); var response = await client.sendRequest(request.getApiRequestBundle()); }
/// <summary> /// Sort through quick search results and create list of items /// Items are grouped by acquired date and item type /// Each item contains a list of strips /// Strips are grouped by strip id /// Each strip contains a list of assets /// Assets inherit from test_docing_Panel.Models.Feature /// </summary> public static List <Model.AcquiredDateGroup> ProcessQuickSearchResults(QuickSearchResult result) { //group results List <Model.AcquiredDateGroup> groupedResults = new List <Model.AcquiredDateGroup>(); Feature[] features = result.features; foreach (Feature feature in features) { Model.AcquiredDateGroup acquiredDateGroup = null; DateTime acquired = feature.properties.acquired; DateTime acquired_day = acquired.Date; int acquiredDateIndex = groupedResults.FindIndex(i => i.acquired == acquired_day); if (acquiredDateIndex < 0) { acquiredDateGroup = new Model.AcquiredDateGroup { acquired = acquired_day, items = new List <Model.Item>() }; groupedResults.Add(acquiredDateGroup); } else { acquiredDateGroup = groupedResults[acquiredDateIndex]; } string itemType = feature.properties.item_type; Model.Item item = null; List <Model.Item> items = acquiredDateGroup.items; int index = items.FindIndex(i => i.itemType == itemType); if (index < 0) { item = new Model.Item { itemType = itemType, acquired = acquired, strips = new List <Model.Strip>(), parent = acquiredDateGroup }; items.Add(item); } else { item = items[index]; } Model.Strip strip = null; List <Model.Strip> strips = item.strips; string stripId = feature.properties.strip_id; int stripIndex = strips.FindIndex(s => s.stripId == stripId); if (stripIndex < 0) { strip = new Model.Strip { stripId = stripId, acquired = acquired, parent = item, assets = new List <Model.Asset>() }; strips.Add(strip); } else { strip = strips[stripIndex]; } List <Model.Asset> assets = strip.assets; Model.Asset asset = new Model.Asset { parent = strip, properties = feature.properties, id = feature.id, type = feature.type, _links = feature._links, _permissions = feature._permissions, geometry = feature.geometry }; asset.setFootprintVertices(); asset.setFootprintSymbol(); asset.setPolygon(); asset.determineParentPermissions(); assets.Add(asset); } //sort the collections if (groupedResults.Count > 0) { foreach (Model.AcquiredDateGroup group in groupedResults) { group.items = group.items.OrderBy(itemGroup => itemGroup.itemType).ToList(); foreach (Model.Item item in group.items) { item.strips = item.strips.OrderByDescending(strip => strip.acquired).ToList(); foreach (Model.Strip strip in item.strips) { strip.assets = strip.assets.OrderByDescending(asset => asset.properties.acquired).ToList(); } } } groupedResults = groupedResults.OrderByDescending(group => group.acquired).ToList(); } return(groupedResults); }
public IEnumerable <Model.Asset> Get(string id) { var assetList = new List <Model.Asset>(); Console.WriteLine("Running Get: " + id); var rootDirectoryName = "/home/ben/git/dejaview/dejaview-frontend/images/" + id; if (Directory.Exists(rootDirectoryName) == false) { return(assetList); } var dirs = Directory.GetDirectories(rootDirectoryName); foreach (var dir in dirs) { var source = Path.GetFileName(dir); foreach (var file in Directory.GetFiles(dir)) { var asset = new Model.Asset() { Id = "foo", BlobUri = "./images/" + id + "/" + source + "/" + Path.GetFileName(file), DateCreated = new DateTime(2018, 1, 28), Source = source }; Console.WriteLine("BlobUri : " + asset.BlobUri); assetList.Add(asset); } } return(assetList); return(new List <Model.Asset>() { new Model.Asset() { Id = "One", BlobUri = "./images/20-haines-st-curtin-act-2605/025ee00bf350b530827d0b3a93ba1f97_hd.jpg", DateCreated = new DateTime(2018, 1, 28), Source = "allhomes.com.au" }, new Model.Asset() { Id = "Two", BlobUri = "./images/20-haines-st-curtin-act-2605/4bdab746fdcb055f00c49e8e496fc596_hd.jpg", DateCreated = new DateTime(2018, 1, 30), Source = "allhomes.com.au" }, new Model.Asset() { Id = "Three", BlobUri = "./images/640x480.png", DateCreated = new DateTime(2018, 1, 30), Source = "allhomes.com.au" } }); }