示例#1
0
        public override string GetObjectServer(string jsonString)
        {
            ExportObject obj = JsonHelper.DeserializeJsonToObject <ExportObject>(jsonString);

            ServerResponseWithoutBody simpleRes = new ServerResponseWithoutBody();

            simpleRes.type = type;

            try
            {
                if (!GetAuthorised(obj.user))
                {
                    simpleRes.state = networkState.SERVER_FAIL_AUTHORISING;
                    return(JsonHelper.SerializeObject(simpleRes));
                }

                if (store.Export(obj.product, obj.comments, obj.user.userName))
                {
                    simpleRes.state = networkState.SERVER_SUCCESS;
                }
                else
                {
                    simpleRes.state = networkState.SERVER_FAIL_OPERATION;
                }

                return(JsonHelper.SerializeObject(simpleRes));
            }
            catch (Exception ex)
            {
                simpleRes.state = networkState.SERVER_FAIL_UNKNOWN;
                return(JsonHelper.SerializeObject(simpleRes));
            }
        }
示例#2
0
        public override string GenerateObjectClient()
        {
            ExportObject obj = new ExportObject();

            obj.type     = type;
            obj.user     = user;
            obj.product  = product;
            obj.comments = comments;

            string s = JsonHelper.SerializeObject(obj);

            return(s);
        }