public static void ProcessOpNpdbChange(Dictionary <string, string> InputKeys, servRequest eRequest, out Dictionary <string, string> KeyNpdb)
        {
            InputKeys.TryGetValue("SUBSCRIBER NUMBER", out string isdn);
            InputKeys.TryGetValue("DESCRIPTION", out string desc);

            if (string.IsNullOrEmpty(isdn))
            {
                MessageBox.Show("'SUBSCRIBER NUMBER' can't be empty.", "missing parameter");
                KeyNpdb = null;
                return;
            }

            isdn = Program.NormalizeMSISDN(isdn, 4);

            if (!isdn.StartsWith("2"))
            {
                isdn = NormalizeMSISDN(isdn, 1);
            }

            string sCommand = string.Empty;

            switch (eRequest)
            {
            case servRequest.prov:
                if (!int.TryParse(InputKeys["INDEX NUMBER"], out int index))
                {
                    MessageBox.Show("check 'INDEX NUMBER'", "invalid parameter value");
                    KeyNpdb = null;
                    return;
                }

                if (string.IsNullOrEmpty(desc))
                {
                    desc = isdn;
                }

                sCommand = "ADD SERUATTR: USRNUM=" + "\"" + isdn + "\"" + ", DESC=" + "\"" + desc + "\"" + " ,SERVATTR=OMNP-1, NUMTYPE=TYPE1, RNIDXTYPE=RN, RNIDX2=" + index + ";";
                break;

            case servRequest.remove:
                sCommand = "RMV SERUATTR: MODE = num, USRNUM=" + "\"" + isdn + "\"" + ";";
                break;

            default:
                break;
            }

            KeyNpdb = new Dictionary <string, string> {
            };

            KeyNpdb.Add("isdn", isdn);

            string[] npdbIPs = parameters.stpIP().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var item in npdbIPs)
            {
                string sResult = string.Empty;

                string sNode   = item.Substring(0, item.IndexOf("="));
                string sNodeIP = item.Substring(sNode.Length + 1);

                KeyNpdb.Add(sNode, null);

                tcpconnect tcp = new tcpconnect();

                tcp.NpdbCommand(sCommand, sNodeIP, out sResult);

                tcp.DisconnectHost(sNodeIP);

                string regExpPattern = string.Concat("RETCODE", ".*?=.*?", "(.*)");

                Regex regExp = new Regex(regExpPattern, RegexOptions.IgnoreCase);

                Match regExpMatch = regExp.Match(sResult);

                if (!regExpMatch.Success)
                {
                    KeyNpdb[sNode] = "result unknown, check with network display.";

                    continue;
                }

                KeyNpdb[sNode] = regExpMatch.Groups[1].ToString();
            }
        }
        public static void ProcessOpNpdbStatus(string isdn, out Dictionary <string, string> KeyNpdb, bool numberRange)
        {
            string[] ArrNpdbIndex = parameters.stpIndex().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

            Dictionary <string, string> KeyNpdbIndex = new Dictionary <string, string> {
            };

            foreach (string item in ArrNpdbIndex)
            {
                string[] ArrIndex = item.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);

                KeyNpdbIndex.Add(ArrIndex.GetValue(0).ToString().Trim(), ArrIndex.GetValue(1).ToString().Trim());
            }

            KeyNpdb = new Dictionary <string, string> {
            };

            isdn = NormalizeMSISDN(isdn, 4);

            if (!isdn.StartsWith("2"))
            {
                isdn = NormalizeMSISDN(isdn, 1);
            }


            string sCommand = "LST SERUATTR: MODE=NUM,USRNUM=" + "\"" + isdn + "\"" + ";";

            string[] sCommands = new string[3];

            sCommands.SetValue(sCommand, 0);

            if (numberRange)
            {
                sCommand = "LST MNPFRGNRNG: MODE=number,NUMBER=" + "\"" + isdn + "\"" + ";";
                sCommands.SetValue(sCommand, 1);

                //sCommand = "LST MNPLOCNRNG: MODE=number,NUMBER=" + "\"" + isdn + "\"" + ";";
                //sCommands.SetValue(sCommand, 2);
            }


            foreach (var item in sCommands)
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }

                sCommand = item.Substring(3, 10);
                sCommand = sCommand.Replace(':', ' ');
                sCommand = sCommand.Trim();

                //KeyNpdb.Add(sCommand, isdn);

                string[] npdbIPs = parameters.stpIP().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var sIP in npdbIPs)
                {
                    string sResult = string.Empty;

                    string sNode   = sIP.Substring(0, sIP.IndexOf("="));
                    string sNodeIP = sIP.Substring(sNode.Length + 1);

                    string sKey = sCommand + "-" + sNode;

                    KeyNpdb.Add(sKey, null);

                    tcpconnect tcp = new tcpconnect();

                    tcp.NpdbCommand(item, sNodeIP, out sResult);

                    tcp.DisconnectHost(sNodeIP);

                    sResult = sResult.ToUpper();

                    string[] npdbOut = sResult.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                    if (sCommand == "SERUATTR")
                    {
                        npdbOut = Array.FindAll(npdbOut, s => s.Contains("ROUTING NUMBER INDEX"));

                        if (npdbOut.Length == 0)
                        {
                            KeyNpdb[sKey] = "no data found.";
                            continue;
                        }

                        npdbOut = npdbOut[0].Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries);

                        int iIndex = Array.IndexOf(npdbOut, "ROUTING NUMBER INDEX");

                        if (iIndex < 0)
                        {
                            KeyNpdb[sKey] = "printout error, please check original output. counld not find string (Routing Number Index)";
                            continue;
                        }

                        npdbOut = sResult.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                        npdbOut = Array.FindAll(npdbOut, s => s.Contains(" " + isdn + " "));

                        if (npdbOut.Length == 0)
                        {
                            KeyNpdb[sKey] = "printout error, please check original output. counld not find string " + isdn;
                            continue;
                        }

                        npdbOut = npdbOut[0].Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries);

                        sResult = npdbOut.GetValue(iIndex).ToString().Trim();

                        KeyNpdb[sKey] = KeyNpdbIndex[sResult].ToLower();

                        continue;
                    }
                    else
                    {
                        KeyNpdb[sKey] = string.Join(Environment.NewLine, npdbOut.Skip(4));
                    }
                }
            }
        }