public static void SaveObject(string persistenceId, string persistenceContext, string objectContent) { try { using (var db = new LiteDatabase(__peristenceDbPath)) { var obj = GetObjects <PersistedObject>(db); var qry = GetQuery(persistenceId, persistenceContext); var po = obj.Find(qry).FirstOrDefault(); if (po == null) { po = new PersistedObject { PersistenceId = persistenceId, PersistenceContext = persistenceContext, Content = objectContent }; obj.Insert(po); } else { po.Content = objectContent; obj.Update(po); } } } catch (Exception ex) { OP_Logger.LogException(ex); } }
public MoveToolContext(MoveToolContext cloneMe) : base(cloneMe) { this.poLiftedPixelsGuid = cloneMe.poLiftedPixelsGuid; this.poLiftedPixels = cloneMe.poLiftedPixels; // do not clone this.liftedPixels = cloneMe.liftedPixels; // do not clone }
public SessionManagerHandler(FileHandlerFactoryLocator fileHandlerFactoryLocator, string path) : base(fileHandlerFactoryLocator) { this.persistedSessionDatas = new PersistedObject<Dictionary<ID<ISession, Guid>, SessionData>>( path, () => new Dictionary<ID<ISession, Guid>, SessionData>(), this.Deserialize, this.Serialize); me = this; this.persistedSessionDatas.Read(sessionDatas => { this.sessions = new Dictionary<ID<ISession, Guid>, Session>(sessionDatas.Count); foreach (var sessionDataKVP in sessionDatas) { var sessionId = sessionDataKVP.Key; var sessionData = sessionDataKVP.Value; this.sessions[sessionId] = new Session( this, fileHandlerFactoryLocator, this.persistedSessionDatas, sessionId, sessionData); } }); // Clean old sessions every hour or so this.cleanOldSessionsTimer = new Timer(CleanOldSessions, null, 0, 6000000); }
public MoveToolChanges(IEnumerable <KeyValuePair <string, object> > drawingSettingsValues, MoveToolPixelSource pixelSource, ISurface <ColorBgra> bitmapSource, bool leaveCopyBehind, RectDouble baseBounds, Matrix3x2Double baseTransform, Matrix3x2Double deltaTransform, TransformEditingMode editingMode, Matrix3x2Double editTransform, PointDouble?rotationAnchorOffset) : base(drawingSettingsValues) { if (((pixelSource == MoveToolPixelSource.Bitmap) && (bitmapSource == null)) || ((pixelSource != MoveToolPixelSource.Bitmap) && (bitmapSource != null))) { ExceptionUtil.ThrowArgumentException($"MoveToolPixelSource.{pixelSource} specified, but bitmapSourcePersistenceKey={this.bitmapSourcePersistenceKey}"); } if (bitmapSource == null) { this.bitmapSourcePO = null; this.bitmapSourcePersistenceKey = Guid.Empty; } else { this.bitmapSourcePO = new PersistedObject <ISurface <ColorBgra> >(bitmapSource, true); this.bitmapSourcePersistenceKey = PersistedObjectLocker.Add <ISurface <ColorBgra> >(this.bitmapSourcePO); } this.pixelSource = pixelSource; this.leaveCopyBehind = leaveCopyBehind; this.baseBounds = baseBounds; this.baseTransform = baseTransform; this.deltaTransform = deltaTransform; this.editingMode = editingMode; this.editTransform = editTransform; this.rotationAnchorOffset = rotationAnchorOffset; this.Initialize(); }
public static object Update(SessionRequest request) { Attachment attachment = (Attachment)request.Session[new Guid(request.Parameters["attachment"])]; UpdateAttachment(attachment, request.Body); return(PersistedObject.GetNoCreate(attachment, request.Session)); }
public NameValuePairsHandler(FileHandlerFactoryLocator fileHandlerFactoryLocator, string path) : base(fileHandlerFactoryLocator, path) { this.persistedPairs = new PersistedObject<Dictionary<string, string>>( path, () => new Dictionary<string, string>(), this.Deserialize, this.Serialize); }
public void TestNonExistingObjectTypeReturnsNullOnGet() { var persistedObject = new PersistedObject { Content = "content", Id = "Id" }; PersistanceStore.Save(persistedObject); Assert.IsNull(PersistanceStore.Get <PersistedString>("Id")); }
public virtual void CommitChanges() { PersistedObject.Update(); PersistedObjectVersion = PersistedObject.Version; LdapcpLogging.Log( String.Format("Updated PersistedObject {0} to version {1}", PersistedObject.DisplayName, PersistedObject.Version), TraceSeverity.Medium, EventSeverity.Information, LdapcpLogging.Categories.Configuration); }
private void Initialize() { if ((this.baseGeometryPO == null) && (this.baseGeometryPersistenceKey != Guid.Empty)) { this.baseGeometryPO = PersistedObjectLocker.TryGet <GeometryList>(this.baseGeometryPersistenceKey); if (this.baseGeometryPO == null) { throw new InternalErrorException("this.baseGeometry == null"); } } }
private void Initialize() { if ((this.bitmapSourcePO == null) && (this.bitmapSourcePersistenceKey != Guid.Empty)) { this.bitmapSourcePO = PersistedObjectLocker.TryGet <ISurface <ColorBgra> >(this.bitmapSourcePersistenceKey); if (this.bitmapSourcePO == null) { throw new PaintDotNet.InternalErrorException("this.bitmapSource == null"); } } }
public void TestSavingAnExistingObjectReplacesIt() { var persistedObject = new PersistedObject { Content = "content", Id = "Id" }; PersistanceStore.Save(persistedObject); persistedObject.Content = "new"; PersistanceStore.Save(persistedObject); var saved = PersistanceStore.Get <PersistedObject>("Id"); Assert.AreEqual("new", saved.Content); }
private static List <PersistedObject <Element> > Wrap(List <AutomationElement> searchResults, Session session) { List <PersistedObject <Element> > result = new List <PersistedObject <Element> >(); STAHelper.Invoke( delegate() { foreach (AutomationElement element in searchResults) { result.Add(PersistedObject.Get(Element.Create(element, session.Process.Id), session)); } } ); return(result); }
public PaintBucketToolChanges(IEnumerable <KeyValuePair <string, object> > drawingSettingsValues, PointDouble originPoint, FloodMode?floodModeOverride, PaintDotNet.WhichUserColor whichUserColor, GeometryList clippingMask) : base(drawingSettingsValues, originPoint, floodModeOverride) { this.whichUserColor = whichUserColor; if (clippingMask == null) { this.clippingMaskPO = null; this.clippingMaskPersistenceKey = Guid.Empty; } else { this.clippingMaskPO = new PersistedObject <GeometryList>(clippingMask, true); this.clippingMaskPersistenceKey = PersistedObjectLocker.Add <GeometryList>(this.clippingMaskPO); } this.Initialize(); }
public MagicWandToolChanges(IEnumerable <KeyValuePair <string, object> > drawingSettingsValues, PointDouble originPoint, PaintDotNet.SelectionCombineMode?selectionCombineModeOverride, FloodMode?floodModeOverride, GeometryList baseGeometry) : base(drawingSettingsValues, originPoint, floodModeOverride) { this.selectionCombineModeOverride = selectionCombineModeOverride; if (baseGeometry == null) { this.baseGeometryPO = null; this.baseGeometryPersistenceKey = Guid.Empty; } else { this.baseGeometryPO = new PersistedObject <GeometryList>(baseGeometry, true); this.baseGeometryPersistenceKey = PersistedObjectLocker.Add <GeometryList>(this.baseGeometryPO); } this.Initialize(); }
public static object GetSelection(ElementRequest request) { Dictionary <string, object> result = new Dictionary <string, object>(); result["multiple"] = request.Target.SelectionAllowsMultiple; result["required"] = request.Target.SelectionIsRequired; List <object> values = new List <object>(); foreach (Element elt in request.Target.Selection) { values.Add(PersistedObject.Get(elt, request.Session)); } result["values"] = values; return(result); }
public Session( SessionManagerHandler sessionManagerHandler, FileHandlerFactoryLocator fileHandlerFactoryLocator, PersistedObject<Dictionary<ID<ISession, Guid>, SessionData>> persistedSessionDatas, ID<ISession, Guid> sessionId, SessionData sessionData) { this.sessionManagerHandler = sessionManagerHandler; this.fileHandlerFactoryLocator = fileHandlerFactoryLocator; this.persistedSessionDatas = persistedSessionDatas; this.sessionId = sessionId; this.maxAge = sessionData.maxAge; this.lastQuery = sessionData.lastQuery; this.keepAlive = sessionData.keepAlive; }
public static object Create(SessionRequest request) { string extension = null; if (request.Body.ContainsKey("name")) { string name = (string)request.Body["name"]; if (name != null && name.Contains(".")) { extension = name.Substring(name.LastIndexOf(".") + 1); } } Attachment attachment = (extension == null) ? new Attachment() : new Attachment(extension); UpdateAttachment(attachment, request.Body); return(PersistedObject.Get(attachment, request.Session)); }
public void TestDifferentObjectTypeCanBeStored() { var persistedString = new PersistedString { Content = "content", Id = "Id" }; var persistedObject = new PersistedObject { Content = "content", Id = "Id" }; PersistanceStore.Save(persistedObject); PersistanceStore.Save(persistedString); var saved = PersistanceStore.Get <PersistedString>("Id"); Assert.IsNotNull(saved); Assert.AreEqual("Id", saved.Id); Assert.AreEqual("content", saved.Content); var saved2 = PersistanceStore.Get <PersistedObject>("Id"); Assert.IsNotNull(saved2); Assert.AreEqual("Id", saved2.Id); Assert.AreEqual("content", saved2.Content); }
public static object GetParent(ElementRequest request) { return(PersistedObject.Get(request.Target.Parent, request.Session)); }
//static ILog log = LogManager.GetLogger<UserHandler>(); internal UserHandler(PersistedObject<UserData> persistedUserData, PersistedObjectSequence<Notification> persistedNotifications, FileHandlerFactoryLocator fileHandlerFactoryLocator) : base(fileHandlerFactoryLocator) { this.persistedUserData = persistedUserData; this.persistedNotifications = persistedNotifications; }
public static object GetScrollerY(ElementRequest request) { return(PersistedObject.Get(request.Target.GetScrollAxis(OrientationType.Vertical), request.Session)); }
public static object GetFocused(SessionRequest request) { return(PersistedObject.Get(Element.Create(AutomationElement.FocusedElement, request.Session.Process.Id), request.Session)); }
public static object GetSelectionContainer(ElementRequest request) { return(PersistedObject.Get(request.Target.SelectionContainer, request.Session)); }
public MoveToolContext(SerializationInfo info, StreamingContext context) : base(info, context) { this.poLiftedPixelsGuid = (Guid)info.GetValue("poLiftedPixelsGuid", typeof(Guid)); this.poLiftedPixels = PersistedObjectLocker.Get<MaskedSurface>(this.poLiftedPixelsGuid); }
protected void BtnReset_Click(object sender, EventArgs e) { PersistedObject.ResetClaimTypesList(); PersistedObject.Update(); Response.Redirect(Request.Url.ToString()); }
public CallHomeFileHandler(PersistedObject<Dictionary<string, Server>> persistedServers, FileHandlerFactoryLocator fileHandlerFactoryLocator) : base(fileHandlerFactoryLocator) { this.persistedServers = persistedServers; }
public MoveToolContext(SerializationInfo info, StreamingContext context) : base(info, context) { this.poLiftedPixelsGuid = (Guid)info.GetValue("poLiftedPixelsGuid", typeof(Guid)); this.poLiftedPixels = PersistedObjectLocker.Get <MaskedSurface>(this.poLiftedPixelsGuid); }
/// <summary> /// Ensures configuration is valid to proceed /// </summary> /// <returns></returns> public virtual ConfigStatus ValidatePrerequisite() { if (!this.IsPostBack) { // DataBind() must be called to bind attributes that are set as "<%# #>"in .aspx // But only during initial page load, otherwise it would reset bindings in other controls like SPGridView DataBind(); ViewState.Add("ClaimsProviderName", ClaimsProviderName); ViewState.Add("PersistedObjectName", PersistedObjectName); ViewState.Add("PersistedObjectID", PersistedObjectID); } else { ClaimsProviderName = ViewState["ClaimsProviderName"].ToString(); PersistedObjectName = ViewState["PersistedObjectName"].ToString(); PersistedObjectID = ViewState["PersistedObjectID"].ToString(); } Status = ConfigStatus.AllGood; if (String.IsNullOrEmpty(ClaimsProviderName)) { Status |= ConfigStatus.ClaimsProviderNamePropNotSet; } if (String.IsNullOrEmpty(PersistedObjectName)) { Status |= ConfigStatus.PersistedObjectNamePropNotSet; } if (String.IsNullOrEmpty(PersistedObjectID)) { Status |= ConfigStatus.PersistedObjectIDPropNotSet; } if (Status != ConfigStatus.AllGood) { ClaimsProviderLogging.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration); // Should not go further if those requirements are not met return(Status); } if (CurrentTrustedLoginProvider == null) { CurrentTrustedLoginProvider = LDAPCP.GetSPTrustAssociatedWithCP(this.ClaimsProviderName); if (CurrentTrustedLoginProvider == null) { Status |= ConfigStatus.NoSPTrustAssociation; return(Status); } } if (PersistedObject == null) { Status |= ConfigStatus.PersistedObjectNotFound; } if (Status != ConfigStatus.AllGood) { ClaimsProviderLogging.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration); // Should not go further if those requirements are not met return(Status); } PersistedObject.CheckAndCleanConfiguration(CurrentTrustedLoginProvider.Name); PersistedObject.ClaimTypes.SPTrust = CurrentTrustedLoginProvider; if (IdentityCTConfig == null && Status == ConfigStatus.AllGood) { IdentityCTConfig = this.IdentityCTConfig = PersistedObject.ClaimTypes.FirstOrDefault(x => String.Equals(CurrentTrustedLoginProvider.IdentityClaimTypeInformation.MappedClaimType, x.ClaimType, StringComparison.InvariantCultureIgnoreCase) && !x.UseMainClaimTypeOfDirectoryObject); if (IdentityCTConfig == null) { Status |= ConfigStatus.NoIdentityClaimType; } } if (PersistedObjectVersion != PersistedObject.Version) { Status |= ConfigStatus.PersistedObjectStale; } if (Status != ConfigStatus.AllGood) { ClaimsProviderLogging.Log($"[{ClaimsProviderName}] {MostImportantError}", TraceSeverity.Unexpected, EventSeverity.Error, TraceCategory.Configuration); } return(Status); }
public virtual void CommitChanges() { PersistedObject.Update(); PersistedObjectVersion = PersistedObject.Version; }
internal UserManagerHandler(PersistedObject<UserManagerData> persistedUserManagerData, FileHandlerFactoryLocator fileHandlerFactoryLocator, int? maxLocalUsers) : base(fileHandlerFactoryLocator) { this.MaxLocalUsers = maxLocalUsers; this.persistedUserManagerData = persistedUserManagerData; }
protected override HistoryMemento OnUndo() { BitmapHistoryMementoData data = this.Data as BitmapHistoryMementoData; BitmapLayer layer = (BitmapLayer)this.historyWorkspace.Document.Layers[this.layerIndex]; PdnRegion region; MaskedSurface maskedSurface = null; if (this.poMaskedSurfaceRef != Guid.Empty) { PersistedObject <MaskedSurface> poMS = PersistedObjectLocker.Get <MaskedSurface>(this.poMaskedSurfaceRef); maskedSurface = poMS.Object; region = maskedSurface.CreateRegion(); } else if (data.UndoImage == null) { region = data.SavedRegion; } else { region = data.UndoImage.Region; } BitmapHistoryMemento redo; if (this.poUndoMaskedSurfaceRef == Guid.Empty) { redo = new BitmapHistoryMemento(Name, Image, this.historyWorkspace, this.layerIndex, region); redo.poUndoMaskedSurfaceRef = this.poMaskedSurfaceRef; } else { redo = new BitmapHistoryMemento(Name, Image, this.historyWorkspace, this.layerIndex, this.poUndoMaskedSurfaceRef); } PdnRegion simplified = Utility.SimplifyAndInflateRegion(region); if (maskedSurface != null) { maskedSurface.Draw(layer.Surface); } else if (data.UndoImage == null) { using (FileStream input = FileSystem.OpenStreamingFile(this.tempFileName, FileAccess.Read)) { LoadSurfaceRegion(input, layer.Surface, data.SavedRegion); } data.SavedRegion.Dispose(); this.tempFileHandle.Dispose(); this.tempFileHandle = null; } else { data.UndoImage.Draw(layer.Surface); data.UndoImage.Dispose(); } layer.Invalidate(simplified); simplified.Dispose(); return(redo); }