//protected void InitializeConfiguration(IConfig config) //{ // var hostKey = config[BlobContainerLocalConfig.ContainerHost]; // _containerName = config[BlobContainerLocalConfig.ContainerName]; // _host = hostKey; // _container = _containerName; // _access = (EntityAccess)Enum.Parse(typeof(EntityAccess), // config.Get(BlobContainerLocalConfig.OptionalAccess, // EntityAccess.Private.ToString())); //} protected void InternalSaveObject <TData>(string objId, TData obj) { try { if (mutex.Wait(TimeSpan.FromSeconds(DefaultTime))) { var data = JsonConvert.SerializeObject(obj); if (_persistentDictionary.ContainsKey(objId)) { _persistentDictionary[objId] = data; } else { _persistentDictionary.Add(objId, data); } _persistentDictionary.Flush(); mutex.Release(); } } catch (Exception ex) { throw new BlobAccessException(ex); } }
private void SaveDiskLayoutVersion(string value) { using (PersistentDictionary <string, string> dictionary = new PersistentDictionary <string, string>( Path.Combine(this.Enlistment.DotGVFSRoot, RepoMetadataDatabaseName))) { dictionary[DiskLayoutVersionKey] = value; dictionary.Flush(); } }
public static void SaveDiskLayoutVersion(string dotGVFSRoot, string value) { using (PersistentDictionary <string, string> dictionary = new PersistentDictionary <string, string>( Path.Combine(dotGVFSRoot, RepoMetadataDatabaseName))) { dictionary[DiskLayoutVersionKey] = value; dictionary.Flush(); } }
public static void SaveDiskLayoutVersionAsEsentDatabase(string dotGVFSRoot, string value) { string metadataPath = Path.Combine(dotGVFSRoot, EsentRepoMetadataFolder); using (PersistentDictionary <string, string> repoMetadata = new PersistentDictionary <string, string>(metadataPath)) { repoMetadata[DiskLayoutVersionKey] = value; repoMetadata.Flush(); } }
public static void CreateEsentPlaceholderDatabase(string dotGVFSRoot) { string metadataPath = Path.Combine(dotGVFSRoot, EsentPlaceholderFolder); using (PersistentDictionary <string, string> placeholders = new PersistentDictionary <string, string>(metadataPath)) { placeholders["mock:\\path"] = new string('0', 40); placeholders.Flush(); } }
/// <summary> /// If the key and value boxes are filled in, save that as an entry in the dictionary /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InsertKeyValue_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(key.Text) && !string.IsNullOrEmpty(value.Text)) { universalWindowsDB[key.Text] = value.Text; key.Text = "Key1"; value.Text = "Value1"; universalWindowsDB.Flush(); } }
public override void Run(int count, int batch) { for (int i = 0; i < count; i += batch) { for (var j = i; j < i + batch; j++) { dictionary[j] = "test" + j; } dictionary.Flush(); } }
public static void CreateEsentBlobSizesDatabase(string dotGVFSRoot, List <KeyValuePair <string, long> > entries) { string metadataPath = Path.Combine(dotGVFSRoot, EsentBlobSizesFolder); using (PersistentDictionary <string, long> blobSizes = new PersistentDictionary <string, long>(metadataPath)) { foreach (KeyValuePair <string, long> entry in entries) { blobSizes[entry.Key] = entry.Value; } blobSizes.Flush(); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <remarks>CFI, 2012-03-10</remarks> public void Dispose() { if (IsDisposed) { return; } values.Flush(); values.Dispose(); lifetime.Flush(); lifetime.Dispose(); IsDisposed = true; }
/// <summary> /// Run a set of tests against a dictionary. /// </summary> /// <typeparam name="TKey">Key type of the dictionary.</typeparam> /// <typeparam name="TValue">Value type of the dictionary.</typeparam> /// <param name="dictionary">The dictionary to test.</param> /// <param name="key">Key value to use.</param> /// <param name="value">Data value to use.</param> private static void RunDictionaryTests <TKey, TValue>(PersistentDictionary <TKey, TValue> dictionary, TKey key, TValue value) where TKey : IComparable <TKey> { Assert.IsFalse(dictionary.IsReadOnly, "Dictionary is read-only"); Assert.AreEqual(DictionaryPath, dictionary.Database); TestBasicOperations(dictionary, key, value); // Add the value var kvp = new KeyValuePair <TKey, TValue>(key, value); dictionary.Add(kvp); dictionary.Flush(); TestDictionaryLinq(dictionary, key, value); TestDictionaryKeysLinq(dictionary, key); TestDictionaryEnumeration(dictionary, key, value); TestDictionaryCopyTo(dictionary, key, value); }
public static void MigratePrevServerGroups(string name) { lock (MigratePrevServerGroupsLock) { var directory = string.Format(@"{0}\{1}\PrevServerGroups", BasicHelper.DataDirectory, name); if (PersistentDictionaryFile.Exists(directory)) { LogService.Debug("Start migrating 'PrevServerGroups' data."); var oldDictionary = new PersistentDictionary <uint, string>(directory); using (var database = new BotDatabaseEntities(GetInstanceConnectionString(name))) { foreach (var oldDictionaryEntry in oldDictionary) { oldDictionaryEntry.Value.Split(';').Select(int.Parse).ForEach(oldServerGroup => { database.PreviousServerGroup.AddObject(new PreviousServerGroup { Id = Guid.NewGuid(), ClientDatabaseId = (int)oldDictionaryEntry.Key, ServerGroup = oldServerGroup, Creation = DateTime.UtcNow }); }); } database.SaveChanges(); } oldDictionary.Flush(); oldDictionary.Dispose(); PersistentDictionaryFile.DeleteFiles(directory); Directory.Delete(directory); LogService.Debug("Finished migrating 'PrevServerGroups' data."); } } }
public static void MigrateModerates(string name) { lock (MigrateModeratesLock) { var directory = string.Format(@"{0}\{1}\Moderates", BasicHelper.DataDirectory, name); if (PersistentDictionaryFile.Exists(directory)) { LogService.Debug("Start migrating 'Moderates' data."); var oldDictionary = new PersistentDictionary <string, ModeratedClientEntity>(directory); using (var database = new BotDatabaseEntities(GetInstanceConnectionString(name))) { foreach (var oldDictionaryEntry in oldDictionary) { database.Moderate.AddObject(new Moderate { Id = Guid.NewGuid(), ClientDatabaseId = (int)oldDictionaryEntry.Value.User, ModeratorDatabaseId = (int)oldDictionaryEntry.Value.Moderator, ServerGroup = (int)oldDictionaryEntry.Value.ServerGroup, Type = (byte)oldDictionaryEntry.Value.Type, Creation = oldDictionaryEntry.Value.Moderated }); } database.SaveChanges(); } oldDictionary.Flush(); oldDictionary.Dispose(); PersistentDictionaryFile.DeleteFiles(directory); Directory.Delete(directory); LogService.Debug("Finished migrating 'Moderates' data."); } } }
public static void MigrateSticky(string name) { lock (MigrateStickyLock) { var directory = string.Format(@"{0}\{1}\Sticky", BasicHelper.DataDirectory, name); if (PersistentDictionaryFile.Exists(directory)) { LogService.Debug("Start migrating 'Sticky' data."); var oldDictionary = new PersistentDictionary <Guid, StickyClientEntity>(directory); using (var database = new BotDatabaseEntities(GetInstanceConnectionString(name))) { foreach (var oldDictionaryEntry in oldDictionary) { database.Sticky.AddObject(new Sticky { Id = Guid.NewGuid(), ClientDatabaseId = (int)oldDictionaryEntry.Value.ClientDatabaseId, ChannelId = (int)oldDictionaryEntry.Value.ChannelId, StickTime = (int)oldDictionaryEntry.Value.StickTime, Creation = oldDictionaryEntry.Value.Creation }); } database.SaveChanges(); } oldDictionary.Flush(); oldDictionary.Dispose(); PersistentDictionaryFile.DeleteFiles(directory); Directory.Delete(directory); LogService.Debug("Finished migrating 'Sticky' data."); } } }
public static void MigrateTimes(string name) { lock (MigrateTimesLock) { var directory = string.Format(@"{0}\{1}\Times", BasicHelper.DataDirectory, name); if (PersistentDictionaryFile.Exists(directory)) { LogService.Debug("Start migrating 'Times' data."); var oldDictionary = new PersistentDictionary <string, TimeClientEntity>(directory); using (var database = new BotDatabaseEntities(GetInstanceConnectionString(name))) { foreach (var oldDictionaryEntry in oldDictionary) { database.Time.AddObject(new Time { Id = Guid.NewGuid(), ClientDatabaseId = (int)oldDictionaryEntry.Value.User, Joined = oldDictionaryEntry.Value.Joined, Disconnected = oldDictionaryEntry.Value.Disconnected, TotalMinutes = (oldDictionaryEntry.Value.Disconnected - oldDictionaryEntry.Value.Joined).TotalMinutes }); } database.SaveChanges(); } oldDictionary.Flush(); oldDictionary.Dispose(); PersistentDictionaryFile.DeleteFiles(directory); Directory.Delete(directory); LogService.Debug("Finished migrating 'Times' data."); } } }
public static void MigrateSeen(string name) { lock (MigrateSeenLock) { var directory = string.Format(@"{0}\{1}\Seen", BasicHelper.DataDirectory, name); if (PersistentDictionaryFile.Exists(directory)) { LogService.Debug("Start migrating 'Seen' data."); var oldDictionary = new PersistentDictionary <uint, DateTime>(directory); using (var database = new BotDatabaseEntities(GetInstanceConnectionString(name))) { foreach (var oldDictionaryEntry in oldDictionary) { database.Seen.AddObject(new Seen { Id = Guid.NewGuid(), ClientDatabaseId = (int)oldDictionaryEntry.Key, LastSeen = oldDictionaryEntry.Value }); } database.SaveChanges(); } oldDictionary.Flush(); oldDictionary.Dispose(); PersistentDictionaryFile.DeleteFiles(directory); Directory.Delete(directory); LogService.Debug("Finished migrating 'Seen' data."); } } }
public void Put <T>(string key, T value) { _persistentDictionary.Add(key, value.ToJson()); _persistentDictionary.Flush(); }
public void Add(int cep, string statusProcessamento) { CheckCacheOpened(); pairs.Add(cep, statusProcessamento); pairs.Flush(); }
public static void SaveCurrentDiskLayoutVersion(PersistentDictionary <string, string> repoMetadata) { repoMetadata[DiskLayoutVersionKey] = CurrentDiskLayoutVerion.ToString(); repoMetadata.Flush(); }
internal void Flush() { _Library.Flush(); }
private void ProcessingThread() { // Start AcquireFrame/ReleaseFrame loop while (senseManager.AcquireFrame(true) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { // Acquire the color image data PXCMCapture.Sample sample = senseManager.QuerySample(); Bitmap colorBitmap; PXCMImage.ImageData colorData; int topScore = 0; FaceExpression expression = FaceExpression.None; sample.color.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB24, out colorData); colorBitmap = colorData.ToBitmap(0, sample.color.info.width, sample.color.info.height); try { IBarcodeReader reader = new BarcodeReader(); // load a bitmap //var barcodeBitmap = (Bitmap)Bitmap.LoadFrom("C:\\sample-barcode-image.png"); // detect and decode the barcode inside the bitmap var result = reader.Decode(colorBitmap); // do something with the result if (result != null) { MessageBox.Show(result.BarcodeFormat.ToString()); MessageBox.Show(result.Text); } } catch (Exception ex) { } // Get face data if (faceData != null) { faceData.Update(); numFacesDetected = faceData.QueryNumberOfDetectedFaces(); if (numFacesDetected > 0) { // Get the first face detected (index 0) PXCMFaceData.Face face = faceData.QueryFaceByIndex(0); // Retrieve face location data PXCMFaceData.DetectionData faceDetectionData = face.QueryDetection(); if (faceDetectionData != null) { PXCMRectI32 faceRectangle; faceDetectionData.QueryBoundingRect(out faceRectangle); if ((faceRectangle.h > 90) || (faceRectangle.w > 90)) { faceRectangleHeight = faceRectangle.h * 3 / 2; faceRectangleWidth = faceRectangle.w * 3 / 2; } else if (((faceRectangle.h < 90) || (faceRectangle.w < 90)) && ((faceRectangle.h > 70) || (faceRectangle.w > 70))) { faceRectangleHeight = faceRectangle.h * 2; faceRectangleWidth = faceRectangle.w * 2; } else { faceRectangleHeight = faceRectangle.h * 5 / 2; faceRectangleWidth = faceRectangle.w * 5 / 2; } faceRectangleX = faceRectangle.x; faceRectangleY = faceRectangle.y; } // Retrieve pose estimation data PXCMFaceData.PoseData facePoseData = face.QueryPose(); if (facePoseData != null) { PXCMFaceData.PoseEulerAngles headAngles; facePoseData.QueryPoseAngles(out headAngles); headRoll = headAngles.roll; headPitch = headAngles.pitch; headYaw = headAngles.yaw; } // Retrieve expression data PXCMFaceData.ExpressionsData expressionData = face.QueryExpressions(); if (expressionData != null) { PXCMFaceData.ExpressionsData.FaceExpressionResult score; expressionData.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_KISS, out score); expressionScore[Convert.ToInt32(FaceExpression.Kiss)] = score.intensity; expressionData.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_MOUTH_OPEN, out score); expressionScore[Convert.ToInt32(FaceExpression.Open)] = score.intensity; expressionData.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_SMILE, out score); expressionScore[Convert.ToInt32(FaceExpression.Smile)] = score.intensity; expressionData.QueryExpression(PXCMFaceData.ExpressionsData.FaceExpression.EXPRESSION_TONGUE_OUT, out score); expressionScore[Convert.ToInt32(FaceExpression.Tongue)] = score.intensity; // Determine the highest scoring expression for (int i = 1; i < TotalExpressions; i++) { if (expressionScore[i] > topScore) { expression = (FaceExpression)i; } } } // Process face recognition data if (face != null) { // Retrieve the recognition data instance recognitionData = face.QueryRecognition(); // Set the user ID and process register/unregister logic if (recognitionData.IsRegistered()) { userId = Convert.ToString(recognitionData.QueryUserID()); if (doUnregister) { recognitionData.UnregisterUser(); SaveDatabaseToFile(); doUnregister = false; if (_persistentDict.ContainsKey(userId) == true) { _persistentDict.Remove(userId); } } } else { if (doRegister) { int uId = recognitionData.RegisterUser(); SaveDatabaseToFile(); if (newUserName != "") { if (_persistentDict.ContainsKey(uId.ToString()) == false) { _persistentDict.Add(uId.ToString(), newUserName); _persistentDict.Flush(); newUserName = ""; } } // Capture a jpg image of registered user colorBitmap.Save("image.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); doRegister = false; } else { userId = "New User"; } } } } else { userId = "No users in view"; } } //hand = senseManager.QueryHand(); //if (hand != null) //{ // // Retrieve the most recent processed data // handData = hand.CreateOutput(); // handData.Update(); // // Get number of tracked hands // nhands = handData.QueryNumberOfHands(); // if (nhands > 0) // { // // Retrieve hand identifier // handData.QueryHandId(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, 0, out handId); // // Retrieve hand data // handData.QueryHandDataById(handId, out ihand); // PXCMHandData.BodySideType bodySideType = ihand.QueryBodySide(); // if (bodySideType == PXCMHandData.BodySideType.BODY_SIDE_LEFT) // { // leftHand = true; // } // else if (bodySideType == PXCMHandData.BodySideType.BODY_SIDE_RIGHT) // { // leftHand = false; // } // // Retrieve all hand joint data // for (int i = 0; i < nhands; i++) // { // for (int j = 0; j < 0x20; j++) // { // PXCMHandData.JointData jointData; // ihand.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData); // nodes[i][j] = jointData; // } // } // // Get world coordinates for tip of middle finger on the first hand in camera range // handTipX = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.x; // handTipY = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.y; // handTipZ = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.z; // swipehandTipX = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionImage.x; // swipehandTipY = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionImage.y; // swipehandTipZ = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionImage.z; // //Console.Out.WriteLine("Before x={0}", swipehandTipX); // //Console.Out.WriteLine("Before speed={0}", nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].speed.x); // // Retrieve gesture data // if (handData.IsGestureFired("spreadfingers", out gestureData)) { gesture = Gesture.FingerSpread; } // else if (handData.IsGestureFired("two_fingers_pinch_open", out gestureData)) { gesture = Gesture.Pinch; } // else if (handData.IsGestureFired("wave", out gestureData)) { gesture = Gesture.Wave; } // else if (handData.IsGestureFired("swipe_left", out gestureData)) { gesture = Gesture.SwipeLeft; } // else if (handData.IsGestureFired("swipe_right", out gestureData)) { gesture = Gesture.SwipeRight; } // else if (handData.IsGestureFired("fist", out gestureData)) { gesture = Gesture.Fist; } // else if (handData.IsGestureFired("thumb_up", out gestureData)) { gesture = Gesture.Thumb; } // } // else // { // gesture = Gesture.Undefined; // } // //UpdateUI(); // if (handData != null) handData.Dispose(); //} // Display the color stream and other UI elements //UpdateUI(colorBitmap, expression, gesture); UpdateUI(colorBitmap, expression); // Release resources colorBitmap.Dispose(); sample.color.ReleaseAccess(colorData); sample.color.Dispose(); // Release the frame senseManager.ReleaseFrame(); } }
public void FlushChanges() { persistMetadata(); _backingStore.Flush(); }