protected override object ExecuteBody() { var crud = Context.Access((tx) => { var cusr = tx.Db[BsonDataModel.GetCollectionName(this.Realm, BsonDataModel.COLLECTION_USER)]; var user = new BSONDocument(); user.Set(new BSONInt64Element(BsonDataModel._ID, Id)); user.Set(new BSONInt32Element(BsonDataModel.FLD_STATUS, (int)Status.Value)); user.Set(new BSONDateTimeElement(BsonDataModel.FLD_CREATEUTC, Context.App.TimeSource.UTCNow)); user.Set(new BSONDateTimeElement(BsonDataModel.FLD_STARTUTC, StartUtc.Value)); user.Set(new BSONDateTimeElement(BsonDataModel.FLD_ENDUTC, EndUtc.Value)); user.Set(new BSONStringElement(BsonDataModel.FLD_ROLE, Role.Default(string.Empty))); user.Set(new BSONStringElement(BsonDataModel.FLD_NAME, Name)); user.Set(new BSONStringElement(BsonDataModel.FLD_DESCRIPTION, Description)); user.Set(new BSONStringElement(BsonDataModel.FLD_NOTE, Note)); user.Set(new BSONStringElement(BsonDataModel.FLD_PROPS, Props)); var cr = cusr.Save(user); Aver.IsNull(cr.WriteErrors, cr.WriteErrors?.FirstOrDefault().Message); return(cr); }); return(crud); }
private void FetchIntoReference(Row row, ObjectName reference) { if (reference == null) { throw new ArgumentNullException("reference"); } var table = Context.Access().GetMutableTable(reference); if (table == null) { throw new ObjectNotFoundException(reference); } try { Context.Query.Session.Enter(table, AccessType.Write); var newRow = table.NewRow(); for (int i = 0; i < row.ColumnCount; i++) { var sourceValue = row.GetValue(i); newRow.SetValue(i, sourceValue); } newRow.SetDefault(Context); table.AddRow(newRow); } catch (CursorException) { throw; } catch (Exception ex) { throw new FetchException(CursorInfo.CursorName, ex); } finally { Context.Query.Session.Exit(new[] { table }, AccessType.Write); } }
protected override object ExecuteBody() { var bson = Context.Access((tx) => { var crole = tx.Db[BsonDataModel.GetCollectionName(this.Realm, BsonDataModel.COLLECTION_USER)]; return(crole.FindOne(Query.ID_EQ_Int64(this.Id))); }); if (bson == null) { return(null); } return(new JsonDataMap { { nameof(SetUser.Id), bson[BsonDataModel._ID]?.ObjectValue }, { nameof(SetUser.Status), (UserStatus)bson[BsonDataModel.FLD_STATUS]?.ObjectValue }, { "createUtc", bson[BsonDataModel.FLD_CREATEUTC]?.ObjectValue }, { nameof(SetUser.StartUtc), bson[BsonDataModel.FLD_STARTUTC]?.ObjectValue }, { nameof(SetUser.EndUtc), bson[BsonDataModel.FLD_ENDUTC]?.ObjectValue }, { nameof(SetUser.Role), bson[BsonDataModel.FLD_ROLE]?.ObjectValue }, { nameof(SetUser.Name), bson[BsonDataModel.FLD_NAME]?.ObjectValue }, { nameof(SetUser.Description), bson[BsonDataModel.FLD_DESCRIPTION]?.ObjectValue }, { nameof(SetUser.Note), bson[BsonDataModel.FLD_NOTE]?.ObjectValue }, { nameof(SetUser.Props), bson[BsonDataModel.FLD_PROPS]?.ObjectValue }, }); }
protected override object ExecuteBody() { var crud = Context.Access((tx) => { var crole = tx.Db[BsonDataModel.GetCollectionName(this.Realm, BsonDataModel.COLLECTION_ROLE)]; var cr = crole.DeleteOne(Query.ID_EQ_String(this.Id)); Aver.IsNull(cr.WriteErrors, cr.WriteErrors?.FirstOrDefault().Message); return(cr); }); return(crud); }
protected override object ExecuteBody() { var bson = Context.Access((tx) => { var crole = tx.Db[BsonDataModel.GetCollectionName(this.Realm, BsonDataModel.COLLECTION_ROLE)]; return(crole.FindAndFetchAll(new Query(), cursorFetchLimit: BsonDataModel.FETCH_LIMIT_LIST)); }); return(bson.Select(doc => { var result = new JsonDataMap(); doc.ForEach(elm => result[elm.Name] = elm.ObjectValue); return result; })); }
protected override object ExecuteBody() { var bson = Context.Access((tx) => { var crole = tx.Db[BsonDataModel.GetCollectionName(this.Realm, BsonDataModel.COLLECTION_ROLE)]; return(crole.FindOne(Query.ID_EQ_String(this.Id))); }); return(new JsonDataMap { { nameof(SetRole.Id), bson[BsonDataModel._ID].ObjectValue }, { nameof(SetRole.Rights), bson[BsonDataModel.FLD_RIGHTS].ObjectValue }, { "createUtc", bson[BsonDataModel.FLD_CREATEUTC].ObjectValue } }); }
protected override object ExecuteBody() { var crud = Context.Access((tx) => { var crole = tx.Db[BsonDataModel.GetCollectionName(this.Realm, BsonDataModel.COLLECTION_ROLE)]; var role = new BSONDocument(); role.Set(new BSONStringElement(BsonDataModel._ID, Id)); role.Set(new BSONStringElement(BsonDataModel.FLD_RIGHTS, Rights.ToLaconicString(CodeAnalysis.Laconfig.LaconfigWritingOptions.Compact))); role.Set(new BSONDateTimeElement(BsonDataModel.FLD_CREATEUTC, Context.App.TimeSource.UTCNow)); var cr = crole.Save(role); Aver.IsNull(cr.WriteErrors, cr.WriteErrors?.FirstOrDefault().Message); return(cr); }); return(crud); }
private void AcquireReferences() { var refNames = CursorInfo.QueryPlan.DiscoverAccessedResources(); var refs = refNames.Select(x => Context.Access().FindObject(x.ResourceName)).ToArray(); var accessType = AccessType.Read; if (CursorInfo.ForUpdate) { accessType |= AccessType.Write; } Context.Query.Session.Enter(refs, accessType); References = refs; }
protected override object ExecuteBody() { var bson = Context.Access((tx) => { var crole = tx.Db[BsonDataModel.GetCollectionName(this.Realm, BsonDataModel.COLLECTION_LOGIN)]; return(crole.FindOne(Query.ID_EQ_String(this.Id))); }); return(new JsonDataMap { { nameof(SetLogin.Id), bson[BsonDataModel._ID].ObjectValue }, { nameof(SetLogin.SysId), bson[BsonDataModel.FLD_SYSID].ObjectValue }, { nameof(SetLogin.Password), "*******" }, { "createUtc", bson[BsonDataModel.FLD_CREATEUTC].ObjectValue }, { nameof(SetLogin.StartUtc), bson[BsonDataModel.FLD_STARTUTC].ObjectValue }, { nameof(SetLogin.EndUtc), bson[BsonDataModel.FLD_ENDUTC].ObjectValue }, }); }
protected override object ExecuteBody() { var crud = Context.Access((tx) => { var clin = tx.Db[BsonDataModel.GetCollectionName(this.Realm, BsonDataModel.COLLECTION_LOGIN)]; var login = new BSONDocument(); login.Set(new BSONStringElement(BsonDataModel._ID, Id.ToLowerInvariant())); login.Set(new BSONInt64Element(BsonDataModel.FLD_SYSID, SysId)); login.Set(new BSONDateTimeElement(BsonDataModel.FLD_CREATEUTC, Context.App.TimeSource.UTCNow)); login.Set(new BSONDateTimeElement(BsonDataModel.FLD_STARTUTC, StartUtc.Value)); login.Set(new BSONDateTimeElement(BsonDataModel.FLD_ENDUTC, EndUtc.Value)); login.Set(new BSONStringElement(BsonDataModel.FLD_PASSWORD, Password)); var cr = clin.Save(login); Aver.IsNull(cr.WriteErrors, cr.WriteErrors?.FirstOrDefault().Message); return(cr); }); return(crud); }