コード例 #1
0
ファイル: AlbumClientier.cs プロジェクト: odys-z/Anclient
        /**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);
        }
コード例 #2
0
ファイル: AlbumClientier.cs プロジェクト: odys-z/Anclient
        public AlbumClientier getSettings(OnOk onOk, OnError onErr)
        {
            Task.Run(() =>
            {
                try
                {
                    AnsonHeader header = client
                                         .Header()
                                         .UsrAct("album.c#", "profile", "r/settings", "load profile");

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

                    client.CommitAsync(q, onOk, onErr);
                }
                catch (Exception e)
                {
                    onErr.err(new MsgCode(MsgCode.exIo), string.Format("%s\n%s", e.GetType().Name, e.Message));
                }
            });

            return(this);
        }
コード例 #3
0
ファイル: AlbumClientier.cs プロジェクト: odys-z/Anclient
        public DocsResp del(string device, string clientpath)
        {
            AlbumReq req = new AlbumReq().del(device, clientpath);

            DocsResp resp = null;

            try
            {
                AnsonHeader header = client.Header().act("album.c#", "del", "d/photo", "");
                AnsonMsg    q      = client.UserReq(uri, new AlbumPort(AlbumPort.album), req)
                                     .Header(header);

                resp = (DocsResp)client.Commit(q, errCtx);
            }
            catch (Exception e)
            {
                if (e is AnsonException || e is SemanticException)
                {
                    errCtx.onError(new MsgCode(MsgCode.exSemantic), e.Message + " " + e.Source == null ? "" : e.Source.GetType().Name);
                }
                else
                {
                    errCtx.onError(new MsgCode(MsgCode.exIo), e.Message + " " + e.Source == null ? "" : e.Source.GetType().Name);
                }
            }
            return(resp);
        }
コード例 #4
0
ファイル: AlbumClientier.cs プロジェクト: odys-z/Anclient
        /// <summary>
        /// Asynchronously synchronize photos
        /// </summary>
        /// <param name="photos"></param>
        /// <param name="user"></param>
        /// <param name="onOk"></param>
        /// <param name="onErr"></param>
        /// <exception cref="SemanticException"></exception>
        /// <exception cref="SemanticException"></exception>
        /// <exception cref="IOException"></exception>
        /// <exception cref="AnsonException"></exception>
        public void asyncPhotos(List <IFileDescriptor> photos, SessionInf user, OnOk onOk, OnError onErr)
        {
            DocsResp resp = null;

            try
            {
                AnsonHeader header = client.Header().act("album.c#", "synch", "c/photo", "multi synch");

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

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

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

                    Task <AnsonResp> tresp = (Task <AnsonResp>)client.Commit_async(q, null, onErr);
                    tresp.Wait();
                    reslts.Add((DocsResp)tresp.Result);
                }
                onOk.ok(resp);
            } catch (Exception e)
            {
                onErr.err(new MsgCode(MsgCode.exIo), string.Format("%s, %s", e.GetType().Name, e.Message));
            }
        }
コード例 #5
0
ファイル: AlbumClientier.cs プロジェクト: odys-z/Anclient
        /// <summary>
        /// Asynchronously query synchronizing records.
        /// </summary>
        /// <param name="files"></param>
        /// <param name="page"></param>
        /// <param name="onOk"></param>
        /// <param name="onErr"></param>
        /// <returns>this</returns>
        public AlbumClientier asyncQuerySyncs(IList <IFileDescriptor> files, SyncingPage page, OnOk onOk, OnError onErr)
        {
            Task.Run(() =>
            {
                DocsResp resp = null;
                try
                {
                    AnsonHeader header = client.Header().act("album.c#", "query", "r/states", "query sync");

                    List <DocsResp> reslts = new List <DocsResp>(files.Count);

                    AlbumReq req = (AlbumReq) new AlbumReq().Syncing(page).A(A.selectSyncs);

                    for (int i = page.start; i < page.end & i < files.Count; i++)
                    {
                        IFileDescriptor p = files[i];
                        req.querySync(p);
                    }

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


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

                    reslts.Add(resp);

                    onOk.ok(resp);
                }
                catch (Exception e) {
                    onErr.err(new MsgCode(MsgCode.exIo), uri, new string[] { e.GetType().Name, e.Message });
                }
            });
            return(this);
        }
コード例 #6
0
ファイル: AlbumClientier.cs プロジェクト: odys-z/Anclient
        public string download(Photo photo, string localpath)
        {
            AlbumReq req = new AlbumReq(uri).download(photo);

            req.A(A.download);
            return(client.download(uri, new AlbumPort(AlbumPort.album), req, localpath));
        }
コード例 #7
0
ファイル: AlbumClientier.cs プロジェクト: odys-z/Anclient
        public AlbumResp getCollect(string collectId)
        {
            AlbumReq req = new AlbumReq(uri).CollectId("c-001");

            req.A(A.collect);
            AnsonMsg q = client.UserReq(uri, new AlbumPort(AlbumPort.album), null, req);

            return((AlbumResp)client.Commit(q, errCtx));
        }
コード例 #8
0
        public SingleRsp UpdateAlbum(AlbumReq alb)
        {
            var   res   = new SingleRsp();
            Album album = new Album();

            album.MaAb   = alb.MaAb;
            album.TenAb  = alb.TenAb;
            album.GhiChu = alb.GhiChu;
            res          = _rep.UpdateAlbum(album);
            return(res);
        }
コード例 #9
0
ファイル: AlbumClientier.cs プロジェクト: odys-z/Anclient
        public AlbumResp insertPhoto(string collId, string fullpath, string clientname)
        {
            AlbumReq req = new AlbumReq(uri)
                           .createPhoto(collId, fullpath)
                           .photoName(clientname);

            req.A(A.insertPhoto);

            AnsonHeader header = client.Header().act("album.c#", "create", "c/photo", "create photo");
            AnsonMsg    q      = client.UserReq(uri, new AlbumPort(AlbumPort.album), req)
                                 .Header(header);

            return((AlbumResp)client.Commit(q, errCtx));
        }
コード例 #10
0
ファイル: AlbumClientier.cs プロジェクト: odys-z/Anclient
        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);
        }
コード例 #11
0
        public IActionResult UpdateAlbum([FromBody] AlbumReq req)
        {
            var res = _svc.UpdateAlbum(req);

            return(Ok(res));
        }
コード例 #12
0
        public IActionResult DeleteAlbum([FromBody] AlbumReq req)
        {
            var res = _svc.DeleteAlbum(req.MaAb);

            return(Ok(res));
        }