private static string FilterLoginSpecificContent(string body, Insider.InsiderEntity user) { Regex re = new Regex(@"\[LOGIN_SPECIFIC(?:\s+)(.*?)Type=(.*?)\]([.\s\S]*?)\[\/LOGIN_SPECIFIC\]"); List <string> List = new List <string>(); MatchCollection matches = re.Matches(body); string accountType = AccountType(user); bool canViewPricing = false; if (user.GetLoginType() != Constants.LOGIN.NONE) { canViewPricing = user.CanViewPricing(); } if (matches.Count > 0) { foreach (Match item in matches) { bool loginTypeMatch = false, pricingMatch = false; List <string> tags = item.Groups[2].Value.Split(',').ToList(); List <string> others = item.Groups[1].Value.Split(' ').ToList(); if (tags.Contains(accountType) || (user.GetLoginType() != Constants.LOGIN.NONE && tags.Contains("ALL"))) { loginTypeMatch = true; } if (!(user.GetLoginType() != Constants.LOGIN.NONE && others.Contains("Pricing=True") && canViewPricing == false)) { pricingMatch = true; } if (loginTypeMatch && pricingMatch) { body = body.Replace(item.Groups[0].Value, item.Groups[3].Value); } else { body = body.Replace(item.Groups[0].Value, ""); } } } return(body); }
private static string AccountType(Insider.InsiderEntity insider) { Constants.LOGIN type = insider.GetLoginType(); switch (type) { case Constants.LOGIN.DEALER: case Constants.LOGIN.CONSULTANT: if (insider.IsProgrammer()) { return("PROGRAMMER"); } else { return(type.ToString()); } default: return(type.ToString()); } }