public bool UpdateUserDashboard(DashboardVo dashboardVo) { bool Result = false; DashboardDao dashboardDao = new DashboardDao(); try { Result = dashboardDao.UpdateUserDashboard(dashboardVo); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "DashboardBo.cs:UpdateUserDashboard()"); object[] objects = new object[2]; objects[0] = dashboardVo.KeyName; objects[1] = dashboardVo.UserId; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(Result); }
protected void UpdatePanel1_Load(object sender, EventArgs e) { if (IsPostBack) { try { DashboardVo dashboardVo = (DashboardVo)Session[this.UniqueID]; string[] PartIds = SortOrder.Value.Split(','); int Order = 1; foreach (string PartId in PartIds) { int PId = int.Parse(PartId); foreach (DashboardPartVo dashboardPartVo in dashboardVo.PartList) { if (dashboardPartVo.DashboardPartId == PId) { dashboardPartVo.UserOrder = Order; break; } } Order++; } DashboardBo dashboardBo = new DashboardBo(); dashboardBo.UpdateUserDashboard(dashboardVo); } catch { } } }
public DashboardVo GetUserDashboard(UserVo userVo, string KeyName) { DashboardVo dashboardVo = null; DashboardDao dashboardDao = new DashboardDao(); try { dashboardVo = dashboardDao.GetUserDashboard(userVo, KeyName); } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "DashboardBo.cs:GetUserDashboard()"); object[] objects = new object[2]; objects[0] = userVo; objects[1] = KeyName; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(dashboardVo); }
protected void btnSave_Click(object sender, EventArgs e) { try { DashboardVo dashboardVo = (DashboardVo)Session[this.UniqueID]; for (int i = 0; i < PartList.Items.Count; i++) { int DPId = int.Parse(PartList.Items[i].Value); bool DPSelected = PartList.Items[i].Selected; foreach (DashboardPartVo dashboardPartVo in dashboardVo.PartList) { if (dashboardPartVo.DashboardPartId == DPId) { dashboardPartVo.Visible = DPSelected; break; } } } DashboardBo dashboardBo = new DashboardBo(); dashboardBo.UpdateUserDashboard(dashboardVo); InitDashboard(); } catch { lblError.Visible = true; lblError.Text = "Unable to save dashboard. Contact System Administrator."; } }
protected void InitDashboard() { UserVo userVo = new UserVo(); userVo.UserId = 20565; DashboardBo dashboardBo = new DashboardBo(); try { DashboardVo dashboardVo = (DashboardVo)Session[this.UniqueID]; if (dashboardVo == null) { dashboardVo = dashboardBo.GetUserDashboard(userVo, m_KeyName); Session[this.UniqueID] = dashboardVo; } PartList.Items.Clear(); foreach (DashboardPartVo dashboardPartVo in dashboardVo.PartList) { PartList.Items.Add(new ListItem(dashboardPartVo.Name, dashboardPartVo.DashboardPartId.ToString(), true)); PartList.Items[PartList.Items.Count - 1].Selected = dashboardPartVo.Visible; } } catch { lblError.Visible = true; lblError.Text = "Unable to display dashboard. Contact System Administrator."; } }
public void SetUserParams(int dashboardPartId, string Params) { DashboardVo dashboardVo = (DashboardVo)Session[this.UniqueID]; if (dashboardVo != null) { foreach (DashboardPartVo dashboardPartVo in dashboardVo.PartList) { if (dashboardPartVo.DashboardPartId == dashboardPartId) { dashboardPartVo.UserParams = Params; DashboardBo dashboardBo = new DashboardBo(); dashboardBo.UpdateUserDashboard(dashboardVo); break; } } } }
public string GetUserParams(int dashboardPartId) { string Params = ""; DashboardVo dashboardVo = (DashboardVo)Session[this.UniqueID]; if (dashboardVo != null) { foreach (DashboardPartVo dashboardPartVo in dashboardVo.PartList) { if (dashboardPartVo.DashboardPartId == dashboardPartId) { Params = dashboardPartVo.UserParams; break; } } } return(Params); }
public bool UpdateUserDashboard(DashboardVo dashboardVo) { Database db; DbCommand getCmd; bool bResult = false; try { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.Indent = true; wSettings.OmitXmlDeclaration = true; MemoryStream ms = new MemoryStream(); XmlWriter xw = XmlWriter.Create(ms, wSettings);// Write Declaration xw.WriteStartDocument(); xw.WriteStartElement("Root"); foreach (DashboardPartVo dashboardPartVo in dashboardVo.PartList) { xw.WriteStartElement("Item"); xw.WriteAttributeString("PartId", dashboardPartVo.DashboardPartId.ToString()); xw.WriteAttributeString("Order", dashboardPartVo.UserOrder.ToString()); xw.WriteAttributeString("Params", dashboardPartVo.UserParams.ToString()); xw.WriteAttributeString("Visible", (dashboardPartVo.Visible)? "1": "0"); xw.WriteEndElement(); } xw.WriteEndElement(); xw.WriteEndDocument(); xw.Flush(); Byte[] buffer = new Byte[ms.Length]; buffer = ms.ToArray(); string xmlOutput = System.Text.Encoding.UTF8.GetString(buffer); db = DatabaseFactory.CreateDatabase("wealtherp"); getCmd = db.GetStoredProcCommand("SP_UpdateUserDashboard"); db.AddInParameter(getCmd, "@D_DashboardId", DbType.Int32, dashboardVo.DashboardId); db.AddInParameter(getCmd, "@U_UserId", DbType.Int32, dashboardVo.UserId); db.AddInParameter(getCmd, "@XML", DbType.String, xmlOutput); db.ExecuteNonQuery(getCmd); bResult = true; } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "DashboardDao.cs:UpdateUserDashboard()"); object[] objects = new object[2]; objects[0] = dashboardVo.UserId; objects[1] = dashboardVo.KeyName; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(bResult); }
public DashboardVo GetUserDashboard(UserVo userVo, string KeyName) { DashboardVo dashboardVo = null; Database db; DbCommand getCmd; DataSet getDs; try { db = DatabaseFactory.CreateDatabase("wealtherp"); getCmd = db.GetStoredProcCommand("SP_GetUserDashboard"); db.AddInParameter(getCmd, "@D_KeyName", DbType.String, KeyName.ToString()); db.AddInParameter(getCmd, "@U_UserId", DbType.Int32, userVo.UserId); getDs = db.ExecuteDataSet(getCmd); dashboardVo = new DashboardVo(); if (getDs.Tables.Count == 0 || getDs.Tables[0].Rows.Count == 0) { throw new Exception("Unable to load dashboard for user"); } int i = 0; foreach (DataRow dr in getDs.Tables[0].Rows) { if (i == 0) { dashboardVo.DashboardId = int.Parse(dr["D_DashboardId"].ToString()); dashboardVo.UserId = userVo.UserId; dashboardVo.Name = dr["D_Name"].ToString(); dashboardVo.KeyName = KeyName; dashboardVo.Columns = int.Parse(dr["D_Columns"].ToString()); i++; } DashboardPartVo dashboardPartVo = new DashboardPartVo(); dashboardPartVo.DashboardId = int.Parse(dr["D_DashboardId"].ToString()); dashboardPartVo.DashboardPartId = int.Parse(dr["DP_DashboardPartId"].ToString()); dashboardPartVo.Name = dr["DP_Name"].ToString(); dashboardPartVo.ControlName = dr["DP_ControlName"].ToString(); dashboardPartVo.Params = dr["DP_Params"].ToString(); dashboardPartVo.UserOrder = int.Parse(dr["UD_Order"].ToString()); dashboardPartVo.UserParams = dr["UD_Params"].ToString(); dashboardPartVo.Visible = (dr["Visible"].ToString() == "1")? true: false; dashboardPartVo.Columns = int.Parse(dr["DP_Columns"].ToString()); dashboardVo.PartList.Add(dashboardPartVo); } } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "DashboardDao.cs:GetUserDashboard()"); object[] objects = new object[2]; objects[0] = KeyName; objects[1] = userVo.UserId; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } return(dashboardVo); }
protected void RenderDashboards() { BPanel.Controls.Clear(); DashboardVo dashboardVo = (DashboardVo)Session[this.UniqueID]; if (dashboardVo == null) { lblError.Visible = true; lblError.Text = "Unable to display dashboard. Contact System Administrator."; return; } HtmlGenericControl[] Columns = new HtmlGenericControl[dashboardVo.Columns]; for (int i = 0; i < Columns.Length; i++) { HtmlGenericControl HGC = new HtmlGenericControl("div"); HGC.Attributes.Add("class", "column"); HGC.ID = "column" + i.ToString(); BPanel.Controls.Add(HGC); Columns[i] = HGC; } int Count = 0; foreach (DashboardPartVo dashboardPartVo in dashboardVo.PartList.OrderBy(part => part.UserOrder)) { if (dashboardPartVo.Visible) { string Classname = "dragbox "; Classname += (dashboardPartVo.Columns == 1) ? "onecolumn" : "twocolumn"; HtmlGenericControl Part = new HtmlGenericControl("div"); Part.Attributes.Add("class", Classname); Part.ID = "Part" + dashboardPartVo.DashboardPartId.ToString(); HtmlGenericControl Handle = new HtmlGenericControl("h2"); Handle.InnerText = dashboardPartVo.Name; Part.Controls.Add(Handle); HtmlGenericControl Content = new HtmlGenericControl("div"); Content.Attributes.Add("class", "dragbox-content"); Part.Controls.Add(Content); try { // if loading user control fails, do nothing // will throw httpexception Control C = Page.LoadControl(dashboardPartVo.ControlName); C.ID = "PartControl_" + dashboardPartVo.DashboardPartId.ToString(); Content.Controls.Add(C); } catch { } int Column = Count % dashboardVo.Columns; Columns[Column].Controls.Add(Part); Count++; } } }