Beispiel #1
0
        /**Get a photo record (this synchronous file base64 content)
         * @param docId
         * @param onErr
         * @return response
         */
        public AlbumResp selectPhotoRec(string docId, ErrorCtx err = null)
        {
            ErrorCtx    errHandler = err == null ? errCtx : err;
            AnsonHeader header     = client.Header().act("album.c#", "synch", "c/photo", "multi synch");

            AlbumReq req = new AlbumReq().selectPhoto(docId);

            AlbumResp resp = null;

            try
            {
                AnsonMsg q = client.UserReq(uri, new AlbumPort(AlbumPort.album), req)
                             .Header(header);

                resp = (AlbumResp)client.Commit(q, errCtx);
            }
            catch (Exception e) {
                if (e is AnsonException || e is SemanticException)
                {
                    errHandler.onError(new MsgCode(MsgCode.exSemantic), e.Message + " " + e.Source == null ? "" : e.Source.GetType().Name);
                }
                else
                {
                    errHandler.onError(new MsgCode(MsgCode.exIo), e.Message + " " + e.Source == null ? "" : e.Source.GetType().Name);
                }
            }
            return(resp);
        }
Beispiel #2
0
        public List <AlbumResp> syncPhotos(List <IFileDescriptor> photos, SessionInf user)
        {
            AnsonHeader header = client.Header().act("album.c#", "synch", "c/photo", "multi synch");

            List <AlbumResp> reslts = new List <AlbumResp>(photos.Count);

            foreach (IFileDescriptor p in photos)
            {
                AlbumReq req = new AlbumReq()
                               .Device(user.device)
                               .createPhoto(p, user);

                AnsonMsg q = client.UserReq(uri, new AlbumPort(AlbumPort.album), req)
                             .Header(header);

                AlbumResp resp = (AlbumResp)client.Commit(q, errCtx);

                reslts.Add(resp);
            }
            return(reslts);
        }