Ejemplo n.º 1
0
        public async Task <ApiLibraryResponse> DeleteLibrary(long id)
        {
            var apiResp = new ApiLibraryResponse {
                ResponseType = -1, ResponseMessage = "Failed"
            };
            var createdBy = 1;
            var deleted   = await(new JukeBox.BLL.Library()).DeleteLibrary(id, createdBy);

            if (deleted)
            {
                var retVal = await(new JukeBox.BLL.Library()).GetLibrary(0, 0);

                if (retVal.Count > 0)
                {
                    apiResp.ResponseObject = new List <ApiLibrary>();
                    foreach (var _library in retVal)
                    {
                        var library = new ApiLibrary();
                        library.Bind(_library);
                        apiResp.ResponseObject.Add(library);
                    }
                    apiResp.ResponseType    = 1;
                    apiResp.ResponseMessage = "Success";
                }
            }
            return(apiResp);
        }
Ejemplo n.º 2
0
        public ActionResult ApiLibrarySave(ApiLibrary obj)
        {
            var relativePath = "";
            var path         = FileHelper.SaveLogoPath(ref relativePath, "PayIcon");

            if (Request.Files["ApiIcon2"] != null && Request.Files["ApiIcon2"].ContentLength != 0)
            {
                var    file     = Request.Files["ApiIcon2"];
                var    fileName = Path.GetFileName(file.FileName);
                string fullname = path + fileName;
                file.SaveAs(fullname);
                obj.ApiIcon = relativePath + fileName;
            }
            if (Request.Files["ApiCloseIcon2"] != null && Request.Files["ApiCloseIcon2"].ContentLength != 0)
            {
                var    file     = Request.Files["ApiCloseIcon2"];
                var    fileName = Path.GetFileName(file.FileName);
                string fullname = path + fileName;
                file.SaveAs(fullname);
                obj.ApiCloseIcon = relativePath + fileName;
            }
            var result = _apiLibraryRepository.AddOrUpdate(obj);

            return(this.ToJsonOperateResult());
        }
Ejemplo n.º 3
0
        private async void GetUpComingMovie(ApiLibrary library)
        {
            // GridMoviesDetail.IsVisible = false;

            try
            {
                SLLoader.IsVisible = true;

                var response = await Library.GetLibraryDetail(library.Id);

                var songs = response.ResponseObject;

                LblMovieName.Text = library.Artist;
                LblType.Text      = library.Type;
                var price = Math.Round(library.Price ?? 0, 2);
                LblPrice.Text       = "R" + price;
                LblLanguage.Text    = library.Type;
                LblDescription.Text = library.Description;
                ImgDetail.Source    = library.CoverFilePath;

                SongListView.ItemsSource   = songs;
                GridMoviesDetail.IsVisible = true;
            }
            catch (Exception e)
            {
                SLLoader.IsVisible = false;

                throw;
            }
            finally
            {
                SLLoader.IsVisible = false;
            }
        }
 public string Upload(string apiid)
 {
     try
     {
         HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
         if (files.Count > 0)
         {
             Random         rnd  = new Random();
             string         path = "";
             HttpPostedFile file = files[0];
             if (file.ContentLength > 0)
             {
                 string fileName  = file.FileName;
                 string extension = Path.GetExtension(fileName);
                 int    num       = rnd.Next(5000, 1000000);
                 path = "/Data/" + num.ToString() + extension;
                 file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path));
             }
             ApiLibrary apiLibrary = ApiLibraryCore.GetInstance().GetApiLibrary(apiid);
             apiLibrary.docurl = path;
             ApiLibraryCore.GetInstance().UpdateApiLibrary(apiLibrary);
             comm.success = true;
             comm.message = "上传成功";
         }
     }
     catch (Exception)
     {
         comm.success = false;
         comm.message = "上传失败";
     }
     return(JsonHelper.SerializeObject(comm));
 }
 public MusicDetailPage(ApiLibrary library)
 {
     InitializeComponent();
     GetUpComingMovie(library);
     _player?.Reset();
     _player?.Release();
     _player?.Dispose();
     _player = null;
     _player = new MediaPlayer();
 }
Ejemplo n.º 6
0
        public ActionResult ApiLibrarySave(int?id)
        {
            var dictList = AutofacDependencyResolver.Current.GetService <ISysDictionaryRepository>().GetItemsByDicpsn(10);

            ViewBag.apiTypes = this.ToSelectTitle(dictList.Select(o => new SelectListItem()
            {
                Text = o.Title, Value = o.DicSN.ToString()
            }), emptyTitle: "请选择");
            var obj = new ApiLibrary()
            {
                ReqMode = 1, State = 1
            };

            if (id.HasValue)
            {
                obj = _apiLibraryRepository.Get(id);
            }
            return(View(obj));
        }
Ejemplo n.º 7
0
        public async Task <ApiLibraryResponse> GetLibrary(int filter, int?clientid = null)
        {
            var apiResp = new ApiLibraryResponse {
                ResponseType = -1, ResponseMessage = "Failed"
            };

            var retVal = await(new JukeBox.BLL.Library()).GetLibrary(filter, clientid);

            if (retVal.Count > 0)
            {
                apiResp.ResponseObject = new List <ApiLibrary>();
                foreach (var _library in retVal)
                {
                    var library = new ApiLibrary();
                    library.Bind(_library);
                    apiResp.ResponseObject.Add(library);
                }
                apiResp.ResponseType    = 1;
                apiResp.ResponseMessage = "Success";
            }
            return(apiResp);
        }
        private async void GetUpComingMovie(ApiLibrary library)
        {
            // GridMoviesDetail.IsVisible = false;

            this.dataService = new DataService();

            try
            {
                //SLLoader.IsVisible = true;
                var main     = MainViewModel.GetInstance();
                var clientId = main.User.UserId > 0 ? main.User.UserId : 0;
                var response = await Library.GetLibraryDetail(library.Id, clientId);

                if (response != null)
                {
                    if (response.ResponseObject != null)
                    {
                        libraryId = library.Id;
                        var songs = response.ResponseObject;
                        LblArtist.Text = library.Artist;
                        LblGenre.Text  = library.Type;
                        var price = Math.Round(library.Price ?? 0, 2);
                        LblPrice.Text       = "R" + price;
                        LblAlbum.Text       = library.Name;
                        LblDescription.Text = library.Description;
                        ImgDetail.Source    = ImageSource.FromUri(new Uri(library.CoverFilePath));
                        BtnBuy.Text         = library.Purchase;
                        filePath            = library.FilePath;
                        albumCover          = library.CoverFilePath;
                        DownloadAlbum       = library.AlbumDownload;
                        if (library != null)
                        {
                            var mainViewModel = MainViewModel.GetInstance();
                            mainViewModel.LibraryDetailModel.LibraryId = library.Id;
                            mainViewModel.LibraryDetailModel.libraryDetail();
                            GridMoviesDetail.IsVisible = true;
                            // BindingContext = mainViewModel;
                            apiLibraryDetails = new List <ApiLibraryDetail>();
                            foreach (var item in response.ResponseObject)
                            {
                                item.IsStream = true;
                                apiLibraryDetails.Add(item);
                            }
                            if (apiLibraryDetails != null)
                            {
                                lblSongs.IsVisible = true;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                //SLLoader.IsVisible = false;

                throw;
            }

            finally
            {
                // SLLoader.IsVisible = false;
            }
        }
Ejemplo n.º 9
0
 public MusicDetailPage(ApiLibrary library)
 {
     InitializeComponent();
     GetUpComingMovie(library);
     //   BindingContext = new MusicDetailViewModel();
 }
Ejemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            this.currentContext = context;
            context.Response.Clear();
            context.Response.ContentType = "text/html";

            parameters = GetParamsFromRequest(context.Request);

            try
            {
                /*---- 获取可选参数 ----*/
                object o = GetParam("format");
                if (o != null && o.ToString().Trim() != "")
                {
                    format = o.ToString().Trim();
                }

                /*---- 校验必选参数 ----*/
                o = GetParam("api_key");
                if (o != null && o.ToString().Trim() != "")
                {
                    api_key = o.ToString().Trim();
                }
                else
                {
                    ResponseErrorInfo((int)ErrorType.API_EC_APPLICATION);
                    return;
                }

                //检查是否上传了api_id
                o = GetParam("api_id");
                if (o != null && o.ToString().Trim() != "")
                {
                    api_id = o.ToString().Trim();
                }
                else
                {
                    ResponseErrorInfo((int)ErrorType.API_EC_NO_API);
                    return;
                }

                //根据api_key去mongodb去查,先查这个是否存在的api_key
                Clients client = clientCore.GetClientByClientid(api_key);
                if (client == null)
                {
                    ResponseErrorInfo((int)ErrorType.API_EC_APPLICATION);
                    return;
                }
                else
                {
                    apiKey    = client.clientid;
                    secretKey = client.clientsecret;
                }

                //判断状态是否正常 如果暂停则返回服务暂不可用
                if (!client.isenabled)
                {
                    ResponseErrorInfo((int)ErrorType.API_EC_SERVICE);
                    return;
                }

                //如果存在api_key 那么在查询是否有接入ip限制
                if (!string.IsNullOrEmpty(client.reqip))
                {
                    if (GetIp() != client.reqip)
                    {
                        ResponseErrorInfo((int)ErrorType.API_EC_BAD_IP);
                        return;
                    }
                }

                //查询是否赋予了查询该Api的权限
                Authorizations authorization = authorizationsCore.GetAuthorization(client.id);
                if (authorization == null)
                {
                    ResponseErrorInfo((int)ErrorType.API_EC_NO_API_ACCESS);
                    return;
                }
                else
                {
                    if (string.IsNullOrEmpty(authorization.apilibraryids))
                    {
                        ResponseErrorInfo((int)ErrorType.API_EC_NO_API_ACCESS);
                        return;
                    }
                    else
                    {
                        if (!authorization.apilibraryids.Contains(api_id))
                        {
                            ResponseErrorInfo((int)ErrorType.API_EC_NO_API_ACCESS);
                            return;
                        }
                    }
                }

                o = GetParam("method");
                if (o != null && o.ToString().Trim() != "")
                {
                    method = o.ToString().Trim();
                }
                else
                {
                    ResponseErrorInfo((int)ErrorType.API_EC_METHOD);
                    return;
                }

                o = GetParam("sig");
                if (o != null && o.ToString().Trim() != "")
                {
                    sig = o.ToString().Trim();
                }
                else
                {
                    ResponseErrorInfo((int)ErrorType.API_EC_SIGNATURE);
                    return;
                }

                string sign = GetSignature(parameters, secretKey);
                if (sign.ToLower() != sig.ToLower())
                {
                    ResponseErrorInfo((int)ErrorType.API_EC_SIGNATURE);
                    return;
                }
            }
            catch
            {
                ResponseErrorInfo((int)ErrorType.API_EC_PARAM);
                return;
            }

            string classname  = method.Substring(0, method.LastIndexOf('.'));
            string methodname = method.Substring(method.LastIndexOf('.') + 1);

            string     content = String.Empty;
            ActionBase action;

            try
            {
                ApiLibrary apiLibrary   = apiLibraryCore.GetApiLibrary(api_id);
                Assembly   t            = Assembly.Load("WebApiCenter." + apiLibrary.apiname);
                Type       typeInstance = null;
                foreach (Type type in t.GetTypes())
                {
                    if (type.Name == classname)
                    {
                        typeInstance = type;
                        break;
                    }
                }
                if (typeInstance == null)
                {
                    ResponseErrorInfo((int)ErrorType.API_EC_METHOD);
                    return;
                }

                action        = (ActionBase)Activator.CreateInstance(typeInstance);
                action.ApiKey = apiKey;
                action.Params = parameters;
                action.Secret = secretKey;
                action.Format = FormatType.JSON;
                context.Response.ContentType = "application/Json";
                action.Signature             = sig;

                if (format.Trim().ToLower() == "xml")
                {
                    context.Response.ContentType = "text/xml";
                    action.Format = FormatType.XML;
                }

                content = typeInstance.InvokeMember(methodname, BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.IgnoreCase, null, action, new object[] { }).ToString();
            }
            catch (Exception ex)
            {
                content = String.Empty;
                ResponseErrorInfo((int)ErrorType.API_EC_METHOD);
                return;
            }
            if (action.ErrorCode > 0)
            {
                content = String.Empty;
                ResponseErrorInfo(action.ErrorCode);
                return;
            }
            this.currentContext.Response.AddHeader("Access-Control-Allow-Origin", "*");
            this.currentContext.Response.Write(content);
            this.currentContext.ApplicationInstance.CompleteRequest();
        }
 public void UpdateApiLibrary(ApiLibrary apiLibrary)
 {
     MongodbHelper.UpdateOne <ApiLibrary>("ApiLibrary", apiLibrary);
 }