Ejemplo n.º 1
0
        private void fillOptions()
        {
            string strRoutineName = "SMSSlaveGroup: fillOptions";

            try
            {
                #region  Fill Modem ...
                ucSMS.CmbModem.Items.Clear();
                foreach (String st in SMSSlave.getModem())
                {
                    ucSMS.CmbModem.Items.Add(st.ToString());
                }
                if (ucSMS.CmbModem.Items.Count > 0)
                {
                    ucSMS.CmbModem.SelectedIndex = 0;
                }
                #endregion  Fill Modem ...

                #region  Fill Debug levels...
                ucSMS.cmbDebug.Items.Clear();
                for (int i = 1; i <= Globals.MAX_DEBUG_LEVEL; i++)
                {
                    ucSMS.cmbDebug.Items.Add(i.ToString());
                }
                ucSMS.cmbDebug.SelectedIndex = 0;
                #endregion  Fill Debug levels...
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void loadValues()
        {
            string strRoutineName = "SMSSlaveGroup:loadValues";

            try
            {
                SMSSlave SMS = SMSSlaveList.ElementAt(editIndex);
                if (SMS != null)
                {
                    ucSMS.txtSlaveNum.Text             = SMS.SlaveNum;
                    ucSMS.txtUnitID.Text               = SMS.UnitID;
                    ucSMS.CmbModem.SelectedIndex       = ucSMS.CmbModem.FindStringExact(SMS.Modem);
                    ucSMS.txtTolerancePeriodInMin.Text = SMS.TolerancePeriodInMin;
                    ucSMS.txtRemoteMobileNo.Text       = SMS.RemoteMobileNo;
                    ucSMS.cmbPortNo.Text               = SMS.PortNum;
                    ucSMS.txtEventQSize.Text           = SMS.EventQSize;
                    DataRowView oDataRowView = ucSMS.cmbPortNo.SelectedItem as DataRowView;
                    string      sValue       = string.Empty;
                    if (oDataRowView != null)
                    {
                        sValue = oDataRowView.Row["PortNum"] as string;
                    }
                    if (ucSMS.cmbPortNo.Items.OfType <DataRowView>().Where(x => x.Row.ItemArray[0].ToString() == sValue).Any())
                    {
                        ucSMS.cmbPortNo.SelectedIndex = ucSMS.cmbPortNo.Items.IndexOf(ucSMS.cmbPortNo.Items.OfType <DataRowView>().Where(x => x.Row.ItemArray[0].ToString() == sValue).Select(x => x).SingleOrDefault());
                    }
                    else
                    {
                        ucSMS.cmbPortNo.SelectedIndex = 0;
                    }

                    ucSMS.txtFirmwareVersion.Text = SMS.AppFirmwareVersion;
                    ucSMS.cmbDebug.SelectedIndex  = ucSMS.cmbDebug.FindStringExact(SMS.DEBUG);

                    foreach (NetworkInterface ni in Utils.getOpenProPlusHandle().getNetworkConfiguration().getNetworkInterfaces())
                    {
                        if (ni.Enable == "YES")
                        {
                            if (ucSMS.cmbPortNo.Items.OfType <DataRowView>().Where(x => x.Row.ItemArray[0].ToString() == ni.PortNum).Any())
                            {
                                ucSMS.cmbPortNo.SelectedIndex = ucSMS.cmbPortNo.Items.IndexOf(ucSMS.cmbPortNo.Items.OfType <DataRowView>().Where(x => x.Row.ItemArray[0].ToString() == ni.PortNum).Select(x => x).SingleOrDefault());
                            }
                        }
                    }
                    if (SMS.Run.ToLower() == "yes")
                    {
                        ucSMS.chkRun.Checked = true;
                    }
                    else
                    {
                        ucSMS.chkRun.Checked = false;
                    }
                    if (SMS.UserFriendlySMS.ToLower() == "yes")
                    {
                        ucSMS.chkUserFriendlySMS.Checked = true;
                    }
                    else
                    {
                        ucSMS.chkUserFriendlySMS.Checked = false;
                    }
                    if (SMS.EnableEncryption.ToLower() == "yes")
                    {
                        ucSMS.chkEnableEncryption.Checked = true;
                    }
                    else
                    {
                        ucSMS.chkEnableEncryption.Checked = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        //private void btnDone_Click(object sender, EventArgs e)
        //{
        //    string strRoutineName = "SMSSlaveGroup:btnDone_Click";
        //    try
        //    {
        //        //TreeNode tmp=null;
        //        if (!Validate()) return;
        //        List<KeyValuePair<string, string>> mbsData = Utils.getKeyValueAttributes(ucSMS.grpSMSSlave);
        //        if (!Utils.IsValidate)
        //        {
        //            if (!CheckTextBox(ucSMS.txtRemoteMobileNo)) return;
        //        }
        //        if (mode == Mode.ADD)
        //        {
        //            if(mbsData[2].Value =="")
        //            {
        //                MessageBox.Show("Please select Port No.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        //                return;
        //            }
        //            TreeNode tmp = null;
        //            if(Utils.IsValidate)
        //            {
        //                tmp = SMSlaveGroupTreeNode.Nodes.Add("SMSSlave_" + Utils.GenerateShortUniqueKey(), "SMSSlave", "SMSSlave", "SMSSlave");
        //                SMSSlaveList.Add(new SMSSlave("SMSSlave", mbsData, tmp));
        //            }
        //            else
        //            {
        //                SMSSlaveList.Add(new SMSSlave("SMSSlave", mbsData, tmp));
        //            }
        //            Globals.TotalSlavesCount += 1; //Ajay: 25/08/2018
        //        }
        //        else if (mode == Mode.EDIT)
        //        {
        //            TreeNode tmp = null;
        //            if (Utils.IsValidate)
        //            {
        //                if(SMSSlaveList[editIndex].SMSSlaveTreeNode == null)
        //                {
        //                    tmp = SMSlaveGroupTreeNode.Nodes.Add("SMSSlave_" + Utils.GenerateShortUniqueKey(), "SMSSlave", "SMSSlave", "SMSSlave");
        //                    SMSSlave NewAIMap = new SMSSlave("SMSSlave", mbsData, tmp);
        //                    SMSSlaveList[editIndex].SMSSlaveTreeNode = Utils.SMSSlaveTreeNode;
        //                    SMSSlaveList[editIndex].updateAttributes(mbsData);
        //                }
        //                else
        //                {
        //                    SMSSlaveList[editIndex].updateAttributes(mbsData);
        //                }

        //            }
        //            else if (Utils.IsValidate == false)
        //            {
        //                if (SMSSlaveList[editIndex].SMSSlaveTreeNode != null)
        //                {
        //                    SMSlaveGroupTreeNode.Nodes.Remove(SMSSlaveList[editIndex].SMSSlaveTreeNode);
        //                    SMSSlaveList[editIndex].SMSSlaveTreeNode = null;
        //                }
        //                else
        //                {
        //                    SMSSlaveList[editIndex].updateAttributes(mbsData);
        //                }
        //            }
        //            else { SMSSlaveList[editIndex].updateAttributes(mbsData); }
        //        }
        //        refreshList();
        //        if (sender != null && e != null)
        //        {
        //            ucSMS.grpSMSSlave.Visible = false;
        //            mode = Mode.NONE;
        //            editIndex = -1;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
        //    }
        //}
        private void btnDone_Click(object sender, EventArgs e)
        {
            string strRoutineName = "SMSSlaveGroup:btnDone_Click";

            try
            {
                if (!Validate())
                {
                    return;
                }
                List <KeyValuePair <string, string> > mbsData = Utils.getKeyValueAttributes(ucSMS.grpSMSSlave);
                if (!Utils.IsValidate)
                {
                    if (!CheckTextBox(ucSMS.txtRemoteMobileNo))
                    {
                        return;
                    }
                }
                if (mode == Mode.ADD)
                {
                    if (mbsData[2].Value == "")
                    {
                        MessageBox.Show("Please select Port No.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    TreeNode tmp = null;
                    if (Utils.IsValidate)
                    {
                        tmp = SMSlaveGroupTreeNode.Nodes.Add("SMSSlave_" + Utils.GenerateShortUniqueKey(), "SMSSlave", "SMSSlave", "SMSSlave");
                        SMSSlaveList.Add(new SMSSlave("SMSSlave", mbsData, tmp));
                    }
                    else
                    {
                        SMSSlaveList.Add(new SMSSlave("SMSSlave", mbsData, tmp));
                    }
                    Globals.TotalSlavesCount += 1; //Ajay: 25/08/2018
                }
                else if (mode == Mode.EDIT)
                {
                    TreeNode tmp = null;
                    if (Utils.IsValidate)
                    {
                        if (SMSSlaveList[editIndex].SMSSlaveTreeNode == null)
                        {
                            tmp = SMSlaveGroupTreeNode.Nodes.Add("SMSSlave_" + Utils.GenerateShortUniqueKey(), "SMSSlave", "SMSSlave", "SMSSlave");
                            SMSSlave NewAIMap = new SMSSlave("SMSSlave", mbsData, tmp);
                            SMSSlaveList[editIndex].SMSSlaveTreeNode = Utils.SMSSlaveTreeNode;
                            SMSSlaveList[editIndex].updateAttributes(mbsData);
                        }
                        else
                        {
                            SMSSlaveList[editIndex].updateAttributes(mbsData);
                        }
                    }
                    else if (Utils.IsValidate == false)
                    {
                        if (SMSSlaveList[editIndex].SMSSlaveTreeNode != null)
                        {
                            SMSlaveGroupTreeNode.Nodes.Remove(SMSSlaveList[editIndex].SMSSlaveTreeNode);
                            SMSSlaveList[editIndex].SMSSlaveTreeNode = null;
                            SMSSlaveList[editIndex].updateAttributes(mbsData);
                        }
                        else
                        {
                            SMSSlaveList[editIndex].updateAttributes(mbsData);
                        }
                    }
                    else
                    {
                        SMSSlaveList[editIndex].updateAttributes(mbsData);
                    }
                }
                refreshList();
                if (sender != null && e != null)
                {
                    ucSMS.grpSMSSlave.Visible = false;
                    mode      = Mode.NONE;
                    editIndex = -1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }