Exemple #1
0
        public JsonResult GetDirSize()
        {
            try
            {
                var tokenId = CommonHelper.GetToken(Request.Form["TokenId"]);
                var gnsId   = CommonHelper.DecodeUrl(Request.Form["Docid"]);

                IShareLinkAPIHelper helper = new ShareLinkAPIHelper();
                long errorCode             = 0;
                var  model = helper.GetDirSize(tokenId, gnsId, out errorCode);
                if (errorCode > 0)
                {
                    return(Json(new JsonModel {
                        Success = true, StatusCode = errorCode
                    }));
                }
                return(Json(new JsonModel {
                    Success = true, StatusCode = errorCode, Data = JsonConvert.SerializeObject(model)
                }));
            }
            catch (Exception ex)
            {
                _log.Debug($"GetDirSize Exception: {ex.Message}");
                return(Json(new JsonModel {
                    Success = false, Message = ex.Message
                }));
            }
        }
Exemple #2
0
        public JsonResult UpdateShareLink()
        {
            try
            {
                _log.Debug("UpdateShareLink Start");
                var tokenId = CommonHelper.GetToken(Request.Form["TokenId"]);
                UpdateShareLinkModel item = new UpdateShareLinkModel()
                {
                    item = new UItem()
                    {
                        perms = GetPerms(Convert.ToInt64(Request.Form["Perm"]))
                    },
                    link_id       = CommonHelper.DecodeUrl(Request.Form["LinkId"]),
                    expires_at    = CommonHelper.DecodeUrl(Request.Form["ExpiresAt"]),
                    limited_times = string.IsNullOrEmpty(Request.Form["LimitedTimes"]) ? -1 : Convert.ToInt64(Request.Form["LimitedTimes"]),
                    password      = string.IsNullOrEmpty(Request.Form["Password"]) ? "" : CommonHelper.DecodeUrl(Request.Form["Password"]),
                    title         = CommonHelper.DecodeUrl(Request.Form["Title"])
                };

                IShareLinkAPIHelper helper = new ShareLinkAPIHelper();
                var errorCode = helper.UpdateShareLink(tokenId, item);
                _log.Debug("UpdateShareLink End");
                return(Json(new JsonModel {
                    Success = true, StatusCode = errorCode
                }));
            }
            catch (Exception ex)
            {
                _log.Debug($"UpdateShareLink Exception: {ex.Message}");
                return(Json(new JsonModel {
                    Success = false, Message = ex.Message
                }));
            }
        }
Exemple #3
0
        public JsonResult GetShareLinks()
        {
            try
            {
                var           tokenId = CommonHelper.GetToken(Request.Form["TokenId"]);
                ShareLinkItem item    = new ShareLinkItem()
                {
                    id   = Request.Form["Docid"],
                    type = Request.Form["FileType"]
                };

                IShareLinkAPIHelper helper = new ShareLinkAPIHelper();
                long errorCode             = 0;
                var  model = helper.GetShareLink(tokenId, item, out errorCode);
                if (errorCode > 0)
                {
                    return(Json(new JsonModel {
                        Success = true, StatusCode = errorCode
                    }));
                }

                return(Json(new JsonModel {
                    Success = true, StatusCode = errorCode, Data = JsonConvert.SerializeObject(model)
                }));
            }
            catch (Exception ex)
            {
                _log.Debug($"GetShareLinks Exception: {ex.Message}");
                return(Json(new JsonModel {
                    Success = false, Message = ex.Message
                }));
            }
        }
Exemple #4
0
        public JsonResult GetRealNameShareLinkId()
        {
            try
            {
                _log.Debug("GetRealNameShareLink Start");
                var           tokenId = CommonHelper.GetToken(Request.Form["TokenId"]);
                ShareLinkItem item    = new ShareLinkItem()
                {
                    id   = Request.Form["Docid"],
                    type = Request.Form["FileType"]
                };

                IShareLinkAPIHelper helper = new ShareLinkAPIHelper();
                long errorCode             = 0;
                var  realNameId            = helper.GetRealNameShareLink(tokenId, item, out errorCode);
                if (errorCode > 0)
                {
                    return(Json(new JsonModel {
                        Success = true, StatusCode = errorCode
                    }));
                }
                if (string.IsNullOrEmpty(realNameId))
                {
                    item.id = CommonHelper.DecodeUrl(item.id);
                    CreatRealNameShareLinkModel model = new CreatRealNameShareLinkModel()
                    {
                        item = item
                    };
                    realNameId = helper.CreatRealNameShareLink(tokenId, model, out errorCode);
                    if (errorCode > 0)
                    {
                        return(Json(new JsonModel {
                            Success = true, StatusCode = errorCode
                        }));
                    }
                }

                _log.Debug("GetRealNameShareLink End");
                return(Json(new JsonModel {
                    Success = true, StatusCode = errorCode, Data = realNameId
                }));
            }
            catch (Exception ex)
            {
                _log.Debug($"GetRealNameShareLink Exception: {ex.Message}");
                return(Json(new JsonModel {
                    Success = false, Message = ex.Message
                }));
            }
        }
Exemple #5
0
        public JsonResult CreateShareLink()
        {
            try
            {
                _log.Debug("CreateShareLink Start");
                var tokenId = CommonHelper.GetToken(Request.Form["TokenId"]);
                CreatShareLinkModel item = new CreatShareLinkModel()
                {
                    item = new CItem()
                    {
                        id    = CommonHelper.DecodeUrl(Request.Form["Docid"]),
                        type  = Request.Form["FileType"],
                        perms = GetPerms(Convert.ToInt64(Request.Form["Perm"]))
                    },
                    expires_at    = CommonHelper.DecodeUrl(Request.Form["ExpiresAt"]),
                    limited_times = string.IsNullOrEmpty(Request.Form["LimitedTimes"]) ? -1 : Convert.ToInt64(Request.Form["LimitedTimes"]),
                    password      = string.IsNullOrEmpty(Request.Form["Password"]) ? "" : CommonHelper.DecodeUrl(Request.Form["Password"]),
                    title         = CommonHelper.DecodeUrl(Request.Form["Title"])
                };

                IShareLinkAPIHelper helper = new ShareLinkAPIHelper();
                long errorCode             = 0;
                var  shareLinkId           = helper.CreatShareLink(tokenId, item, out errorCode);
                if (errorCode > 0)
                {
                    return(Json(new JsonModel {
                        Success = true, StatusCode = errorCode
                    }));
                }

                _log.Debug("CreateShareLink End");
                return(Json(new JsonModel {
                    Success = true, StatusCode = errorCode, Data = shareLinkId
                }));
            }
            catch (Exception ex)
            {
                _log.Debug($"CreateShareLink Exception: {ex.Message}");
                return(Json(new JsonModel {
                    Success = false, Message = ex.Message
                }));
            }
        }
Exemple #6
0
        public JsonResult RemoveShareLink()
        {
            try
            {
                _log.Debug("RemoveShareLink Start");
                var tokenId = CommonHelper.GetToken(Request.Form["TokenId"]);
                var link_id = CommonHelper.DecodeUrl(Request.Form["LinkId"]);

                IShareLinkAPIHelper helper = new ShareLinkAPIHelper();
                var errorCode = helper.DeleteShareLink(tokenId, link_id);
                _log.Debug("RemoveShareLink End");
                return(Json(new JsonModel {
                    Success = true, StatusCode = errorCode
                }));
            }
            catch (Exception ex)
            {
                _log.Debug($"RemoveShareLink Exception: {ex.Message}");
                return(Json(new JsonModel {
                    Success = false, Message = ex.Message
                }));
            }
        }