Exemplo n.º 1
0
        /// <summary>
        /// 根据Entity的编号获取MDM中Entity的所有数据
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet dsRequest = new DataSet();

                string strMainEntity = "";
                strMainEntity = m_request.Tables[0].Rows[0]["Entity"].ToString();


                int nPage = 1;
                int nPageRowCount = 20;
                string strOrder = " desc  ";
                string strSort = " body_id ";
                string strWhere = " ";

                if (m_request != null && m_request.Tables.Contains("Page_Info"))
                {
                    nPage = Convert.ToInt32(m_request.Tables[0].Rows[0]["page"]);
                    nPageRowCount = Convert.ToInt32(m_request.Tables[0].Rows[0]["pagerows"]);
                    strOrder = m_request.Tables[0].Rows[0]["order"].ToString() != "" ? m_request.Tables[0].Rows[0]["order"].ToString() : strOrder;
                    strSort = m_request.Tables[0].Rows[0]["sort"].ToString() != "" ? m_request.Tables[0].Rows[0]["sort"].ToString() : strSort;
                    strWhere = m_request.Tables[0].Rows[0]["where"].ToString() != "" ? m_request.Tables[0].Rows[0]["where"].ToString() : strWhere;
                    

                    if (strWhere.Trim() != "")
                    {
                        strWhere = " " + strWhere;
                    }
                }

                //获取所有的列
                Dbconn conn = new Dbconn("MDM_Master");
                ds = conn.GetDataSet(@"
                    SELECT Property_Name FROM dbo.Lib_ExdPropertyList
                    WHERE Class_Name='" + strMainEntity + @"'
                    ");

                string strColumns = "";

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    strColumns += "[";
                    strColumns += ds.Tables[0].Rows[i]["Property_Name"].ToString() + ",";
                    strColumns += strMainEntity + ",";
                    strColumns += ds.Tables[0].Rows[i]["Property_Name"].ToString() + ",";
                    strColumns += "CN";
                    strColumns += "]";
                }

                MDM_GetEntityData mdm = new MDM_GetEntityData();
                DataTable dt = new DataTable();
                dt.Columns.Add("Columns");
                dt.Columns.Add("Where");
                dt.Columns.Add("MainEntity");

                dt.Columns.Add("Page");
                dt.Columns.Add("PageRowCount");
                dt.Columns.Add("Order");

                dt.Rows.Add(new object[] { strColumns, strWhere, strMainEntity, nPage, nPageRowCount,strSort + " " + strOrder });

                DataSet ds_request = new DataSet();
                ds_request.Tables.Add(dt);
                mdm.Request = ds_request;

                return mdm.GetData();
            }
            catch
            {
                throw;

            }



        }
        /// <summary>
        /// 获取F22相关的店铺链接数据
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet dsRequest = new DataSet();

                string strMainEntity = "006";
                string strAppBodyID = m_request.Tables[0].Rows[0]["AppBodyID"].ToString();

                int nPage = 1;
                int nPageRowCount = 20;
                string strOrder = " desc  ";
                string strSort = " body_id ";
                string strWhere = " ";

                if (m_request != null && m_request.Tables.Contains("Page_Info"))
                {
                    nPage = Convert.ToInt32(m_request.Tables[0].Rows[0]["page"]);
                    nPageRowCount = Convert.ToInt32(m_request.Tables[0].Rows[0]["pagerows"]);
                    strOrder = m_request.Tables[0].Rows[0]["order"].ToString() != "" ? m_request.Tables[0].Rows[0]["order"].ToString() : strOrder;
                    strSort = m_request.Tables[0].Rows[0]["sort"].ToString() != "" ? m_request.Tables[0].Rows[0]["sort"].ToString() : strSort;
                    strWhere = m_request.Tables[0].Rows[0]["where"].ToString() != "" ? m_request.Tables[0].Rows[0]["where"].ToString() : strWhere;
                    

                    if (strWhere.Trim() != "")
                    {
                        strWhere = " " + strWhere;
                    }
                }

                //获取所有的列
                Dbconn conn = new Dbconn("MDM_Master");
                ds = conn.GetDataSet(@"
                    SELECT Property_Name FROM dbo.Lib_ExdPropertyList
                    WHERE Class_Name='" + strMainEntity + @"'
                    ");

                string strColumns = "";

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    strColumns += "[";
                    strColumns += ds.Tables[0].Rows[i]["Property_Name"].ToString() + ",";
                    strColumns += strMainEntity + ",";
                    strColumns += ds.Tables[0].Rows[i]["Property_Name"].ToString() + ",";
                    strColumns += "CN";
                    strColumns += "]";
                }

                MDM_GetEntityData mdm = new MDM_GetEntityData();
                DataTable dt = new DataTable();
                dt.Columns.Add("Columns");
                dt.Columns.Add("Where");
                dt.Columns.Add("MainEntity");

                dt.Columns.Add("Page");
                dt.Columns.Add("PageRowCount");
                dt.Columns.Add("Order");

                dt.Rows.Add(new object[] { strColumns, strWhere, strMainEntity, nPage, nPageRowCount,strSort + " " + strOrder });

                DataSet ds_request = new DataSet();
                ds_request.Tables.Add(dt);
                mdm.Request = ds_request;

                DataSet ds_Store= mdm.GetData();


                //取到Link的数据
                dt.Clear();
                dt.Columns.Remove("page");
                dt.Rows.Add(new object[] { "", "body_ID_L01='"+strAppBodyID+"'", "L05"});
                DataSet ds_App_Store_Link = mdm.GetData();

                ds_Store.Tables[0].Columns.Add("body_ID_L01");
                ds_Store.Tables[0].Columns.Add("body_ID_L05");
                ds_Store.Tables[0].Columns["body_ID_L01"].SetOrdinal(0);
                //ds_Store.Tables[0].Columns["body_ID_L05"].SetOrdinal(0);
                for (int i = 0; i < ds_Store.Tables[0].Rows.Count; i++)
                {
                    string strBodyID = ds_Store.Tables[0].Rows[i]["body_id"].ToString();
                    DataRow[] dr = ds_App_Store_Link.Tables[0].Select("Body_ID_006='"+strBodyID+"'");
                    if (dr.Length > 0)
                    {
                        ds_Store.Tables[0].Rows[i]["body_ID_L01"] = dr[0]["body_ID_L01"].ToString();
                        ds_Store.Tables[0].Rows[i]["body_ID_L05"] = dr[0]["body_ID"].ToString();
                    }
                }
                return ds_Store;
            }
            catch
            {
                throw;

            }



        }
        /// <summary>
        /// 根据Entity的编号获取MDM中Entity的所有数据
        /// </summary>
        /// <returns></returns>
        public DataSet GetData()
        {
            try
            {
                DataSet ds = new DataSet();
                DataSet dsRequest = new DataSet();


                int nPage = 1;
                int nPageRowCount = 200000;
                string strOrder = " desc  ";
                string strSort = " body_id ";
                string strWhere = " 1=1 ";

                if (m_request != null && m_request.Tables.Contains("Page_Info"))
                {
                    nPage = Convert.ToInt32(m_request.Tables[0].Rows[0]["page"]);
                    nPageRowCount = Convert.ToInt32(m_request.Tables[0].Rows[0]["pagerows"]);
                    strOrder = m_request.Tables[0].Rows[0]["order"].ToString() != "" ? m_request.Tables[0].Rows[0]["order"].ToString() : strOrder;
                    strSort = m_request.Tables[0].Rows[0]["sort"].ToString() != "" ? m_request.Tables[0].Rows[0]["sort"].ToString() : strSort;
                   
                    string strWhereTemp = m_request.Tables[0].Rows[0]["where"].ToString();

                    if (strWhereTemp.Trim() != "")
                    {
                        strWhere = " AND " + strWhereTemp;
                    } 
                }
                if (m_request != null && m_request.Tables[0].Columns.Contains("TableType"))
                {
                    this.m_TableType = m_request.Tables[0].Rows[0]["TableType"].ToString();
                }

                string strTableName = "";
                strTableName = m_request.Tables[0].Rows[0]["MarketTableName"].ToString();

                if (m_request.Tables[0].Columns.Contains("Condition"))
                { 
                    strWhere += " AND " + m_request.Tables[0].Rows[0]["Condition"].ToString() + " ";
                }

                Dbconn conn = new Dbconn("MDM_Master");

                string strSQL = "SELECT MainEntity,Filter FROM Lib_View_Table WITH(NOLOCK)  WHERE Table_Name = '" + strTableName + "' ";

                //取到主实体信息
                DataTable dtInfo = conn.GetDataTable(strSQL);

                if (dtInfo.Rows.Count == 0)
                {
                    throw new Exception(strTableName + "不存在");
                }

                
                m_MainEntity = dtInfo.Rows[0]["MainEntity"].ToString();

                if (dtInfo.Rows[0]["Filter"].ToString().Trim() != "")
                {
                    strWhere += " AND " + dtInfo.Rows[0]["Filter"].ToString().Trim();
                }

                
                //获取所有的属性列
                string strAUZProperty = " 1=1 ";
                string strAUZEntity = " 1=1 ";

                if (m_CheckAUZ)
                {
                    strAUZProperty = GetAuzProperty(false);
                    if (strAUZProperty == "")
                    {
                        strAUZProperty = " 1=1 ";
                    }

                    //获取所有有权限的实体
                    strAUZEntity = "  Entity IN (" + GetAUZEntity() + @")";

                    //获取权限的过滤条件
                    strWhere += " AND " + GetAUZFilter(strTableName);
                }

                ds = conn.GetDataSet(@"

                SELECT  t2.Porperty_Name ,
                        t2.Table_Property_Name ,
                        Expression_Name ,
                        Entity ,
                        MainEntity ,
                        IsSelfConnection ,
                        [SPType]
                FROM    [dbo].[Lib_View_Table] t1
                        LEFT JOIN dbo.Lib_View_TableColumn t2 ON t1.Table_ID = t2.Table_ID
                        LEFT JOIN dbo.Lib_MDM_Config t3 ON t1.MainEntity = t3.MDM_Entity
                        LEFT JOIN dbo.Lib_AUZ_Property t4 ON t2.Porperty_ID=t4.Property_ID
                WHERE   Table_Name = '" + strTableName + @"'
                        AND Table_Type = 'Market'
                        AND (
                        " + strAUZProperty + @"
                        )
                        AND "+strAUZEntity+@"
                    ");

                if (ds.Tables[0].Rows.Count == 0)
                {
                    return new DataSet();
                }


                string strColumns = "";

                string strMainEntity = ds.Tables[0].Rows[0]["MainEntity"].ToString();

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    strColumns += "[";
                    strColumns += ds.Tables[0].Rows[i]["Table_Property_Name"].ToString() + ",";
                    strColumns += ds.Tables[0].Rows[i]["Entity"].ToString() + ",";
                    strColumns += ds.Tables[0].Rows[i]["Porperty_Name"].ToString() + ",";
                    strColumns += ds.Tables[0].Rows[i]["Expression_Name"].ToString() + ",";

                    strColumns += "]";
                }

                MDM_GetEntityData mdm = new MDM_GetEntityData();

                mdm.TableType = m_TableType;

                DataTable dt = new DataTable();

                dt.Columns.Add("Columns");
                dt.Columns.Add("Where");
                dt.Columns.Add("MainEntity");

                dt.Columns.Add("Page");
                dt.Columns.Add("PageRowCount");
                dt.Columns.Add("Order");

                dt.Rows.Add(new object[] { strColumns, strWhere, strMainEntity, nPage, nPageRowCount, strSort + " " + strOrder });

                DataSet ds_request = new DataSet();
                ds_request.Tables.Add(dt);
                mdm.Request = ds_request;

                return mdm.GetData();
            }
            catch
            {
                throw;

            }



        }