Exemplo n.º 1
0
        /// <summary>
        /// 查询当前机构配置信息
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public dynamic GetPolyvInfoModel(int System_Station_ID)
        {
            //查询当前机构是否使用自己的保利威视配置
            PolyvInfoModel     Model        = SqlMapper.QueryForObject <PolyvInfoModel>("GetPolyvInfo", new { System_Station_ID = System_Station_ID });
            W_PolyvInfo_Detail Model_Detail = SqlMapper.QueryForObject <W_PolyvInfo_Detail>("GetPolyvInfo_Detail", new { System_Station_ID = System_Station_ID });

            if (Model_Detail != null)
            {
                //是系统配置
                if (Model == null)
                {
                    Model             = new PolyvInfoModel();
                    Model.PolyvSource = 1;//系统
                }
                else
                {
                    Model.PolyvSource = 2;//自定义
                }
                Model.PolyvInfo_ID = Model_Detail.PolyvInfo_ID;
                Model.Valid        = Model_Detail.Valid;
                Model.cataid       = Model_Detail.cataid == null ? "" : Model_Detail.cataid;
            }

            return(Model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新视频状态
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public dynamic UpdateStatus(W_CourseWare model, int System_Station_ID)
        {
            W_CourseWare CourseWareModel = Orm.Single <W_CourseWare>(x => x.ID == model.ID && x.System_Station_ID == System_Station_ID);

            if (CourseWareModel == null)
            {
                throw new ApiException("操作失败,未找到操作数据,请刷新重试");
            }

            if (model.Status == 7)
            {
                PolyvInfoMapper bll        = new PolyvInfoMapper();
                PolyvInfoModel  PolyvModel = bll.GetPolyvSetByWhere(System_Station_ID);
                if (PolyvModel == null)
                {
                    throw new ApiException("资源上传目录未设置,请先设置!");
                }
                else
                {
                    if (PolyvModel.Valid == 0)
                    {
                        throw new ApiException("资源上传设置未开启,请先开启!");
                    }
                }

                try
                {
                    //string readtoken = "88cb627e-0bf2-4b64-833f-3e8e60a9f8e8";
                    //string secretkey = "UfmKG8jJ82";
                    string readtoken = PolyvModel.readtoken;
                    string secretkey = PolyvModel.secretkey;
                    string signn     = string.Format("readtoken={0}&vid={1}{2}", readtoken, CourseWareModel.PolyvVID, secretkey);
                    string Sign      = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signn, "sha1");

                    string postData = string.Format("readtoken={0}&vid={1}&sign={2}", readtoken, CourseWareModel.PolyvVID, Sign);

                    string Url    = "http://v.polyv.net/uc/services/rest?method=getById&readtoken=" + readtoken + "&vid=" + CourseWareModel.PolyvVID + "&sign=" + Sign;
                    string result = bll.doGet(Url);

                    JavaScriptSerializer jss  = new JavaScriptSerializer();
                    PlayModelData        Json = jss.Deserialize <PlayModelData>(result);
                    DateTime             dt   = DateTime.Parse(Json.data[0].duration);
                    model.Duration = dt.Hour * 60 * 60 + dt.Minute * 60 + dt.Second;

                    //if (Json.data[0].filesize.Length > 0)
                    //    CourseSize = Json.data[0].filesize[Json.data[0].filesize.Length - 1].ToInt(0);
                    model.CourseSize = Convert.ToInt64(Json.data[0].source_filesize);
                }
                catch (Exception)
                {
                }
            }
            return(SqlMapper.Update("UpdateStatus", new { PolyvVID = model.PolyvVID, Status = model.Status, Duration = model.Duration, CourseSize = model.CourseSize, ID = model.ID }));
        }
Exemplo n.º 3
0
        public dynamic SavePolyvInfo(PolyvInfoModel model)
        {
            if (model == null)
            {
                return(Success("未传任何参数!"));
            }

            model.System_Station_ID = this.System_Station_ID;
            if (model.ID == 0)
            {
                model.AddTime = DateTime.Now;
            }
            var dict = mapper.SavePolyvInfo(model);

            return(Success(dict));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 读取视频配置数据 hx add 20171205
        /// </summary>
        /// <param name="System_Station_ID"></param>
        /// <returns></returns>
        public PolyvInfoModel GetPolyvSetByWhere(int System_Station_ID)
        {
            PolyvInfoModel model = SqlMapper.QueryForObject <PolyvInfoModel>("GetPolyvSetByWhere", new { System_Station_ID = System_Station_ID });

            if (model == null)
            {
                throw new ApiException("资源上传目录未设置,请先设置!");
            }
            else
            {
                if (model.Valid == 0)
                {
                    throw new ApiException("资源上传设置未开启,请先开启!");
                }
            }
            return(model);
        }
Exemplo n.º 5
0
        public dynamic Hash()
        {
            //string Token = "Y07Q4yopIVXN83n-MPoIlirBKmrMPJu0";
            //string serviceUrl = "http://upload.polyv.net:1080/files/";
            //string writeToken = "cb1ffbac-ae05-4b4e-b310-3f92c344a2a2";
            //string secretkey = "UfmKG8jJ82";
            PolyvInfoModel model = mapper.GetPolyvSetByWhere(this.System_Station_ID);

            var ts   = GenerateTimeStamp().ToString();
            var hash = EncryptToMD5(ts + model.writetoken).ToLower();
            var resp = new
            {
                ts,
                hash
            };

            return(resp);
        }
Exemplo n.º 6
0
 public dynamic GetPolyvInfoModel(PolyvInfoModel model)
 {
     return(Success(mapper.GetPolyvInfoModel(this.System_Station_ID)));
 }
Exemplo n.º 7
0
        /// <summary>
        /// 保利威视配置
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool SavePolyvInfo(PolyvInfoModel model)
        {
            if (model.System_Station_ID == 0)
            {
                throw new ApiException("机构ID不存在!");
            }

            //自主类型  参数判断
            if (model.PolyvSource == 1)
            {
                if (string.IsNullOrEmpty(model.userid))
                {
                    throw new ApiException("userid不能为空!");
                }

                if (string.IsNullOrEmpty(model.writetoken))
                {
                    throw new ApiException("writetoken不能为空!");
                }

                if (string.IsNullOrEmpty(model.readtoken))
                {
                    throw new ApiException("readtoken不能为空!");
                }

                if (string.IsNullOrEmpty(model.secretkey))
                {
                    throw new ApiException("secretkey不能为空!");
                }

                string refMessage = "";
                //测试接口是否可用、参数是否正确
                if (!CheckParameter(model.userid, model.writetoken, model.readtoken, model.secretkey, ref refMessage))
                {
                    throw new ApiException(refMessage);
                }
            }

            H_Station station     = Orm.Single <H_Station>(x => x.ID == model.System_Station_ID);
            string    StationName = station != null ? station.Name : "";

            if (model.PolyvSource == 1)
            {
                model.Name = StationName; //自主的就读机构的名称
            }
            string Message = string.Empty;

            //是否第一次设置
            W_PolyvInfo_Detail polyvDetail = Orm.Single <W_PolyvInfo_Detail>(x => x.System_Station_ID == model.System_Station_ID);

            if (polyvDetail == null)        //第一次设置
            {
                if (model.PolyvSource == 0) //系统默认
                {
                    #region
                    W_PolyvInfo Model = Orm.Single <W_PolyvInfo>(x => x.System_Station_ID == 0); //读主表默认
                    if (model == null)
                    {
                        throw new ApiException("未找到对应的默认配置数据!");
                    }

                    //调用接口创建目录
                    string cataid = CreateDirectory(Model, StationName, out Message);
                    //创建目录失败
                    if (string.IsNullOrEmpty(cataid))
                    {
                        throw new ApiException("创建目录失败!" + Message);
                    }
                    else
                    {
                        //添加详细
                        return(SavePolyvDetail(true, model.System_Station_ID, Model.ID, cataid, model.Valid, model.PolyvSource));
                    }
                    #endregion
                }
                else if (model.PolyvSource == 1) //自主类型
                {
                    #region
                    W_PolyvInfo Model = Orm.Single <W_PolyvInfo>(x => x.System_Station_ID == model.System_Station_ID); //读主表配置
                    if (Model == null)                                                                                 //主表为空
                    {
                        W_PolyvInfo polyv = new W_PolyvInfo();
                        polyv.System_Station_ID = model.System_Station_ID;
                        polyv.Name       = model.Name;
                        polyv.userid     = model.userid;
                        polyv.writetoken = model.writetoken;
                        polyv.readtoken  = model.readtoken;
                        polyv.secretkey  = model.secretkey;
                        polyv.AddTime    = DateTime.Now;
                        int polyv_id = (int)Orm.Insert(polyv, true);
                        if (polyv_id > 0)
                        {
                            //调用接口创建目录
                            string cataid = CreateDirectory(polyv, StationName, out Message);

                            //创建目录失败
                            if (string.IsNullOrEmpty(cataid))
                            {
                                throw new ApiException("创建目录失败!" + Message);
                            }
                            else
                            {
                                //添加详细
                                return(SavePolyvDetail(true, polyv.System_Station_ID, polyv_id, cataid, model.Valid, model.PolyvSource));
                            }
                        }
                        else
                        {
                            throw new ApiException("设置不成功,设置主表添加异常!");
                        }
                    }
                    else
                    {
                        //调用接口创建目录
                        string cataid = CreateDirectory(model, StationName, out Message);

                        //创建目录失败
                        if (string.IsNullOrEmpty(cataid))
                        {
                            throw new ApiException("创建目录失败!" + Message);
                        }
                        else
                        {
                            //直接修改明细
                            return(SavePolyvDetail(true, model.System_Station_ID, Model.ID, cataid, model.Valid, model.PolyvSource));
                        }
                    }
                    #endregion
                }
                else
                {
                    throw new ApiException("设置不成功,账号类型不正确!");
                }
            }
            else //不是第一次设置
            {
                if (model.PolyvSource == 0) //系统默认
                {
                    #region
                    W_PolyvInfo Model = Orm.Single <W_PolyvInfo>(x => x.System_Station_ID == 0); //读主表默认
                    if (model == null)
                    {
                        throw new ApiException("未找到对应的默认配置数据!");
                    }

                    //读详细表
                    W_PolyvInfo_Detail D_Model = Orm.Single <W_PolyvInfo_Detail>(x => x.System_Station_ID == model.System_Station_ID);
                    if (D_Model != null)
                    {
                        //不创建目录 直接修改详细
                        return(SavePolyvDetail(false, D_Model.System_Station_ID, Model.ID, D_Model.cataid, model.Valid, model.PolyvSource));
                    }
                    else
                    {
                        throw new ApiException("未找到对应的明细配置数据!");
                    }
                    #endregion
                }
                else if (model.PolyvSource == 1) //自主类型
                {
                    #region
                    W_PolyvInfo Model = Orm.Single <W_PolyvInfo>(x => x.System_Station_ID == model.System_Station_ID); //读主表配置
                    if (Model == null)                                                                                 //主表为空
                    {
                        W_PolyvInfo polyv = new W_PolyvInfo();
                        polyv.System_Station_ID = model.System_Station_ID;
                        polyv.Name       = model.Name;
                        polyv.userid     = model.userid;
                        polyv.writetoken = model.writetoken;
                        polyv.readtoken  = model.readtoken;
                        polyv.secretkey  = model.secretkey;
                        polyv.AddTime    = DateTime.Now;
                        int polyv_id = (int)Orm.Insert(polyv, true);

                        if (polyv_id > 0)
                        {
                            //调用接口创建目录
                            string cataid = CreateDirectory(polyv, StationName, out Message);

                            //创建目录失败
                            if (string.IsNullOrEmpty(cataid))
                            {
                                throw new ApiException("创建目录失败!" + Message);
                            }
                            else
                            {
                                //修改详细
                                return(SavePolyvDetail(false, polyv.System_Station_ID, polyv_id, cataid, model.Valid, model.PolyvSource));
                            }
                        }
                        else
                        {
                            throw new ApiException("设置不成功,设置主表添加异常!");
                        }
                    }
                    else //主表不为空,修改
                    {
                        //数据是否修改
                        bool HasChange = false;
                        if (model.userid != Model.userid)
                        {
                            HasChange = true;
                        }
                        if (model.writetoken != Model.writetoken)
                        {
                            HasChange = true;
                        }
                        if (model.readtoken != Model.readtoken)
                        {
                            HasChange = true;
                        }
                        if (model.secretkey != Model.secretkey)
                        {
                            HasChange = true;
                        }

                        W_PolyvInfo_Detail D_Model = Orm.Single <W_PolyvInfo_Detail>(x => x.System_Station_ID == model.System_Station_ID); //读详细表

                        if (HasChange)                                                                                                     //如果数据有变更
                        {
                            //调用接口创建目录
                            string cataid = CreateDirectory(model, StationName, out Message);

                            //创建目录失败
                            if (string.IsNullOrEmpty(cataid))
                            {
                                throw new ApiException("创建目录失败!" + Message);
                            }
                            else
                            {
                                //修改主表
                                if (SqlMapper.Update("UpdatePolyvInfo", new { Name = model.Name, userid = model.userid, writetoken = model.writetoken, readtoken = model.readtoken, secretkey = model.secretkey, System_Station_ID = model.System_Station_ID, ID = Model.ID }) > 0)
                                {
                                    //修改详细
                                    return(SavePolyvDetail(false, D_Model.System_Station_ID, Model.ID, cataid, model.Valid, model.PolyvSource));
                                }
                                else
                                {
                                    throw new ApiException("主表修改失败!" + Message);
                                }
                            }
                        }
                        else
                        {
                            //直接修改明细
                            return(SavePolyvDetail(false, D_Model.System_Station_ID, Model.ID, D_Model.cataid, model.Valid, model.PolyvSource));
                        }
                    }
                    #endregion
                }
                else
                {
                    throw new ApiException("设置不成功,账号类型不正确!");
                }
            }
        }