示例#1
0
        /// <summary>
        /// 获取所有菜单
        /// </summary>
        /// <returns></returns>
        public DataGridResult GetMenu(SearchItem item)
        {
            string sql = @" select aa.id,
                                    aa.pid,
                                    ab.id menuid,
                                    aa.name,
                                    ab.url url,
                                    ab.platformid
                               from menutree aa, menu ab
                              where  aa.menuid = ab.id(+)  ";

            if (int.Parse(employee.Id) > 0)
            {
                sql += @" and (aa.menuid in (
                                                   select a.id
                                                     from menu a,
                                                           menuqx        b,
                                                           USER_ROLE c
                                                    where a.id = b.menuid
                                                      and b.roleid = c.roleid
                                                      and c.userid = " + employee.Id + @") or
                                    aa.menuid is null)";
            }

            sql += " order by aa.id  ";
            DataTable             dt           = DbHelper.ExecuteTable(sql);
            List <PLATFORMEntity> PlatFormList = DbHelper.SelectList(new PLATFORMEntity());

            foreach (DataRow dr in dt.Rows)
            {
                string url = dr["URL"].ToString();
                dr["PLATFORMID"].ToString().TryToInt(PlatFormId =>
                {
                    var pt = PlatFormList.Where(a => a.ID == PlatFormId.ToString()).FirstOrDefault(a => url.IsRegexMatch(a.MATCH));
                    if (pt != null)
                    {
                        dr["URL"] = pt.DOMAIN + url;
                    }
                });
            }
            return(new DataGridResult(dt, 0));
        }
        public async Task <UpdateRegistrationResponseModel> UpdateHubRegistration(string handle, PlatFormId platform, string registrationId, string userName)
        {
            RegistrationDescription registration;

            switch (platform)
            {
            case PlatFormId.MicrosoftPushNotificationService:
                registration = new MpnsRegistrationDescription(handle);
                break;

            case PlatFormId.WindowsPushNotificationService:
                registration = new WindowsRegistrationDescription(handle);
                break;

            case PlatFormId.ApplePushNotificationService:
                registration = new AppleRegistrationDescription(handle);
                break;

            case PlatFormId.FirebaseCloudMessaging:
                registration = new FcmRegistrationDescription(handle);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(platform));
            }

            registration.RegistrationId = registrationId;

            // add check if user is allowed to add these tags
            registration.Tags = new HashSet <string>();
            registration.Tags.Add("username:" + userName);

            try
            {
                var hub = _hubClientFactory.Primary;
                var registrationDescription = await hub.CreateOrUpdateRegistrationAsync(registration);

                return(new UpdateRegistrationResponseModel
                {
                    RegistrationId = registrationDescription.RegistrationId
                });
            }
            catch (MessagingException e)
            {
                var webex = e.InnerException as WebException;
                if (webex.Status == WebExceptionStatus.ProtocolError)
                {
                    var response = (HttpWebResponse)webex.Response;
                    if (response.StatusCode == HttpStatusCode.Gone)
                    {
                        return(null);
                    }
                }

                throw;
            }
        }
示例#3
0
        public UIResult GetMenuNew(MENUEntity data, string host)
        {
            List <MENUTREEModule> MENU_GROUPList = new List <MENUTREEModule>();
            List <PLATFORMEntity> PlatFormList   = DbHelper
                                                   .SelectList(new PLATFORMEntity()
            {
                ID = data.PLATFORMID
            })
                                                   .GroupBy(a => a.ID)
                                                   .Select(a =>
            {
                var pt = a.FirstOrDefault(b => host.IsRegexMatch(b.MATCH));
                if (pt == null)
                {
                    pt = a.First();
                }
                return(new PLATFORMEntity()
                {
                    ID = a.Key,
                    DOMAIN = pt.DOMAIN
                });
            }).ToList();

            //子系统要多传递参数回来
            string sqlgroup = @" SELECT MODULECODE ID,MODULENAME NAME,ICON FROM USERMODULE WHERE LENGTH(MODULECODE)=4  and ENABLE_FLAG=1";

            if (int.Parse(employee.Id) > 0)
            {
                sqlgroup += @" and MODULECODE in (
                                        SELECT DISTINCT SUBSTR(A.MODULECODE,1,4) FROM USERMODULE A,ROLE_MENU B,USER_ROLE C
                                        WHERE A.MENUID=B.MENUID AND B.ROLEID=C.ROLEID
                                        AND C.USERID=" + employee.Id + ")";
            }
            if (int.Parse(data.PLATFORMID) == 1)
            {
                sqlgroup += @" and MODULECODE like '02%'";
            }
            if (int.Parse(data.PLATFORMID) == 2)
            {
                sqlgroup += @" and MODULECODE like '05%'";
            }
            sqlgroup += @" ORDER BY MODULECODE";
            DataTable menuGroup = DbHelper.ExecuteTable(sqlgroup);


            if (menuGroup.IsNotNull())
            {
                MENU_GROUPList = menuGroup.ToList <MENUTREEModule>();

                foreach (var menuGr in MENU_GROUPList)
                {
                    string sql = @" select aa.moduleid id,
                                    ab.id menuid,
                                    aa.modulename name,
                                    ab.url url,
                                    ab.platformid
                               from usermodule aa, menu ab
                              where  aa.menuid = ab.id and LENGTH(aa.MODULECODE)=6 and aa.ENABLE_FLAG=1
                                and aa.modulecode like  '" + menuGr.ID + "%'";
                    if (int.Parse(employee.Id) > 0)
                    {
                        //因菜单树型权限 按扭权限不全选时 对应菜单未保存到ROLE_MENU
                        //暂改成 由按扭权单id截取6位关联菜单id   by wangkx 20190705
                        //b.menuid 改为 to_number(substr( to_char(b.menuid),1,6))
                        // by DZK  20190716   ID取6位引起crm找不到子菜单,根据PLATFORMID 查询
                        if (int.Parse(data.PLATFORMID) == 1)
                        {
                            sql += @" and aa.menuid in (
                                                   select a.id
                                                     from menu a,
                                                           ROLE_MENU b,
                                                           USER_ROLE c
                                                    where a.id = to_number(substr( to_char(b.menuid),1,6))  
                                                      and b.roleid = c.roleid
                                                      and c.userid = " + employee.Id + @" or
                                    aa.menuid is null)";
                        }
                        else
                        {
                            sql += @" and aa.menuid in (
                                                   select a.id
                                                     from menu a,
                                                           ROLE_MENU b,
                                                           USER_ROLE c
                                                    where a.id = b.menuid 
                                                      and b.roleid = c.roleid
                                                      and c.userid = " + employee.Id + @" or
                                    aa.menuid is null)";
                        }
                    }

                    sql += " order by aa.modulecode  ";
                    DataTable menu = DbHelper.ExecuteTable(sql);
                    foreach (DataRow dr in menu.Rows)
                    {
                        string url = dr["URL"].ToString();
                        dr["PLATFORMID"].ToString().TryToInt(PlatFormId =>
                        {
                            var pt = PlatFormList.FirstOrDefault(a => a.ID == PlatFormId.ToString());
                            if (pt != null)
                            {
                                dr["URL"] = pt.DOMAIN + url;
                            }
                        });
                    }
                    menuGr.MENUList = menu.ToList <MENUEntity>();
                }
                ;
            }
            ;
            return(new UIResult(new
            {
                MENU = MENU_GROUPList
            }));
        }
 private static bool InvalidPlatForm(PlatFormId platFormId)
 {
     return(platFormId <= PlatFormId.MicrosoftPushNotificationService &&
            platFormId > PlatFormId.FirebaseCloudMessaging);
 }