Exemple #1
0
        public UserOnlineInfo MyUser; //= UserManage.UserInfo;

        #region 初始化 在OnInit执行
        /// <summary>
        /// 设置当前登录人的信息
        /// 设置元数据的数据库的实例
        /// </summary>
        /// <param name="e"></param>
        protected override void OnInit(EventArgs e)
        {
            var debugInfo = new NatureDebugInfo {
                Title = "[Nature.Service.Ashx.BaseAshx]判断Url参数"
            };

            base.OnInit(e);

            //验证是否已经登录
            //如果已经登录了,加载登录人员的信息,
            var manageUser = new ManageUser {
                Dal = Dal
            };

            UserWebappInfo userWebappInfo = AppManage.UserWebappInfoByCookies(debugInfo.DetailList);

            if (userWebappInfo.State != UserState.NormalAccess)
            {
                //没有登录。
                Response.Write("您还没有登录,请到<a href='/default.aspx' target='_top'>这里</a>登录");
                Response.End();
            }

            MyUser = manageUser.CreateUser(Convert.ToString(userWebappInfo.UserWebappID), null);

            //保存访问日志
            //SaveViewLog();
        }
        /// <summary>
        /// 保存数据。如果保存成功则返回空字符串,如果不成功,返回说明信息。
        /// 如果是添加数据,成功的话,可以使用 DataID 获得新纪录的主键值(限于SQL数据库、自增ID)
        /// </summary>
        /// <returns></returns>
        public string SaveData(ManagerLogOperate operateLog, ManagerLogDataChange managerLogDataChange)
        {
            var debugInfo = new NatureDebugInfo {
                Title = "webform的保存数据"
            };

            //提取用户输入的信息,检查信息是否安全
            string msg = GetInputValue();

            if (msg.Length != 0)
            {
                //输入的信息格式不正确,不能继续
                return("<BR>填写的信息格式不正确<BR>" + msg);
            }

            ManagerData.DataID = DataID;

            ManagerData.DictFormColumnMeta = DicBaseCols;
            ManagerData.DictColumnsValue   = DicColumnsValue;
            ManagerData.TypeOperationData  = OpenButonType;

            ManagerData.ManagerLogDataChange = managerLogDataChange;

            string err = ManagerData.SaveData(operateLog, debugInfo.DetailList);

            return(err);
        }
        private void BindTree()
        {
            var debugInfo = new NatureDebugInfo { Title = "[NatureFramework.SupportingPlatform.BindTree] " };
 
            var mgrModule = new ManagerModule {DalCollection = Dal};


            //判断权限
            string query = "ModuleLevel <=2 ";

            
            if (MyUser.BaseUser.PersonID != "1")
            {
                string moduleIDs = MyUser.UserPermission.ModuleIDs;
                query += " and ModuleID in (" + moduleIDs + ") ";
            }

            mgrModule.Query = query;

            LstTree = mgrModule.GetMetaData(debugInfo.DetailList);

            Key = new int[LstTree.Count];

            
            int i = 0;
            foreach (KeyValuePair<int, IColumn> info in LstTree)
            {
                Key[i++] = info.Key;
            }
            debugInfo.Stop();
             

        }
        private void TreeMeta()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "获取树的元数据"
            };

            BaseDebug.DetailList.Add(debugInfo);
            debugInfo.Remark = "";


            //返回模块ID的json
            const string sql = @"SELECT   ModuleID, ParentID, ParentIDAll, ModuleName, ModuleLevel, IconID, URL, Target, IsLeaf, GridPageViewID, FindPageViewID, IsHidden, IsLock, DisOrder
                            FROM    Manage_Module
                            WHERE   ModuleLevel in (1,2)  {0} 
                            Order by disOrder";

            string query = "";  //查询条件

            string projectID = Request.QueryString["ProjectID"];

            if (!string.IsNullOrEmpty(projectID))
            {
                if (!Functions.IsIDString(projectID))
                {
                    Response.Write("projectID参数不正确!" + projectID);
                    debugInfo.Remark += "<br/>projectID参数不正确!" + projectID;
                    return;
                }
                //加上项目的查询条件
                query = " and ProjectID in (" + projectID + ")";
            }

            //判断权限
            string roleModuleID = MyUser.UserPermission.ModuleIDs;

            if (MyUser.BaseUser.PersonID == "1")
            {
                //管理员
                debugInfo.Remark += "<br/>管理员";
            }
            else
            {
                //不是管理员,加上权限限制
                query            += " and ModuleID in (" + roleModuleID + ")";
                debugInfo.Remark += "<br/>不是管理员," + query;
            }

            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColName(string.Format(sql, query));

            Response.Write(data);

            debugInfo.Stop();
        }
Exemple #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string userCode = txtUserCode.Value; // Request.Form["userCode"];
            string userPsw  = txtUserPsw.Value;

            //实现登录

            userCode = userCode.Replace("'", "''");
            userPsw  = Functions.ToMD5(userPsw);

            var dal = CommonClass.SetMetadataDal();

            const string sql = "SELECT TOP 1 userID from Person_User_Info where UserCode='{0}' and LoginPsw ='{1}'";

            string userId = dal.DalUser.ExecuteString(string.Format(sql, userCode, userPsw));

            if (dal.DalUser.ErrorMessage.Length > 2)
            {
                //debugInfo.Remark = "到数据库验证登录账户和密码,出现异常!";
                Response.Write("<br>" + dal.DalUser.ErrorMessage);
            }

            if (dal.DalUser.ErrorMessage.Length > 2)
            {
                //debugInfo.Remark = "到数据库验证登录账户和密码,出现异常!";
                Response.Write("\"msg\":\"" + dal.DalUser.ErrorMessage + "\"");
                return;
            }

            if (string.IsNullOrEmpty(userId))
            {
                Response.Write("\"msg\":\"用户名和密码不匹配!\"");
                return;
            }

            Response.Write("<br>" + userId);

            var mUser = new ManageUser {
                Dal = dal
            };

            var debugInfo2 = new NatureDebugInfo {
                Title = "判断访问权限"
            };

            UserOnlineInfo user = mUser.CreateUser(userId, debugInfo2.DetailList);

            Response.Write("<br>" + user.BaseUser.UserID);
            Functions.PageRegisterJavascript(Page, "isLogin();");
        }
        private void TreeMeta()
        {
            var debugInfo = new NatureDebugInfo { Title = "获取树的元数据" };
            BaseDebug.DetailList.Add(debugInfo);
            debugInfo.Remark = "";
                    

            //返回模块ID的json
            const string sql = @"SELECT   ModuleID, ParentID, ParentIDAll, ModuleName, ModuleLevel, IconID, URL, Target, IsLeaf, GridPageViewID, FindPageViewID, IsHidden, IsLock, DisOrder
                            FROM    Manage_Module
                            WHERE   ModuleLevel in (1,2)  {0} 
                            Order by disOrder";

            string query = "";  //查询条件

            string projectID = Request.QueryString["ProjectID"];
            if (!string.IsNullOrEmpty(projectID))
            {
                if (!Functions.IsIDString(projectID))
                {
                    Response.Write("projectID参数不正确!" + projectID);
                    debugInfo.Remark += "<br/>projectID参数不正确!" + projectID;
                    return;
                }
                //加上项目的查询条件
                query = " and ProjectID in (" + projectID + ")";
            }

            //判断权限
            string roleModuleID = MyUser.UserPermission.ModuleIDs;
            if ( MyUser.BaseUser.PersonID == "1")
            {
                //管理员
                debugInfo.Remark += "<br/>管理员";
            }
            else
            {
                //不是管理员,加上权限限制
                query += " and ModuleID in (" + roleModuleID + ")";
                debugInfo.Remark += "<br/>不是管理员," + query;
            }

            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColName(string.Format(sql, query));

            Response.Write(data);

            debugInfo.Stop();
          
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string userCode = txtUserCode.Value; // Request.Form["userCode"];
            string userPsw = txtUserPsw.Value;

            //实现登录

            userCode = userCode.Replace("'", "''");
            userPsw = Functions.ToMD5(userPsw);

            var dal = CommonClass.SetMetadataDal();

            const string sql = "SELECT TOP 1 userID from Person_User_Info where UserCode='{0}' and LoginPsw ='{1}'";

            string userId = dal.DalUser.ExecuteString(string.Format(sql, userCode, userPsw));
            if (dal.DalUser.ErrorMessage.Length > 2)
            {
                //debugInfo.Remark = "到数据库验证登录账户和密码,出现异常!";
                Response.Write("<br>" + dal.DalUser.ErrorMessage);
            }

            if (dal.DalUser.ErrorMessage.Length > 2)
            {
                //debugInfo.Remark = "到数据库验证登录账户和密码,出现异常!";
                Response.Write("\"msg\":\"" + dal.DalUser.ErrorMessage + "\"");
                return;
            }

            if (string.IsNullOrEmpty(userId))
            {
                Response.Write("\"msg\":\"用户名和密码不匹配!\"");
                return;
            }

            Response.Write("<br>" + userId);

            var mUser = new ManageUser {Dal = dal};

            var debugInfo2 = new NatureDebugInfo {Title = "判断访问权限"};

            UserOnlineInfo user = mUser.CreateUser(userId, debugInfo2.DetailList);

            Response.Write("<br>" + user.BaseUser.UserID);
            Functions.PageRegisterJavascript(Page,"isLogin();");


        }
        private void ButtonMeta()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "获取操作按钮的元数据"
            };

            //返回模块ID的json
            string sql =
                @"SELECT    ButtonID, ModuleID, OpenModuleID, OpenPageViewID, FindPageViewID, BtnTitle, BtnTypeID, BtnKind, URL, WebWidth, WebHeight, IsNeedSelect
                            FROM      Manage_ButtonBar
                            WHERE     (ModuleID = {0})
                            ORDER BY DisOrder";


            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(string.Format(sql, ModuleID));
            var    sb   = new StringBuilder(data.Length + 500);

            if (MyUser.BaseUser.PersonID == "1")
            {
                //超级管理员,可以访问全部的按钮
                sb.Append("\"buttonRole\":\"admin\",");
                debugInfo.Remark = "管理员";
            }
            else
            {
                //获取可以操作的按钮
                //sql = "SELECT TOP 1 ButtonIDs FROM Role_RoleButtonPV WHERE RoleID in ({0}) AND ModuleID = {1}";
                //string buttonIDs = "";      //当前用户可以访问的按钮ID集合
                //buttonIDs = Dal.DalMetadata.ExecuteString(string.Format(sql, MyUser.UserPermission.RoleIDs, ModuleID));

                string buttonIDs = MyUser.UserPermission.GetUserButtonID(ModuleID, Dal.DalMetadata);

                sb.Append("\"buttonRole\":[");
                sb.Append(buttonIDs);
                sb.Append("], ");
                debugInfo.Remark = "不是管理员," + buttonIDs + "。";
            }

            sb.Append(data);

            Response.Write(sb.ToString());

            debugInfo.Stop();
            BaseDebug.DetailList.Add(debugInfo);
        }
        //日志显示部分
        #region 获取表里的字段
        private void TableColumnMeta()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "[Nature.Service.MetaData.GetMeta.TableColumnMeta]获取表里的字段"
            };

            BaseDebug.DetailList.Add(debugInfo);

            //获取页面视图元数据
            //GetPageViewMeta(MasterPageViewID, debugInfo.DetailList);

            var managerTableColumnMeta = new ManagerTableColumnMeta
            {
                DalCollection = Dal,
                PageViewID    = ModuleID //这里ModuleID传递过来的是表id
            };

            var sb = new StringBuilder(3000);

            sb.Append("\"colMeta\":{ ");

            Dictionary <int, IColumn> dictFormColumnMeta = managerTableColumnMeta.GetMetaData(debugInfo.DetailList);

            //遍历元数据,给dic_ColumnsValue赋值——字段值
            foreach (KeyValuePair <int, IColumn> info in dictFormColumnMeta)
            {
                var colMeta = (ColumnMeta)info.Value;
                if (colMeta.ColumnKind != 15)
                {
                    sb.Append("\"");
                    sb.Append(colMeta.ColumnID);
                    sb.Append("\":\"");
                    sb.Append(colMeta.ColName);
                    sb.Append("\",");
                }
            }


            sb[sb.Length - 1] = '}';

            Response.Write(sb.ToString());

            debugInfo.Stop();
        }
        private void GridMeta()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "获取列表元数据"
            };

            //返回模块ID的json
            //            string sql = @"SELECT ColumnID, CASE ColTitle WHEN '' THEN ColName ELSE ColTitle END AS ColTitle, ColHelp, HelpStation, ColWidth, ColAlign, Kind, IsSort, Format, MaxLength
            //                            FROM    V_Frame_List_DataGridListCol
            //                            WHERE   (PVID = {0})
            //                            ORDER BY DisOrder";

            const string sql = @"SELECT ColumnID, ColTitle, ColName , ColHelp, HelpStation, ColWidth, ColAlign, Kind, IsSort, Format, MaxLength
                            FROM    V_Frame_List_DataGridListCol
                            WHERE   (PVID = {0})
                            ORDER BY DisOrder";

            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(string.Format(sql, MasterPageViewID));

            var sb = new StringBuilder(data.Length + 300);

            //设置锁定行列的字段
            #region 获取页面视图元数据
            GetPageViewMeta(MasterPageViewID, debugInfo.DetailList);

            #endregion

            sb.Append("\"LockColumns\":" + PageViewMeta.LockColumns + "");
            sb.Append(",\"LockRows\":" + PageViewMeta.LockRows + "");
            sb.Append(",\"TableWidth\":" + PageViewMeta.TableWidth + " ");
            sb.Append(",\"ViewExtend\":\"" + PageViewMeta.ViewExtend + "\" ");

            //设置可以访问的字段
            SetCanUseCol(sb, MasterPageViewID);

            sb.Append(data);

            Response.Write(sb.ToString());

            debugInfo.Stop();
            BaseDebug.DetailList.Add(debugInfo);
        }
        private void FormMeta()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "获取表单元数据"
            };

            //获取页面视图元数据
            GetPageViewMeta(MasterPageViewID, debugInfo.DetailList);

            const string sql = @"SELECT  ColumnID, ColTitle , ColName , ColHelp, HelpStation,
                                DefaultValue, ControlState, ControlTypeID,IsClear,ClearTDStart,ClearTDEnd,TDColspan,CheckTypeID,CheckUserDefined,CheckTip
                            FROM   V_Frame_List_BaseFormCol
                            WHERE  (PVID = {0})
                            ORDER BY DisOrder";

            Dal.DalMetadata.ManagerJson.JsonName = "controlInfo";
            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(string.Format(sql, MasterPageViewID));

            var sb = new StringBuilder(data.Length + 3000);

            sb.Append(data);

            GetControlExtend(sb, true, MasterPageViewID);

            //设置可以访问的字段
            SetCanUseCol(sb, MasterPageViewID);

            const string sql2      = @"SELECT  BtnTypeID FROM Manage_ButtonBar WHERE (ButtonID = {0})";
            var          butonType = (ButonType)Dal.DalMetadata.ExecuteScalar <int>(string.Format(sql2, ButtonID));

            sb.Append("\"type\":" + (int)butonType);

            sb.Append(",\"ViewExtend\":\"" + PageViewMeta.ViewExtend + "\"");
            sb.Append(",\"isLoadCustomerJs\":\"" + PageViewMeta.LockRows + "\"");
            sb.Append(",\"columnCount\":" + PageViewMeta.ColumnCount);

            Response.Write(sb.ToString());

            debugInfo.Stop();
            BaseDebug.DetailList.Add(debugInfo);
        }
Exemple #12
0
        /// <summary>
        /// 输出debug子步骤信息
        /// </summary>
        private void DebugDetail(StringBuilder sb, NatureDebugInfo info)
        {
            if (info == null)
            {
                //没有详细步骤
                return;
            }

            //输出详细步骤
            sb.Append("\"Title\":\""); sb.Append(info.Title);
            sb.Append("\", \"UseTime\":\""); sb.Append(info.UseTime);
            sb.Append("\", \"Remark\":\""); sb.Append(info.Remark);
            sb.Append("\", \"Detail\": ");

            if (info.DetailList == null || info.DetailList.Count == 0)
            {
                //没有详细步骤
                sb.Append("[] ");
                return;
            }

            sb.Append("[");
            //输出详细步骤
            foreach (var dic in info.DetailList)
            {
                sb.Append("{ "); DebugDetail(sb, dic); sb.Append("},");
            }

            if (sb[sb.Length - 1] == ',')
            {
                sb[sb.Length - 1] = ']';
            }
            else
            {
                sb.Append("] ");
            }
        }
Exemple #13
0
        private void BindTree()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "[NatureFramework.SupportingPlatform.BindTree] "
            };

            var mgrModule = new ManagerModule {
                DalCollection = Dal
            };


            //判断权限
            string query = "ModuleLevel <=2 ";


            if (MyUser.BaseUser.PersonID != "1")
            {
                string moduleIDs = MyUser.UserPermission.ModuleIDs;
                query += " and ModuleID in (" + moduleIDs + ") ";
            }

            mgrModule.Query = query;

            LstTree = mgrModule.GetMetaData(debugInfo.DetailList);

            Key = new int[LstTree.Count];


            int i = 0;

            foreach (KeyValuePair <int, IColumn> info in LstTree)
            {
                Key[i++] = info.Key;
            }
            debugInfo.Stop();
        }
        private void FindMeta()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "获取查询元数据"
            };

            //获取页面视图元数据
            GetPageViewMeta(FindPageViewID, debugInfo.DetailList);

            int colCount = PageViewMeta.ColumnCount;

            const string sql = @"SELECT  ColumnID, ColTitle , ColName , ColHelp, HelpStation, DefaultValue, ControlState, 
                                   Ser_FindKindID, ControlTypeID, ControlInfo,ClearTDStart,ClearTDEnd,TDColspan
                            FROM   V_Frame_List_BaseFormCol
                            WHERE  (PVID = {0})
                            ORDER BY DisOrder";

            Dal.DalMetadata.ManagerJson.JsonName = "controlInfo";
            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(string.Format(sql, FindPageViewID));

            var sb = new StringBuilder(data.Length + 3000);

            sb.Append("\"columnCount\":" + colCount);
            //设置可以访问的字段
            SetCanUseCol(sb, FindPageViewID);
            //输出数据
            sb.Append(data);

            //处理ControlExtend
            GetControlExtend(sb, false, FindPageViewID);

            Response.Write(sb.ToString());

            debugInfo.Stop();
            BaseDebug.DetailList.Add(debugInfo);
        }
        private void ModuleViewButtonMeta()
        {
            var debugInfo = new NatureDebugInfo { Title = "[Nature.Service.MetaData.GetMeta.ModuleViewButtonMeta]获取模块、视图、按钮的名称" };
            BaseDebug.DetailList.Add(debugInfo);

            #region 定义sql
            var debugInfo2 = new NatureDebugInfo { Title = "定义sql" };
          
            const string sqlModule = "SELECT ModuleID, ModuleName, ParentIDAll FROM Manage_Module ORDER BY DisOrder";
            const string sqlPageView = "SELECT PVID, PVTitle,ModuleID,PVTypeID FROM Manage_PageView ORDER BY PVID";
            const string sqlButton = "SELECT ButtonID, BtnTitle,ModuleID FROM Manage_ButtonBar ORDER BY ButtonID";
            const string sqlTable = "SELECT TableID, TableName, [Content] FROM Manage_Table ORDER BY TableID";
            debugInfo2.Stop();
            #endregion

            #region new StringBuilder(10000)
            debugInfo2 = new NatureDebugInfo { Title = "new StringBuilder(10000)" };
            debugInfo.DetailList.Add(debugInfo2);
            var sb = new StringBuilder(10000);
            debugInfo2.Stop();
            #endregion

            #region 获取Module
            debugInfo2 = new NatureDebugInfo { Title = "获取Module" };
            debugInfo.DetailList.Add(debugInfo2);

            Dal.DalMetadata.ManagerJson.JsonName = "Module";
            string json = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(sqlModule);
            sb.Append(json);
            sb.Append(",");
            debugInfo2.Stop();
             #endregion

            #region 获取PageView
            debugInfo2 = new NatureDebugInfo { Title = "获取PageView" };
            debugInfo.DetailList.Add(debugInfo2);

            Dal.DalMetadata.ManagerJson.JsonName = "PageView";
            json = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(sqlPageView);
            sb.Append(json);
            sb.Append(",");
            debugInfo2.Stop();
            #endregion

            #region 获取Button
            debugInfo2 = new NatureDebugInfo { Title = "获取Button" };
            debugInfo.DetailList.Add(debugInfo2);
            Dal.DalMetadata.ManagerJson.JsonName = "Button";
            json = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(sqlButton);
            sb.Append(json);
            sb.Append(",");
            debugInfo2.Stop();
            #endregion

            #region 获取Table
            debugInfo2 = new NatureDebugInfo { Title = "获取Table" };
            debugInfo.DetailList.Add(debugInfo2);
            Dal.DalMetadata.ManagerJson.JsonName = "Table";
            json = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(sqlTable);
            sb.Append(json);

            debugInfo2.Stop();
            #endregion

            #region Response.Write
            debugInfo2 = new NatureDebugInfo { Title = "Response.Write" };
            debugInfo.DetailList.Add(debugInfo2);

            Response.Write(sb.ToString());
            debugInfo2.Stop();
            #endregion

            debugInfo.Stop();
        }
        //日志显示部分
        #region 获取表里的字段
        private void TableColumnMeta()
        {
            var debugInfo = new NatureDebugInfo { Title = "[Nature.Service.MetaData.GetMeta.TableColumnMeta]获取表里的字段" };
            BaseDebug.DetailList.Add(debugInfo);

            //获取页面视图元数据
            //GetPageViewMeta(MasterPageViewID, debugInfo.DetailList);

            var managerTableColumnMeta = new ManagerTableColumnMeta
            {
                DalCollection = Dal,
                PageViewID = ModuleID //这里ModuleID传递过来的是表id
            };

            var sb = new StringBuilder(3000);
            sb.Append("\"colMeta\":{ ");

            Dictionary<int, IColumn> dictFormColumnMeta = managerTableColumnMeta.GetMetaData(debugInfo.DetailList);

            //遍历元数据,给dic_ColumnsValue赋值——字段值
            foreach (KeyValuePair<int, IColumn> info in dictFormColumnMeta)
            {
                var colMeta = (ColumnMeta)info.Value;
                if (colMeta.ColumnKind != 15)
                {
                    sb.Append("\"");
                    sb.Append(colMeta.ColumnID);
                    sb.Append("\":\"");
                    sb.Append(colMeta.ColName);
                    sb.Append("\",");
                }
            }


            sb[sb.Length - 1] = '}';

            Response.Write(sb.ToString());

            debugInfo.Stop();
           
        }
        private void FormMeta()
        {
            var debugInfo = new NatureDebugInfo { Title = "获取表单元数据" };

            //获取页面视图元数据
            GetPageViewMeta(MasterPageViewID, debugInfo.DetailList);
             
            const string sql = @"SELECT  ColumnID, ColTitle , ColName , ColHelp, HelpStation,
                                DefaultValue, ControlState, ControlTypeID,IsClear,ClearTDStart,ClearTDEnd,TDColspan,CheckTypeID,CheckUserDefined,CheckTip
                            FROM   V_Frame_List_BaseFormCol
                            WHERE  (PVID = {0})
                            ORDER BY DisOrder";

            Dal.DalMetadata.ManagerJson.JsonName = "controlInfo";
            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(string.Format(sql, MasterPageViewID));

            var sb = new StringBuilder(data.Length + 3000);
            sb.Append(data);
           
            GetControlExtend(sb, true, MasterPageViewID);

            //设置可以访问的字段
            SetCanUseCol(sb, MasterPageViewID);
         
            const string sql2 = @"SELECT  BtnTypeID FROM Manage_ButtonBar WHERE (ButtonID = {0})";
            var butonType = (ButonType)Dal.DalMetadata.ExecuteScalar<int>(string.Format(sql2, ButtonID));
            sb.Append("\"type\":" + (int)butonType);

            sb.Append(",\"ViewExtend\":\"" + PageViewMeta.ViewExtend + "\"");
            sb.Append(",\"isLoadCustomerJs\":\"" + PageViewMeta.LockRows + "\"");
            sb.Append(",\"columnCount\":" + PageViewMeta.ColumnCount  );

            Response.Write(sb.ToString());

            debugInfo.Stop();
            BaseDebug.DetailList.Add(debugInfo);
        }
        private void FindMeta()
        {
            var debugInfo = new NatureDebugInfo { Title = "获取查询元数据" };

            //获取页面视图元数据
            GetPageViewMeta(FindPageViewID, debugInfo.DetailList);

            int colCount = PageViewMeta.ColumnCount;
          
            const string sql = @"SELECT  ColumnID, ColTitle , ColName , ColHelp, HelpStation, DefaultValue, ControlState, 
                                   Ser_FindKindID, ControlTypeID, ControlInfo,ClearTDStart,ClearTDEnd,TDColspan
                            FROM   V_Frame_List_BaseFormCol
                            WHERE  (PVID = {0})
                            ORDER BY DisOrder";

            Dal.DalMetadata.ManagerJson.JsonName = "controlInfo";
            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(string.Format(sql, FindPageViewID));
              
            var sb = new StringBuilder(data.Length + 3000);
            sb.Append("\"columnCount\":" + colCount);
            //设置可以访问的字段
            SetCanUseCol(sb, FindPageViewID);
            //输出数据
            sb.Append(data);
         
            //处理ControlExtend
            GetControlExtend(sb, false, FindPageViewID);
              
            Response.Write(sb.ToString());

            debugInfo.Stop();
            BaseDebug.DetailList.Add(debugInfo);

        }
        private void GridMeta()
        {
            var debugInfo = new NatureDebugInfo { Title = "获取列表元数据" };

            //返回模块ID的json
            //            string sql = @"SELECT ColumnID, CASE ColTitle WHEN '' THEN ColName ELSE ColTitle END AS ColTitle, ColHelp, HelpStation, ColWidth, ColAlign, Kind, IsSort, Format, MaxLength
            //                            FROM    V_Frame_List_DataGridListCol
            //                            WHERE   (PVID = {0})
            //                            ORDER BY DisOrder";

            const string sql = @"SELECT ColumnID, ColTitle, ColName , ColHelp, HelpStation, ColWidth, ColAlign, Kind, IsSort, Format, MaxLength
                            FROM    V_Frame_List_DataGridListCol
                            WHERE   (PVID = {0})
                            ORDER BY DisOrder";

            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(string.Format(sql, MasterPageViewID));

            var sb = new StringBuilder(data.Length + 300);
           
            //设置锁定行列的字段
            #region 获取页面视图元数据
            GetPageViewMeta(MasterPageViewID, debugInfo.DetailList);

            #endregion

            sb.Append("\"LockColumns\":" + PageViewMeta.LockColumns + "");
            sb.Append(",\"LockRows\":" + PageViewMeta.LockRows + "");
            sb.Append(",\"TableWidth\":" + PageViewMeta.TableWidth + " ");
            sb.Append(",\"ViewExtend\":\"" + PageViewMeta.ViewExtend + "\" ");

            //设置可以访问的字段
            SetCanUseCol(sb, MasterPageViewID);
         
            sb.Append(data);
         
            Response.Write(sb.ToString());

            debugInfo.Stop();
            BaseDebug.DetailList.Add(debugInfo);

        }
        private void ButtonMeta()
        {
            var debugInfo = new NatureDebugInfo { Title = "获取操作按钮的元数据" };

            //返回模块ID的json
            string sql =
                @"SELECT    ButtonID, ModuleID, OpenModuleID, OpenPageViewID, FindPageViewID, BtnTitle, BtnTypeID, BtnKind, URL, WebWidth, WebHeight, IsNeedSelect
                            FROM      Manage_ButtonBar
                            WHERE     (ModuleID = {0})
                            ORDER BY DisOrder";


            string data = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(string.Format(sql, ModuleID));
            var sb = new StringBuilder(data.Length + 500);
           
            if (MyUser.BaseUser.PersonID == "1")
            {
                //超级管理员,可以访问全部的按钮
                sb.Append("\"buttonRole\":\"admin\",");
                debugInfo.Remark = "管理员";
            }
            else
            {
                //获取可以操作的按钮
                //sql = "SELECT TOP 1 ButtonIDs FROM Role_RoleButtonPV WHERE RoleID in ({0}) AND ModuleID = {1}";
                //string buttonIDs = "";      //当前用户可以访问的按钮ID集合
                //buttonIDs = Dal.DalMetadata.ExecuteString(string.Format(sql, MyUser.UserPermission.RoleIDs, ModuleID));

                string buttonIDs = MyUser.UserPermission.GetUserButtonID(ModuleID, Dal.DalMetadata);
              
                sb.Append("\"buttonRole\":[");
                sb.Append(buttonIDs);
                sb.Append("], ");
                debugInfo.Remark = "不是管理员," + buttonIDs + "。";

            }

            sb.Append(data);
          
            Response.Write(sb.ToString());

            debugInfo.Stop();
            BaseDebug.DetailList.Add(debugInfo);

        }
        /// <summary>
        /// 保存数据。如果保存成功则返回空字符串,如果不成功,返回说明信息。
        /// 如果是添加数据,成功的话,可以使用 DataID 获得新纪录的主键值(限于SQL数据库、自增ID)
        /// </summary>
        /// <returns></returns>
        public string SaveData(ManagerLogOperate operateLog,ManagerLogDataChange managerLogDataChange)
        {
            var debugInfo = new NatureDebugInfo { Title = "webform的保存数据" };
          
            //提取用户输入的信息,检查信息是否安全
            string msg = GetInputValue();

            if (msg.Length != 0)
            {
                //输入的信息格式不正确,不能继续
                return "<BR>填写的信息格式不正确<BR>" + msg;
            }
            
            ManagerData.DataID = DataID;
            
            ManagerData.DictFormColumnMeta = DicBaseCols;
            ManagerData.DictColumnsValue = DicColumnsValue;
            ManagerData.TypeOperationData = OpenButonType;

            ManagerData.ManagerLogDataChange = managerLogDataChange;

            string err = ManagerData.SaveData(operateLog, debugInfo.DetailList);

            return err;

        }
        private void Datagrid()
        {
            //修改排序,交换和插入前、插入后
            string col1ID = Request["col1ID"];
            string col2ID = Request["col2ID"];
            string kind = Request["kind"];

            int col1Order;
            int col2Order;

            var debugInfo = new NatureDebugInfo { Title = "修改排序。" + kind + "_" + col1ID + "_" + col2ID };
            BaseDebug.DetailList.Add(debugInfo);
            
            const string sql =
                @"SELECT  PVColID, DisOrder FROM Manage_PageViewCol WHERE (PVID = {0}) AND  (PVColID  in ({1}) ) ORDER BY DisOrder";

            DataTable dtColOrder =
                Dal.DalCustomer.ExecuteFillDataTable(string.Format(sql, MasterPageViewID, col1ID + "," + col2ID));

            if (dtColOrder.Rows.Count != 2)
                return;

            if (dtColOrder.Rows[0][0].ToString() == col1ID)
            {
                col1Order = int.Parse(dtColOrder.Rows[0][1].ToString());
                col2Order = int.Parse(dtColOrder.Rows[1][1].ToString());
            }
            else
            {
                col1Order = int.Parse(dtColOrder.Rows[1][1].ToString());
                col2Order = int.Parse(dtColOrder.Rows[0][1].ToString());

            }
            const string sqlUpdate ="update Manage_PageViewCol set DisOrder = {0} WHERE  (PVColID = {1} )"; //设置
            //前面c
            const string sqlInsertFront =
                "update Manage_PageViewCol set DisOrder = DisOrder - 10  WHERE (PVID = {0}) AND (DisOrder >= {1} and DisOrder < {2} )";

            //后面c
            const string sqlInsertAfter =
                "update Manage_PageViewCol set DisOrder = DisOrder - 10  WHERE (PVID = {0}) AND (DisOrder > {1} and DisOrder <= {2} )";

            //前面
            const string sqlInsertFront2 =
                "update Manage_PageViewCol set DisOrder = DisOrder + 10  WHERE (PVID = {0}) AND (DisOrder >= {1} and DisOrder <{2} )";

            //后面
            const string sqlInsertAfter2 =
                "update Manage_PageViewCol set DisOrder = DisOrder + 10  WHERE (PVID = {0}) AND (DisOrder > {1} and DisOrder <={2} )";
            
            string sql1;
            string sql2;

            switch (kind)
            {
                case "1": //加在上面      
                case "left": //加在左面      
                    if (col1Order < col2Order)
                    {
                        sql1 = string.Format(sqlInsertFront, MasterPageViewID, col1Order, col2Order);
                        sql2 = string.Format(sqlUpdate, col2Order - 10, col1ID);
                        //后面的插到前面  c
                        Dal.DalCustomer.ExecuteNonQuery(sql1);
                        Dal.DalCustomer.ExecuteNonQuery(sql2);
                        debugInfo.Remark = "left< <br>" + sql1 + "<br>" + sql2;
                    }
                    else if (col1Order > col2Order)
                    {
                        sql1 = string.Format(sqlInsertFront2, MasterPageViewID, col2Order, col1Order);
                        sql2 = string.Format(sqlUpdate, col2Order, col1ID);
                        //前面的查到后面
                        Dal.DalCustomer.ExecuteNonQuery(sql1);
                        Dal.DalCustomer.ExecuteNonQuery(sql2);
                        debugInfo.Remark = "left> <br>" + sql1 + "<br>" + sql2;
                    }
                    break;

                case "3": //加在下面      
                case "right": //加在右面
                    if (col1Order < col2Order)
                    {
                        sql1 = string.Format(sqlInsertAfter, MasterPageViewID, col1Order, col2Order);
                        sql2 = string.Format(sqlUpdate, col2Order , col1ID);
                        //后面的插到前面  r
                        Dal.DalCustomer.ExecuteNonQuery(sql1);
                        Dal.DalCustomer.ExecuteNonQuery(sql2);
                        debugInfo.Remark = "right< <br>" + sql1 + "<br>" + sql2;
                  
                    }
                    else if (col1Order > col2Order)
                    {
                        sql1 = string.Format(sqlInsertAfter2, MasterPageViewID, col2Order, col1Order);
                        sql2 = string.Format(sqlUpdate, col2Order + 10, col1ID);
                        //前面的查到后面 r
                        Dal.DalCustomer.ExecuteNonQuery(sql1);
                        Dal.DalCustomer.ExecuteNonQuery(sql2);
                        debugInfo.Remark = "right> <br>" + sql1 + "<br>" + sql2;
                    }
                    break;

                case "2": //交换位置
                case "exchange": //交换位置
                    sql1 = string.Format(sqlUpdate, col1Order, col2ID);
                    sql2 = string.Format(sqlUpdate, col2Order, col1ID);
                    Dal.DalCustomer.ExecuteNonQuery(sql1);
                    Dal.DalCustomer.ExecuteNonQuery(sql2);
                    debugInfo.Remark = "exchange <br>" + sql1 + "<br>" + sql2;
                  
                    break;

            }

            Response.Write("\"s\":" + kind);

            debugInfo.Stop();
            
        }
        public void LoadData()
        {
            var debugInfo = new NatureDebugInfo { Title = "[Nature.Service.Ashx.BaseAshx]判断Url参数" };

            DalCollection dalCollection = DalCollection;
            dalCollection.DalMetadata = DalCollection.DalCustomer;

            var managerFormMeta = new ManagerFormMeta
                                      {
                                          DalCollection = dalCollection,
                                          PageViewID = int.Parse(PageViewID)
                                      };

            DicFormInfo = managerFormMeta.GetMetaData(debugInfo.DetailList);

            if (DicFormInfo == null)
                return;

            foreach (KeyValuePair<int, IColumn> info in DicFormInfo)
            {
                var bInfo = (ColumnMeta)info.Value;

                //修改类型,把数据库字段类型,变成.net类型
                switch (bInfo.ColType)
                {
                    case "nvarchar":
                    case "varchar":
                    case "nchar":
                    case "char":
                    case "text":
                    case "ntext":
                    case "uniqueidentifier":
                        bInfo.PropertyType = "string";
                        break;

                    case "bigint":
                        bInfo.PropertyType = "Int64";
                        break;
                    case "int":
                        bInfo.PropertyType = "Int32";
                        break;
                    case "smallint":
                    case "tinyint":
                        bInfo.PropertyType = "Int16";
                        break;

                    case "datetime":
                    case "smalldatetime":
                        bInfo.PropertyType = "DateTime";
                        break;

                    case "bit":
                        bInfo.PropertyType = "bool";
                        break;


                    case "money":
                    case "smallmoney":
                        bInfo.PropertyType = "decimal";
                        break;

                    default:
                        bInfo.PropertyType = bInfo.ColType;
                        break;
                    

                }
            }

            debugInfo.Stop();

        }
Exemple #24
0
        private void Datagrid()
        {
            //修改排序,交换和插入前、插入后
            string col1ID = Request["col1ID"];
            string col2ID = Request["col2ID"];
            string kind   = Request["kind"];

            int col1Order;
            int col2Order;

            var debugInfo = new NatureDebugInfo {
                Title = "修改排序。" + kind + "_" + col1ID + "_" + col2ID
            };

            BaseDebug.DetailList.Add(debugInfo);

            const string sql =
                @"SELECT  PVColID, DisOrder FROM Manage_PageViewCol WHERE (PVID = {0}) AND  (PVColID  in ({1}) ) ORDER BY DisOrder";

            DataTable dtColOrder =
                Dal.DalCustomer.ExecuteFillDataTable(string.Format(sql, MasterPageViewID, col1ID + "," + col2ID));

            if (dtColOrder.Rows.Count != 2)
            {
                return;
            }

            if (dtColOrder.Rows[0][0].ToString() == col1ID)
            {
                col1Order = int.Parse(dtColOrder.Rows[0][1].ToString());
                col2Order = int.Parse(dtColOrder.Rows[1][1].ToString());
            }
            else
            {
                col1Order = int.Parse(dtColOrder.Rows[1][1].ToString());
                col2Order = int.Parse(dtColOrder.Rows[0][1].ToString());
            }
            const string sqlUpdate = "update Manage_PageViewCol set DisOrder = {0} WHERE  (PVColID = {1} )"; //设置
            //前面c
            const string sqlInsertFront =
                "update Manage_PageViewCol set DisOrder = DisOrder - 10  WHERE (PVID = {0}) AND (DisOrder >= {1} and DisOrder < {2} )";

            //后面c
            const string sqlInsertAfter =
                "update Manage_PageViewCol set DisOrder = DisOrder - 10  WHERE (PVID = {0}) AND (DisOrder > {1} and DisOrder <= {2} )";

            //前面
            const string sqlInsertFront2 =
                "update Manage_PageViewCol set DisOrder = DisOrder + 10  WHERE (PVID = {0}) AND (DisOrder >= {1} and DisOrder <{2} )";

            //后面
            const string sqlInsertAfter2 =
                "update Manage_PageViewCol set DisOrder = DisOrder + 10  WHERE (PVID = {0}) AND (DisOrder > {1} and DisOrder <={2} )";

            string sql1;
            string sql2;

            switch (kind)
            {
            case "1":     //加在上面
            case "left":  //加在左面
                if (col1Order < col2Order)
                {
                    sql1 = string.Format(sqlInsertFront, MasterPageViewID, col1Order, col2Order);
                    sql2 = string.Format(sqlUpdate, col2Order - 10, col1ID);
                    //后面的插到前面  c
                    Dal.DalCustomer.ExecuteNonQuery(sql1);
                    Dal.DalCustomer.ExecuteNonQuery(sql2);
                    debugInfo.Remark = "left< <br>" + sql1 + "<br>" + sql2;
                }
                else if (col1Order > col2Order)
                {
                    sql1 = string.Format(sqlInsertFront2, MasterPageViewID, col2Order, col1Order);
                    sql2 = string.Format(sqlUpdate, col2Order, col1ID);
                    //前面的查到后面
                    Dal.DalCustomer.ExecuteNonQuery(sql1);
                    Dal.DalCustomer.ExecuteNonQuery(sql2);
                    debugInfo.Remark = "left> <br>" + sql1 + "<br>" + sql2;
                }
                break;

            case "3":     //加在下面
            case "right": //加在右面
                if (col1Order < col2Order)
                {
                    sql1 = string.Format(sqlInsertAfter, MasterPageViewID, col1Order, col2Order);
                    sql2 = string.Format(sqlUpdate, col2Order, col1ID);
                    //后面的插到前面  r
                    Dal.DalCustomer.ExecuteNonQuery(sql1);
                    Dal.DalCustomer.ExecuteNonQuery(sql2);
                    debugInfo.Remark = "right< <br>" + sql1 + "<br>" + sql2;
                }
                else if (col1Order > col2Order)
                {
                    sql1 = string.Format(sqlInsertAfter2, MasterPageViewID, col2Order, col1Order);
                    sql2 = string.Format(sqlUpdate, col2Order + 10, col1ID);
                    //前面的查到后面 r
                    Dal.DalCustomer.ExecuteNonQuery(sql1);
                    Dal.DalCustomer.ExecuteNonQuery(sql2);
                    debugInfo.Remark = "right> <br>" + sql1 + "<br>" + sql2;
                }
                break;

            case "2":        //交换位置
            case "exchange": //交换位置
                sql1 = string.Format(sqlUpdate, col1Order, col2ID);
                sql2 = string.Format(sqlUpdate, col2Order, col1ID);
                Dal.DalCustomer.ExecuteNonQuery(sql1);
                Dal.DalCustomer.ExecuteNonQuery(sql2);
                debugInfo.Remark = "exchange <br>" + sql1 + "<br>" + sql2;

                break;
            }

            Response.Write("\"s\":" + kind);

            debugInfo.Stop();
        }
Exemple #25
0
        public void LoadData()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "[Nature.Service.Ashx.BaseAshx]判断Url参数"
            };

            DalCollection dalCollection = DalCollection;

            dalCollection.DalMetadata = DalCollection.DalCustomer;

            var managerFormMeta = new ManagerFormMeta
            {
                DalCollection = dalCollection,
                PageViewID    = int.Parse(PageViewID)
            };

            DicFormInfo = managerFormMeta.GetMetaData(debugInfo.DetailList);

            if (DicFormInfo == null)
            {
                return;
            }

            foreach (KeyValuePair <int, IColumn> info in DicFormInfo)
            {
                var bInfo = (ColumnMeta)info.Value;

                //修改类型,把数据库字段类型,变成.net类型
                switch (bInfo.ColType)
                {
                case "nvarchar":
                case "varchar":
                case "nchar":
                case "char":
                case "text":
                case "ntext":
                case "uniqueidentifier":
                    bInfo.PropertyType = "string";
                    break;

                case "bigint":
                    bInfo.PropertyType = "Int64";
                    break;

                case "int":
                    bInfo.PropertyType = "Int32";
                    break;

                case "smallint":
                case "tinyint":
                    bInfo.PropertyType = "Int16";
                    break;

                case "datetime":
                case "smalldatetime":
                    bInfo.PropertyType = "DateTime";
                    break;

                case "bit":
                    bInfo.PropertyType = "bool";
                    break;


                case "money":
                case "smallmoney":
                    bInfo.PropertyType = "decimal";
                    break;

                default:
                    bInfo.PropertyType = bInfo.ColType;
                    break;
                }
            }

            debugInfo.Stop();
        }
        private void ModuleViewButtonMeta()
        {
            var debugInfo = new NatureDebugInfo {
                Title = "[Nature.Service.MetaData.GetMeta.ModuleViewButtonMeta]获取模块、视图、按钮的名称"
            };

            BaseDebug.DetailList.Add(debugInfo);

            #region 定义sql
            var debugInfo2 = new NatureDebugInfo {
                Title = "定义sql"
            };

            const string sqlModule   = "SELECT ModuleID, ModuleName, ParentIDAll FROM Manage_Module ORDER BY DisOrder";
            const string sqlPageView = "SELECT PVID, PVTitle,ModuleID,PVTypeID FROM Manage_PageView ORDER BY PVID";
            const string sqlButton   = "SELECT ButtonID, BtnTitle,ModuleID FROM Manage_ButtonBar ORDER BY ButtonID";
            const string sqlTable    = "SELECT TableID, TableName, [Content] FROM Manage_Table ORDER BY TableID";
            debugInfo2.Stop();
            #endregion

            #region new StringBuilder(10000)
            debugInfo2 = new NatureDebugInfo {
                Title = "new StringBuilder(10000)"
            };
            debugInfo.DetailList.Add(debugInfo2);
            var sb = new StringBuilder(10000);
            debugInfo2.Stop();
            #endregion

            #region 获取Module
            debugInfo2 = new NatureDebugInfo {
                Title = "获取Module"
            };
            debugInfo.DetailList.Add(debugInfo2);

            Dal.DalMetadata.ManagerJson.JsonName = "Module";
            string json = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(sqlModule);
            sb.Append(json);
            sb.Append(",");
            debugInfo2.Stop();
            #endregion

            #region 获取PageView
            debugInfo2 = new NatureDebugInfo {
                Title = "获取PageView"
            };
            debugInfo.DetailList.Add(debugInfo2);

            Dal.DalMetadata.ManagerJson.JsonName = "PageView";
            json = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(sqlPageView);
            sb.Append(json);
            sb.Append(",");
            debugInfo2.Stop();
            #endregion

            #region 获取Button
            debugInfo2 = new NatureDebugInfo {
                Title = "获取Button"
            };
            debugInfo.DetailList.Add(debugInfo2);
            Dal.DalMetadata.ManagerJson.JsonName = "Button";
            json = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(sqlButton);
            sb.Append(json);
            sb.Append(",");
            debugInfo2.Stop();
            #endregion

            #region 获取Table
            debugInfo2 = new NatureDebugInfo {
                Title = "获取Table"
            };
            debugInfo.DetailList.Add(debugInfo2);
            Dal.DalMetadata.ManagerJson.JsonName = "Table";
            json = Dal.DalMetadata.ManagerJson.ExecuteFillJsonByColNameKey(sqlTable);
            sb.Append(json);

            debugInfo2.Stop();
            #endregion

            #region Response.Write
            debugInfo2 = new NatureDebugInfo {
                Title = "Response.Write"
            };
            debugInfo.DetailList.Add(debugInfo2);

            Response.Write(sb.ToString());
            debugInfo2.Stop();
            #endregion

            debugInfo.Stop();
        }