Advertisement

05.22.2008 at 12:02PM PDT, ID: 23425561
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.7

The main form was disappeared. Why?

Asked by YANKAUSKAS in .NET, C# Programming Language, Microsoft Visual C#.Net

Tags: , , ,

I don't know why my main form was disappeared after I start to run the project. I view the process by looking at Task Manager and find the program, but can't find the Form.

File Program.cs
static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FrmParkedCalls());
        }

Form FrmParkedCalls (code is in the Snippet)

The process I debug this program:
I set one breakpoint at the line 85: lvParkedCalls.Items.Add(ExtractInformation("Channel", mr.Response), 0);
I press F10. Visual Studio direct me to the Program.cs file. The focus is in the Visual Studio IDE Window.
F10 =>    Application.EnableVisualStyles();
F10 =>   Application.SetCompatibleTextRenderingDefault(false);
F10 =>   Application.Run(new FrmParkedCalls());
F10 =>   at this time the focus change to no where, maybe the program, but I don't see any Form display.
Why?
My source code is here:
http://nhactre.eu/Demo_1.zip
Please help me!
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
namespace ParkedCalls
{
    public partial class FrmParkedCalls : Form
    {
        const string DEV_HOST = "10.0.0.3";
        const int ASTERISK_PORT = 5038;
        const string ASTERISK_HOST = "10.0.0.12";
        const string ASTERISK_LOGINNAME = "hiep";
        const string ASTERISK_LOGINPWD = "matkhau";
        const string ORIGINATE_CONTEXT = "local";
        const string ORIGINATE_CHANNEL = "SIP/401";
        const string ORIGINATE_EXTRA_CHANNEL = "SIP/402";
        const string ORIGINATE_EXTRA_EXTEN = "101";
        const string ORIGINATE_EXTEN = "101";
        const string ORIGINATE_CALLERID = "Test Asterisk";
        const string TRANSFER_CHANNEL = "SIP/402";
        
        public static AsteriskManager manager;
        private static string monitorChannel = null;
        private static string transferChannel = null;
 
        string ChannelConnect = "New channel Event";
        string ChannelDisConnect = "Hangup Event";
 
 
        public FrmParkedCalls()
        {
            InitializeComponent();
 
            manager = new AsteriskManager(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD);
            string strErrorConnection = "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond";
 
            // Add or Remove events
            manager.NewChannel += new NewChannelEventHandler(dam_NewChannel);
            manager.Hangup += new HangupEventHandler(dam_Hangup);
            manager.PeerStatus += new PeerStatusEventHandler(dam_PeerStatus);
            manager.Dial += new DialEventHandler(dam_Dial);
            manager.OriginateFailure += new OriginateFailureEventHandler(dam_OriginateFailure);
            manager.OriginateSuccess += new OriginateSuccessEventHandler(dam_OriginateSuccess);
 
            try
            {
                manager.Connection.DefaultTimeout = 0;
                manager.Connection.DefaultEventTimeout = 0;
                manager.Initialize();		// Login and initialize queue and channels (slow)                
            }
            catch (Exception ex)
            {
                if (ex.Message.Equals("Authentication failed"))
                {
                    Console.WriteLine("Authentication failed!");
                }
                if (String.Compare(strErrorConnection, 0, ex.Message, 0, 20) == 0)
                {
                    Console.WriteLine("Please check the connection again!");
                }
                manager.Logoff();
                return;
            }
 
            //	Monitor call.
            LinkEventHandler le = new LinkEventHandler(dam_Link);
            manager.Link += le;
            while (monitorChannel == null)
            {
                System.Threading.Thread.Sleep(100);
            }
            manager.Link -= le;
            // Now send Monitor action
            MonitorAction ma = new MonitorAction();
            ma.Channel = monitorChannel;
            ma.File = "voicefile";
            ma.Format = "gsm";
            ma.Mix = true;
            try
            {
                ManagerResponse mr = manager.Connection.SendAction(ma, 10000);
                //Console.WriteLine("Monitor Call" + "\n\tResponse:" + mr.Response);
 
                if (String.Compare(ChannelConnect, 0, mr.Response, 0, 17) == 0)
                {
                    lvParkedCalls.Items.Add(ExtractInformation("Channel", mr.Response), 0);
                    lvParkedCalls.Items.Add(ExtractInformation("UniqueId", mr.Response), 1);
                    lvParkedCalls.Items.Add(ExtractInformation("CallerId", mr.Response), 2);
                    lvParkedCalls.Items.Add(ExtractInformation("CallerIdName", mr.Response), 3);
                    lvParkedCalls.Items.Add(ExtractInformation("State", mr.Response), 4);
                    lvParkedCalls.Items.Add(ExtractInformation("DateReceived", mr.Response), 5);
 
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 
        private string ExtractInformation(string regExPattern, string searchString)
        {
            string returnValue = string.Empty;
            Regex searchRegEx = new Regex(@"(" + regExPattern + @").*");
            Regex replaceRegEx = new Regex(@"(" + regExPattern + @")(:)*\s*");
            MatchCollection matches = searchRegEx.Matches(searchString);
 
            foreach (Match m in matches)
            {
                returnValue = replaceRegEx.Replace(m.Value, "");
                break;
            }
 
            return returnValue;
        }
 
        #region Event handlers
        static void dam_Events(object sender, ManagerEvent e)
        {
            Console.WriteLine("+++ Event : " + e.GetType().FullName);
 
        }
        static void dam_Reload(object sender, ReloadEvent e)
        {
            Console.WriteLine("Reload Event"
                + "\n\tMessage\t\t" + e.Message
            );
        }
        static void dam_ExtensionStatus(object sender, ExtensionStatusEvent e)
        {
            Console.WriteLine("ExtensionStatus Event"
                + "\n\tContext\t\t" + e.Context
                + "\n\tExten\t\t" + e.Exten
                + "\n\tStatus\t\t" + e.Status
            );
        }
 
        static void dam_Dial(object sender, DialEvent e)
        {
            Console.WriteLine("Dial Event"
                + "\n\tCallerId\t" + e.CallerId
                + "\n\tCallerIdName\t" + e.CallerIdName
                + "\n\tDestination\t" + e.Destination
                + "\n\tDestUniqueId\t" + e.DestUniqueId
                + "\n\tSrc\t\t" + e.Src
                + "\n\tSrcUniqueId\t" + e.SrcUniqueId
            );
            if (e != null && e.Destination != null && e.Destination.StartsWith(ORIGINATE_CHANNEL))
                transferChannel = e.Src;
        }
        static void dam_OriginateFailure(object sender, OriginateFailureEvent e)
        {
            Console.WriteLine("Originate Failure Event"
                + "\n\tChannel\t\t" + e.Channel
                + "\n\tUniqueId\t" + e.UniqueId
                + "\n\tContext\t\t" + e.Context
                );
        }
        static void dam_OriginateSuccess(object sender, OriginateSuccessEvent e)
        {
            Console.WriteLine("Originate Success Event"
                + "\n\tChannel\t\t" + e.Channel
                + "\n\tUniqueId\t" + e.UniqueId
                + "\n\tContext\t\t" + e.Context
                );
        }
        static void dam_Hangup(object sender, HangupEvent e)
        {
            Console.WriteLine("Hangup Event"
                + "\n\tChannel\t\t" + e.Channel
                + "\n\tUniqueId\t" + e.UniqueId
                );
        }
        static void dam_NewExten(object sender, NewExtenEvent e)
        {
            Console.WriteLine("New Extension Event"
                + "\n\tChannel\t\t" + e.Channel
                + "\n\tExtension\t" + e.Extension
                + "\n\tContext\t\t" + e.Context
                + "\n\tDateReceived\t" + e.DateReceived.ToString()
                + "\n\tPriority\t" + e.Priority.ToString()
                + "\n\tPrivilege\t" + e.Privilege
                + "\n\tUniqueId\t" + e.UniqueId
                + "\n\tAppData\t\t" + e.AppData
                + "\n\tApplication\t" + e.Application
                );
        }
        static void dam_NewChannel(object sender, NewChannelEvent e)
        {
            Console.WriteLine("New channel Event"
                + "\n\tChannel\t\t" + e.Channel
                + "\n\tUniqueId\t" + e.UniqueId
                + "\n\tCallerId\t" + e.CallerId
                + "\n\tCallerIdName\t" + e.CallerIdName
                + "\n\tState\t\t" + e.State
                + "\n\tDateReceived\t" + e.DateReceived.ToString()
                );
        }
        static void dam_PeerStatus(object sender, PeerStatusEvent e)
        {
            Console.WriteLine("Peer Status Event"
                + "\n\tPeer\t\t" + e.Peer
                + "\n\tStatus\t\t" + e.PeerStatus
                + "\n\tDateReceived\t" + e.DateReceived.ToString()
                );
        }
        static void dam_Link(object sender, LinkEvent e)
        {
            Console.WriteLine("Link Event"
                + "\n\tChannel1:\t" + e.Channel1
                + "\n\tChannel2:\t" + e.Channel2
                );
            if (e.Channel1.StartsWith(ORIGINATE_CHANNEL) || e.Channel2.StartsWith(ORIGINATE_CHANNEL))
                monitorChannel = e.Channel1;
        }
        #endregion
    }
}
[+][-]05.22.2008 at 12:16PM PDT, ID: 21626753

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET, C# Programming Language, Microsoft Visual C#.Net
Tags: Microsoft, Visual Studio, 2005, C#
Sign Up Now!
Solution Provided By: p_davis
Participating Experts: 2
Solution Grade: B
 
 
[+][-]05.22.2008 at 12:22PM PDT, ID: 21626817

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 12:25PM PDT, ID: 21626837

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 12:28PM PDT, ID: 21626846

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.22.2008 at 12:41PM PDT, ID: 21626921

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 12:50PM PDT, ID: 21626984

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 12:53PM PDT, ID: 21627004

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 01:19PM PDT, ID: 21627204

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 01:28PM PDT, ID: 21627265

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 01:35PM PDT, ID: 21627321

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 01:36PM PDT, ID: 21627341

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628