Exemple #1
0
        public List <Link> GetLink()
        {
            BLL.Cookie.TeUser U = GetCookie.GetUserCookie();

            string condition = string.Format(@"[UserType]=1  and UserCode ='{0}' ", U.userCode);

            DataSet dataSet  = UserManager.GetUserRoleInfoList(condition);
            string  RoleCode = "";

            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                RoleCode += "'" + dataSet.Tables[0].Rows[i]["RoleCode"].ToString() + "',";
            }
            if (RoleCode != "")
            {
                RoleCode = RoleCode.Substring(0, RoleCode.Length - 1);
                StringBuilder strSql = new StringBuilder();
                strSql.Append("SELECT DISTINCT ");
                strSql.Append("[Code],[oaName],[link],[sort],[img],[State]");
                strSql.Append(" FROM ViewRoleLink where ");
                strSql.Append(string.Format("RoleCode In ({0}) order by sort asc", RoleCode));
                using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
                {
                    DataSet     Dt      = SqlQueryForDataTatable1(Db.Database, strSql.ToString());
                    List <Link> result1 = List.ToList <Link>(Dt, 0);
                    return(result1.ToList());
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
 public ActionResult Edit(BLL.Link L)
 {
     GetCookie.ExistCookie();
     using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
     {
         try
         {
             var image = Request.Files["FileUpload1"];
             if (image != null && image.ContentLength > 0)
             {
                 string fileName = DateTime.Now.ToString("yyyyMMdd") + "-" + Path.GetFileName(image.FileName);
                 string filePath = Path.Combine(Server.MapPath("~/Content/Img"), fileName);
                 image.SaveAs(filePath);
                 L.img = fileName;
             }
             DbEntityEntry <BLL.Link> entry = Db.Entry <BLL.Link>(L);
             entry.State = System.Data.Entity.EntityState.Modified;
             int re = Db.SaveChanges();
             if (re > 0)
             {
                 BLL.Log.UserLog.AddUserLog("修改系统成功", GetCookie.GetUserCookie().userName + " 成功修改 " + L.oaName + " 系统 ");
             }
             else
             {
                 BLL.Log.UserLog.AddUserLog("修改系统失败", "数据修改失败!");
             }
         }
         catch (Exception ex)
         {
             BLL.Log.UserLog.AddUserLog("修改系统失败", ex.Message);
             throw;
         }
         return(View("List"));
     }
 }
Exemple #3
0
 public ActionResult Add(BLL.Link L)
 {
     using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
     {
         try
         {
             var image = Request.Files["FileUpload1"];
             if (image != null && image.ContentLength > 0)
             {
                 string fileName = DateTime.Now.ToString("yyyyMMdd") + "-" + Path.GetFileName(image.FileName);
                 string filePath = Path.Combine(Server.MapPath("~/Content/Img"), fileName);
                 image.SaveAs(filePath);
                 L.img = fileName;
             }
             L.State = 1;
             Db.Link.Add(L);
             int re = Db.SaveChanges();
             if (re > 0)
             {
                 BLL.Log.UserLog.AddUserLog("添加系统成功", GetCookie.GetUserCookie().userName + " 成功创建 " + L.oaName + " 系统 ");
             }
             else
             {
                 BLL.Log.UserLog.AddUserLog("创建系统失败", "数据插入失败!");
             }
         }
         catch (Exception ex)
         {
             BLL.Log.UserLog.AddUserLog("创建系统失败", ex.Message);
             throw;
         }
         return(View("List"));
     }
 }
Exemple #4
0
        public ActionResult Del(int code)
        {
            using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
            {
                try
                {
                    BLL.Link L = new BLL.Link();
                    L.State = 0;
                    L.Code  = code;
                    Db.Link.Attach(L);
                    Db.Entry(L).Property(x => x.State).IsModified = true;

                    string oaName = (from B in Db.Link
                                     where B.Code == code
                                     select B.oaName).ToList().FirstOrDefault();

                    int re = Db.SaveChanges();
                    if (re > 0)
                    {
                        BLL.Log.UserLog.AddUserLog("删除系统成功", GetCookie.GetUserCookie().userName + " 成功删除 " + oaName + " 系统 ");
                    }
                    else
                    {
                        BLL.Log.UserLog.AddUserLog("删除系统失败", "数据删除失败!");
                    }
                }
                catch (Exception ex)
                {
                    BLL.Log.UserLog.AddUserLog("删除系统失败", ex.Message);
                    throw;
                }
                return(View("List"));
            }
        }
Exemple #5
0
        public int GetUserLogCount()
        {
            int Count = 0;

            using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
            {
                Count = Db.UserLog.Count();
                return(Count);
            }
        }
Exemple #6
0
        public int GetPostCount()
        {
            int Count = 0;

            using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
            {
                Count = Db.Link.Count();
                return(Count);
            }
        }
Exemple #7
0
        public ActionResult Edit(int Code)
        {
            GetCookie.ExistCookie();
            using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
            {
                var Model = (from B in Db.Link
                             where B.Code == Code
                             select B).ToList().FirstOrDefault();

                return(View(Model));
            }
        }
Exemple #8
0
        public ActionResult Redir(int Code)
        {
            //Cookie 验证
            BLL.Cookie.TeUser U = GetCookie.GetUserCookie();
            //获取数据
            using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
            {
                var link = from b in Db.Link
                           where b.Code == Code && b.State == 1
                           orderby b.sort
                           select b;
                //假数据模式
                //BLL.StringDb Db2 = new BLL.StringDb();
                //List<BLL.StringDb.Link> linkDb = Db2.getLink();
                //var link = from b in linkDb
                //           where b.Code == Code
                //           select b;

                foreach (var item in link)
                {
                    string Url = "";
                    switch (Code)
                    {
                    case 12:
                        Url = digital.getUrl(item.link, U.userCode, U.userType);
                        return(Redirect("Http://" + Url));

                    case 2:
                        Url = digital.GetDianUrl(item.link, U.userCode, U.userType);
                        return(Redirect("Http://" + Url));

                    case 5:
                        //Url = digital.GuangBo("user1", "111111");
                        return(Redirect("/VidoLogin/Login"));

                    //return Redirect("Http://" + Url);

                    default:
                        break;
                    }

                    //其余直接跳转Url
                    if (item.Code == Code)
                    {
                        return(Redirect("Http://" + item.link));
                    }
                }
            }
            return(Redirect("~/Home/Index"));
        }
Exemple #9
0
        protected void Application_Start()
        {
            System.Data.Entity.Database.SetInitializer <BLL.NETDISKDBEntities>(null);
            using (var dbcontext = new BLL.NETDISKDBEntities())
            {
                var objectContext     = ((IObjectContextAdapter)dbcontext).ObjectContext;
                var mappingCollection = (StorageMappingItemCollection)objectContext.MetadataWorkspace.GetItemCollection(DataSpace.CSSpace);
                mappingCollection.GenerateViews(new List <EdmSchemaError>());
            }


            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Exemple #10
0
        public List <T> GetPostList <T>(int pageIndex, int pageSize, string strWhere, string TableName, string Order)
        {
            string wherestr = "";

            if (!string.IsNullOrEmpty(strWhere))
            {
                wherestr = " oaName like '%" + strWhere + "%' and ";
            }
            int           startRow = (pageIndex - 1) * pageSize;
            StringBuilder strSql   = new StringBuilder();

            strSql.Append(" SELECT TOP " + pageSize + " * From (SELECT ROW_NUMBER() OVER (ORDER BY " + Order + " desc) AS RowNumber,* FROM " + TableName + " where " + wherestr + " State =1 ) as A ");
            strSql.Append("WHERE  RowNumber > " + startRow + " ORDER BY RowNumber ASC ");
            using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
            {
                DbRawSqlQuery <T> query = Db.Database.SqlQuery <T>(strSql.ToString());
                return(query.ToList());
            }
        }