3using System.Threading.Tasks;
22 : base(
"/SetContractState")
26 public override bool HandlesSubPaths =>
false;
27 public override bool UserSessions =>
true;
41 if (Content.
HasError || !(Content.
Decoded is Dictionary<string, object> Form))
47 if (!Form.TryGetValue(
"contractId", out
object Obj) || !(Obj is
string ContractId) ||
48 !Form.TryGetValue(
"state", out Obj) || !(Obj is
string StateStr) ||
55 Dictionary<string, object> Result = await SetState(ContractId, State, User);
57 Response.StatusCode = 200;
58 Response.StatusMessage =
"OK";
64 internal static async Task<Dictionary<string, object>> SetState(
string ContractId,
ContractState State,
IUser User)
73 return new Dictionary<string, object>()
79 DateTime Now = DateTime.Now;
82 Contract.State = State;
88 Message =
"Contract deleted.";
96 Message =
"Contract state changed to " + State.ToString() +
".";
122 new KeyValuePair<string, object>(
"State", State));
129 return new Dictionary<string, object>()
131 {
"date", Now.ToShortDateString() },
132 {
"time", Now.ToLongTimeString() },
133 {
"type", EventType.Informational },
134 {
"object", ContractId },
135 {
"actor", User.UserName },
136 {
"message", Message },
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
Helps with common JSON-related tasks.
static string Encode(string s)
Encodes a string for inclusion in JSON.
const string DefaultContentType
application/json
Static class managing the application event log. Applications and services log events on this static ...
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Static class managing the runtime environment of the IoT Gateway.
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
bool HasData
If the request has data.
async Task< ContentResponse > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
Task Write(byte[] Data)
Returns binary data in the response.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static async Task Update(object Object)
Updates an object in the database.
static async Task Delete(object Object)
Deletes an object in the database.
This filter selects objects that have a named field equal to a given value.
Static class managing persistent counters.
static Task< long > IncrementCounter(CaseInsensitiveString Key)
Increments a counter.
Represents a named semaphore, i.e. an object, identified by a name, that allows single concurrent wri...
Static class of application-wide semaphores that can be used to order access to editable objects.
static async Task< Semaphore > BeginWrite(string Key)
Waits until the semaphore identified by Key is ready for writing. Each call to BeginWrite must be fo...
Contains the definition of a contract
byte[] DigitalSignature
Digital Signature
DateTime Timestamp
Timestamp of signature.
bool AllowsPOST
If the POST method is allowed.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
Service Module hosting the XMPP broker and its components.
POST Interface for HTTP resources.
Basic interface for a user.
string UserName
User Name.
ContractState
Recognized contract states