public static void Test() { //defining new asset object TableAsset <SensorData> assetA = new TableAsset <SensorData> { Irai = Helper.GenerateSampleIrai("sample PLC asset", "001"), Description = "This is a demo asset", FullName = "Sample PLC asset", }; //creating random asset value var sensorDatas = new List <SensorData>(); var rng = new Random(); for (int i = 0; i < 99; i++) { sensorDatas.Add(new SensorData { Value = rng.Next(100), Time = DateTime.Now.AddMinutes(i) }); } //add value to object assetA.Values.AddRange(sensorDatas); //add asset to DB AAS_Core.Core.MongoHelper.CreateAsset(assetA); }
protected void ButtonTransferRecordings_Click(object sender, EventArgs e) { using (CascadeEdgeCaptureDataContext LoadedLocalEvents = new CascadeEdgeCaptureDataContext()) { LabelRecordings.Text = "Transferring Recordings - Please Wait"; var LocalRecordings = LoadedLocalEvents.TableLocalEvents.Where(TableLocalEvents => TableLocalEvents.LocalEventStatus == 1); foreach (TableLocalEvent RecordingsToOutput in LocalRecordings) { string fileName = RecordingsToOutput.LocalAssetFileName; string sourcePath = @"C:\Users\Mark C Strathdee\Documents\Visual Studio 2013\Projects\BrittishCouncil\BrittishCouncil\Uploads\Source\"; string targetPath = @"M:\bc\"; string sourceFile = System.IO.Path.Combine(sourcePath, fileName); string destFile = System.IO.Path.Combine(targetPath, fileName); System.IO.File.Copy(sourceFile, destFile, true); using (CascadeCoreDataContext NewEventEntry = new CascadeCoreDataContext()) { TableEvent NewEvent = new TableEvent(); NewEvent.CustomerID = RecordingsToOutput.LocalCustomerID; NewEvent.EventID = RecordingsToOutput.LocalEventID; NewEvent.EventName = RecordingsToOutput.LocalEventName; NewEvent.EventDescription = RecordingsToOutput.LocalEventDescription; NewEvent.EventSite = RecordingsToOutput.LocalEventSite; NewEvent.AssetFileName = RecordingsToOutput.LocalAssetFileName; NewEvent.EventStatus = "2"; NewEvent.EventReleaseDate = RecordingsToOutput.LocalEventReleaseDate; NewEvent.EventDateCreated = DateTime.Now; NewEventEntry.TableEvents.InsertOnSubmit(NewEvent); NewEventEntry.SubmitChanges(); } using (CascadeCoreDataContext NewAssetEntry = new CascadeCoreDataContext()) { TableAsset NewAsset = new TableAsset(); NewAsset.CustomerID = RecordingsToOutput.LocalCustomerID; NewAsset.EventID = RecordingsToOutput.LocalEventID; NewAsset.AssetID = RecordingsToOutput.LocalAssetID; NewAsset.AssetName = RecordingsToOutput.LocalEventName; NewAsset.AssetDescription = RecordingsToOutput.LocalEventDescription; NewAsset.AssetFileName = RecordingsToOutput.LocalAssetFileName; NewAsset.AssetDateCreated = RecordingsToOutput.LocalEventDateCreated; NewAssetEntry.TableAssets.InsertOnSubmit(NewAsset); NewAssetEntry.SubmitChanges(); } using (CascadeEdgeCaptureDataContext UpdateEventStatus = new CascadeEdgeCaptureDataContext()) { TableLocalEvent CheckEvent = UpdateEventStatus.TableLocalEvents.SingleOrDefault(TableLocalEvent => TableLocalEvent.LocalEventID == RecordingsToOutput.LocalEventID); CheckEvent.LocalEventStatus = 2; CheckEvent.LocalEventDateModified = DateTime.Now; UpdateEventStatus.SubmitChanges(); } LabelRecordings.Text = "Transferring Recordings - Please Wait"; } LabelRecordings.Text = "The following recordings have been transferred to the central archive."; } }