Пример #1
0
 /// <summary>
 /// 获取资源属性(是否可打印,存盘)
 /// </summary>
 /// <param name="ResourceFolder_Id"></param>
 /// <returns></returns>
 public static Rc.Interface.BookAttrModel GetBookAttrValue(string ResourceFolder_Id)
 {
     Rc.Interface.BookAttrModel model = new Rc.Interface.BookAttrModel();
     model.IsPrint = false;
     model.IsSave  = false;
     try
     {
         List <Model_BookAttrbute> listModel = new BLL_BookAttrbute().GetModelList("ResourceFolder_Id='" + ResourceFolder_Id + "'");
         foreach (var item in listModel)
         {
             if (item.AttrEnum == BookAttrEnum.Print.ToString() && item.AttrValue == "1")
             {
                 model.IsPrint = true;
             }
             else if (item.AttrEnum == BookAttrEnum.Save.ToString() && item.AttrValue == "1")
             {
                 model.IsSave = true;
             }
         }
     }
     catch (Exception)
     {
     }
     return(model);
 }
Пример #2
0
        public static string GetCloudResource(string ResourceFolder_Id, string DocName, string ShowFolderIn, string strResource_Class, int PageSize, int PageIndex)
        {
            Rc.Model.Resources.Model_F_User FloginUser = Rc.Common.StrUtility.clsUtility.IsFPageFlag() as Rc.Model.Resources.Model_F_User;
            try
            {
                DocName   = DocName.Filter();
                PageIndex = Convert.ToInt32(PageIndex.ToString().Filter());
                #region 资源信息
                DataTable     dtRes       = new DataTable();
                List <object> listReturn  = new List <object>();
                string        strSql      = string.Empty;
                string        strSqlCount = string.Empty;
                string        strWhere    = string.Empty;
                if (!string.IsNullOrEmpty(DocName))
                {
                    strWhere = " and File_Name like '%" + DocName.Filter() + "%' ";
                }
                //strWhere += string.Format(" and LessonPlan_Type='{0}' and Resource_Class = '{1}'", strLessonPlan_Type.Filter(), strResource_Class.Filter());
                strWhere += string.Format(" and Resource_Class = '{0}'", strResource_Class.Filter());
                if (Resource_ClassConst.云资源 == strResource_Class)
                {
                    strWhere += string.Format(" AND Book_ID IN(SELECT Book_ID FROM UserBuyResources WHERE A.Book_ID=UserBuyResources.Book_id AND UserBuyResources.UserId='{0}' )"
                                              , FloginUser.UserId);
                }

                if (ShowFolderIn != "1")
                {
                    strWhere += " and ResourceFolder_Id='" + ResourceFolder_Id.Filter() + "' ";
                }
                else
                {
                    strWhere += " and 1<>1 ";
                }
                //strWhere += string.Format(" and Resource_Class='{0}' and Resource_Type='{1}'", strResource_Class, strResource_Type);
                strSqlCount = @"select count(*) from ResourceToResourceFolder A
INNER JOIN Resource B ON A.Resource_Id=B.Resource_Id  where 1=1 " + strWhere + " ";
                strSql      = @"select * from (select ROW_NUMBER() over(ORDER BY A.ResourceToResourceFolder_Order,A.Resource_Name) row,A.*,B.Resource_ContentLength from ResourceToResourceFolder A
INNER JOIN Resource B ON A.Resource_Id=B.Resource_Id  where 1=1 "
                              + strWhere + " ) t where row between " + ((PageIndex - 1) * PageSize + 1) + " and " + (PageIndex * PageSize) + "  ";
                dtRes = Rc.Common.DBUtility.DbHelperSQL.Query(strSql).Tables[0];
                int    rCount     = Convert.ToInt32(Rc.Common.DBUtility.DbHelperSQL.GetSingle(strSqlCount).ToString());
                int    inum       = 0;
                string operateStr = string.Empty;
                for (int i = 0; i < dtRes.Rows.Count; i++)
                {
                    Rc.Interface.BookAttrModel bkAttrModel = GetBookAttrValue(dtRes.Rows[i]["Book_ID"].ToString());
                    inum++;
                    string docName = dtRes.Rows[i]["File_Name"].ToString().ReplaceForFilter();
                    //docName = pfunction.GetDocFileName(docName);
                    string resUrl = "Upload/Resource/" + dtRes.Rows[i]["Resource_Url"].ToString().Replace("\\", "/");
                    if (!string.IsNullOrEmpty(resUrl) && resUrl.IndexOf(".") > 0)
                    {
                        resUrl = resUrl.Substring(0, resUrl.LastIndexOf(".")) + ".htm";
                    }
                    if (dtRes.Rows[i]["Resource_Class"].ToString() == Resource_ClassConst.自有资源)
                    {
                    }
                    listReturn.Add(new
                    {
                        inum    = (i + 1),
                        docId   = dtRes.Rows[i]["ResourceToResourceFolder_Id"].ToString(),
                        docName = docName,
                        docType = dtRes.Rows[i]["File_Suffix"].ToString(),
                        // docTypeAll = dtRes.Rows[i]["File_Suffix"].ToString(),
                        docSize        = pfunction.ConvertDocSizeUnit(dtRes.Rows[i]["Resource_ContentLength"].ToString()),
                        docUrl         = pfunction.GetResourceHost("TeachingPlanViewWebSiteUrl") + resUrl,
                        docTime        = pfunction.ConvertToLongDateTime(dtRes.Rows[i]["CreateTime"].ToString()),
                        IsDownload     = bkAttrModel.IsSave,
                        Resource_Class = dtRes.Rows[i]["Resource_Class"].ToString() == Resource_ClassConst.自有资源 ? true : false,
                        IsShare        = dtRes.Rows[i]["Resource_shared"].ToString()
                                         //Opearate = operateStr
                    });
                }
                #endregion

                if (inum > 0)
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "null",
                        PageIndex = PageIndex,
                        PageSize = PageSize,
                        TotalCount = rCount,
                        list = listReturn
                    }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "暂无数据"
                    }));
                }
            }
            catch (Exception)
            {
                return(JsonConvert.SerializeObject(new
                {
                    err = "error"//ex.Message.ToString()
                }));
            }
        }