private AnyStatus SaveRelatedData(StackAppContext appContext, EntityModelBase model, IDbConnection connection, IDbTransaction transaction) { AnyStatus sts = AnyStatus.Success; //save child entities foreach (var f in model.Attributes) { var val = f.Value; if (val.Field.Type == FieldType.OneToMany && val.IsChanged && val.Value != null && (val.Value as IList).Count > 0) { var itemColl = (List <EntityModelBase>)val.Value; var field = val.Field; var entity = GetEntity(field.RefObject); foreach (var localModel in itemColl) { SetRelationshipValue(model.ID, field.Name, localModel); sts = entity.Save(appContext, localModel, connection, transaction); if (sts != AnyStatus.Success) { break; } } } } return(sts); }
public virtual AnyStatus OnAfterDbSave(StackAppContext appContext, EntityModelBase model, IDbConnection connection, IDbTransaction transaction) { AnyStatus sts = AnyStatus.Success; sts = SaveRelatedData(appContext, model, connection, transaction); return(sts); }
public override AnyStatus OnAfterDbSave(StackAppContext appContext, EntityModelBase model, IDbConnection connection, IDbTransaction transaction) { AnyStatus sts = base.OnAfterDbSave(appContext, model, connection, transaction); if (sts == AnyStatus.Success) { if (model.IsNew) { } } return(sts); }
public override AnyStatus OnAfterDbSave(StackAppContext appContext, EntityModelBase model, IDbConnection connection, IDbTransaction transaction) { AnyStatus sts = base.OnAfterDbSave(appContext, model, connection, transaction); int defaultItemType = 0; if (sts == AnyStatus.Success) { if (model.IsNew) { EntityBuilder.CreateEntityTable(model, connection, transaction, out defaultItemType); } } return(sts); }
public EntityModelBase Generate(UIFormModel model) { this.ValidatrRequest(); _formContext.CreateDataModel(); RecordModel = _formContext.EntityModel; SetRelationShip(); this.SetFieldsModelToRecord(model); Status = AnyStatus.Success; return(RecordModel); }
public virtual void Build(DataListContext context) { var defn = GetSourceDefinition(context); try { OnBuildInit(context, defn); Compile(context, defn); ExecutePrepareData(context, defn); } catch (Exception ex) { Status = AnyStatus.InvalidData; Status.Message = ex.Message; return; } }
public AnyStatus ExecuteScript(string codeStr) { currentScriptTag = "Start<>"; AnyStatus sts = AnyStatus.Success; try { var parser = new JavaScriptParser(codeStr); var program = parser.ParseScript(); ExecuteScript(program); } catch (Exception ex) { sts = AnyStatus.ScriptFailure; sts.Message = currentScriptTag + "::" + ex.Message; } return(sts); }
public AnyStatus ExecuteFunction <T>(StackAppContext appContext, string codeStr, Dictionary <string, object> param, T output) //Arguments param { AnyStatus sts = AnyStatus.Success; try { currentScriptTag = "Start<>"; var parser = new JavaScriptParser(codeStr); var program = parser.ParseScript(); _DataProvider = new ObjectDataProvider(appContext, param); _DataProvider.output = output; ExecuteBody(program.Body); } catch (Exception ex) { sts = AnyStatus.ScriptFailure; sts.Message = currentScriptTag + "::" + ex.Message; } return(sts); }
public AnyStatus Save(StackAppContext appContext, EntityModelBase model, IDbConnection connection, IDbTransaction transaction) { AnyStatus status = AnyStatus.NotInitialized; try { if (model.IsNew) { model.SetValue("CREATEDON", DateTime.Now.ToUniversalTime()); model.SetValue("CREATEDBY", appContext.UserInfo.UserId); model.SetMasterId(appContext.MasterId); } model.SetValue("UPDATEDON", DateTime.Now.ToUniversalTime()); model.SetValue("UPDATEDBY", appContext.UserInfo.UserId); if (this.Validate(model)) { if (model is EntityRecordModel) { ((EntityRecordModel)model).ResolveComputedFields(); } status = EntityDBService.SaveEntity(appContext, this, model, connection, transaction); if (status == AnyStatus.Success) { status = OnSaveComplete(appContext, model); } } else { status = AnyStatus.InvalidData; } } catch (AppException ex) { status = AnyStatus.SaveFailure; status.Message = ex.Message; } return(status); }
public EntityModelGenerator(EditFormContext context) { _formContext = context; Status = AnyStatus.NotInitialized; ValueProvider = new FormValueProvider(context); }
public static AnyStatus SaveEntity(StackAppContext appContext, IDBEntity entity, EntityModelBase model, IDbConnection connection, IDbTransaction transaction) { AnyStatus sts = AnyStatus.UpdateFailure; var eSave = new EntityDBSave(entity); if (model.IsNew) { var eId = GetNextEntityDBId(entity.EntityId.Code); model.SetID(eId); } IDbConnection conn; IDbTransaction trans; bool isLocalConnection = true; if (connection == null) { conn = DBService.Connection; conn.Open(); trans = conn.BeginTransaction(); } else { conn = connection; trans = transaction; isLocalConnection = false; } try { sts = entity.OnBeforeDbSave(appContext, model, conn, trans); if (sts == AnyStatus.Success) { eSave.Save(model, conn, trans); sts = entity.OnAfterDbSave(appContext, model, conn, trans); if (sts != AnyStatus.Success) { if (isLocalConnection) { trans.Rollback(); } } else { if (isLocalConnection) { trans.Commit(); } } } } catch (Exception ex) { sts = AnyStatus.SaveFailure; sts.Message = ex.Message; if (isLocalConnection) { trans.Rollback(); } } finally { if (isLocalConnection) { trans.Dispose(); conn.Close(); } } return(sts); }
public override AnyStatus Save(StackAppContext appContext, EntityModelBase model) { AnyStatus status = AnyStatus.NotInitialized; return(status); }