using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using DataLibrary; using System.Web; namespace CoreSavingLibrary { public class MenuBar { private WebState state; private XmlConfigService xmlconfig; private DataTable menuBar; private DataTable menuSub; private String groupName; public String GroupName { get { return groupName; } set { groupName = value; } } public MenuBar(WebState state, XmlConfigService xmlconfig) { this.state = state; this.xmlconfig = xmlconfig; DataTable[] dt = this.GetMenuData(state.SsOracleTA, state.SsCoopId, state.SsUsername, state.SsApplication, state.CurrentGroup); menuBar = dt[0]; menuSub = dt[1]; groupName = menuSub.Rows[0]["group_desc"].ToString(); } public DataTable GetMenuBar() { return menuBar; } public DataTable GetMenuSub() { return menuSub; } public DataTable[] GetMenuData(Sta ta, String coopWorking, String username, String application, String gId) { string savingCore = WebUtil.GetSavingUrlCore(); String defaultUrl = "concat('" + WebUtil.GetSavingUrl() + "Default.aspx?setApp=" + application + "&setGroup=' , trim(a.group_code) )"; string iconUrl = "'" + savingCore + "Image/ico/MyDocuments.png'"; DataTable[] dt = new DataTable[2]; String groupCode = ""; String sql1 = @" select distinct a.application, trim(a.group_code) as group_code, a.group_desc, a.group_order, " + defaultUrl + @" as default_url, " + iconUrl + @" as icon_url from amsecwinsgroup a left join amsecwins b on a.group_code = b.group_code and a.application = b.application left join amsecpermiss c on b.window_id = c.window_id and a.application= c.application where c.coop_id = '" + coopWorking + @"' and a.application = '" + application + @"' and b.used_flag = 1 and (b.webwinwork_code <> 'WIN' or b.webwinwork_code is null) and check_flag = 1 and c.user_name = '" + username + @"' order by a.group_order "; DataTable dt00 = ta.QueryDataTable(sql1); dt00.TableName = "groupcode"; if (gId == "") { groupCode = dt00.Rows[0]["group_code"].ToString(); } else { groupCode = gId; } dt[0] = dt00; string pureUrl = WebUtil.GetUrlAddressOnly(); string savUrl0 = pureUrl + "ICORE"; string savUrl1 = pureUrl + "" + xmlconfig.SavPathOpenType1; string savUrl3 = pureUrl + "" + xmlconfig.SavPathOpenType3; String sql = @" select a.application, trim(a.group_code) as group_code, a.group_desc, a.group_order, trim(b.window_id) as window_id, b.win_object, b.win_description, b.win_parameter, b.open_type, decode(b.open_type , 2 , b.win_object || '_ctrl/' || b.win_object, b.win_object) as websheet_location, (case when b.win_parameter is not null and length(b.win_parameter) > 0 then b.win_parameter else a.application end) as physical_dir, ( decode(b.open_type , 3 , '" + savUrl3 + @"', decode(b.core_flag, 1, '" + savUrl0 + @"', '" + savUrl1 + @"')) || '/ICOOP/Saving/Applications/' || (case when b.win_parameter is not null and length(b.win_parameter) > 0 then b.win_parameter else a.application end) || '/' || decode(b.open_type , 2, b.win_object || '_ctrl/' || b.win_object, 3, b.win_object || '_ctrl/' || b.win_object, b.win_object ) || '.aspx' ) as full_url from amsecwinsgroup a left join amsecwins b on a.group_code = b.group_code and a.application = b.application left join amsecpermiss c on b.window_id = c.window_id and a.application= c.application where c.coop_id = '" + coopWorking + @"' and a.application = '" + application + @"' and b.used_flag = 1 and (b.webwinwork_code <> 'WIN' or b.webwinwork_code is null) and check_flag = 1 and c.user_name = '" + username + @"' and b.group_code = '" + groupCode + @"' order by a.group_order, b.win_order"; if(Sta.IS_MYSQL_MODE){ sql = @" select a.application, trim(a.group_code) as group_code, a.group_desc, a.group_order, trim(b.window_id) as window_id, b.win_object, b.win_description, b.win_parameter, b.open_type, (CASE WHEN b.open_type = 2 THEN concat(concat(b.win_object , '_ctrl/' ), b.win_object) ELSE b.win_object END ) as websheet_location, (case when b.win_parameter is not null and length(b.win_parameter) > 0 then b.win_parameter else a.application end) as physical_dir, ( concat(concat(concat( concat(concat((case when b.open_type = 3 then '" + savUrl3 + @"' else (case when b.core_flag= 1 then '" + savUrl0 + @"' else '" + savUrl1 + @"' END ) END ), '/ICOOP/Saving/Applications/' ), (case when b.win_parameter is not null and length(b.win_parameter) > 0 then b.win_parameter else a.application end) ), '/' ) , (case when b.open_type = 2 then concat(concat(b.win_object , '_ctrl/' ) , b.win_object ) when b.open_type =3 then concat(concat(b.win_object , '_ctrl/' ), b.win_object ) else b.win_object END ) ) , '.aspx') ) as full_url from amsecwinsgroup a left join amsecwins b on a.group_code = b.group_code and a.application = b.application left join amsecpermiss c on b.window_id = c.window_id and a.application= c.application where c.coop_id = '" + coopWorking + @"' and a.application = '" + application + @"' and b.used_flag = 1 and (b.webwinwork_code <> 'WIN' or b.webwinwork_code is null) and check_flag = 1 and c.user_name = '" + username + @"' and b.group_code = '" + groupCode + @"' order by a.group_order, b.win_order"; } DataTable dt01 = ta.QueryDataTable(sql); dt01.TableName = "groupdesc"; dt[1] = dt01; return dt; } } }