Ejemplo n.º 1
0
        public static void SynchronizeViewPermission( )
        {
            GEPermissionViewsController permissionCtrl = new GEPermissionViewsController();
            String strQuery = String.Format(@"DELETE FROM GEPermissionViews WHERE FK_GEPermissionID NOT IN (SELECT GEPermissionID FROM GEPermissions)");

            BusinessObjectController.RunQuery(strQuery);


            #region Init Views
            STViewsController viewCtrl = new STViewsController();

            Dictionary <Guid, STViewsInfo> lstSTViews = new Dictionary <Guid, STViewsInfo>();
            DataSet ds = viewCtrl.GetDataSetAllObjects();
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    STViewsInfo viewInfo = viewCtrl.GetObjectFromDataRow(dr) as STViewsInfo;
                    if (lstSTViews.ContainsKey(viewInfo.STViewID) == false)
                    {
                        lstSTViews.Add(viewInfo.STViewID, viewInfo);
                    }
                }
            }
            #endregion

            foreach (GEPermissionsInfo permission in new GEPermissionsController().GetListAllObjects())
            {
                #region View
                Dictionary <Guid, GEPermissionViewsInfo> lstGroupViews = new Dictionary <Guid, GEPermissionViewsInfo>();
                foreach (GEPermissionViewsInfo viewInfo in permissionCtrl.GetListByForeignKey("FK_GEPermissionID", permission.GEPermissionID).Cast <GEPermissionViewsInfo>().ToList())
                {
                    if (viewInfo.FK_STViewID.HasValue && lstGroupViews.ContainsKey(viewInfo.FK_STViewID.Value) == false)
                    {
                        if (lstSTViews.ContainsKey(viewInfo.FK_STViewID.Value))
                        {
                            lstGroupViews.Add(viewInfo.FK_STViewID.Value, viewInfo);
                        }
                        else
                        {
                            permissionCtrl.DeleteObject(viewInfo);
                        }
                    }
                }


                foreach (Guid strViewID in lstSTViews.Keys)
                {
                    if (lstGroupViews.ContainsKey(strViewID) == false)
                    {
                        GEPermissionViewsInfo viewInfo = new GEPermissionViewsInfo();
                        viewInfo.FK_STViewID = lstSTViews[strViewID].STViewID;

                        if (lstSTViews[strViewID].FK_STViewGroupID.HasValue)
                        {
                            viewInfo.ViewGroup = GetViewGroupCaption(lstSTViews[strViewID].FK_STViewGroupID.Value);
                        }
                        viewInfo.FK_GEPermissionID = permission.GEPermissionID;

                        viewInfo.AllowView  = true;
                        viewInfo.IsHomePage = false;

                        permissionCtrl.CreateObject(viewInfo);
                        lstGroupViews.Add(viewInfo.FK_STViewID.Value, viewInfo);
                    }
                }
                #endregion
            }
        }
Ejemplo n.º 2
0
        public void RefreshViewList( )
        {
            MyData tlDataSource = new MyData(null, null, null);

            //   MyData root=new MyData( tlDataSource , new string[] { "Root" , "" } , null );

            STViewGroupsController viewGroupCtrl = new STViewGroupsController();
            STViewsController      viewCtrl      = new STViewsController();

            DataSet ds = viewGroupCtrl.GetDataSet("SELECT * FROM STViewGroups ORDER BY SortOrder");
            List <BusinessObject>     lst       = viewGroupCtrl.GetListFromDataset(ds);
            Dictionary <Guid, MyData> listNodes = new Dictionary <Guid, MyData>();

            foreach (STViewGroupsInfo objGroup in lst)
            {
                MyData group = new MyData(tlDataSource, new object[] { objGroup.No, objGroup.STViewGroupID }, objGroup);
                listNodes.Add(objGroup.STViewGroupID, group);
            }
            foreach (Guid iID in listNodes.Keys)
            {
                if ((listNodes[iID].InnerData as STViewGroupsInfo).FK_STViewGroupID.HasValue &&
                    (listNodes[iID].InnerData as STViewGroupsInfo).FK_STViewGroupID.Value != Guid.Empty)
                {
                    foreach (Guid iID2 in listNodes.Keys)
                    {
                        if (iID2 != iID)
                        {
                            if ((listNodes[iID].InnerData as STViewGroupsInfo).FK_STViewGroupID == (listNodes[iID2].InnerData as STViewGroupsInfo).STViewGroupID)
                            {
                                listNodes[iID].parentCore.childrenCore.Remove(listNodes[iID]);
                                listNodes[iID].parentCore = listNodes[iID2];
                                listNodes[iID2].childrenCore.Add(listNodes[iID]);
                            }
                        }
                    }
                }
            }

            foreach (Guid iID in listNodes.Keys)
            {
                DataSet dsView = viewCtrl.GetDataSet(String.Format("SELECT * FROM STViews WHERE FK_STViewGroupID ='{0}' ORDER BY SortOrder", iID));
                if (dsView == null || dsView.Tables.Count <= 0)
                {
                    continue;
                }

                foreach (DataRow dr in dsView.Tables[0].Rows)
                {
                    STViewsInfo objView = (STViewsInfo)viewCtrl.GetObjectFromDataRow(dr);
                    if (objView != null)
                    {
                        new MyData(listNodes[iID], new object[] { objView.STViewNo, objView.STViewID }, objView);
                    }
                }
            }



            this.DataSource = tlDataSource;
            this.CollapseAll();
        }