Exemple #1
0
        public void pageInit(OtherDevices pParent, string gatewayID, string devName)
        {
            this.m_pParent   = pParent;
            this.m_gatewayID = gatewayID;
            InSnergyGateway gateWaybyGID = InSnergyGateway.GetGateWaybyGID(gatewayID);

            if (gateWaybyGID == null)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DevInfo_nofind, new string[]
                {
                    devName
                }));
                return;
            }
            this.tbDevName.Text  = gateWaybyGID.GatewayName;
            this.labDevIp.Text   = InSnergyService.getGatewayIP(gateWaybyGID.GatewayID);
            this.labDevType.Text = gateWaybyGID.GatewayType;
            this.dgvBranchPanels.Rows.Clear();
            int num = 1;

            foreach (Branch current in gateWaybyGID.BranchList)
            {
                string[] values = new string[]
                {
                    num.ToString(),
                            current.BranchName,
                            current.Location,
                            current.SubMeterList.Count.ToString(),
                            current.GatewayID,
                            current.BranchID
                };
                this.dgvBranchPanels.Rows.Add(values);
                num++;
            }
        }
Exemple #2
0
 private object delGateWayPro(object param)
 {
     System.Collections.ArrayList arrayList = param as System.Collections.ArrayList;
     for (int i = 0; i < arrayList.Count; i++)
     {
         string          text         = (string)arrayList[i];
         InSnergyGateway gateWaybyGID = InSnergyGateway.GetGateWaybyGID(text);
         int             num          = InSnergyGateway.DeleteGateway(text);
         if (num < 0)
         {
             return(num);
         }
         string valuePair = ValuePairs.getValuePair("Username");
         if (!string.IsNullOrEmpty(valuePair))
         {
             LogAPI.writeEventLog("0432011", new string[]
             {
                 gateWaybyGID.GatewayName,
                 valuePair
             });
         }
         else
         {
             LogAPI.writeEventLog("0432011", new string[]
             {
                 gateWaybyGID.GatewayName
             });
         }
         InSnergyService.Unmanage(text);
     }
     return(1);
 }
        public void pageInit()
        {
            this.cbsel_changeonly = false;
            InSnergyService.UpdateLocalTree();
            System.Collections.Generic.Dictionary <string, string> gatewayList = InSnergyService.GetGatewayList(true);
            int num = 1;

            if (gatewayList != null && gatewayList.Count > 0)
            {
                foreach (System.Collections.Generic.KeyValuePair <string, string> current in gatewayList)
                {
                    string value = current.Value;
                    string text  = current.Key;
                    text = text.Replace("-", "");
                    this.dgvAutoDevice.Rows.Add(new object[]
                    {
                        true,
                        "ISG_" + text,
                        "In-Snergy Gateway",
                        value.Split(new char[]
                        {
                            ':'
                        })[0],
                        current.Key
                    });
                    num++;
                }
            }
            if (this.dgvAutoDevice.Rows.Count > 0)
            {
                this.butAdd.Enabled = true;
                return;
            }
            this.butAdd.Enabled = false;
        }
        public void TimerProc()
        {
            string gatewayIP = InSnergyService.getGatewayIP(this.m_gatewayID);

            this.labDevIp.Text = gatewayIP;
            System.Collections.Generic.Dictionary <string, IMeter> branch = InSnergyService.GetBranch(this.m_gatewayID, this.m_branchID);
            foreach (DataGridViewRow dataGridViewRow in (System.Collections.IEnumerable) this.dgvSubMeters.Rows)
            {
                string key    = dataGridViewRow.Cells[11].Value.ToString();
                string value  = "";
                string value2 = "";
                string value3 = "";
                string value4 = "";
                string value5 = "";
                string value6 = "";
                if (branch.ContainsKey(key))
                {
                    IMeter meter = branch[key];
                    if (meter.listParam.ContainsKey(2))
                    {
                        double dvalue = meter.listParam[2].dvalue;
                        value = dvalue.ToString("F2");
                    }
                    if (meter.listParam.ContainsKey(1))
                    {
                        double dvalue = meter.listParam[1].dvalue;
                        value2 = dvalue.ToString("F2");
                    }
                    if (meter.listParam.ContainsKey(3))
                    {
                        double dvalue = meter.listParam[3].dvalue;
                        value3 = dvalue.ToString("F1");
                    }
                    if (meter.listParam.ContainsKey(5))
                    {
                        double dvalue = meter.listParam[5].dvalue;
                        value4 = dvalue.ToString("F2");
                    }
                    if (meter.listParam.ContainsKey(8))
                    {
                        double dvalue = meter.listParam[8].dvalue;
                        value5 = dvalue.ToString("F3");
                    }
                    if (meter.listParam.ContainsKey(4))
                    {
                        double dvalue = meter.listParam[4].dvalue;
                        value6 = dvalue.ToString("F2");
                    }
                }
                dataGridViewRow.Cells[1].Value = value;
                dataGridViewRow.Cells[2].Value = value2;
                dataGridViewRow.Cells[3].Value = value3;
                dataGridViewRow.Cells[4].Value = value4;
                dataGridViewRow.Cells[5].Value = value5;
                dataGridViewRow.Cells[6].Value = value6;
            }
        }
Exemple #5
0
        private void DevtreeInit()
        {
            InSnergyService.UpdateLocalTree();
            this.tvDevOther.Nodes.Clear();
            TreeNode treeNode = new TreeNode();

            treeNode.Text               = EcoLanguage.getMsg(LangRes.OtherDevRoot, new string[0]);
            treeNode.Name               = "DevRoot";
            treeNode.Tag                = "DevRoot";
            treeNode.ImageIndex         = 0;
            treeNode.SelectedImageIndex = 0;
            this.tvDevOther.Nodes.Add(treeNode);
            System.Collections.Generic.List <InSnergyGateway> allGateWay = InSnergyGateway.GetAllGateWay();
            foreach (InSnergyGateway current in allGateWay)
            {
                string   gatewayName = current.GatewayName;
                TreeNode treeNode2   = new TreeNode();
                treeNode2.Text = gatewayName;
                treeNode2.Name = current.GatewayID;
                treeNode2.Tag  = "GateWay";
                if (InSnergyService.IsGatewayOnline(current.GatewayID))
                {
                    treeNode2.ImageIndex         = 3;
                    treeNode2.SelectedImageIndex = 3;
                }
                else
                {
                    treeNode2.ImageIndex         = 2;
                    treeNode2.SelectedImageIndex = 2;
                }
                treeNode.Nodes.Add(treeNode2);
                foreach (Branch current2 in current.BranchList)
                {
                    TreeNode treeNode3 = new TreeNode();
                    treeNode3.Text = current2.BranchName;
                    treeNode3.Name = current2.GatewayID + ":" + current2.BranchID;
                    treeNode3.Tag  = "BrPanel";
                    if (InSnergyService.IsBranchOnline(current2.GatewayID, current2.BranchID))
                    {
                        treeNode3.ImageIndex         = 5;
                        treeNode3.SelectedImageIndex = 5;
                    }
                    else
                    {
                        treeNode3.ImageIndex         = 4;
                        treeNode3.SelectedImageIndex = 4;
                    }
                    treeNode2.Nodes.Add(treeNode3);
                }
            }
        }
 private void otherDevSave(System.Collections.Generic.List <System.Collections.Hashtable> list)
 {
     foreach (System.Collections.Hashtable current in list)
     {
         string str_ip   = (string)current["ip"];
         string text     = (string)current["devNm"];
         string str_type = (string)current["type"];
         string text2    = (string)current["devID"];
         int    i_usage  = 0;
         System.Collections.Generic.List <Branch> list2      = new System.Collections.Generic.List <Branch>();
         System.Collections.Generic.List <string> branchList = InSnergyService.GetBranchList(text2);
         foreach (string current2 in branchList)
         {
             System.Collections.Generic.List <SubMeter> list3 = new System.Collections.Generic.List <SubMeter>();
             Branch item = new Branch(text2, current2, "", "", list3);
             list2.Add(item);
             System.Collections.Generic.List <string> meterList = InSnergyService.GetMeterList(text2, current2);
             foreach (string current3 in meterList)
             {
                 SubMeter item2 = new SubMeter(text2, current2, current3, "", 0f, i_usage);
                 list3.Add(item2);
             }
         }
         InSnergyGateway inSnergyGateway = new InSnergyGateway(text2, text, str_type, str_ip, list2);
         if (inSnergyGateway.Insert() > 0)
         {
             string valuePair = ValuePairs.getValuePair("Username");
             if (!string.IsNullOrEmpty(valuePair))
             {
                 LogAPI.writeEventLog("0432010", new string[]
                 {
                     text,
                     valuePair
                 });
             }
             else
             {
                 LogAPI.writeEventLog("0432010", new string[]
                 {
                     text
                 });
             }
             InSnergyService.Manage(text2);
         }
     }
 }
Exemple #7
0
 public void refreshTree(TreeNodeCollection Nodes)
 {
     foreach (TreeNode treeNode in Nodes)
     {
         string name = treeNode.Name;
         string text = (string)treeNode.Tag;
         if (text.Equals("GateWay"))
         {
             if (!InSnergyService.IsGatewayOnline(name))
             {
                 treeNode.ImageIndex         = 2;
                 treeNode.SelectedImageIndex = 2;
             }
             else
             {
                 treeNode.ImageIndex         = 3;
                 treeNode.SelectedImageIndex = 3;
             }
         }
         else
         {
             if (text.Equals("BrPanel"))
             {
                 string gw = name.Split(new char[]
                 {
                     ':'
                 })[0];
                 string branch = name.Split(new char[]
                 {
                     ':'
                 })[1];
                 if (InSnergyService.IsBranchOnline(gw, branch))
                 {
                     treeNode.ImageIndex         = 5;
                     treeNode.SelectedImageIndex = 5;
                 }
                 else
                 {
                     treeNode.ImageIndex         = 4;
                     treeNode.SelectedImageIndex = 4;
                 }
             }
         }
         this.refreshTree(treeNode.Nodes);
     }
 }
Exemple #8
0
 public void TimerProc()
 {
     foreach (DataGridViewRow dataGridViewRow in (System.Collections.IEnumerable) this.dgvAllOtherDevices.Rows)
     {
         string gw        = dataGridViewRow.Cells[4].Value.ToString();
         string gatewayIP = InSnergyService.getGatewayIP(gw);
         dataGridViewRow.Cells[2].Value = gatewayIP;
         if (InSnergyService.IsGatewayOnline(gw))
         {
             dataGridViewRow.Cells[3].Value = EcoLanguage.getMsg(LangRes.ISGST_online, new string[0]);
         }
         else
         {
             dataGridViewRow.Cells[3].Value = EcoLanguage.getMsg(LangRes.ISGST_offline, new string[0]);
         }
     }
 }
Exemple #9
0
        public static bool QPushLong(long nData)
        {
            if (SharedData.semaphoreInSnergy == null)
            {
                return(false);
            }
            SharedData.semaphoreInSnergy.WaitOne();
            long num  = SharedData.ReadShareLong(64L);
            long num2 = SharedData.ReadShareLong(72L);
            long num3 = SharedData.ReadShareLong(80L);

            if ((num2 + 1L) % num == num3)
            {
                return(false);
            }
            SharedData.WriteShareLong(88L + num2 * 8L, nData);
            SharedData.WriteShareLong(72L, (num2 + 1L) % num);
            SharedData.semaphoreInSnergy.Release();
            InSnergyService.EventAdded();
            return(true);
        }
Exemple #10
0
        private void deviceTimerRefresh()
        {
            this.dTimer.Interval = 10000.0;
            InSnergyService.UpdateLocalTree();
            this.refreshTree(this.tvDevOther.Nodes[0].Nodes);
            TreeNode selectedNode = this.tvDevOther.SelectedNode;
            string   text         = selectedNode.Tag.ToString();

            if (text.Equals("DevRoot"))
            {
                this.otherDevicesAllDev1.TimerProc();
                return;
            }
            if (text.Equals("GateWay"))
            {
                this.otherDeviceISGBrPanel1.TimerProc();
                return;
            }
            if (text.Equals("BrPanel"))
            {
                this.otherDeviceISGSubMeter1.TimerProc();
            }
        }
        public bool IsTimeout()
        {
            long num = Common.ElapsedTime(this.status.tConnected);

            if (this.status.nAuthorized <= 0)
            {
                if ((int)num > 60000)
                {
                    InSnergyService.PostLog("TIMEOUT_AUTHORIZE: " + 60000);
                    return(true);
                }
            }
            else
            {
                num = Common.ElapsedTime(this.status.tLastReceived);
                if (num > (long)ConnectionContext.TIMEOUT_RECEIVE)
                {
                    InSnergyService.PostLog("TIMEOUT_RECEIVE: " + ConnectionContext.TIMEOUT_RECEIVE);
                    return(true);
                }
            }
            return(false);
        }
Exemple #12
0
        public static Semaphore OpenGlobalSemaphore(string semName, int sInit, int sMax)
        {
            Semaphore semaphore = null;
            bool      flag      = false;
            bool      flag2     = false;

            try
            {
                semaphore = Semaphore.OpenExisting(semName);
            }
            catch (WaitHandleCannotBeOpenedException)
            {
                InSnergyService.PostLog("Semaphore does not exist: " + semName);
                flag = true;
            }
            catch (UnauthorizedAccessException ex)
            {
                InSnergyService.PostLog("Unauthorized access: " + ex.Message + "===>" + semName);
                flag2 = true;
            }
            catch (Exception)
            {
            }
            if (flag)
            {
                Environment.UserDomainName + "\\" + Environment.UserName;
                SecurityIdentifier identity          = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
                SemaphoreSecurity  semaphoreSecurity = new SemaphoreSecurity();
                semaphoreSecurity.AddAccessRule(new SemaphoreAccessRule(identity, SemaphoreRights.FullControl, AccessControlType.Allow));
                bool flag3;
                semaphore = new Semaphore(sInit, sMax, semName, ref flag3, semaphoreSecurity);
                if (!flag3)
                {
                    InSnergyService.PostLog("Unable to create the semaphore: " + semName);
                    return(null);
                }
                InSnergyService.PostLog("Created the semaphore: " + semName);
            }
            else
            {
                if (flag2)
                {
                    try
                    {
                        semaphore = Semaphore.OpenExisting(semName);
                        Environment.UserDomainName + "\\" + Environment.UserName;
                        SecurityIdentifier identity2          = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
                        SemaphoreSecurity  semaphoreSecurity2 = new SemaphoreSecurity();
                        semaphoreSecurity2.AddAccessRule(new SemaphoreAccessRule(identity2, SemaphoreRights.FullControl, AccessControlType.Allow));
                        semaphore.SetAccessControl(semaphoreSecurity2);
                        InSnergyService.PostLog("Updated semaphore security: " + semName);
                        semaphore = Semaphore.OpenExisting(semName);
                    }
                    catch (UnauthorizedAccessException ex2)
                    {
                        InSnergyService.PostLog("Unable to change permissions: " + ex2.Message + "===>" + semName);
                        if (semaphore != null)
                        {
                            semaphore.Close();
                            semaphore.Dispose();
                        }
                        return(null);
                    }
                    catch (Exception)
                    {
                    }
                    return(semaphore);
                }
            }
            return(semaphore);
        }
Exemple #13
0
        public static void LocalToShareEx(Dictionary <string, Gateway> gts, bool bRemoveOffline)
        {
            if (!SharedData.IsProducer())
            {
                return;
            }
            if (SharedData.semaphoreInSnergy == null)
            {
                return;
            }
            if (gts.Count <= 0)
            {
                lock (SharedData.thisSharedLock)
                {
                    if (SharedData.semaphoreInSnergy != null)
                    {
                        SharedData.semaphoreInSnergy.WaitOne();
                        SharedData.WriteShareLong(32L, 0L);
                        SharedData.WriteShareLong(48L, 0L);
                        SharedData.semaphoreInSnergy.Release();
                    }
                }
                return;
            }
            byte[] array = new byte[SharedData.MAX_SHARE_DATA_SIZE + 1024L];
            Array.Clear(array, 0, array.Length);
            long num  = 0L;
            long num2 = 0L;
            long num3 = 0L;
            long num4 = 0L;
            long num5 = 0L;

            foreach (KeyValuePair <string, Gateway> current in gts)
            {
                byte[]   bytes  = Encoding.ASCII.GetBytes(current.Key);
                string[] array2 = current.Value.status.gatewayIP.Split(new char[]
                {
                    ':'
                });
                DateTime tUptime = current.Value.status.tUptime;
                if (ApplicationHandler.IsTopologyNotEmpty(current.Key) && (!bRemoveOffline || current.Value.status.gatewayIP.IndexOf(":0") < 0))
                {
                    num5 += 1L;
                    if (num2 >= SharedData.MAX_SHARE_DATA_SIZE || num3 > 0L)
                    {
                        num3 = 1L;
                    }
                    else
                    {
                        Buffer.BlockCopy(bytes, 0, array, (int)num2, 20);
                        num2 += 20L;
                        byte[] array3 = new byte[6];
                        Array.Clear(array3, 0, array3.Length);
                        if (array2.Length == 2)
                        {
                            string[] array4 = array2[0].Split(new char[]
                            {
                                '.'
                            });
                            if (array4.Length == 4)
                            {
                                array3[0] = Convert.ToByte(array4[0]);
                                array3[1] = Convert.ToByte(array4[1]);
                                array3[2] = Convert.ToByte(array4[2]);
                                array3[3] = Convert.ToByte(array4[3]);
                                array3[4] = (byte)(Convert.ToInt32(array2[1]) & 255);
                                array3[5] = (byte)(Convert.ToInt32(array2[1]) >> 8);
                            }
                        }
                        Buffer.BlockCopy(array3, 0, array, (int)num2, 6);
                        num2 += 6L;
                        long   value  = ((long)tUptime.Year << 40) + ((long)tUptime.Month << 32) + ((long)tUptime.Day << 24) + (long)((long)tUptime.Hour << 16) + (long)((long)tUptime.Minute << 8) + (long)tUptime.Second;
                        byte[] bytes2 = BitConverter.GetBytes(value);
                        Buffer.BlockCopy(bytes2, 0, array, (int)num2, 8);
                        num2 += 8L;
                        Array.Clear(array3, 0, array3.Length);
                        array3[0] = Convert.ToByte(current.Value.listDevice.Count);
                        Buffer.BlockCopy(array3, 0, array, (int)num2, 1);
                        num2 += 1L;
                        foreach (KeyValuePair <string, Device> current2 in current.Value.listDevice)
                        {
                            if (num2 >= SharedData.MAX_SHARE_DATA_SIZE)
                            {
                                num3 = 1L;
                                InSnergyService.PostLog("OutOfMem #2");
                                break;
                            }
                            byte[] bytes3 = Encoding.ASCII.GetBytes(current2.Value.sDID);
                            Buffer.BlockCopy(bytes3, 0, array, (int)num2, 20);
                            num2 += 20L;
                            long num6 = num2;
                            Array.Clear(array3, 0, array3.Length);
                            array3[0] = Convert.ToByte(current2.Value.listChannel.Count);
                            Buffer.BlockCopy(array3, 0, array, (int)num2, 1);
                            num2 += 1L;
                            long num7 = 0L;
                            foreach (KeyValuePair <string, Channel> current3 in current2.Value.listChannel)
                            {
                                if (num2 >= SharedData.MAX_SHARE_DATA_SIZE)
                                {
                                    num3 = 1L;
                                    InSnergyService.PostLog("OutOfMem #3");
                                    break;
                                }
                                int num8 = Convert.ToInt32(current3.Value.sCID);
                                if (num8 >= 1 && num8 <= 12)
                                {
                                    int num9 = current2.Value.mapChannel[num8 - 1];
                                    if (num9 != 0)
                                    {
                                        string text = num8.ToString();
                                        while (text.Length < 2)
                                        {
                                            text = "0" + text;
                                        }
                                        for (int i = 0; i < 3; i++)
                                        {
                                            string str   = "0" + (i + 1).ToString();
                                            string text2 = (num9 >> 8 * (2 - i) & 255).ToString();
                                            while (text2.Length < 2)
                                            {
                                                text2 = "0" + text2;
                                            }
                                            if (!(text2 == "00"))
                                            {
                                                byte[] bytes4 = Encoding.ASCII.GetBytes(text + str + text2);
                                                Buffer.BlockCopy(bytes4, 0, array, (int)num2, 6);
                                                num2 += 6L;
                                                long num10 = num2;
                                                Array.Clear(array3, 0, array3.Length);
                                                array3[0] = Convert.ToByte(current3.Value.measurePair.Count);
                                                Buffer.BlockCopy(array3, 0, array, (int)num2, 1);
                                                num2 += 1L;
                                                long num11 = 0L;
                                                foreach (KeyValuePair <string, Param> current4 in current3.Value.measurePair)
                                                {
                                                    int num12 = Convert.ToInt32(current4.Value.aID);
                                                    if ((SharedData.listParamEnabled == null || SharedData.listParamEnabled.Contains(num12)) && num12 > 1000 && num12 / 1000 == i + 1)
                                                    {
                                                        if (num2 >= SharedData.MAX_SHARE_DATA_SIZE)
                                                        {
                                                            num3 = 1L;
                                                            InSnergyService.PostLog("OutOfMem #4");
                                                            break;
                                                        }
                                                        byte[] bytes5 = BitConverter.GetBytes(num12);
                                                        Buffer.BlockCopy(bytes5, 0, array, (int)num2, 4);
                                                        num2 += 4L;
                                                        byte[] bytes6 = BitConverter.GetBytes(current4.Value.dvalue);
                                                        Buffer.BlockCopy(bytes6, 0, array, (int)num2, 8);
                                                        num2  += 8L;
                                                        value  = ((long)current4.Value.time.Year << 40) + ((long)current4.Value.time.Month << 32) + ((long)current4.Value.time.Day << 24) + (long)((long)current4.Value.time.Hour << 16) + (long)((long)current4.Value.time.Minute << 8) + (long)current4.Value.time.Second;
                                                        bytes2 = BitConverter.GetBytes(value);
                                                        Buffer.BlockCopy(bytes2, 0, array, (int)num2, 8);
                                                        num2  += 8L;
                                                        num11 += 1L;
                                                    }
                                                }
                                                if (num3 > 0L)
                                                {
                                                    break;
                                                }
                                                Array.Clear(array3, 0, array3.Length);
                                                array3[0] = Convert.ToByte(num11);
                                                Buffer.BlockCopy(array3, 0, array, (int)num10, 1);
                                                num7 += 1L;
                                            }
                                        }
                                    }
                                }
                            }
                            if (num3 > 0L)
                            {
                                break;
                            }
                            Array.Clear(array3, 0, array3.Length);
                            array3[0] = Convert.ToByte(num7);
                            Buffer.BlockCopy(array3, 0, array, (int)num6, 1);
                        }
                        if (num3 <= 0L)
                        {
                            num += 1L;
                            num4 = num2;
                        }
                    }
                }
            }
            Array.Resize <byte>(ref array, (int)num4);
            lock (SharedData.thisSharedLock)
            {
                if (SharedData.semaphoreInSnergy != null)
                {
                    num += num5 << 32;
                    SharedData.semaphoreInSnergy.WaitOne();
                    SharedData.WriteShareLong(32L, num);
                    SharedData.WriteShareLong(48L, num4);
                    SharedData.WriteShareArray(8280L, array);
                    long num13 = SharedData.ReadShareLong(56L);
                    num13 |= 8L;
                    SharedData.WriteShareLong(56L, num13);
                    SharedData.semaphoreInSnergy.Release();
                }
            }
            if (num3 > 0L)
            {
                if (num3 != SharedData.nLastShareMemoryErrorCode)
                {
                    InSnergyService.PostLog("Out of share-memory, data truncated");
                }
                SharedData.WriteStatus(2L, true);
            }
            else
            {
                SharedData.WriteStatus(2L, false);
            }
            SharedData.nLastShareMemoryErrorCode = num3;
        }
Exemple #14
0
        private static int SetupShareMemoryWithSercurity(int nSize)
        {
            bool   flag     = false;
            IntPtr intPtr   = IntPtr.Zero;
            int    cb       = 68;
            IntPtr arg_12_0 = IntPtr.Zero;

            Win32.SECURITY_ATTRIBUTES sECURITY_ATTRIBUTES = default(Win32.SECURITY_ATTRIBUTES);
            try
            {
                intPtr = Marshal.AllocHGlobal(cb);
                if (!Win32.CreateWellKnownSid(WellKnownSidType.BuiltinAdministratorsSid, IntPtr.Zero, intPtr, ref cb))
                {
                    InSnergyService.PostLog("CreateWellKnownSid " + Marshal.GetLastWin32Error());
                    int result = -1;
                    return(result);
                }
                if (!Win32.ConvertStringSecurityDescriptorToSecurityDescriptor("D:(A;;GA;;;RD)(A;;GA;;;S-1-5-32-544)(A;;GA;;;S-1-5-4)", 1, out sECURITY_ATTRIBUTES.lpSecurityDescriptor, IntPtr.Zero))
                {
                    InSnergyService.PostLog("ConvertStringSecurityDescriptorToSecurityDescriptor " + Marshal.GetLastWin32Error());
                    int result = -1;
                    return(result);
                }
                sECURITY_ATTRIBUTES.nLength        = Marshal.SizeOf(sECURITY_ATTRIBUTES);
                sECURITY_ATTRIBUTES.bInheritHandle = false;
                SharedData.hMapFile = Win32.CreateFileMapping(4294967295u, ref sECURITY_ATTRIBUTES, 4, 0, nSize + 1024, "Global\\InSnergySharedName");
                flag = ((long)Marshal.GetLastWin32Error() == 183L);
                if (SharedData.hMapFile == IntPtr.Zero)
                {
                    InSnergyService.PostLog("CreateFileMapping " + Marshal.GetLastWin32Error());
                    int result = -1;
                    return(result);
                }
                SharedData.pMapBuf = Win32.MapViewOfFile(SharedData.hMapFile, 983071, 0, 0, nSize + 128);
                if (SharedData.pMapBuf == IntPtr.Zero)
                {
                    InSnergyService.PostLog("MapViewOfFile " + Marshal.GetLastWin32Error());
                    int result = -1;
                    return(result);
                }
            }
            catch (Exception ex)
            {
                InSnergyService.PostLog(ex.Message + " failed with '" + ex.InnerException.Message);
            }
            finally
            {
                if (intPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(intPtr);
                }
                if (sECURITY_ATTRIBUTES.lpSecurityDescriptor != IntPtr.Zero)
                {
                    Win32.LocalFree(sECURITY_ATTRIBUTES.lpSecurityDescriptor);
                }
            }
            if (!flag)
            {
                return(0);
            }
            return(1);
        }
Exemple #15
0
        private static bool CreateShareMemory(long maxGateways, long maxDevices, long maxChannels, long maxAttributes)
        {
            if (SharedData.semaphoreInSnergy == null)
            {
                return(false);
            }
            SharedData.nMaxGateways   = maxGateways;
            SharedData.nMaxDevices    = maxDevices;
            SharedData.nMaxChannels   = maxChannels;
            SharedData.nMaxAttributes = maxAttributes;
            int num = 0;

            num += (int)(SharedData.nMaxGateways * 35L);
            num += (int)(SharedData.nMaxDevices * 21L);
            num += (int)(SharedData.nMaxChannels * (7L + SharedData.nMaxAttributes * 20L));
            SharedData.MAX_SHARE_DATA_SIZE = (long)num;
            InSnergyService.PostLog(string.Concat(new object[]
            {
                "Header + data = ",
                8280L,
                "+",
                num,
                "=",
                (long)num + 8280L
            }));
            num += 8280;
            SharedData.semaphoreInSnergy.WaitOne();
            int num2 = SharedData.SetupShareMemoryWithSercurity(num);

            if (num2 < 0)
            {
                InSnergyService.PostLog("SetupShareMemory failed");
                SharedData.semaphoreInSnergy.Release();
                return(false);
            }
            if (num2 > 0)
            {
                SharedData.nMaxGateways   = SharedData.ReadShareLong(0L);
                SharedData.nMaxDevices    = SharedData.ReadShareLong(8L);
                SharedData.nMaxChannels   = SharedData.ReadShareLong(16L);
                SharedData.nMaxAttributes = SharedData.ReadShareLong(24L);
                num  = (int)(SharedData.nMaxGateways * 35L);
                num += (int)(SharedData.nMaxDevices * 21L);
                num += (int)(SharedData.nMaxChannels * (7L + SharedData.nMaxAttributes * 20L));
                SharedData.MAX_SHARE_DATA_SIZE = (long)num;
            }
            else
            {
                SharedData.WriteShareLong(0L, SharedData.nMaxGateways);
                SharedData.WriteShareLong(8L, SharedData.nMaxDevices);
                SharedData.WriteShareLong(16L, SharedData.nMaxChannels);
                SharedData.WriteShareLong(24L, SharedData.nMaxAttributes);
                SharedData.WriteShareLong(64L, 1024L);
                SharedData.WriteShareLong(72L, 0L);
                SharedData.WriteShareLong(80L, 0L);
                SharedData.WriteShareLong(32L, 0L);
                SharedData.WriteShareLong(40L, 0L);
                SharedData.WriteShareLong(56L, 0L);
            }
            SharedData.semaphoreInSnergy.Release();
            return(true);
        }
Exemple #16
0
        public void TimerProc()
        {
            string gatewayIP = InSnergyService.getGatewayIP(this.m_gatewayID);

            this.labDevIp.Text = gatewayIP;
        }
        public void pageInit(OtherDevices pParent, string gatewayID, string BranchID)
        {
            this.m_pParent = pParent;
            InSnergyGateway gateWaybyBID = InSnergyGateway.GetGateWaybyBID(BranchID);

            if (gateWaybyBID == null)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DevInfo_nofind, new string[]
                {
                    gatewayID
                }));
                return;
            }
            this.m_gatewayID     = gatewayID;
            this.m_branchID      = BranchID;
            this.labDevName.Text = gateWaybyBID.GatewayName;
            this.labDevIp.Text   = InSnergyService.getGatewayIP(gateWaybyBID.GatewayID);
            this.labDevType.Text = gateWaybyBID.GatewayType;
            Branch branch = gateWaybyBID.BranchList[0];

            if (branch == null)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DevInfo_nofind, new string[]
                {
                    BranchID
                }));
                return;
            }
            this.tbBranchNm.Text   = branch.BranchName;
            this.tbBranchLoct.Text = branch.Location;
            this.dgvtbISG_SubMElecUsage.Items.Clear();
            this.dgvtbISG_SubMElecUsage.Items.Add("IT Power");
            this.dgvtbISG_SubMElecUsage.Items.Add("Non IT Power");
            this.dgvtbISG_SubMElecUsage.Items.Add("Undefined");
            this.dgvSubMeters.Rows.Clear();
            string text = "";
            int    num  = 1;

            System.Collections.Generic.Dictionary <string, IMeter> branch2 = InSnergyService.GetBranch(this.m_gatewayID, this.m_branchID);
            foreach (SubMeter current in branch.SubMeterList)
            {
                switch (current.ElectricityUsage)
                {
                case 0:
                    text = "Undefined";
                    break;

                case 1:
                    text = "IT Power";
                    break;

                case 2:
                    text = "Non IT Power";
                    break;
                }
                string submeterID = current.SubmeterID;
                string text2      = "";
                string text3      = "";
                string text4      = "";
                string text5      = "";
                string text6      = "";
                string text7      = "";
                if (branch2.ContainsKey(submeterID))
                {
                    IMeter meter = branch2[submeterID];
                    if (meter.listParam.ContainsKey(2))
                    {
                        double dvalue = meter.listParam[2].dvalue;
                        text2 = dvalue.ToString("F2");
                    }
                    if (meter.listParam.ContainsKey(1))
                    {
                        double dvalue = meter.listParam[1].dvalue;
                        text3 = dvalue.ToString("F2");
                    }
                    if (meter.listParam.ContainsKey(3))
                    {
                        double dvalue = meter.listParam[3].dvalue;
                        text4 = dvalue.ToString("F1");
                    }
                    if (meter.listParam.ContainsKey(5))
                    {
                        double dvalue = meter.listParam[5].dvalue;
                        text5 = dvalue.ToString("F2");
                    }
                    if (meter.listParam.ContainsKey(8))
                    {
                        double dvalue = meter.listParam[8].dvalue;
                        text6 = dvalue.ToString("F3");
                    }
                    if (meter.listParam.ContainsKey(4))
                    {
                        double dvalue = meter.listParam[4].dvalue;
                        text7 = dvalue.ToString("F2");
                    }
                }
                string[] values = new string[]
                {
                    num.ToString(),
                         text2,
                         text3,
                         text4,
                         text5,
                         text6,
                         text7,
                         current.Capacity.ToString("F2"),
                    text,
                    current.GatewayID,
                    current.BranchID,
                    current.SubmeterID
                };
                this.dgvSubMeters.Rows.Add(values);
                num++;
            }
        }
Exemple #18
0
        private void btnsavePort_Click(object sender, System.EventArgs e)
        {
            if (!this.tbManagerPort.Visible)
            {
                int num  = 0;
                int num2 = 0;
                int num3 = 0;
                if (this.tbTrapPort.Visible)
                {
                    if (!this.portparacheck(this.lbTrapPort, this.tbTrapPort, 1))
                    {
                        return;
                    }
                    num = System.Convert.ToInt32(this.tbTrapPort.Text);
                }
                if (this.tbBillingPort.Visible)
                {
                    if (!this.portparacheck(this.lbBillingPort, this.tbBillingPort, 3))
                    {
                        return;
                    }
                    num2 = System.Convert.ToInt32(this.tbBillingPort.Text);
                    if (num2 == num)
                    {
                        this.tbBillingPort.Focus();
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Portconflict, new string[]
                        {
                            this.tbBillingPort.Text
                        }));
                        return;
                    }
                }
                if (this.tbGatewayPort.Visible)
                {
                    if (!this.portparacheck(this.lbGatewayPort, this.tbGatewayPort, 2))
                    {
                        return;
                    }
                    num3 = System.Convert.ToInt32(this.tbGatewayPort.Text);
                    if (num3 == num || num3 == num2)
                    {
                        this.tbGatewayPort.Focus();
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Portconflict, new string[]
                        {
                            this.tbGatewayPort.Text
                        }));
                        return;
                    }
                }
                if (this.tbTrapPort.Visible)
                {
                    new Sys_Para
                    {
                        TrapPort = num
                    }.update();
                    string valuePair = ValuePairs.getValuePair("Username");
                    if (!string.IsNullOrEmpty(valuePair))
                    {
                        LogAPI.writeEventLog("0130022", new string[]
                        {
                            valuePair
                        });
                    }
                    else
                    {
                        LogAPI.writeEventLog("0130022", new string[0]);
                    }
                }
                if (this.tbBillingPort.Visible)
                {
                    Sys_Para.SetBPPort(num2);
                    InSnergyService.RestartBillingProtocol(Sys_Para.GetBPFlag() == 1, num2, Sys_Para.GetBPSecurity());
                }
                if (this.tbGatewayPort.Visible)
                {
                    Sys_Para.SetISGPort(num3);
                    if (Sys_Para.GetISGFlag() == 0)
                    {
                        InSnergyService.Restart(false, num3);
                    }
                    else
                    {
                        InSnergyService.Restart(true, num3);
                    }
                }
                base.DialogResult = DialogResult.OK;
                return;
            }
            if (!this.portparacheck(this.lbManagerPort, this.tbManagerPort, 0))
            {
                return;
            }
            int value = System.Convert.ToInt32(this.tbManagerPort.Text);

            ValuePairs.setValuePair("ServicePort", System.Convert.ToString(value));
            ValuePairs.SaveValueKeyToRegistry(true);
            base.DialogResult = DialogResult.OK;
        }
Exemple #19
0
        private void butSysparaSave_Click(object sender, System.EventArgs e)
        {
            int    bPFlag     = Sys_Para.GetBPFlag();
            int    num        = 0;
            int    bPPort     = Sys_Para.GetBPPort();
            int    num2       = bPPort;
            string bPSecurity = Sys_Para.GetBPSecurity();
            string text       = Sys_Para.GetBPSecurity();
            bool   flag       = false;

            if (this.cbEnableBP.Checked)
            {
                num = 1;
                Ecovalidate.checkTextIsNull(this.tbBPlistenport, ref flag);
                if (flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[]
                    {
                        this.lbBPlistenPort.Text
                    }));
                    return;
                }
                if (!Ecovalidate.Rangeint(this.tbBPlistenport, 1, 65535))
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[]
                    {
                        this.lbBPlistenPort.Text,
                        "1",
                        "65535"
                    }));
                    return;
                }
                num2 = System.Convert.ToInt32(this.tbBPlistenport.Text);
                if (bPPort != num2)
                {
                    bool flag2 = NetworkShareAccesser.TcpPortInUse(num2);
                    if (flag2)
                    {
                        this.tbBPlistenport.Focus();
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Portconflict, new string[]
                        {
                            this.tbBPlistenport.Text
                        }));
                        return;
                    }
                }
                Ecovalidate.checkTextIsNull(this.tbBPsecuritystr, ref flag);
                if (flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[]
                    {
                        this.lbBPsecuritystr.Text
                    }));
                    return;
                }
                text = this.tbBPsecuritystr.Text;
            }
            if (bPFlag != num || bPPort != num2 || !bPSecurity.Equals(text))
            {
                Sys_Para.SetBPFlag(num);
                Sys_Para.SetBPPort(num2);
                Sys_Para.SetBPSecurity(text);
                InSnergyService.RestartBillingProtocol(num == 1, num2, text);
            }
            EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0]));
        }
Exemple #20
0
        private void butSaveISGSetting_Click(object sender, System.EventArgs e)
        {
            int  iSGFlag     = Sys_Para.GetISGFlag();
            int  num         = 0;
            int  iSGPort     = Sys_Para.GetISGPort();
            int  num2        = iSGPort;
            int  iTPowerFlag = Sys_Para.GetITPowerFlag();
            int  num3        = iTPowerFlag;
            bool flag        = false;

            if (this.cbEnableISGateway.Checked)
            {
                num = 1;
                Ecovalidate.checkTextIsNull(this.tbISGServicePort, ref flag);
                if (flag)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[]
                    {
                        this.lbServicePort.Text
                    }));
                    return;
                }
                if (!Ecovalidate.Rangeint(this.tbISGServicePort, 1, 65535))
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[]
                    {
                        this.lbServicePort.Text,
                        "1",
                        "65535"
                    }));
                    return;
                }
                num2 = System.Convert.ToInt32(this.tbISGServicePort.Text);
                if (iSGPort != num2)
                {
                    bool flag2 = NetworkShareAccesser.TcpPortInUse(num2);
                    if (flag2)
                    {
                        this.tbISGServicePort.Focus();
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Portconflict, new string[]
                        {
                            this.tbISGServicePort.Text
                        }));
                        return;
                    }
                }
                if (!this.cbAtenPDU.Checked)
                {
                    num3 = 0;
                }
                else
                {
                    num3 = 1;
                }
            }
            Sys_Para.SetISGFlag(num);
            Sys_Para.SetISGPort(num2);
            Sys_Para.SetITPowerFlag(num3);
            if (iSGFlag != num || iSGPort != num2)
            {
                if (num == 0)
                {
                    InSnergyService.Restart(false, num2);
                }
                else
                {
                    InSnergyService.Restart(true, num2);
                }
            }
            string valuePair = ValuePairs.getValuePair("Username");

            if (!string.IsNullOrEmpty(valuePair))
            {
                LogAPI.writeEventLog("0432000", new string[]
                {
                    valuePair
                });
            }
            else
            {
                LogAPI.writeEventLog("0432000", new string[0]);
            }
            if (iSGFlag != num || iTPowerFlag != num3)
            {
                EcoGlobalVar.setDashBoardFlg(32uL, "", 32);
            }
            EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0]));
        }
Exemple #21
0
        public static void LoadPUEData(ref double[] ret_v, ref int[] DB_Flg, ref string[] strTimePrompt)
        {
            try
            {
                int iSGFlag     = Sys_Para.GetISGFlag();
                int iTPowerFlag = Sys_Para.GetITPowerFlag();
                DB_Flg[0] = iSGFlag;
                DB_Flg[1] = iTPowerFlag;
                if (iSGFlag != 0)
                {
                    DateTime now  = DateTime.Now;
                    double   num  = 0.0;
                    double   num2 = 0.0;
                    List <InSnergyGateway> allGateWay = InSnergyGateway.GetAllGateWay();
                    foreach (InSnergyGateway current in allGateWay)
                    {
                        if (InSnergyService.IsGatewayOnlineEx(current.GatewayID))
                        {
                            foreach (Branch current2 in current.BranchList)
                            {
                                if (InSnergyService.IsBranchOnlineEx(current2.GatewayID, current2.BranchID))
                                {
                                    Dictionary <string, IMeter> branchEx = InSnergyService.GetBranchEx(current.GatewayID, current2.BranchID);
                                    foreach (SubMeter current3 in current2.SubMeterList)
                                    {
                                        if (branchEx.ContainsKey(current3.SubmeterID) && current3.ElectricityUsage != 0)
                                        {
                                            IMeter meter = branchEx[current3.SubmeterID];
                                            switch (current3.ElectricityUsage)
                                            {
                                            case 1:
                                                if (meter.listParam.ContainsKey(5))
                                                {
                                                    double dvalue = meter.listParam[5].dvalue;
                                                    num += dvalue;
                                                }
                                                break;

                                            case 2:
                                                if (meter.listParam.ContainsKey(5))
                                                {
                                                    double dvalue = meter.listParam[5].dvalue;
                                                    num2 += dvalue;
                                                }
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    double num3;
                    if (iTPowerFlag == 1)
                    {
                        num3 = num;
                    }
                    else
                    {
                        num3 = num;
                    }
                    double num4 = num3 + num2;
                    ret_v[0]         = num3;
                    ret_v[1]         = num4;
                    strTimePrompt[0] = "";
                    strTimePrompt[1] = "";
                    if (InSnergyGateway.Need_Calculate_PUE)
                    {
                        DebugCenter.GetInstance().appendToFile("^^^ Begin to update PUE data ");
                        DateTime now2 = DateTime.Now;
                        num  = InSnergyGateway.GetPUE(0);
                        num2 = InSnergyGateway.GetPUE(1);
                        num3 = num;
                        if (iTPowerFlag == 1)
                        {
                            double dataCenterPDSum = DBTools.GetDataCenterPDSum(0);
                            num3 = dataCenterPDSum + num;
                        }
                        num4                         = num3 + num2;
                        ret_v[2]                     = num3;
                        ret_v[3]                     = num4;
                        strTimePrompt[2]             = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[3]             = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                        InSnergyGateway.Last_IT_HOUR = num3;
                        InSnergyGateway.Last_TT_HOUR = num4;
                        num  = InSnergyGateway.GetPUE(2);
                        num2 = InSnergyGateway.GetPUE(3);
                        num3 = num;
                        if (iTPowerFlag == 1)
                        {
                            double dataCenterPDSum = DBTools.GetDataCenterPDSum(1);
                            num3 = dataCenterPDSum + num;
                        }
                        num4                        = num3 + num2;
                        ret_v[4]                    = num3;
                        ret_v[5]                    = num4;
                        strTimePrompt[4]            = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[5]            = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        InSnergyGateway.Last_IT_DAY = num3;
                        InSnergyGateway.Last_TT_DAY = num4;
                        num  = InSnergyGateway.GetPUE(4);
                        num2 = InSnergyGateway.GetPUE(5);
                        num3 = num;
                        if (iTPowerFlag == 1)
                        {
                            double dataCenterPDSum = DBTools.GetDataCenterPDSum(2);
                            num3 = dataCenterPDSum + num;
                        }
                        num4     = num3 + num2;
                        ret_v[6] = num3;
                        ret_v[7] = num4;
                        DateTime dateTime = now.AddDays((double)(1 - Convert.ToInt32(now.DayOfWeek.ToString("d"))));
                        if (now.DayOfWeek == DayOfWeek.Sunday)
                        {
                            dateTime = dateTime.AddDays(-7.0);
                        }
                        DateTime dateTime2 = dateTime.AddDays(6.0);
                        strTimePrompt[6]                   = dateTime.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime2.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[7]                   = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        InSnergyGateway.Last_IT_WEEK       = num3;
                        InSnergyGateway.Last_TT_WEEK       = num4;
                        InSnergyGateway.Need_Calculate_PUE = false;
                        DebugCenter.GetInstance().appendToFile("^^^^ Finish to update PUE data " + (DateTime.Now - now2).TotalSeconds + " sec");
                    }
                    else
                    {
                        ret_v[2]         = InSnergyGateway.Last_IT_HOUR;
                        ret_v[3]         = InSnergyGateway.Last_TT_HOUR;
                        ret_v[4]         = InSnergyGateway.Last_IT_DAY;
                        ret_v[5]         = InSnergyGateway.Last_TT_DAY;
                        ret_v[6]         = InSnergyGateway.Last_IT_WEEK;
                        ret_v[7]         = InSnergyGateway.Last_TT_WEEK;
                        strTimePrompt[2] = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[4] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        DateTime dateTime3 = now.AddDays((double)(1 - Convert.ToInt32(now.DayOfWeek.ToString("d"))));
                        if (now.DayOfWeek == DayOfWeek.Sunday)
                        {
                            dateTime3 = dateTime3.AddDays(-7.0);
                        }
                        DateTime dateTime4 = dateTime3.AddDays(6.0);
                        strTimePrompt[6] = dateTime3.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime4.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[3] = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[5] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                        strTimePrompt[7] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                string str = CommonAPI.ReportException(0, ex, true, "    ");
                Common.WriteLine("LoadPUEData: " + ex.Message + "\r\n" + str, new string[0]);
            }
        }
Exemple #22
0
 public void pageInit(OtherDevices pParent, TreeNode rootNode)
 {
     this.m_pParent = pParent;
     if (Sys_Para.GetISGFlag() == 0)
     {
         this.cbEnableISGateway.Checked = false;
         this.tbISGServicePort.Enabled  = false;
         this.cbAtenPDU.Enabled         = false;
     }
     else
     {
         this.cbEnableISGateway.Checked = true;
         this.tbISGServicePort.Enabled  = true;
         this.cbAtenPDU.Enabled         = true;
     }
     this.tbISGServicePort.Text = System.Convert.ToString(Sys_Para.GetISGPort());
     if (Sys_Para.GetITPowerFlag() == 0)
     {
         this.cbAtenPDU.Checked = false;
     }
     else
     {
         this.cbAtenPDU.Checked = true;
     }
     this.dgvAllOtherDevices.Rows.Clear();
     System.Collections.Generic.List <InSnergyGateway> allGateWay = InSnergyGateway.GetAllGateWay();
     foreach (TreeNode treeNode in rootNode.Nodes)
     {
         string          text            = treeNode.Text;
         string          name            = treeNode.Name;
         bool            flag            = false;
         InSnergyGateway inSnergyGateway = null;
         for (int i = 0; i < allGateWay.Count; i++)
         {
             inSnergyGateway = allGateWay[i];
             if (inSnergyGateway.GatewayID == name)
             {
                 flag = true;
                 break;
             }
         }
         if (flag)
         {
             string gatewayIP = InSnergyService.getGatewayIP(inSnergyGateway.GatewayID);
             string msg       = EcoLanguage.getMsg(LangRes.ISGST_offline, new string[0]);
             if (InSnergyService.IsGatewayOnline(name))
             {
                 msg = EcoLanguage.getMsg(LangRes.ISGST_online, new string[0]);
             }
             string[] values = new string[]
             {
                 text,
                 inSnergyGateway.GatewayType,
                 gatewayIP,
                 msg,
                 inSnergyGateway.GatewayID
             };
             this.dgvAllOtherDevices.Rows.Add(values);
         }
     }
     if (this.dgvAllOtherDevices.Rows.Count == 0)
     {
         this.butOthDevicesDel.Enabled  = false;
         this.butOthDeviceSetup.Enabled = false;
         return;
     }
     this.butOthDevicesDel.Enabled  = true;
     this.butOthDeviceSetup.Enabled = true;
 }