Example #1
0
        private void UpdateDid(Info did)
        {
            SqlConnection dataConnection = null;

            try
            {
                StringBuilder cmdStr = new StringBuilder("UPDATE DID SET DidStateId = 4, SPId = " + did.SPID + ",");

                cmdStr.Append(" GroupId = " + did.GroupNum + " WHERE DID = '" + did.DID + "'");

                // make the connection

                OpenDataConn(ref dataConnection);

                try
                {

                    SqlCommand sqlCommand = new SqlCommand(cmdStr.ToString(), dataConnection);
                    sqlCommand.CommandType = CommandType.Text;
                    sqlCommand.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    LogFileError("BWorksDNListParser::UpdateDid():ECaught:" + ex.Message + ex.StackTrace);
                }

            }//try
            catch (Exception ex)
            {
                LogFileError("BWorksDNListParser::UpdateDid():ECaught:" + ex.Message + ex.StackTrace);
            }

            CloseDataConn(ref dataConnection);
        }
Example #2
0
        /// <summary>
        /// private method to parse the dids in the file
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private ArrayList ParseTheDIDs(string fileName)
        {
            // make the array size (number of cdrs per file ) configurable
            System.Collections.ArrayList theControls = new System.Collections.ArrayList(1000);
            char[] sep = new char[] { ',' };
            char[] trim = new char[] { ' ' };

            bool newGroup = false;
            int groupNumber = 0;
            try
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    String line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        try
                        {

                            // parse the line
                            string[] controls = line.Split(sep);
                            if (controls[0].Contains("<command") )
                            {
                                newGroup = true;
                                // we have a non-data line -- header or footer... so skip it
                                continue;
                            }
                            else if ( controls[0].Contains("</command") )
                            {
                                newGroup = false;
                                groupNumber++;
                                continue;
                            }
                            else if (controls[0].Contains("phoneNumber") )
                            {
                                int indx = controls[0].IndexOf(">");
                                string did = controls[0].Substring(indx+1, 10 );
                                Info info = new Info();
                                info.DID = did;
                                info.GroupName = groups[groupNumber];
                                info.GroupNum = groupNum[groupNumber];
                                info.SPID = spId[groupNumber];

                                theControls.Add( info );
                            }

                        }
                        catch (System.Exception ex)
                        {
                            string errorMsg = "Error in File>" + fileName + " Line>" + groupNumber;
                            if (line != null)
                            {// add the line information if available
                                errorMsg += "Line>" + line;
                            }
                            LogFileError(errorMsg + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                        }
                    }
                }
            }// try
            catch (Exception e)
            {
                LogFileError(e.Message + "\r\n" + e.StackTrace);
            }// catch

            return theControls;
        }