static void Main(string[] args) { Dictionary<int, Dictionary<int, List<TRXInfo>>> aDictionary = new Dictionary<int, Dictionary<int, List<TRXInfo>>>(); int counter = 0; string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(@"D:\input\input1.txt"); List<TRXInfo> inputList=new List<TRXInfo>(); while ((line = file.ReadLine()) != null) { string[] words = line.Split(' '); TRXInfo aInfo = new TRXInfo(); aInfo.BCF = Convert.ToInt32(words[1]); aInfo.BSC = Convert.ToInt32(words[0]); aInfo.BTS = Convert.ToInt32(words[2]); aInfo.TRX = Convert.ToInt32(words[3]); aInfo.PCM = Convert.ToInt32(words[4]); aInfo.FirstTSL=Convert.ToInt32(words[5]); aInfo.LapdTSL=Convert.ToInt32(words[7]); aInfo.LapdSSL = Convert.ToInt32(words[8]); aInfo.LAPD = words[6]; inputList.Add(aInfo); Dictionary<int, List<TRXInfo>> pcmDictionary = new Dictionary<int, List<TRXInfo>>(); List<TRXInfo> aList = new List<TRXInfo>(); // Console.WriteLine(words[0]); if (aDictionary.ContainsKey(Convert.ToInt32(words[0]))) { //a1Dictionary = aDictionary[Convert.ToInt32(words[0])]; if (aDictionary[Convert.ToInt32(words[0])].ContainsKey(Convert.ToInt32(words[4]))) { aDictionary[Convert.ToInt32(words[0])][Convert.ToInt32(words[4])].Add(aInfo); } else { aList.Add(aInfo); aDictionary[Convert.ToInt32(words[0])].Add(Convert.ToInt32(words[4]),aList); } } else { //List<TRXInfo> aList = new List<TRXInfo>(); aList.Add(aInfo); int pcm = Convert.ToInt32(words[4]); Dictionary<int, List<TRXInfo>> anotherDic = new Dictionary<int, List<TRXInfo>>(); anotherDic.Add(pcm,aList); aDictionary.Add(Convert.ToInt32(words[0]),anotherDic); } // System.Console.WriteLine(line.Split()); counter++; } file.Close(); //System.Console.WriteLine("There were {0} lines.", counter); //// Suspend the screen. //System.Console.ReadLine(); TRX.DAL.TrxManager aTrxManager=new TrxManager(); //aTrxManager.CheckTRX(aDictionary,inputList); TRXShifter aTrxShifter=new TRXShifter(); aTrxShifter.ShiftTRX(aDictionary, inputList); }
public int[,] GetPCMInfo(int bsc,int pcmNo) { int[,] pcmAllocation=new int[4,31]; string qCSDAP = string.Format("select bsc,csdap,pcmCircuit_ID,firstTSL,lastTSL from csdap where bsc={0} and pcmCircuit_ID={1}", bsc, pcmNo); string qTRX =string.Format("select bsc,bcf,bts,trx,channel0Tsl,channel0PCM from trx where bsc={0} and channel0PCM={1}",bsc,pcmNo); string qDAP =string.Format("select bsc,dap,pcmCircuit_ID,firstTSL,lastTSL from dap where bsc={0} and pcmCircuit_ID={1}", bsc,pcmNo); string qLAPD =string.Format("SELECT lapd.bsc,name,abissigchannelTimeslotPcm,abissigchannelTimeslotTSL,abissigchannelSubSlot,bitrate,lapd.logicalbcsuAddress FROM lapd where lapd.bsc={0} and abissigchannelTimeslotPcm={1}",bsc, pcmNo); aSqlConnection.Open(); aSqlCommand = new SqlCommand(qCSDAP, aSqlConnection); SqlDataReader aDataReaderCSDAP = aSqlCommand.ExecuteReader(); List<DynamicAbisPool> abisPoolList = new List<DynamicAbisPool>(); while (aDataReaderCSDAP.Read()) { DynamicAbisPool abisPool = new DynamicAbisPool(); abisPool.BSC = Convert.ToInt32(aDataReaderCSDAP["bsc"]); abisPool.PoolID = Convert.ToInt32(aDataReaderCSDAP["csdap"]); abisPool.PCM = Convert.ToInt32(aDataReaderCSDAP["pcmCircuit_ID"]); abisPool.FirstTSL = Convert.ToInt32(aDataReaderCSDAP["firstTSL"]); abisPool.LastTSL = Convert.ToInt32(aDataReaderCSDAP["lastTSL"]); abisPoolList.Add(abisPool); } aDataReaderCSDAP.Close(); aSqlCommand = new SqlCommand(qDAP, aSqlConnection); SqlDataReader aDataReaderDAP = aSqlCommand.ExecuteReader(); while (aDataReaderDAP.Read()) { DynamicAbisPool abisPool = new DynamicAbisPool(); abisPool.BSC = Convert.ToInt32(aDataReaderDAP["bsc"]); abisPool.PoolID = Convert.ToInt32(aDataReaderDAP["dap"]); abisPool.PCM = Convert.ToInt32(aDataReaderDAP["pcmCircuit_ID"]); abisPool.FirstTSL = Convert.ToInt32(aDataReaderDAP["firstTSL"]); abisPool.LastTSL = Convert.ToInt32(aDataReaderDAP["lastTSL"]); abisPoolList.Add(abisPool); } aDataReaderDAP.Close(); foreach (DynamicAbisPool pool in abisPoolList) { for (int i = pool.FirstTSL; i <= pool.LastTSL; i++) { pcmAllocation[0,i] = 1; pcmAllocation[1, i] = 1; pcmAllocation[2, i] = 1; pcmAllocation[3, i] = 1; } } aSqlCommand = new SqlCommand(qLAPD, aSqlConnection); SqlDataReader aDataReaderLAPD = aSqlCommand.ExecuteReader(); List<LAPD> lapdList=new List<LAPD>(); while (aDataReaderLAPD.Read()) { LAPD aLapd=new LAPD(); aLapd.BSC = Convert.ToInt32(aDataReaderLAPD["bsc"]); aLapd.PCM = Convert.ToInt32(aDataReaderLAPD["abissigchannelTimeslotPcm"]); aLapd.LapdTSL = Convert.ToInt32(aDataReaderLAPD["abissigchannelTimeslotTSL"]); if (aDataReaderLAPD["abissigchannelSubSlot"] != null) { aLapd.subslot = Convert.ToInt32(aDataReaderLAPD["abissigchannelSubSlot"]); } aLapd.Bitrate = Convert.ToInt32(aDataReaderLAPD["bitrate"]); lapdList.Add(aLapd); } aDataReaderLAPD.Close(); foreach (LAPD lapd in lapdList) { if (lapd.Bitrate == 32) { pcmAllocation[lapd.subslot, lapd.LapdTSL] = 1; pcmAllocation[lapd.subslot+1, lapd.LapdTSL] = 1; } else if (lapd.Bitrate == 64) { pcmAllocation[0, lapd.LapdTSL] = 1; pcmAllocation[1, lapd.LapdTSL] = 1; pcmAllocation[2, lapd.LapdTSL] = 1; pcmAllocation[3, lapd.LapdTSL] = 1; } else if (lapd.Bitrate == 16) { pcmAllocation[lapd.subslot, lapd.LapdTSL] = 1; } } aSqlCommand = new SqlCommand(qTRX, aSqlConnection); SqlDataReader aDataReaderTRX = aSqlCommand.ExecuteReader(); List<TRXInfo> aTrxInfosList=new List<TRXInfo>(); while (aDataReaderDAP.Read()) { TRXInfo aTRXInfo=new TRXInfo(); aTRXInfo.BSC = Convert.ToInt32(aDataReaderTRX["bsc"]); aTRXInfo.BCF = Convert.ToInt32(aDataReaderTRX["bcf"]); aTRXInfo.PCM = Convert.ToInt32(aDataReaderTRX["channel0PCM"]); aTRXInfo.FirstTSL = Convert.ToInt32(aDataReaderTRX["channel0Tsl"]); aTrxInfosList.Add(aTRXInfo); } aDataReaderTRX.Close(); foreach (TRXInfo info in aTrxInfosList) { pcmAllocation[0, info.FirstTSL] = 1; pcmAllocation[1, info.FirstTSL] = 1; pcmAllocation[2, info.FirstTSL] = 1; pcmAllocation[3, info.FirstTSL] = 1; pcmAllocation[0, info.FirstTSL+1] = 1; pcmAllocation[1, info.FirstTSL+1] = 1; pcmAllocation[2, info.FirstTSL+1] = 1; pcmAllocation[3, info.FirstTSL+1] = 1; } aSqlConnection.Close(); return pcmAllocation; }