Exemple #1
0
        public virtual void AppPrivilegeAdd(string appid, string appName, string appCode, string buaappid, string buaprivilege, string buaprivilegetext, string enablesync, string syncinterval)
        {
            if (buaprivilege == null)
            {
                buaprivilege = "";
            }
            AppPrivilegeDao dao    = new AppPrivilegeDao(AppConfig.mainDbKey);
            ApplicationDao  appDao = new ApplicationDao(AppConfig.mainDbKey);
            KeyValuePair <string, object>          pk  = new KeyValuePair <string, object>("name", appCode);
            IList <KeyValuePair <string, object> > par = new List <KeyValuePair <string, object> >();

            par.Add(pk);
            Application  application    = appDao.Get(par);
            int          appPrivilegeid = application.PrivilegeID != null ? application.PrivilegeID.Value : 0;
            AppPrivilege ap             = null;
            bool         exists         = dao.Exists(appPrivilegeid.ToString());

            if (exists)
            {
                IList <KeyValuePair <string, object> > pars = new List <KeyValuePair <string, object> >();
                KeyValuePair <string, object>          p    = new KeyValuePair <string, object>("id", appPrivilegeid);

                pars.Add(p);
                ap                  = dao.Get(pars);
                ap.BuaAppCode       = buaappid;
                ap.BuaPrivilegeCode = buaprivilege;
                ap.DisplayName      = buaprivilegetext;

                ap.EnableSync       = enablesync == "ENABLE" ? true : false;
                ap.SyncIntervalTime = String.IsNullOrEmpty(syncinterval) ? 0 : int.Parse(syncinterval);
                dao.Update(ap);
            }
            else
            {
                ap = new AppPrivilege();
                //ap.ID = int.Parse(appid);
                ap.BuaAppCode       = buaappid;
                ap.BuaPrivilegeCode = buaprivilege;
                ap.EnableSync       = enablesync == "ENABLE" ? true : false;
                ap.Name             = appCode;
                ap.DisplayName      = buaprivilegetext;
                ap.SyncIntervalTime = String.IsNullOrEmpty(syncinterval) ? 0 : int.Parse(syncinterval);
                ap.SyncLastTime     = DateTime.Now;
                ap.SyncTime         = DateTime.Now;
                ap.CreateUid        = "";
                ap.CreateTime       = DateTime.Now;
                ap.UpdateTime       = DateTime.Now;
                ap.UpdateUid        = "";

                dao.Insert(ap);
            }

            if (application != null)
            {
                application.PrivilegeID = ap.ID;
                appDao.Update(application);
            }
        }
        public virtual void AppPrivilegeAdd(string appid, string appName, string appCode, string buaappid, string buaprivilege, string buaprivilegetext, string enablesync, string syncinterval)
        {
            if (buaprivilege == null)
                buaprivilege = "";
            AppPrivilegeDao dao = new AppPrivilegeDao(AppConfig.mainDbKey);
            ApplicationDao appDao = new ApplicationDao(AppConfig.mainDbKey);
            KeyValuePair<string, object> pk = new KeyValuePair<string, object>("name", appCode);
            IList<KeyValuePair<string, object>> par = new List<KeyValuePair<string, object>>();
            par.Add(pk);
            Application application = appDao.Get(par);
            int appPrivilegeid = application.PrivilegeID != null ? application.PrivilegeID.Value : 0;
            AppPrivilege ap = null;
            bool exists = dao.Exists(appPrivilegeid.ToString());
            if (exists)
            {
                IList<KeyValuePair<string, object>> pars = new List<KeyValuePair<string, object>>();
                KeyValuePair<string, object> p = new KeyValuePair<string, object>("id", appPrivilegeid);

                pars.Add(p);
                ap = dao.Get(pars);
                ap.BuaAppCode = buaappid;
                ap.BuaPrivilegeCode = buaprivilege;
                ap.DisplayName = buaprivilegetext;

                ap.EnableSync = enablesync == "ENABLE" ? true : false;
                ap.SyncIntervalTime = String.IsNullOrEmpty(syncinterval) ? 0 : int.Parse(syncinterval);
                dao.Update(ap);
            }
            else
            {
                ap = new AppPrivilege();
                //ap.ID = int.Parse(appid);
                ap.BuaAppCode = buaappid;
                ap.BuaPrivilegeCode = buaprivilege;
                ap.EnableSync = enablesync == "ENABLE" ? true : false;
                ap.Name = appCode;
                ap.DisplayName = buaprivilegetext;
                ap.SyncIntervalTime = String.IsNullOrEmpty(syncinterval) ? 0 : int.Parse(syncinterval);
                ap.SyncLastTime = DateTime.Now;
                ap.SyncTime = DateTime.Now;
                ap.CreateUid = "";
                ap.CreateTime = DateTime.Now;
                ap.UpdateTime = DateTime.Now;
                ap.UpdateUid = "";

                dao.Insert(ap);
            }

            if (application != null)
            {
                application.PrivilegeID = ap.ID;
                appDao.Update(application);
            }
        }
Exemple #3
0
        public virtual void UnAuthAppPrivilege(string id)
        {
            AppPrivilegeDao  apdao        = new AppPrivilegeDao(AppConfig.mainDbKey);
            PrivilegeUserDao pudao        = new PrivilegeUserDao(AppConfig.mainDbKey);
            ApplicationDao   appDao       = new ApplicationDao(AppConfig.mainDbKey);
            AppPrivilege     appPrivilege = apdao.Get(id);

            if (appPrivilege != null)
            {
                IList <Tuple <string, string, object> > _pars = new List <Tuple <string, string, object> >();
                _pars.Add(new Tuple <string, string, object>("PrivilegeId", "=", appPrivilege.ID));

                List <Application> applications = appDao.QueryList(_pars);
                if (applications != null && applications.Count > 0)
                {
                    foreach (Application app in applications)
                    {
                        app.PrivilegeID = null;
                        appDao.Update(app);
                    }
                }

                IList <Tuple <string, string, object> > pars = new List <Tuple <string, string, object> >();
                pars.Add(new Tuple <string, string, object>("id", "=", appPrivilege.ID));
                List <PrivilegeUser> privilegeUsers = pudao.QueryList(pars);
                pudao.DeleteList(privilegeUsers);
                apdao.Delete(appPrivilege);
                //appPrivilege.BuaAppCode = "";
                //appPrivilege.BuaPrivilegeCode = "";
                //appPrivilege.DisplayName = "";
                //appPrivilege.EnableSync = false;
                //appPrivilege.SyncIntervalTime = 0;

                //apdao.Update(appPrivilege);
            }
        }
        public virtual void UnAuthAppPrivilege(string id)
        {
            AppPrivilegeDao apdao = new AppPrivilegeDao(AppConfig.mainDbKey);
            PrivilegeUserDao pudao = new PrivilegeUserDao(AppConfig.mainDbKey);
            ApplicationDao appDao = new ApplicationDao(AppConfig.mainDbKey);
            AppPrivilege appPrivilege = apdao.Get(id);
            if (appPrivilege != null)
            {
                IList<Tuple<string, string, object>> _pars = new List<Tuple<string, string, object>>();
                _pars.Add(new Tuple<string, string, object>("PrivilegeId", "=", appPrivilege.ID));

                List<Application> applications = appDao.QueryList(_pars);
                if (applications != null && applications.Count > 0)
                {
                    foreach (Application app in applications)
                    {
                        app.PrivilegeID = null;
                        appDao.Update(app);
                    }
                }

                IList<Tuple<string, string, object>> pars = new List<Tuple<string, string, object>>();
                pars.Add(new Tuple<string, string, object>("id", "=", appPrivilege.ID));
                List<PrivilegeUser> privilegeUsers = pudao.QueryList(pars);
                pudao.DeleteList(privilegeUsers);
                apdao.Delete(appPrivilege);
                //appPrivilege.BuaAppCode = "";
                //appPrivilege.BuaPrivilegeCode = "";
                //appPrivilege.DisplayName = "";
                //appPrivilege.EnableSync = false;
                //appPrivilege.SyncIntervalTime = 0;

                //apdao.Update(appPrivilege);
            }
        }