Example #1
0
        public ActionResult AddOrEdit(int?id)
        {
            var channellist = _syschannelService.LoadAllEnable();

            var list = channellist.Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            });

            ViewBag.ChannelList = list.ToList <SelectListItem>();
            //ViewBag.ChannelList = list.Select(x => new SelectListItem { Text=x.Name,Value=x.Id.ToString() });
            SysCategory entity = null;

            ViewBag.Title = "添加分类";
            if (id.HasValue)
            {
                entity        = _syscategoryService.Get(id.Value);
                ViewBag.Title = "修改分类";
            }
            entity = entity ?? new SysCategory
            {
                Name = string.Empty,
            };
            ViewBag.CategoryType = ExSelectListItem.ToSelectListItem(typeof(CategoryType));
            return(View(entity));
        }
Example #2
0
        /// <summary>
        /// 添加站点类别
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddSysCateGory(SysCategory model)
        {
            string sqlname = ""; string sqlvalue = "";

            if (model.ID != null && model.ID != "")
            {
                sqlname += "ID,"; sqlvalue += "'" + model.ID + "',";
            }
            if (model.SiteName != null && model.SiteName != "")
            {
                sqlname += "SiteName,"; sqlvalue += "'" + model.SiteName + "',";
            }
            if (model.SiteDesc != null && model.SiteDesc != "")
            {
                sqlname += "SiteDesc,"; sqlvalue += "'" + model.SiteDesc + "',";
            }
            if (model.SiteOrder > -1)
            {
                sqlname += "SiteOrder,"; sqlvalue += model.SiteOrder + ",";
            }
            sqlname += "IsDel"; sqlvalue += (model.IsDel?0:1);
            sqlname  = "insert into Sys_Category(" + sqlname + ") values(" + sqlvalue + ")";
            int rowsAffected = DbHelperSQL.ExecuteSql(sqlname.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// 更新站点类别
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateSysCateGory(SysCategory model)
        {
            string safesql = " update Sys_Category set ";

            if (model.SiteName != null && model.SiteName != "")
            {
                safesql += " SiteName='" + model.SiteName + "',";
            }
            if (model.SiteDesc != null && model.SiteDesc != "")
            {
                safesql += " SiteDesc='" + model.SiteDesc + "',";
            }
            if (model.SiteOrder > 0)
            {
                safesql += " SiteOrder=" + model.SiteOrder + ",";
            }
            safesql += " IsDel=" + (model.IsDel ? 0 : 1) + " where id='" + model.ID + "'";
            int rowsAffected = DbHelperSQL.ExecuteSql(safesql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool InsertCategory(CategoryModel model)
        {
            try
            {
                if (model == null)
                {
                    return(false);
                }

                using (var db = new PORTALEntities())
                {
                    var item = new SysCategory
                    {
                        ID         = model.ID,
                        Name       = model.Name,
                        Remark     = model.Remark,
                        CreateDate = model.CreateDate,
                        CreateUid  = model.CreateUID
                    };

                    db.SysCategories.Add(item);
                    db.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("CategoryRepository Insert Category: " + ex.Message + " Inner exception: " + ex.InnerException.Message);
                return(false);
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (SiteName.Text.Trim() != null && SiteName.Text.Trim() != "")
     {
         SysCategory    model = new SysCategory();
         SysCategoryDAL dal   = new SysCategoryDAL();
         model.SiteName = SiteName.Text;
         model.ID       = Guid.NewGuid().ToString("N").ToUpper();
         model.IsDel    = isstateyes.Checked ? true : false;
         model.SiteDesc = hd_SiteDesc.Value;
         if (txtOrder.Text.Trim() != null && txtOrder.Text.Trim() != "")
         {
             model.SiteOrder = Convert.ToInt32(txtOrder.Text);
         }
         else
         {
             model.SiteOrder = 1;
         }
         if (dal.AddSysCateGory(model))
         {
             MessageBox.Show(this, "操作成功!");
         }
         else
         {
             MessageBox.Show(this, "操作失败!");
         }
     }
     else
     {
         MessageBox.Show(this, "名称不能为空!");
         return;
     }
 }
Example #6
0
        public bool HasSysCategory(SysCategory permission)
        {
            var sysIDs = string.Join("", Role.SysCateIDs).Split(',');

            if (sysIDs.Contains(((int)SysCategory.ALL).ToString()))
            {
                return(true);
            }
            return(SysCateIDs != null && sysIDs.Any(p => p == ((int)(permission)).ToString()));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (null != Common.Common.NoHtml(Request.QueryString["action"]))
            {
                strAction = Common.Common.NoHtml(Request.QueryString["action"]);
            }
            if (null != Common.Common.NoHtml(Request.QueryString["id"]))
            {
                strID = Common.Common.NoHtml(Request.QueryString["id"]);
            }

            SysCategoryDAL dal     = new SysCategoryDAL();
            int            statein = 0;

            try
            {
                statein = Convert.ToInt32(dal.GetSysCategoryByValue("IsDel", strID));
            }
            catch (Exception)
            {
                statein = 0;
            }
            switch (statein)
            {
            case 0:
                statein = 1;
                break;

            default:
                statein = 0;
                break;
            }
            SysCategory model = new SysCategory();

            model.ID    = strID;
            model.IsDel = (statein == 0?true:false);
            switch (strAction)
            {
            case "del":
                if (dal.UpdateSysCateGory(model))
                {
                    strMessage = "操作成功!";
                }
                else
                {
                    strMessage = "操作失败!";
                }
                break;

            default:
                break;
            }
            Response.Write(strMessage);
            Response.End();
        }
Example #8
0
        const string dateFileFormat      = "yyyyMMdd_";               //文件名中日期字段的格式

        //在进行日志系统注册之后,可使用该方法获系统编号
        public static SysCategory GetSystemID()
        {
            try
            {
                SysCategory sysID = (SysCategory)dataCache.GetCache(AppConfig.GetCacheKey(CacheConst.systemName));
                return(sysID);
            }
            catch
            {
                return(SysCategory.NoDefined);
            }
        }
Example #9
0
        public ActionResult Save(SysCategory entity, int?channelId)
        {
            if (ModelState.IsValid)
            {
                var forum = _syschannelService.Get(channelId.Value);
                if (forum == null)
                {
                    return(Json(new CommonResult
                    {
                        Success = false,
                        Message = "未选择频道,保存失败!"
                    }, "text/html", JsonRequestBehavior.AllowGet));
                }
                if (entity.Id == 0)
                {
                    if (_syscategoryService.IsExist(entity.Name.Trim()))
                    {
                        return(Json(new CommonResult
                        {
                            Success = false,
                            Message = "分类名称已经存在,请重新输入!"
                        }, "text/html", JsonRequestBehavior.AllowGet));
                    }
                    entity.Channel = forum;
                    base._syscategoryService.Save(entity);
                }
                else
                {
                    var model = base._syscategoryService.Get(entity.Id);
                    model.Name         = entity.Name;
                    model.OrderNo      = entity.OrderNo;
                    model.IsEnabled    = entity.IsEnabled;
                    model.CategoryType = entity.CategoryType;
                    model.Content      = entity.Content;
                    model.Url          = entity.Url;
                    entity.Channel     = forum;
                    base._syscategoryService.Update(model);
                }

                return(Json(new CommonResult {
                    Success = true, Message = "保存成功"
                }, "text/html", JsonRequestBehavior.AllowGet));
            }
            return(RedirectToAction("AddOrEdit", entity));
        }
Example #10
0
        public void ShowActivityInfo(string strID)
        {
            SysCategoryDAL dal   = new SysCategoryDAL();
            DataSet        ds    = dal.GetSysCateGoryDetail(strID);
            SysCategory    model = DataConvert.DataRowToModel <SysCategory>(ds.Tables[0].Rows[0]);

            SiteName.Text     = model.SiteName;
            hd_SiteDesc.Value = model.SiteDesc;
            txtOrder.Text     = model.SiteOrder.ToString();
            if (model.IsDel == true)
            {
                isstateyes.Checked = true;
            }
            else
            {
                isstateno.Checked = true;
            }
            if (strAction == "show")
            {
                this.btnReset.Visible = false;
                this.btnSave.Visible  = false;
            }
        }
Example #11
0
        /// <summary>
        /// 注册日志组件到本系统,为日志组件准备基础信息:服务器IP、服务器主机名,系统名称等
        /// </summary>
        /// <param name="sys">业务系统类型</param>
        /// <param name="application">应用程序的Application对象</param>
        /// <param name="bWriteStartLog">是否是启动日志</param>
        /// <param name="bLogMonitor">是否写定时监控日志</param>
        public static void RegisterLogInitMsg(SysCategory sys, object applicationObj = null, UserCfg userConfig = null, Dictionary <SysCategory, string> webAppName = null, bool bWriteStartLog = true, bool bLogMonitor = true)
        {
            webAppNames = webAppName ?? new Dictionary <SysCategory, string>();
            new HttpCacheHelper().SetCache(AppConfig.GetCacheKey(CacheConst.userCfgInCode), userConfig, expireType: Expire.Month);
            userCfg   = GetUserConfigItem();
            userCfg   = userCfg ?? new UserCfg();
            dataCache = CacheFac.CacheFactory();
            appender  = AppenderFac.AppenderFactory();

            logLevelCfg = AppConfig.GetFinalConfig("log2NetLevel", LogLevel.Debug, GetLog2NetLevel());
            if (logLevelCfg == LogLevel.Off)
            {
                return;
            }

            // AutoMapperConfig.Configure();//注册AutoMapper
#if NET
            bRegister = true;
            ApplicationVisitCount.ApplicationObj = applicationObj;
#endif

            //var machineName = System.Web.HttpContext.Current.Server.MachineName;//服务器计算机名
            var    machineName = Environment.MachineName;//服务器计算机名
            var    server      = ClientServerInfo.ClientInfo.GetIPAccordingHost(machineName);
            string serverIP    = server.IP;
            dataCache.SetCache(AppConfig.GetCacheKey(CacheConst.serverIP), serverIP, expireType: Expire.Month);
            dataCache.SetCache(AppConfig.GetCacheKey(CacheConst.serverHost), machineName, expireType: Expire.Month);
            dataCache.SetCache(AppConfig.GetCacheKey(CacheConst.systemName), sys, expireType: Expire.Month);

            #region 使用EF自动创建数据库
            try
            {
                var initTraceDBWhenOracle = AppConfig.GetFinalConfig("initTraceDBWhenOracle", false, LogApi.IsInitTraceDBWhenOracle());
                //     initTraceDBWhenOracle = "1";
                var traceDBType = ComDBFun.GetDBGeneralInfo(DBType.LogTrace).DataBaseType;
                if (traceDBType != DataBaseType.Oracle || (traceDBType == DataBaseType.Oracle && initTraceDBWhenOracle))
                {
                    using (var context = new Log_OperateTraceContext())  //oracle 不建议使用EF,会导致字段名和数据库名必须加引号
                    {
#if NET
                        context.Database.Initialize(true); //EF6
#else
                        context.Database.EnsureCreated();  //EFCore
#endif
                    }
                }

                var initMonitorDBWhenOracle = AppConfig.GetFinalConfig("initMonitorDBWhenOracle", false, LogApi.IsInitMonitorDBWhenOracle());
                //    initMonitorDBWhenOracle = "1";
                var monitorDBType = ComDBFun.GetDBGeneralInfo(DBType.LogMonitor).DataBaseType;
                if (monitorDBType != DataBaseType.Oracle || (monitorDBType == DataBaseType.Oracle && initMonitorDBWhenOracle))
                {
                    using (var context = new Log_SystemMonitorContext())
                    {
#if NET
                        context.Database.Initialize(true); //EF6
#else
                        context.Database.EnsureCreated();  //EFCore
#endif
                    }
                }
            }
            catch (Exception ex)
            {
                WriteExceptToFile(ex);
            }
            #endregion 使用EF自动创建数据库

            if (bWriteStartLog)
            {
                WriteServerStartupLog();//系统启动的日志
            }

            StartThreadToWriteFileToAppender();  //开启线程,将备份日志写到Appender中

            //在线人数和访客人数的初始化
            VisitOnline.VisitCountFactory.GetInstance().SetVisitNumWhenInit();
            if (bLogMonitor)
            {
                WriteMonitorLogThread();
            }
        }