Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

Updating only one Raddock by Event Command by a RadWindow

$
0
0

Good afternoon following is for support'm working with a dashboard using Raddock
in the aspx I have the RadDockLayout and within the I have 4 Raddock zone and the dock are created in programming I can now create them but the problem I have is to create a command event to edit that Raddock which by clicking call a radwindow and edit the information but when saving the edited information is not as it should do so that the dock is displayed again with editing changes

currently the dock have a user control
I have no problems to eliminate them or close them I need to edit and I've tried so ask for your help

 

<asp:ContentID="Content1"ContentPlaceHolderID="head"runat="Server">
    <linkhref="css/common.css"rel="stylesheet"/>
    <linkhref="css/dashboard.css"rel="stylesheet"/>
    <%--    <linkhref="../../Styles/kendo.common.min.css"rel="stylesheet"/>
    <%--<linkhref="../../Styles/kendo.default.min.css"rel="stylesheet"/>--%>
    <%-- <linkhref="../../Styles/kendo.mobile.all.min.css"rel="stylesheet"/>
    <linkhref="../../Styles/kendo.bootstrap.min.css"rel="stylesheet"/>--%>
    <%--  <styletype="text/css">
        #ctl00_CPH1_verticalMenu div {
            padding: 0 !important;
        }
 
        #ctl00_CPH1_verticalMenu ul {
            border: 30px !important;
            background: rgba(218, 39, 39, 0) !important;
            margin: 0;
            padding: 0;
            width: 200px;
        }
 
        .RadMenu_sfs .rmVertical a.rmLink {
            padding-top: 0px !important;
            padding-bottom: 0px !important;
            padding-left: 0px !important;
        }
 
        .RadMenu_sfs .rmVertical > div {
            border-left: none !important;
        }
 
        .RadMenu_sfs, .RadMenu_sfs a.rmLink {
            color: white !important;
            font-family: "Segoe UI",Arial,Helvetica,sans-serif !important;
            font-weight: 100 !important;
        }
 
        #ctl00_CPH1_verticalMenu .mail:after {
            background: #C0C4C5;
        }
 
        .slider .mail .rmRootLink:before {
            background: #3C4142 !important;
        }
    </style>--%>
 
    <scripttype="text/javascript"src="Js/dashboard4.js"></script>
    <%-- <scripttype="text/javascript"src="js.min/dashboard4.js"></script>--%>
    <telerik:RadCodeBlockID="RadCodeBlock1"runat="server">
        <scripttype="text/javascript">
            serverIDs({
                ajaxID: "<%= RadAjaxPanel1.ClientID%>",
                ajaxServerID: "<%= RadAjaxPanel1.UniqueID %>",
                windowsId: "<%= newSensorWindows.ClientID%>",
                rcbSensorInventory: "<%= rcbSensorInventory.ClientID%>",
                rcSensorTYpe: "<%= rcSensorType.ClientID %>",
                rcWidgetType: "<%= rcWidgetType.ClientID %>",
                rcRadDockSensor: "<%= rcRadDockSensor.ClientID %>",
                rtbsensorName: "<%= rtbsensorName.ClientID %>",
                RadDockZone2: "<%= RadDockZone2.ClientID %>",
                regKey: "<%= dashregKey.ClientID%>",
                cliKey: "<%= dashcliKey.ClientID%>",
                entitykey: "<%= dashentitykey.ClientID%>",
                cboEntities: "<%=cboEntities.ClientID%>",
                rcRadDockSensor: "<%=rcRadDockSensor.ClientID%>",
                rcTemperatureType: "<%=rcTemperatureType.ClientID%>"
            });
        </script>
    </telerik:RadCodeBlock>
    <%-- <scripttype="text/javascript"src="../Scripts/kendo.all.min.js"></script>--%>
</asp:Content>
<asp:ContentID="Content2"ContentPlaceHolderID="CPH1"runat="Server">
 
    <inputtype="hidden"clientidmode="Static"id="dashregKey"name="regKey"runat="server"value=""/>
    <inputtype="hidden"clientidmode="Static"id="dashcliKey"name="cliKey"runat="server"value=""/>
    <inputtype="hidden"clientidmode="Static"id="dashentitykey"name="entitykey"runat="server"value=""/>
    <inputtype="hidden"clientidmode="Static"id="dashdockid"name="dashdockid"runat="server"value=""/>
    <telerik:RadAjaxLoadingPanelID="panel1"runat="server"Transparency="30"BackColor="#E0E0E0">
        <asp:ImageID="image2"runat="server"AlternateText="Actualizando Datos..."BorderWidth="0px"
            ImageUrl="images/loading1.gif"/>
    </telerik:RadAjaxLoadingPanel>
    <divclass="prueba">
        <divclass="page">
            <divclass="container clear">
                <divclass="section bottom">
 
                    <telerik:RadAjaxPanelID="RadAjaxPanel1"runat="server"LoadingPanelID="panel1"
                        OnAjaxRequest="RadAjaxPanel1_AjaxRequest"Width="100%">
 
                        <divclass="scroller">
                            <divclass="Panel"style="margin: 0 auto; width: 96.7%;">
                                <divclass="home-btn">
                                    <spanid="entityList"class="icon icon-Home"onclick="entityList()">
                                        <asp:LabelID="entTitle"runat="server"Text="<%$ Resources:Dashboard4,iotEntitiesList%> " /></span>
 
                                    <telerik:RadComboBoxrunat="server"DropDownWidth="300px"Text=""OnItemDataBound="cboEntities_ItemDataBound"ID="cboEntities"ClientIDMode="Static"Width="260px"AutoPostBack="false"Filter="Contains"Style="padding: 5px 27%;"
                                        OnSelectedIndexChanged="cboEntities_SelectedIndexChanged"OnClientSelectedIndexChanged="OnClientSelectedIndexChangedEntity"Sort="Ascending"SortCaseSensitive="true"Height="100%"MarkFirstMatch="true"/>
 
                                    <spanid="addSensor"class="icon icon-Add-Circle spanTag"onclick="addSensorWindow()"style="float: right; padding-right: 30px;">
                                        <asp:LabelID="Label1"runat="server"Text="<%$ Resources:Dashboard4,AddSensor%> " /></span>
 
                                </div>
 
 
 
                            </div>
                            <telerik:RadDockLayoutID="RadDockLayout1"runat="server"OnSaveDockLayout="RadDockLayout1_SaveDockLayout"OnLoadDockLayout="RadDockLayout1_LoadDockLayout">
 
                                <ulid="ctl00_MainContent_rlvContacts_itemPlaceholder"class="contacts-listNew">
 
                                    <li>
                                        <divclass="itemTemplateNew">
                                            <divclass="content">
                                                <telerik:RadDockZoneID="RadDockZone1"runat="server"CssClass="contacts-list"BorderColor="#F7F7F7"Orientation="Horizontal">
                                                </telerik:RadDockZone>
                                            </div>
 
                                        </div>
                                    </li>
                                </ul>
                                <ulid="Ul1"class="contacts-list">
                                    <li>
                                        <divclass="itemTemplate">
                                            <divclass="content">
                                                <telerik:RadDockZoneID="RadDockZone2"runat="server"CssClass="contacts-list"BorderColor="white"Orientation="Vertical">
                                                </telerik:RadDockZone>
                                            </div>
                                        </div>
                                    </li>
                                    <li>
                                        <divclass="itemTemplate">
                                            <divclass="content">
                                                <telerik:RadDockZoneID="RadDockZone3"runat="server"CssClass="contacts-list"BorderColor="white"Orientation="Vertical">
                                                </telerik:RadDockZone>
                                            </div>
                                        </div>
 
                                    </li>
                                    <li>
                                        <divclass="itemTemplate">
                                            <divclass="content">
                                                <telerik:RadDockZoneID="RadDockZone4"runat="server"CssClass="contacts-list"BorderColor="white"Orientation="Vertical">
                                                </telerik:RadDockZone>
 
                                            </div>
                                        </div>
                                    </li>
 
 
                                </ul>
                            </telerik:RadDockLayout>
                        </div>
                        <telerik:RadWindowrunat="server"ID="newSensorWindows"Width="600px"Title="New Sensor "Heigth="380px"MinHeight="370px"VisibleStatusbar="false"ReloadOnShow="true"Behaviors="Close"Style="z-index: 2345"Modal="true">
                            <ContentTemplate>
                                <divstyle="width: 90%; margin: 0 auto; height: 320px">
                                    <divclass="Panel">
                                        <divstyle="float: left">
                                            <asp:LabelID="sensorTitle"runat="server"Text="<%$ Resources:Dashboard4,AddSensor%>" />
                                        </div>
                                    </div>
 
                                    <divclass="PanelContent"style="height: 80%; overflow: auto; padding-top: 10px; padding-left: 100px">
                                        <divclass="row"style="margin: 10px;">
                                            <%-- <label><%$ Resources:Dashboard4,sensorName%></label>--%>
                                            <asp:LabelID="lbsensorname"runat="server"Text="<%$ Resources:Dashboard4,sensorName%>" Width="160"></asp:Label>
                                            <telerik:RadTextBoxrunat="server"ID="rtbsensorName"AutoPostBack="false"></telerik:RadTextBox>
                                            <asp:RequiredFieldValidatorrunat="server"ID="RequiredFieldValidator1"ControlToValidate="rtbsensorName"
                                                Display="Dynamic"ErrorMessage="!"CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
                                        <divclass="row"style="margin: 10px;">
                                            <%--<label><%$ Resources:Dashboard4,sensorStock%></label>--%>
                                            <asp:LabelID="Label2"runat="server"Text="<%$ Resources:Dashboard4,sensorStock%>" Width="160"></asp:Label>
                                            <telerik:RadComboBoxID="rcbSensorInventory"Height="200"runat="server"Width="176px"ClientIDMode="Static"AutoPostBack="true"Filter="Contains"MaxHeight="200px"
                                                EmptyMessage="- Select a Sensor -"ZIndex="1000000"OnDataBound="rcbSensorInventory_DataBound"DropDownAutoWidth="Enabled"HighlightTemplatedItems="true"OnClientSelectedIndexChanged="OnClientSelectedIndexChanged">
                                                <HeaderTemplate>
                                                    <tablestyle="width: 300px"cellspacing="0"cellpadding="0">
                                                        <tr>
                                                            <tdstyle="width: 75px;">
                                                                <asp:LabelID="Label2"runat="server"Text="<%$ Resources:Dashboard4,imei%>"></asp:Label>
                                                            </td>
                                                            <tdstyle="width: 100px;">
                                                                <asp:LabelID="Label6"runat="server"Text="<%$ Resources:Dashboard4,brand%>"></asp:Label>
                                                            </td>
                                                            <tdstyle="width: 125px;">
                                                                <asp:LabelID="Label7"runat="server"Text="<%$ Resources:Dashboard4,model%>"></asp:Label>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <tablestyle="width: 300px"cellspacing="0"cellpadding="0">
                                                        <tr>
                                                            <tdstyle="width: 75px;">
                                                                <%# DataBinder.Eval(Container, "Text")%>
                                                            </td>
                                                            <tdstyle="width: 100px;">
                                                                <%# DataBinder.Eval(Container, "Attributes['Marca']")%>
                                                            </td>
                                                            <tdstyle="width: 125px;">
                                                                <%# DataBinder.Eval(Container, "Attributes['Modelo']")%>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </ItemTemplate>
                                            </telerik:RadComboBox>
                                            <asp:RequiredFieldValidatorrunat="server"ID="RequiredFieldValidator5"ControlToValidate="rcbSensorInventory"
                                                Display="Dynamic"ErrorMessage="!"CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
                                        <divclass="row"style="margin: 10px;">
                                            <%--<label><%$ Resources:Dashboard4,sensorType%></label>--%>
                                            <asp:LabelID="Label3"runat="server"Text="<%$ Resources:Dashboard4,sensorType%>" Width="160"></asp:Label>
                                            <telerik:RadComboBoxID="rcSensorType"runat="server"Width="176px"ClientIDMode="Static"AutoPostBack="false"OnClientSelectedIndexChanged="checkifisTemperature"
                                                EmptyMessage="- Select a Sensor Type -"ZIndex="1000000">
                                            </telerik:RadComboBox>
                                            <asp:RequiredFieldValidatorrunat="server"ID="RequiredFieldValidator2"ControlToValidate="rcSensorType"
                                                Display="Dynamic"ErrorMessage="!"CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
                                        <divid="tempDiv"class="row"style="margin: 10px;">
                                            <%--<label><%$ Resources:Dashboard4,sensorType%></label>--%>
                                            <asp:LabelID="Label8"runat="server"Text="<%$ Resources:Dashboard4,temperatureUnit%>" Width="160"></asp:Label>
                                            <telerik:RadComboBoxID="rcTemperatureType"runat="server"Width="176px"ClientIDMode="Static"AutoPostBack="false"
                                                EmptyMessage="- Select a Temperature Type -"ZIndex="1000000">
                                            </telerik:RadComboBox>
                                            <%--<asp:RequiredFieldValidatorrunat="server"ID="RequiredFieldValidator6"ControlToValidate="rcTemperatureType"
                                                Display="Dynamic"ErrorMessage="!"CssClass="validator">
                                            </asp:RequiredFieldValidator>--%>
                                        </div>
                                        <divclass="row"style="margin: 10px;">
                                            <%--<labelstyle="margin-right: 37px;"><%$ Resources:Dashboard4,widgetType%></label>--%>
                                            <asp:LabelID="Label4"runat="server"Text="<%$ Resources:Dashboard4,widgetType%>" Width="160"></asp:Label>
                                            <telerik:RadComboBoxID="rcWidgetType"runat="server"Width="176px"ClientIDMode="Static"AutoPostBack="false"
                                                EmptyMessage="- Select a Widget Type -"ZIndex="10001">
                                            </telerik:RadComboBox>
                                            <asp:RequiredFieldValidatorrunat="server"ID="RequiredFieldValidator3"ControlToValidate="rcWidgetType"
                                                Display="Dynamic"ErrorMessage="!"CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
                                        <divid="locationID"class="row"style="margin: 10px;">
                                            <%--<labelstyle="margin-right: 20px;"><%$ Resources:Dashboard4,widgetLocation%></label>--%>
                                            <asp:LabelID="Label5"runat="server"Text="<%$ Resources:Dashboard4,widgetLocation%>" Width="160"></asp:Label>
                                            <telerik:RadComboBoxID="rcRadDockSensor"runat="server"Width="176px"ClientIDMode="Static"AutoPostBack="false"
                                                EmptyMessage="- Select Dock Location -"ZIndex="1000000">
                                            </telerik:RadComboBox>
                                            <asp:RequiredFieldValidatorrunat="server"ID="RequiredFieldValidator4"ControlToValidate="rcRadDockSensor"
                                                Display="Dynamic"ErrorMessage="!"CssClass="validator">
                                            </asp:RequiredFieldValidator>
                                        </div>
 
                                        <divid="saveDiv"style="text-align: center; padding-top: 7px">
 
                                            <telerik:RadButtonID="SaveData"runat="server"AutoPostBack="false"Text="<%$ Resources:language,save %>" OnClientClicked="addDock">
                                                <IconPrimaryIconCssClass="rbEdit"PrimaryIconLeft="4px"PrimaryIconTop="4px"/>
                                            </telerik:RadButton>
                                        </div>
                                        <divid="editDiv"style="text-align: center; padding-top: 7px">
 
                                            <telerik:RadButtonID="RadButton1"runat="server"AutoPostBack="false"Text="<%$ Resources:language,Edit %>" OnClientClicked="editDock">
                                                <IconPrimaryIconCssClass="rbEdit"PrimaryIconLeft="4px"PrimaryIconTop="4px"/>
                                            </telerik:RadButton>
                                        </div>
                                        <telerik:RadNotificationID="RadNotification1"runat="server"Position="Center"
                                            Width="250px"EnableRoundedCorners="true"VisibleTitlebar="True"TitleIcon="none"ContentIcon="none"CssClass="boxcontainer"Title="Mensaje"AnimationDuration="0"AutoCloseDelay="0">
                                        </telerik:RadNotification>
                            </ContentTemplate>
                        </telerik:RadWindow>
                    </telerik:RadAjaxPanel>
                </div>
            </div>
        </div>
    </div>
    <divclass="tm-click-overlay"></div>
 
    <asp:HiddenFieldrunat="server"ID="nav"/>
 
</asp:Content>

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using sFleet.General;
using sfleet.Api;
using sfleet.General;
using sfleet.dashboardModels;
 
public partial class app_DashBoard : app_Page
{
    enum WidgetType { ImageDock, BarWidget, GaugeChart, RadarChart, Weather, Gauge, AreaChart, KendoAreaChart };
    string[] PrimaryDockZone = new string[] { "RadDockZone1" };
    string[] SensorDockZone = new string[] { "RadDockZone2", "RadDockZone3", "RadDockZone4" };
    private int regkey = 0, clikey = 0, entkey = 0;
 
 
 
    private void LoadWidget(RadDock dock)
    {
        if (string.IsNullOrEmpty(dock.Tag))
            return;
        Control widget = LoadControl(dock.Tag);
        dock.ContentContainer.Controls.Add(widget);
    }
 
    public void loadVariable()
    {
        //if (regkey != 0)
        regkey = Convert.ToInt32(Session["RegionKey"]);
        // if (clikey != 0)
        clikey = Convert.ToInt32(Session["ClientKey"]);
        entkey = Convert.ToInt32(Session["EntityKey"]);
 
        //Session["EntityKey"] = entkey;
        this.dashregKey.Value = regkey.ToString();
        this.dashcliKey.Value = clikey.ToString();
        this.dashentitykey.Value = entkey.ToString();
    }
 
   
    protected void Page_Init(object sender, EventArgs e)
    {
        //loadEntitiesList();
         
          loadVariable();
 
        if (entkey == 0)
        {
            Response.Redirect("iotEntities.Aspx");
        }
        //Recreate the docks in order to ensure their proper operation
        for (int i = 0; i < CurrentDockStates.Count; i++)
        {
            if (CurrentDockStates[i].Closed == true) continue;
            RadDock dock= CreateRadDockFromState(CurrentDockStates[i]);
 
            //We will just add the RadDock control to the RadDockLayout.
            // You could use any other control for that purpose, just ensure
            // that it is inside the RadDockLayout control.
            // The RadDockLayout control will automatically move the RadDock
            // controls to their corresponding zone in the LoadDockLayout
            // event (see below).
            RadDockLayout1.Controls.Add(dock);
            //We want to save the dock state every time a dock is moved.
            CreateSaveStateTrigger(dock);
            LoadWidget(dock);
 
            // prevents the rendering of closed docks, used for improving
            // performance
            if (CurrentDockStates[i].Closed == true)
            {
                dock.Visible= false;
            }
        }
 
 
    }
 
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        //string title= this.Page.Title;
        this.Page.Title= "";
        nav.Value= "desktop";
        if (!Page.IsPostBack && !Page.IsCallback)
        {
            //if (this.RadDockZone1.Docks.Count < 2)
            //{
            //    CreateDockforGatewayZone();
            //}
            loadSensorInventory();
            loadEntitiesList();
            loadWidgetType();
            loadRadDockZoneSensor();
            loadTemperatureType();
        }
 
 
 
    }
 
    private RadDock CreateRadDockFromState(DockState state)
    {
        RadDock dock= newRadDock();
        dock.DockMode= DockMode.Docked;
        dock.ID= string.Format("RadDock{0}", state.UniqueName);
        dock.Title= state.Title;
        dock.CssClass= "higherZIndex new";
        dock.EnableRoundedCorners= true;
        dock.BackColor= System.Drawing.Color.White;
        dock.BorderColor= System.Drawing.Color.LightGray;
        dock.ForbiddenZones= getZone(state);
        dock.RenderMode= RenderMode.Lightweight;//RenderMode.Lightweight;
        dock.CommandsAutoPostBack= true;
        dock.ApplyState(state);
        var close= newDockCloseCommand();
        close.CssClass= "CloseCustom";
        close.AutoPostBack= true;
        dock.Commands.Add(close);
        dock.Command += new DockCommandEventHandler(dock_Command);
        //dock.Commands.Add(new DockCloseCommand());
        //dock.Commands.Add(new DockExpandCollapseCommand());
        var editCommand= newDockCommand();
        
        editCommand.Name= "Edit";
        editCommand.CssClass= "EditCustom";
        editCommand.OnClientCommand= "EditWidget";
        editCommand.AutoPostBack= false;
        dock.Commands.Add(editCommand);
        return dock;
 
    }
 
 
    private void CreateSaveStateTrigger(RadDock dock)
    {
        //Ensure that the RadDock control will initiate postback
        // when its position changes on the client or any of the commands is clicked.
        //Using the trigger we will "ajaxify" that postback.
        dock.AutoPostBack= true;
        dock.CommandsAutoPostBack= false;
         
    }
 
    void dock_Command(object sender, DockCommandEventArgs e)
    {
        if (e.Command.Name == "Close")
        {
            //Delete Sensor
            var dockid = ((Telerik.Web.UI.RadDock)(sender)).UniqueName;
            var iot= newsfDataAccess();
            iot.DeleteRadDockSensor(regkey, clikey, entkey, dockid);
            //Delete Dock
            sender.ToString();
            //var current= CurrentDockStates;
            rcbSensorInventory.Items.Clear();
            loadSensorInventory();
        }
         
         
 
    }
 
    //private void LoadMobile(DeviceScreenDimensions screenDimensions)
    //{
 
    //}
 
    private void CreateDockforGatewayZone()
    {
 
        WidgetType[] values = (WidgetType[])Enum.GetValues(typeof(WidgetType));
 
        int PrimaryDock= 3- this.RadDockZone1.Docks.Count;
 
        for (int i= 0; i < PrimaryDock; i++)
        {
            //WidgetType widget= ParseEnum<WidgetType>(widType[i]);
            //RadDock dock = CreateRadDock(widget, ForbZone);
 
            RadDock dock = CreateRadDock(values[i], SensorDockZone, "Widget "+i, 32, 350);
            RadDockLayout1.Controls.Add(dock);
            dock.Dock(RadDockZone1);
            CreateSaveStateTrigger(dock);
        }
 
    }
 
    private RadDock CreateRadDock(WidgetType widget, string[] zone, string Title, int dockWidth, int dockHeight)
    {
        RadDock dock = new RadDock();
        dock.DockMode = DockMode.Docked;
        dock.UniqueName = Guid.NewGuid().ToString().Replace("-", "a");
        dock.ID = string.Format("RadDock{0}", dock.UniqueName);
        dock.Title = Title;
        dock.Text = string.Format("Add to {0}", DateTime.Now);
        dock.RenderMode = RenderMode.Native;//RenderMode.Lightweight;
        dock.ForbiddenZones = zone;
        //dock.Style = "margin-left: 100px;";
        dock.BorderColor = System.Drawing.Color.LightGray;
        dock.BackColor = System.Drawing.Color.White;
        dock.CommandsAutoPostBack = false;
        dock.CssClass = "higherZIndex new";
        //if (dockHeight == 300)
        //{
        dock.Width = Unit.Percentage(dockWidth);
        //dock.Height = Unit.Percentage(dockHeight);
        //}
        //else
        //{
        //    dock.Width = Unit.Pixel(dockWidth);
            dock.Height = Unit.Pixel(dockHeight);
        //}
         
        dock.DockHandle = DockHandle.TitleBar;
        dock.Tag = getTag(widget);
        dock.EnableRoundedCorners = true;
         
        LoadWidget(dock);
        var close = new DockCloseCommand();
        close.AutoPostBack = true;
        close.CssClass = "CloseCustom";
        dock.Commands.Add(close);
        dock.Command += new DockCommandEventHandler(dock_Command);
         
        var editCommand = new DockCommand();
        editCommand.Name = "Edit";
        editCommand.CssClass = "EditCustom";
        editCommand.OnClientCommand = "EditWidget";
        editCommand.AutoPostBack = false;
        dock.Commands.Add(editCommand);
 
        return dock;
    }
 
    protected void RadAjaxPanel1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "AddDock")
        {
            
 
            try
            {
                //RadAjaxPanel1.ResponseScripts.Add("../Scripts/kendo.all.min.js");
                var sensor = new sfsSensor();
                sensor.SensorName = this.rtbsensorName.Text;
                sensor.regionKey = regkey;
                sensor.clientKey = clikey;
                sensor.entityKey = entkey;
                sensor.sensorTypeKey = Convert.ToInt32(this.rcSensorType.SelectedValue);
                sensor.sensorInv_Key = Convert.ToInt32(this.rcbSensorInventory.SelectedValue);
                int width, heigth;
                width = 40;
                heigth = 345;
                if (sensor.sensorTypeKey == 7)
                {
                    sensor.temperatureType = Convert.ToChar(rcTemperatureType.SelectedValue);
                }
 
                RadDock dock = CreateRadDock(WidgetType.BarWidget, PrimaryDockZone, sensor.SensorName, width, heigth);
 
                sensor.sensorDockId = dock.UniqueName;
 
                var iot = new sfDataAccess();
                iot.saveIotSensor(sensor);
                RadDockLayout1.Controls.Add(dock);
                var radzone = Page.Master.FindControl("CPH1").FindControl(this.rcRadDockSensor.SelectedValue) as RadDockZone;
                dock.Dock(radzone);
                CreateSaveStateTrigger(dock);
                dock.Closed = false;
 
                //RadAjaxPanel1.ResponseScripts.Add("../Scripts/kendo.all.min.js");
 
                rcbSensorInventory.Items.Clear();
                loadSensorInventory();
 
                RadNotification1.Text = "Sensor Agregado Correctamente";
                RadNotification1.Show();
 
                //ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('Hello World');", true);setTimeout(updateSensor, sfs.timer, sfs.sensorKey);
                //RadAjaxPanel1.ResponseScripts.Add("setTimeout(updateSensor, "+60000+", "+sensor.sensorKey+");");
            }
            catch (Exception ex)
            {
                var iot = new sfGenerall();
                iot.InsertErrorLog(ex);
                RadNotification1.Text = ex.ToString();
                RadNotification1.Show();
                 
            }
           
             
        }
 
        if (e.Argument == "EditDock")
        {
            try
            {
                var sensor = new sfsSensor();
                sensor.SensorName = this.rtbsensorName.Text;
                sensor.regionKey = regkey;
                sensor.clientKey = clikey;
                sensor.entityKey = entkey;
                sensor.sensorTypeKey = Convert.ToInt32(this.rcSensorType.SelectedValue);
                sensor.sensorInv_Key = Convert.ToInt32(this.rcbSensorInventory.SelectedValue);
 
                if (sensor.sensorTypeKey == 7)
                {
                    sensor.temperatureType = Convert.ToChar(rcTemperatureType.SelectedValue);
                }
                else
                {
                    sensor.temperatureType = 'C';
                }
 
                var iot = new sfDataAccess();
                iot.updateIotSensor(sensor);
                string dockid = dashdockid.Value;
                //var raddock = iot.LoadRadDockState(sensor.regionKey, sensor.clientKey, sensor.entityKey);
 
                //foreach (var oneDock in CurrentDockStates)
                //{
                //    RadDock dock = CreateRadDockFromState(oneDock);
                //    if (oneDock.UniqueName == dockid)
                //    {
                //        dock.Title = sensor.SensorName;
                //        dock.Tag = getTag(WidgetType.BarWidget);
                         
                //    }
                //    RadDockLayout1.Controls.Add(dock);
                //    //We want to save the dock state every time a dock is moved.
                //    CreateSaveStateTrigger(dock);
                //    LoadWidget(dock);
                //}
 
                foreach (var item in RadDockLayout1.Controls)
                {
                    var x = item;
                }
                 
                for (int i = 0; i < CurrentDockStates.Count; i++)
                {
                    if (CurrentDockStates[i].Closed == true) continue;
                    RadDock dock= CreateRadDockFromState(CurrentDockStates[i]);
                    var resp1= RadDockZone1.Docks.Contains(dock);
                    var resp2= RadDockZone2.Docks.Contains(dock);
                    var resp3= RadDockZone3.Docks.Contains(dock);
                    if (dock.UniqueName == dockid)
                    {
                        RadDockLayout1.Controls.RemoveAt(i);
                        dock.Title= sensor.SensorName;
                        dock.Tag= getTag(WidgetType.BarWidget);
                    }
                    //We will just add the RadDock control to the RadDockLayout.
                    // You could use any other control for that purpose, just ensure
                    // that it is inside the RadDockLayout control.
                    // The RadDockLayout control will automatically move the RadDock
                    // controls to their corresponding zone in the LoadDockLayout
                    // event (see below).
                    //RadDockLayout1.Controls.Add(dock);
                    //We want to save the dock state every time a dock is moved.
                    //CreateSaveStateTrigger(dock);
                    //LoadWidget(dock);
 
                    // prevents the rendering of closed docks, used for improving
                    // performance
                    if (CurrentDockStates[i].Closed == true)
                    {
                        dock.Visible= false;
                    }
                }
                CurrentDockStates=RadDockLayout1.GetRegisteredDocksState();
                 
 
            }
            catch (Exception ex)
            {
                var iot= newsfGenerall();
                iot.InsertErrorLog(ex);
                RadNotification1.Text= ex.ToString();
                RadNotification1.Show();
 
            }
 
        }
 
        
 
    }
 
    protected void RadDock1_Command(object sender, Telerik.Web.UI.DockCommandEventArgs e)
    {
        if (e.Command.Name == "Close")
        {
 
        }
 
    }
 
    #region raddockState
    protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
    {
 
        //Populate the event args with the state information. The RadDockLayout control
        // will automatically move the docks according that information.
        foreach (DockState state in CurrentDockStates)
        {
 
            e.Positions[state.UniqueName] = state.DockZoneID;
            e.Indices[state.UniqueName] = state.Index;
        }
 
 
    }
 
    protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
    {
        //Save the dock state in the page Session. This will enable us
        // to recreate the dock in the next Page_Init.
 
        CurrentDockStates= RadDockLayout1.GetRegisteredDocksState();
 
    }
 
 
 
    #endregion
 
    #region raddockState
 
    private List<DockState> CurrentDockStates
    {
        get
        {
            var iot = new sfDataAccess();
            List<DockState> _currentDockSates = iot.LoadRadDockState(regkey, clikey, entkey);
            //List<DockState> _currentDockSates = (List<DockState>)Session["CurrentDockStatesDynamicDock"];
            if (Object.Equals(_currentDockSates, null))
            {
                _currentDockSates = new List<DockState>();
            }
            return _currentDockSates;
        }
        set
        {
            var iot = new sfDataAccess();
            iot.SaveRadDockState(value, regkey, clikey, entkey);
            //Session["CurrentDockStatesDynamicDock"] = value;
        }
    }
 
    #endregion
 
    public void loadSensorInventory()
    {
        List<sfsSensorInventary> inventorySensor = new List<sfsSensorInventary>();
        var iot = new sfDataAccess();
        var sensor = new sfsSensorInventary();
        sensor.regkey = regkey;
        sensor.clientKey = clikey;
        sensor.entityKey = entkey;
        inventorySensor = iot.getSensorInventoryforDashboard(sensor);
 
 
        foreach (var x in inventorySensor)
        {
            //rcbSensorInventory.Items.Add(new RadComboBoxItem(x.sensorkey.ToString(), x.sensorsenrie));
            RadComboBoxItem item = new RadComboBoxItem();
 
            item.Text = x.sensorserie;
            item.Value = x.sensorkey.ToString();
 
            item.Attributes.Add("Marca", x.brandName.ToString());
            item.Attributes.Add("Modelo", x.modelName.ToString());
 
            if (x.checheck == x.sensorCount)
            {
                item.ForeColor = System.Drawing.Color.Red;
            }
            //else
            //{
            //    item.BackColor = ;
            //}
            //item.Value += ":" + unitPrice;
 
            rcbSensorInventory.Items.Add(item);
 
            item.DataBind();
        }
 
    }
 
    public void loadEntitiesList()
    {
        //if(regkey==0)
        //regkey =  Convert.ToInt32((object)Session["RegionKey"]);
 
        //if(clikey==0)
        //clikey = Convert.ToInt32((object)Session["ClientKey"]);
 
        var iot = new sfDataAccess();
        var entitiesList = iot.getEntityDataByUser(regkey, clikey);
 
        foreach (var entities in entitiesList)
        {
            if (entities.SensorCount > 0)
            {
                RadComboBoxItem item = new RadComboBoxItem();
                item.Value = entities.IdEntity.ToString();
                item.Text = entities.Name;
                //+ "("+entities.IdEntity.ToString()+") "
                cboEntities.Items.Add(item);
                if (item.Value == entkey.ToString())
                    item.Selected = true;
 
                item.DataBind();
            }
        }
 
        cboEntities.SelectedIndex = entkey - 1;
 
        //entTitle.Text = cboEntities.SelectedItem.Text;
    }
 
 
    public void loadSensorType()
    {
        List<sfsSensorType> sensorType = new List<sfsSensorType>();
        sfsDashController sfs = new sfsDashController();
        sensorType = sfs.loadddpSensorType();
        //DropDownListItem item = new DropDownListItem();
        foreach (var x in sensorType)
        {
            rcSensorType.Items.Add(new RadComboBoxItem(x.sensorName, x.sensorTypeId.ToString()));
 
        }
        //RadDropDownSensorType.DataSource = sensorType;
        //RadDropDownSensorType.DataBind();
 
    }
 
    public void loadTemperatureType()
    {
        rcTemperatureType.Items.Add(new RadComboBoxItem("Celsius","C"));
        rcTemperatureType.Items.Add(new RadComboBoxItem("Fahrenheit", "F"));
    }
 
    public void loadWidgetType()
    {
        rcWidgetType.Items.Add(new RadComboBoxItem(WidgetType.BarWidget.ToString(), WidgetType.BarWidget.GetType().ToString()));
        //rcWidgetType.Items.Add(new RadComboBoxItem(WidgetType.KendoAreaChart.ToString(), WidgetType.KendoAreaChart.GetType().ToString()));
    }
 
    public void loadRadDockZoneSensor()
    {
            //culture = new System.Globalization.CultureInfo(Session["USER_LANGUAGE"].ToString());
        int langNumber = 0;
        var lang = Session["USER_LANGUAGE"].ToString();
        if (lang.Substring(0, 2) == "en")
        {
            langNumber = 1;
        }
        //var  radDockName = new String[3]  {"Izquierda","Centro","Derecha"};
        var radDockName = new String[2, 3] { { "Izquierda", "Centro", "Derecha" }, { "Left", "Center", "Right" } };
         
        int zoneCount = 0;
        foreach (string x in SensorDockZone)
        {
            rcRadDockSensor.Items.Add(new RadComboBoxItem(radDockName[langNumber,zoneCount], x.ToString()));
            zoneCount++;
        }
    }
 
    private string getTag(WidgetType value)
    {
        string widgetName;
        switch (value)
        {
            case WidgetType.GaugeChart:
                widgetName = "~/app/Widget/GaugeChart.ascx";
                break;
            case WidgetType.Gauge:
                widgetName = "~/app/Widget/WeatherControl.ascx";
                break;
            case WidgetType.RadarChart:
                widgetName = "~/app/Widget/RadarChart.ascx";
                break;
            case WidgetType.AreaChart:
                widgetName = "~/app/Widget/AreaChart.ascx";
                break;
            case WidgetType.ImageDock:
                widgetName = "~/app/Widget/ImgWidget.ascx";
                break;
            case WidgetType.BarWidget:
                widgetName = "~/app/Widget/BarWidget.ascx";
                break;
            case WidgetType.KendoAreaChart:
                widgetName = "~/app/Widget/KendoAreaChart.ascx";
                break;
            default:
                widgetName = "~/app/Widget/WeatherControl.ascx";
                break;
        }
 
        return widgetName;
 
    }
 
    public string[] getZone(DockState state)
    {
        if (!String.IsNullOrEmpty(state.DockZoneID))
        {
            if (state.DockZoneID.Substring(11, 12) == "RadDockZone1")
            {
                return SensorDockZone;
            }
            else
            {
 
                return PrimaryDockZone;
            }
        }
        else
        {
            return null;
        }
    }
 
 
    
   
 
    
}

Viewing all articles
Browse latest Browse all 84751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>