public override void callAction() { iostatus.AddNote($"Init:[{meta.Request.Url.PathAndQuery}]"); if (meta.Request.SOURCE.AccessLevel > meta.Request.Security.AuthToken.User.role) { iostatus.AddNote("Access denied. User not permitted to access the source[" + meta.Request.SOURCE.NAME + "].", WSConstants.ACCESS_LEVEL.READ, WSStatus.ERROR.CODE); WSSystemRecord rec = new WSSystemRecord(meta.ClientFunctions, new WSSystemEntity() { status = iostatus }, meta.Request.Security.AuthToken.User.role); #region VERSION 0 if (WSConstants.PARAMS.IOVERSION.VERSION0.Match(meta.Request.VERSION)) { response = rec; } #endregion #region VERSION 1 else if (WSConstants.PARAMS.IOVERSION.VERSION1.Match(meta.Request.VERSION)) { response = new V1SystemResponseRecord(meta.ClientFunctions, new V1SystemResponseEntity() { status = (rec == null || rec.entity == null) ? WSStatus.ERROR.NAME : iostatus.NAME, data = rec, message = iostatus.DeepNotes } , meta.Request.Security.AuthToken.User.role); if (response == null) { response = new V1SystemResponseRecord(meta.ClientFunctions, new V1SystemResponseEntity() { status = WSStatus.ERROR.NAME, message = iostatus.DeepNotes }, meta.Request.Security.AuthToken.User.role); } } #endregion } else { proceedCall(); } if (response is V1SystemResponseRecord) { ((V1SystemResponseEntity)((V1SystemResponseRecord)response).entity).message = iostatus.DeepNotes; } }
public override void proceedCall() { try { WSSystemEntity entity = new WSSystemEntity() { }; WSSystemRecord rec = new WSSystemRecord(meta.ClientFunctions, entity, meta.Request.Security.AuthToken.User.role); if (WSConstants.ALIACES.ACTION_READ.Match(meta.Request.ACTION)) { entity.status = WSServerMeta.LoadStatusStatic; } else if (WSConstants.ALIACES.ACTION_WRITE.Match(meta.Request.ACTION)) { WSEntitySchema USchema = meta.Request.SOURCE != null && meta.Request.SOURCE is WSTableSource? ((WSTableSource)meta.Request.SOURCE).DynamicSchema : null; if (USchema != null && USchema is WSEntitySchema) { WSEntitySchema schema = USchema; } } else if (WSConstants.ALIACES.ACTION_FLUSH.Match(meta.Request.ACTION)) { try { if (reloadCoreSources()) { entity.status.AddNote($"Reset succeeded.", WSConstants.ACCESS_LEVEL.READ, WSStatus.SUCCESS.CODE); } else { entity.status.AddNote("Reset failed.", WSConstants.ACCESS_LEVEL.READ, WSStatus.ERROR.CODE); } } catch (Exception e) { meta.RegError(GetType(), e, ref iostatus); } } else if (WSConstants.ALIACES.ACTION_CREATE.Match(meta.Request.ACTION)) { string ENTITY = meta.Request.INPUT.ReadValue(WSConstants.ALIACES.ENTITY, out ENTITY) ? ENTITY : null; if (!string.IsNullOrEmpty(ENTITY)) { if (WSConstants.ALIACES.ACCESS_KEY.Match(ENTITY)) { entity.data = meta.GenerateWSAccessKey(); } } } #region VERSION 0 if (WSConstants.PARAMS.IOVERSION.VERSION0.Match(meta.Request.VERSION)) { response = rec; } #endregion #region VERSION 1 else if (WSConstants.PARAMS.IOVERSION.VERSION1.Match(meta.Request.VERSION)) { response = new V1SystemResponseRecord(meta.ClientFunctions, new V1SystemResponseEntity() { status = (rec == null || rec.entity == null) ? WSStatus.ERROR.NAME : iostatus.NAME, data = rec, message = iostatus.NOTES }, meta.Request.Security.AuthToken.User.role); if (response == null) { response = new V1SystemResponseRecord(meta.ClientFunctions, new V1SystemResponseEntity() { status = WSStatus.ERROR.NAME, message = iostatus.NOTES }, meta.Request.Security.AuthToken.User.role); } } #endregion } catch (Exception e) { meta.RegError(GetType(), e, ref iostatus); } }