This is a migrated thread and some comments may be shown as answers.
Dock not refreshed
2 Answers 21 Views
This is a migrated thread and some comments may be shown as answers.
Golu
Top achievements
Rank 1
Golu asked on 02 Jul 2009, 08:50 AM
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ZZ_DashBoard.aspx.cs" Inherits="ZZ_DashBoard" 
    EnableViewState="false" %> 
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>DashBoard</title> 
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
 
        <script type="text/javascript">  
            var currentLoadingPanel = null;  
            var currentUpdatedControl = null;  
 
            function RequestStart(sender, args) {  
                currentLoadingPanel = $find("RadAjaxLoadingPanel1");  
                currentUpdatedControl = "TableLayout";  
                currentLoadingPanel.show(currentUpdatedControl);  
            }  
            function ResponseEnd() {  
                //hide the loading panel and clean up the global variables    
                if (currentLoadingPanel != null)  
                    currentLoadingPanel.hide(currentUpdatedControl);  
                currentUpdatedControl = null;  
                currentLoadingPanel = null;  
            }  
            function OnDateClick(sender, args) {  
                //--when load calender dashlet  
                args.get_domEvent().stopPropagation();  
            }  
 
            function CustomCommand(dock, args) {  
                alert('11');  
                args.set_cancel(true);  
 
            }  
            function btnAddZone_OnClientClick() {  
                try {  
                    ctl = $find("<%= cmbTableLayouts.ClientID%>");  
                    if (ctl.get_value() == "") {  
                        alert("Select Table Layout !");  
                        ctl.get_inputDomElement().focus();  
                        return false;  
                    }  
                }  
                catch (e) {  
                    alert("Error:- Page: ZZ_DashBoard.aspx; Method: \"btnAddZone_OnClientClick\" \n Description:- \n" + e.description);  
                    return false;  
                }  
            }  
            function btnAddDock_OnClientClick() {  
                try {  
                    ctl = $find("<%= cmbDashlets.ClientID%>");  
                    if (ctl.get_value() == "") {  
                        alert("Select Dashlet !");  
                        ctl.get_inputDomElement().focus();  
                        return false;  
                    }  
                    ctl = $find("<%= cmbZone.ClientID%>");  
                    if (ctl.get_value() == "") {  
                        alert("Select Zone !");  
                        ctl.get_inputDomElement().focus();  
                        return false;  
                    }  
                }  
                catch (e) {  
                    alert("Error:- Page: ZZ_DashBoard.aspx; Method: \"btnAddDock_OnClientClick\" \n Description:- \n" + e.description);  
                    return false;  
                }  
            }  
        </script> 
 
    </telerik:RadCodeBlock> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="scriptmanager1" runat="server">  
    </asp:ScriptManager> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        <ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" /> 
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="btnAddZone">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblMessage" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone1" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone2" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone3" /> 
                    <telerik:AjaxUpdatedControl ControlID="cmbTableLayout" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="btnAddDock">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblMessage" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone1" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone2" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone3" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="btnSaveDock">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblMessage" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone1" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone2" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadDockZone3" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="200px" 
        Width="250px" Transparency="50">  
        <img alt="Loading..." src='Images/LoadingProgressBar.gif' style="border: 0;" /> 
    </telerik:RadAjaxLoadingPanel> 
    <table id="Table1" width="100%" runat="server" cellspacing="0">  
        <tr> 
            <th class="tdMainHeader1" style="width: 10%;">  
                <img alt="Customer" src="Images/dashboard.gif" /> 
                Dashboard  
            </th> 
            <th style="text-align: right;" class="tdMainHeader1">  
                <asp:Button ID="btnSaveDock" runat="server" Text="Save My Dashboard" OnClick="btnSaveDock_Click" /> 
                <asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="100px" /> 
            </th> 
        </tr> 
        <tr id="trZoneLayout" runat="server">  
            <td style="width: 7%;" align="left">  
                Zone Layout  
            </td> 
            <td align="left">  
                <telerik:RadComboBox ID="cmbTableLayouts" runat="server">  
                </telerik:RadComboBox> 
                &nbsp;&nbsp;  
                <asp:Button ID="btnAddZone" runat="server" Text="Add Zone" OnClick="btnAddZone_Click" 
                    Width="100px" /> 
                <%--OnClientClick="javascript:return btnAddZone_OnClientClick();"--%> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                Dashlets  
            </td> 
            <td> 
                <telerik:RadComboBox ID="cmbDashlets" runat="server" Skin="Office2007">  
                </telerik:RadComboBox> 
                &nbsp;&nbsp;  
                <telerik:RadComboBox ID="cmbZone" runat="server" Skin="Office2007" DataSource="<%#GetZones() %>" 
                    DataTextField="ID" DataValueField="ClientID">  
                </telerik:RadComboBox> 
                &nbsp;&nbsp;  
                <asp:Button ID="btnAddDock" runat="server" Text="Add Dock" Width="100px" OnClick="btnAddDock_Click" /> 
                <%--OnClientClick="javascript:return btnAddDock_OnClientClick();"--%> 
            </td> 
        </tr> 
        <tr> 
            <td colspan="2">  
                <telerik:RadDockLayout runat="server" ID="rdDockLayout" OnSaveDockLayout="rdDockLayout_SaveDockLayout" 
                    Skin="Office2007" OnLoadDockLayout="rdDockLayout_LoadDockLayout">  
                    <table width="100%" id="TableLayout" cellpadding="2" cellspacing="2">  
                        <tr id="trOneZone" runat="server">  
                            <td colspan="2">  
                                <asp:Label ID="lblZone3" runat="server" Visible="false" Text="Zone3"></asp:Label> 
                                <telerik:RadDockZone runat="server" ID="RadDockZone3" Width="99%" MinHeight="100" 
                                    Style="background: #f5f4e8; float: left;" Orientation="Vertical" FitDocks="true" 
                                    Visible="false" BorderStyle="None">  
                                </telerik:RadDockZone> 
                            </td> 
                        </tr> 
                        <tr id="trTwoZone" runat="server">  
                            <td style="width: 50%;" align="left" valign="top">  
                                <table width="100%">  
                                    <tr> 
                                        <td> 
                                            <asp:Label ID="lblZone1" runat="server" Visible="false" Text="Zone1"></asp:Label> 
                                            <telerik:RadDockZone runat="server" ID="RadDockZone1" Width="99%" MinHeight="100" 
                                                Style="background: #f5f4e8; float: left;" Orientation="Vertical" FitDocks="true" 
                                                Visible="false" BorderStyle="None">  
                                            </telerik:RadDockZone> 
                                        </td> 
                                    </tr> 
                                </table> 
                            </td> 
                            <td style="width: 50%;" align="left" valign="top">  
                                <table width="100%">  
                                    <tr> 
                                        <td> 
                                            <asp:Label ID="lblZone2" runat="server" Visible="false" Text="Zone2"></asp:Label> 
                                            <telerik:RadDockZone runat="server" ID="RadDockZone2" Width="99%" MinHeight="100" 
                                                Style="background: #d5f0fa; float: left;" Orientation="Vertical" FitDocks="true" 
                                                Visible="false" BorderStyle="None">  
                                            </telerik:RadDockZone> 
                                        </td> 
                                    </tr> 
                                </table> 
                            </td> 
                        </tr> 
                    </table> 
                </telerik:RadDockLayout> 
            </td> 
        </tr> 
        <tr> 
            <td colspan="2">  
                <asp:Label ID="lblMessage" runat="server"></asp:Label> 
            </td> 
        </tr> 
    </table> 
    </form> 
</body> 
</html> 
 
 
 int i = 0;  
    string dockState = "";  
    string strRegisteredZones = string.Empty;  
    string strDockTag = string.Empty;  
    string strZone = string.Empty;  
    string strZoneName = string.Empty;  
    string strDockTagName = string.Empty;  
    string strResult = string.Empty;  
    string strZoneControlID = string.Empty;  
    int nLoggedInUserId = 1;  
    int nPageId = 1;  
 
    DockStateWS objDockStateWS;  
    DataSet dsDataSet;  
    List<DockState> stateList;  
    StringBuilder serializedList = new StringBuilder();  
    ArrayList zones = new ArrayList();  
 
 
    protected void Page_InIt(object sender, EventArgs e)  
    {  
        try  
        {  
            cmbZone.DataBind();  
            BindDockZoneTableLayouts();  
            BindDashlets();  
            LoadDockState();  
            cmbZone.Enabled = true;  
            cmbDashlets.Enabled = true;  
        }  
        catch (Exception ex)  
        {  
            LogMessage(ex, 1, "Page_InIt");  
        }  
    }  
 
    protected void Page_Load(object sender, EventArgs e)  
    {  
        //LoadDockState();  
    }  
 
    protected void btnSaveDock_Click(object sender, EventArgs e)  
    {  
        try  
        {  
            //--Save Dock states in Database  
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();  
            stateList = rdDockLayout.GetRegisteredDocksState();  
 
 
            while (i < stateList.Count)  
            {  
                serializedList.Append(serializer.Serialize(stateList[i]));  
                serializedList.Append("|");  
                i++;  
            }  
            dockState = serializedList.ToString();  
            if (dockState.Trim() != String.Empty)  
            {  
                objDockStateWS = new DockStateWS();  
                dsDataSet = new DataSet();  
                dsDataSet = objDockStateWS.Insert_DashBoardState(0, nLoggedInUserId, dockState, nPageId);  
            }  
            //LoadDockState();  
        }  
        catch (Exception ex)  
        {  
            LogMessage(ex, 1, "btnSaveDock_Click");  
        }  
    }  
 
    protected void rdDockLayout_LoadDockLayout(object sender, DockLayoutEventArgs e)  
    {  
        bool bDocStateCreate = false;  
 
        //--from database  
        DataTable dt = new DataTable();  
 
        try  
        {  
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();  
            //--use session  
            foreach (DockState state in CurrentDockStates)  
            {  
                bDocStateCreate = true;  
                e.Positions[state.UniqueName] = state.DockZoneID;  
                e.Indices[state.UniqueName] = state.Index;  
            }  
            if (bDocStateCreate == false)  
            {  
                objDockStateWS = new DockStateWS();  
                dsDataSet = new DataSet();  
                dsDataSet = objDockStateWS.Fetch_DashBoardState(0, nLoggedInUserId, nPageId);  
 
                if (dsDataSet.Tables["DockState"].Rows.Count > 0)  
                {  
                    dockState = Convert.ToString(dsDataSet.Tables["DockState"].Rows[0]["dock_dashboard_state"]);  
                    string[] currentDockStates = dockState.Split('|');  
                    foreach (string stringState in currentDockStates)  
                    {  
                        if (stringState.Trim() != string.Empty)  
                        {  
                            serializer = new System.Web.Script.Serialization.JavaScriptSerializer();  
                            DockState state = serializer.Deserialize<DockState>(stringState);  
                            RadDock dock = CreateRadDockFromState(state);  
                            rdDockLayout.Controls.Add(dock);  
                            LoadWidget(dock);  
                        }  
                    }  
                }  
            }  
            //-- Get zones from Database  
            objDockStateWS = new DockStateWS();  
            dsDataSet = new DataSet();  
            dsDataSet = objDockStateWS.Fetch_UserZoneSettings(0, nLoggedInUserId, nPageId);  
 
            if (dsDataSet.Tables["Response"].Rows[0]["ResultCode"].ToString() != "0")  
            {  
                strResult = dsDataSet.Tables["Response"].Rows[0]["ResultString"].ToString();  
                LogMessage(new Exception(strResult), 1, "rdDockLayout_LoadDockLayout");  
                return;  
            }  
            else  
            {  
                if (dsDataSet.Tables["DockZoneSettings"].Rows.Count > 0)  
                {  
                    for (int i = 0; i < dsDataSet.Tables["DockZoneSettings"].Rows.Count; i++)  
                    {  
                        string strDockZoneID = Convert.ToString(dsDataSet.Tables["DockZoneSettings"].Rows[i]["zone_setting_zones_name"]);  
                        int dockZoneDesignCode = Convert.ToInt32(dsDataSet.Tables["DockZoneSettings"].Rows[i]["zone_setting_table_layout_id"]);  
 
                        //-- Visible already registered Zones  
                        string[] strZones = strDockZoneID.Split(',');  
                        for (int j = 0; j < strZones.Length; j++)  
                        {  
                            RadDockZone dz = (RadDockZone)rdDockLayout.FindControl(strZones[j]);  
                            if (dz != null)  
                            {  
                                dz.Visible = true;  
                            }  
                        }  
                        //-- Disable registered zone design layput from cmbZoneLayouts                              
                        cmbTableLayouts.FindItemByValue(Convert.ToString(dockZoneDesignCode)).Remove();  
                    }  
                }  
            }  
            cmbZone.Enabled = true;  
            cmbDashlets.Enabled = true;  
            if (cmbTableLayouts.Items.Count == 0)  
            {  
                trZoneLayout.Visible = false;  
            }  
            //  }  
        }  
        catch (Exception ex)  
        {  
            LogMessage(ex, 1, "rdDockLayout_LoadDockLayout");  
        }  
    }  
 
    protected void rdDockLayout_SaveDockLayout(object sender, DockLayoutEventArgs e)  
    {  
        CurrentDockStates = rdDockLayout.GetRegisteredDocksState();  
    }  
 
    protected void btnAddDock_Click(object sender, EventArgs e)  
    {  
        try  
        {  
            UserControl uclDashlets = (UserControl)Page.LoadControl(Convert.ToString(cmbDashlets.SelectedValue));  
            strDockTag = Convert.ToString(cmbDashlets.SelectedValue);  
 
            RadDock dock = CreateRadDock();  
            RadDockZone dz = (RadDockZone)rdDockLayout.FindControl(Convert.ToString(cmbZone.SelectedValue));  
 
            dz.Controls.Add(dock);  
            dock.Tag = strDockTag;  
            LoadWidget(dock);  
        }  
        catch (Exception ex)  
        {  
            LogMessage(ex, 1, "btnAddDock_Click");  
        }  
    }  
 
    protected void btnAddZone_Click(object sender, EventArgs e)  
    {  
        try  
        {  
            if (cmbTableLayouts.SelectedValue == "1") //-- 1 Row 1 Column  
            {  
                RadDockZone3.Visible = true;  
                lblZone3.Visible = true;  
                strRegisteredZones = RadDockZone3.ID;  
            }  
            else //-- 1 Row 2 Column  
            {  
                RadDockZone1.Visible = true;  
                RadDockZone2.Visible = true;  
                lblZone1.Visible = true;  
                lblZone2.Visible = true;  
                strRegisteredZones = RadDockZone1.ID + "," + RadDockZone2.ID;  
            }  
 
            //--Save ZoneID and ZoneLayout in Database and remove selected item from cmbTableLayouts       
            objDockStateWS = new DockStateWS();  
            dsDataSet = new DataSet();  
            dsDataSet = objDockStateWS.Insert_UserZoneSettings(0, Convert.ToInt32(cmbTableLayouts.SelectedValue), strRegisteredZones, nLoggedInUserId, nPageId, nLoggedInUserId);  
 
            if (dsDataSet.Tables["Response"].Rows[0]["ResultCode"].ToString() != "0")  
            {  
                strResult = dsDataSet.Tables["Response"].Rows[0]["ResultString"].ToString();  
                LogMessage(new Exception(strResult), 1, "btnSaveDock_Click");  
                return;  
            }  
            cmbTableLayouts.SelectedItem.Remove();  
            cmbZone.Enabled = true;  
            //cmbSelectDock.Enabled = true;  
            cmbDashlets.Enabled = true;  
 
            if (cmbTableLayouts.Items.Count == 0)  
            {  
                trZoneLayout.Visible = false;  
            }  
        }  
        catch (Exception ex)  
        {  
            LogMessage(ex, 1, "btnAddZone_Click");  
        }  
    }  
 
    public ArrayList GetZones()  
    {  
        ArrayList zones = new ArrayList();  
 
        zones.Add(RadDockZone1);  
        zones.Add(RadDockZone2);  
        zones.Add(RadDockZone3);  
 
        return zones;  
    }  
 
    private List<DockState> CurrentDockStates  
    {  
        get  
        {  
            List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesMyPortal"];  
            if (Object.Equals(_currentDockStates, null))  
            {  
                _currentDockStates = new List<DockState>();  
                Session["CurrentDockStatesMyPortal"] = _currentDockStates;  
            }  
            return _currentDockStates;  
        }  
        set  
        {  
            Session["CurrentDockStatesMyPortal"] = value;  
        }  
    }  
 
    private RadDock CreateRadDockFromState(DockState state)  
    {  
        RadDock dock = new RadDock();  
        dock.ID = string.Format("RadDock{0}", state.UniqueName);  
        dock.ApplyState(state);  
        dock.Command += new DockCommandEventHandler(dock_Command);  
        dock.Commands.Add(new DockCloseCommand());  
        dock.CommandsAutoPostBack = true;   //  rt now commented     
        return dock;  
    }  
 
    private RadDock CreateRadDock()  
    {  
        int docksCount = CurrentDockStates.Count;  
        string strCount = System.DateTime.Now.Millisecond.ToString();  
        RadDock dock = new RadDock();  
        dock.AutoPostBack = true;  
        //dock.Title = cmbSelectDock.SelectedItem.Text;  
        dock.Title = Convert.ToString(cmbDashlets.SelectedItem.Text);  
        dock.Text = string.Format("Added at {0}", DateTime.Now);  
        dock.ID = string.Format("RadDock{0}", strCount);  
        dock.UniqueName = string.Format("Dock {0}", strCount);  
 
        //rt now added  
        dock.Commands.Add(new DockCloseCommand());  
        dock.Commands.Add(new DockExpandCollapseCommand());  
        dock.Command += new DockCommandEventHandler(dock_Command);  
 
        return dock;  
    }  
 
    private void BindDockZoneTableLayouts()  
    {  
        try  
        {  
            objDockStateWS = new DockStateWS();  
            dsDataSet = new DataSet();  
            dsDataSet = objDockStateWS.Fetch_DockZoneTableLayouts(0);  
            cmbTableLayouts.DataSource = dsDataSet;  
            cmbTableLayouts.DataTextField = "dock_zone_layout";  
            cmbTableLayouts.DataValueField = "dock_zone_layout_id";  
            cmbTableLayouts.DataBind();  
            cmbTableLayouts.Items.Insert(0, new RadComboBoxItem("Select", ""));  
        }  
        catch (Exception ex)  
        {  
            LogMessage(ex, 1, "BindDockZoneTableLayouts");  
        }  
    }  
 
    private void BindDashlets()  
    {  
        try  
        {  
            objDockStateWS = new DockStateWS();  
            dsDataSet = new DataSet();  
            dsDataSet = objDockStateWS.Fetch_Dashlest(0);  
 
            cmbDashlets.DataSource = dsDataSet;  
            cmbDashlets.DataTextField = "dock_dashlets_name";  
            cmbDashlets.DataValueField = "dock_dashlects_value";  
            cmbDashlets.DataBind();  
            cmbDashlets.Items.Insert(0, new RadComboBoxItem("Select", ""));  
        }  
        catch (Exception ex)  
        {  
            LogMessage(ex, 1, "BindDashlets");  
        }  
    }  
 
    private void LoadWidget(RadDock dock)  
    {  
        try  
        {  
            if (string.IsNullOrEmpty(dock.Tag))  
            {  
                return;  
            }  
            else  
            {  
                Control widget = LoadControl(dock.Tag);  
                dock.ContentContainer.Controls.Add(widget);  
            }  
        }  
        catch (Exception ex)  
        {  
            LogMessage(ex, 1, "LoadWidget");  
        }  
    }  
 
    private void LoadDockState()  
    {  
        for (int i = 0; i < CurrentDockStates.Count; i++)  
        {  
            if (CurrentDockStates[i].Closed == false)  
            {  
                RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);  
                rdDockLayout.Controls.Add(dock);  
                RadDockZone dz = (RadDockZone)rdDockLayout.FindControl(Convert.ToString(dock.DockZoneID));  
                if (dz != null)  
                {  
                    dz.Visible = true;  
                }  
                LoadWidget(dock);  
            }  
        }  
    }  
 
    void dock_Command(object sender, DockCommandEventArgs e)  
    {  
        try  
        {  
            if (e.Command.Name == "Close")  
            {  
                (((RadDock)sender)).Closed = true;  
            }  
        }  
        catch (Exception ex)  
        {  
            LogMessage(ex, 1, "dock_Command");  
        }  
    }  
 
    void LogMessage(Exception e, Int32 param, string strMethodName)  
    {  
        if (param == 1)  
        {  
            lblMessage.Text = e.Message + "  Method:- " + strMethodName;  
            lblMessage.CssClass = "error";  
        }  
        else  
        {  
            lblMessage.Text = e.Message;  
            lblMessage.CssClass = "success";  
        }  
    }  
}  
 
WebMethods  
 
  [WebMethod]  
    public DataSet Fetch_DockZoneTableLayouts(long nSessionId)  
    {  
        int nResultCode = -1;  
        string strResult = "Fail - ";  
        SqlDataAdapter m_SqlDataAdapter = null;  
        DataTable m_DataTable = new DataTable("DockZoneTableLayouts");  
        string szColumns = string.Empty;  
        string szTemp = string.Empty;  
        string szFilter = string.Empty;  
        m_DataSet = new DataSet();  
        strParameters = Convert.ToString(nSessionId);  
 
        try  
        {  
            int nState = 1;  
            if (nSessionId > 0)  
                nState = GetSessionState(nSessionId);  
            if (nState == 0)  
            {  
                nResultCode = -1;  
                strResult = "Your session has been expired, Please relogin again.\n " +  
                            "Method : Fetch_DockZoneTableLayouts \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
            else if (nState == 2)  
            {  
                nResultCode = -1;  
                strResult = "Unable to get session state.\n " +  
                            "Method : Fetch_DockZoneTableLayouts \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_DockZoneTableLayouts", strParameters);  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_DockZoneTableLayouts", strParameters);  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
 
        try  
        {  
            m_Connection.Openconnection();  
 
            strTemp = "SELECT dock_zone_layout_id,dock_zone_layout FROM CRM_DOCK_Zone_Table_Layouts";  
 
            m_SqlDataAdapter = new SqlDataAdapter(strTemp, m_Connection.oCon);  
            m_SqlDataAdapter.Fill(m_DataTable);  
            m_DataSet.Tables.Add(m_DataTable);  
 
            nResultCode = 0;  
            strResult = "Pass";  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult + strResult, "Fetch_DockZoneTableLayouts", strParameters);  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_DockZoneTableLayouts", strParameters);  
        }  
        finally  
        {  
            m_Connection.Closeconnection();  
        }  
        m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
        return m_DataSet;  
    }  
 
    [WebMethod]  
    public DataSet Fetch_Dashlest(long nSessionId)  
    {  
        int nResultCode = -1;  
        string strResult = "Fail - ";  
        SqlDataAdapter m_SqlDataAdapter = null;  
        DataTable m_DataTable = new DataTable("Dashlets");  
        string szColumns = string.Empty;  
        string szTemp = string.Empty;  
        string szFilter = string.Empty;  
        m_DataSet = new DataSet();  
        strParameters = Convert.ToString(nSessionId);  
 
        try  
        {  
            int nState = 1;  
            if (nSessionId > 0)  
                nState = GetSessionState(nSessionId);  
            if (nState == 0)  
            {  
                nResultCode = -1;  
                strResult = "Your session has been expired, Please relogin again.\n " +  
                            "Method : Fetch_Dashlest \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
            else if (nState == 2)  
            {  
                nResultCode = -1;  
                strResult = "Unable to get session state.\n " +  
                            "Method : Fetch_Dashlest \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_Dashlest", strParameters);  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_Dashlest", strParameters);  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
 
        try  
        {  
            m_Connection.Openconnection();  
 
            strTemp = "SELECT dock_dashlects_value,dock_dashlets_name FROM CRM_DOCK_Dashlets";  
 
            m_SqlDataAdapter = new SqlDataAdapter(strTemp, m_Connection.oCon);  
            m_SqlDataAdapter.Fill(m_DataTable);  
            m_DataSet.Tables.Add(m_DataTable);  
 
            nResultCode = 0;  
            strResult = "Pass";  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult + strResult, "Fetch_Dashlest", strParameters);  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_Dashlest", strParameters);  
        }  
        finally  
        {  
            m_Connection.Closeconnection();  
        }  
        m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
        return m_DataSet;  
    }  
 
    [WebMethod]  
    public DataSet Insert_UserZoneSettings(long nSessionId, int nTableLayoutId, string strZonesName, int nUserId, int nPageId, int nLoggedInUserId)  
    {  
        long nResultCode = -1;  
        string strResult = "Fail - ";  
 
        m_DataSet = new DataSet();  
        m_SqlCommand = new SqlCommand();  
 
        strParameters = nSessionId + "," + nTableLayoutId + "," + strZonesName + "," + nUserId + "," + nPageId + "," + nLoggedInUserId + "," + strIPAddress;  
        try  
        {  
            int nState = 1;  
            if (nSessionId > 0)  
                nState = GetSessionState(nSessionId);  
            if (nState == 0)  
            {  
                nResultCode = -1;  
                strResult = "Your session has been expired, Please relogin again.\n " +  
                            "Method : Insert_UserZoneSettings \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
            else if (nState == 2)  
            {  
                nResultCode = -1;  
                strResult = "Unable to get session state.\n " +  
                            "Method : Insert_UserZoneSettings \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
 
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
 
        try  
        {  
            m_Connection.Openconnection();  
 
            string strTemp = "INSERT INTO CRM_DOCK_User_Zone_Settings " +  
                             "(zone_setting_table_layout_id,zone_setting_zones_name,zone_setting_user_id, " +  
                             "zone_setting_page_id,zone_setting_created_by,zone_setting_created_date, " +  
                             "zone_setting_created_ip) " +  
                             "VALUES (" + nTableLayoutId + ",@strZonesName," + nUserId + "," + nPageId + "," + nLoggedInUserId + ",GetDate(),@strIPAddress) ";  
 
            m_SqlCommand = new SqlCommand(strTemp, m_Connection.oCon);  
            m_SqlCommand.Parameters.Add("@strZonesName", SqlDbType.VarChar).Value = strZonesName;  
            m_SqlCommand.Parameters.Add("@strIPAddress", SqlDbType.VarChar).Value = strIPAddress;  
 
            m_SqlCommand.ExecuteNonQuery();  
            nResultCode = 0;  
            strResult = "Pass - ";  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Insert_UserZoneSettings", strParameters);  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Insert_UserZoneSettings", strParameters);  
        }  
        finally  
        {  
            m_Connection.Closeconnection();  
        }  
        m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
        return m_DataSet;  
    }  
 
    [WebMethod]  
    public DataSet Insert_DashBoardState(long nSessionId, int nLoggedInUserId, string strDockState, int nPageId)  
    {  
        long nResultCode = -1;  
        string strResult = "Fail - ";  
        int value = 0;  
        string strTemp = "";  
 
        m_DataSet = new DataSet();  
        m_SqlCommand = new SqlCommand();  
 
        strParameters = nSessionId + "," + nLoggedInUserId;  
        try  
        {  
            int nState = 1;  
            if (nSessionId > 0)  
                nState = GetSessionState(nSessionId);  
            if (nState == 0)  
            {  
                nResultCode = -1;  
                strResult = "Your session has been expired, Please relogin again.\n " +  
                            "Method : Insert_DashBoardState \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
            else if (nState == 2)  
            {  
                nResultCode = -1;  
                strResult = "Unable to get session state.\n " +  
                            "Method : Insert_DashBoardState \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
 
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
 
        try  
        {  
            m_Connection.Openconnection();  
            //--Delete Exist DashBoard State  
            strTemp = "DELETE FROM CRM_DOCK_DashBoard_State WHERE dock_dashboard_state_user_id =" + nLoggedInUserId + " AND dock_dashboard_state_page_id = " + nPageId;  
            m_SqlCommand = new SqlCommand(strTemp, m_Connection.oCon);  
            m_SqlCommand.ExecuteNonQuery();  
 
            //--Insert DashBoard State  
            strTemp = "INSERT INTO CRM_DOCK_DashBoard_State " +  
                      "(dock_dashboard_state,dock_dashboard_state_user_id, dock_dashboard_state_page_id ," +  
                      "dock_dashboard_state_created_by,dock_dashboard_state_created_date,dock_dashboard_state_created_ip) " +  
                      "VALUES (@strDockState," + nLoggedInUserId + "," + nPageId + "," + nLoggedInUserId + ",GetDate(),@strIPAddress) ";  
 
            m_SqlCommand = new SqlCommand(strTemp, m_Connection.oCon);  
            m_SqlCommand.Parameters.Add("@strDockState", SqlDbType.VarChar).Value = strDockState;  
            m_SqlCommand.Parameters.Add("@strIPAddress", SqlDbType.VarChar).Value = strIPAddress;  
 
            value = Convert.ToInt32(m_SqlCommand.ExecuteScalar());  
            if (value > 0)  
            {  
                nResultCode = 0;  
                strResult = "Pass - ";  
            }  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Insert_DashBoardState", strParameters);  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Insert_DashBoardState", strParameters);  
        }  
        finally  
        {  
            m_Connection.Closeconnection();  
        }  
        m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
        return m_DataSet;  
    }  
 
    [WebMethod]  
    public DataSet Fetch_DashBoardState(long nSessionId, int nLoggedInUserId, int nPageId)  
    {  
        int nResultCode = -1;  
        string strResult = "Fail - ";  
        SqlDataAdapter m_SqlDataAdapter = null;  
        DataTable m_DataTable = new DataTable("DockState");  
        string szColumns = string.Empty;  
        string szTemp = string.Empty;  
        string szFilter = string.Empty;  
        m_DataSet = new DataSet();  
        strParameters = nSessionId + "," + nLoggedInUserId + "," + nPageId;  
 
        try  
        {  
            int nState = 1;  
            if (nSessionId > 0)  
                nState = GetSessionState(nSessionId);  
            if (nState == 0)  
            {  
                nResultCode = -1;  
                strResult = "Your session has been expired, Please relogin again.\n " +  
                            "Method : Fetch_DashBoardState \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
            else if (nState == 2)  
            {  
                nResultCode = -1;  
                strResult = "Unable to get session state.\n " +  
                            "Method : Fetch_DashBoardState \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_DashBoardState", strParameters);  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_DashBoardState", strParameters);  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
 
        try  
        {  
            m_Connection.Openconnection();  
 
            strTemp = "SELECT dock_dashboard_state, dock_dashboard_state_user_id, " +  
                      "dock_dashboard_state_created_by, dock_dashboard_state_created_date, " +  
                      "dock_dashboard_state_created_ip,dock_dashboard_state_page_id " +  
                      "FROM CRM_DOCK_DashBoard_State " +  
                      "WHERE  dock_dashboard_state_user_id = " + nLoggedInUserId + " AND dock_dashboard_state_page_id =" + nPageId;  
 
            m_SqlDataAdapter = new SqlDataAdapter(strTemp, m_Connection.oCon);  
            m_SqlDataAdapter.Fill(m_DataTable);  
            m_DataSet.Tables.Add(m_DataTable);  
 
            nResultCode = 0;  
            strResult = "Pass";  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult + strResult, "Fetch_DashBoardState", strParameters);  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_DashBoardState", strParameters);  
        }  
        finally  
        {  
            m_Connection.Closeconnection();  
        }  
        m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
        return m_DataSet;  
    }  
 
    [WebMethod]  
    public DataSet Fetch_UserZoneSettings(long nSessionId, int nLoggedInUserID, int nPageId)  
    {  
        int nResultCode = -1;  
        string strResult = "Fail - ";  
        SqlDataAdapter m_SqlDataAdapter = null;  
        DataTable m_DataTable = new DataTable("DockZoneSettings");  
        string szColumns = string.Empty;  
        string szTemp = string.Empty;  
        string szFilter = string.Empty;  
        m_DataSet = new DataSet();  
        strParameters = nSessionId + "," + nLoggedInUserID + "," + nPageId;  
 
        try  
        {  
            int nState = 1;  
            if (nSessionId > 0)  
                nState = GetSessionState(nSessionId);  
            if (nState == 0)  
            {  
                nResultCode = -1;  
                strResult = "Your session has been expired, Please relogin again.\n " +  
                            "Method : Fetch_UserZoneSettings \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
            else if (nState == 2)  
            {  
                nResultCode = -1;  
                strResult = "Unable to get session state.\n " +  
                            "Method : Fetch_UserZoneSettings \n" +  
                            "SessionID: " + nSessionId;  
                m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
                return m_DataSet;  
            }  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_UserZoneSettings", strParameters);  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_UserZoneSettings", strParameters);  
            m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
            return m_DataSet;  
        }  
 
        try  
        {  
 
            m_Connection.Openconnection();  
 
            strTemp = "SELECT zone_setting_table_layout_id,zone_setting_zones_name,zone_setting_user_id, " +  
                     "zone_setting_page_id,zone_setting_created_by,zone_setting_created_date,zone_setting_created_ip " +  
                     "FROM CRM_DOCK_User_Zone_Settings " +  
                     "WHERE zone_setting_user_id =" + nLoggedInUserID + " AND zone_setting_page_id=" + nPageId;  
 
            m_SqlDataAdapter = new SqlDataAdapter(strTemp, m_Connection.oCon);  
            m_SqlDataAdapter.Fill(m_DataTable);  
            m_DataSet.Tables.Add(m_DataTable);  
 
            nResultCode = 0;  
            strResult = "Pass";  
        }  
        catch (SqlException ex)  
        {  
            nResultCode = ex.Number;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult + strResult, "Fetch_UserZoneSettings", strParameters);  
        }  
        catch (Exception ex)  
        {  
            nResultCode = -1;  
            strResult = ex.Message;  
            LogMessage(strTemp + strResult, "Fetch_Zones_Settings", strParameters);  
        }  
        finally  
        {  
            m_Connection.Closeconnection();  
        }  
        m_DataSet.Tables.Add(GetResponseTable(nResultCode, strResult));  
        return m_DataSet;  
    }  
}  
 
 

Dear sir,

I am creating a DashBoard, and its fully customizes.In that Im not using any update panel.
the problem is when I closed any dock its closed, but continously closed next dock its not possible.
before that I have to refrsh page then it works.same with save button . once save the state then after refreshing a page then we move / close dock.

I mean on any activity  i m refreshing a page then its works..

I am sending you my code.plz help me [sry 4 poor english]

and plz answere in without using update panel


thanks with regards

 

2 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 06 Jul 2009, 09:58 AM
Hi Golu,

A page post back is needed for the dock state to be saved. So when the close command is pressed a post back should occur. As I can see from the source code that you sent you never set the CommandsAutoPostBack property of the RadDock to true in the CreateRadDock() method. Try setting it there and let me know if this solves your problem.



All the best,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Golu
Top achievements
Rank 1
answered on 09 Jul 2009, 05:25 AM
Yes ! now its working perfect

Thank you with Regards


Tags
Dock
Asked by
Golu
Top achievements
Rank 1
Answers by
Pero
Telerik team
Golu
Top achievements
Rank 1
Share this question
or