Success









How do I use Success
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: WorkerInGame.cs Copy
26     public void OnGUI()
27     {
28         if (GUILayout.Button("Return to Lobby"))
29         {
30             PhotonNetwork.LeaveRoom(); // we will load the menu level when we successfully left the room
31         }
32     }
File name: AccountService.cs Copy
29     public string Message { get; private set; } // msg from server (in case of success, this is the appid)
31     protected internal Exception Exception { get; set; } // exceptions in account-server communication
File name: PingCloudRegions.cs Copy
43     public override bool Done()
44     {
45         if (this.GotResult || sock == null)
46         {
47             return true;
48         }
49
50         if (sock.Available <= 0)
51         {
52             return false;
53         }
54
55         int read = sock.Receive(PingBytes, SocketFlags.None);
56         //Debug.Log("Got: " + SupportClass.ByteArrayToString(PingBytes));
57         bool replyMatch = PingBytes[PingBytes.Length - 1] == PingId && read == PingLength;
58         if (!replyMatch) Debug.Log("ReplyMatch is false! ");
59
60
61         this.Successful = read == PingBytes.Length && PingBytes[PingBytes.Length - 1] == PingId;
62         this.GotResult = true;
63         return true;
64     }
File name: PingCloudRegions.cs Copy
118     public IEnumerator PingSocket(Region region)
119     {
120         region.Ping = Attempts*MaxMilliseconsPerPing;
121
122         this.PingsRunning++; // TODO: Add try-catch to make sure the PingsRunning are reduced at the end and that the lib does not crash the app
123         PhotonPing ping;
124         //Debug.Log("PhotonHandler.PingImplementation " + PhotonHandler.PingImplementation);
125         if (PhotonHandler.PingImplementation == typeof(PingNativeDynamic))
126         {
127             Debug.Log("Using constructor for new PingNativeDynamic()"); // it seems on android, the Activator can't find the default Constructor
128             ping = new PingNativeDynamic();
129         }
130         else
131         {
132             ping = (PhotonPing)Activator.CreateInstance(PhotonHandler.PingImplementation);
133         }
134
135         //Debug.Log("Ping is: " + ping + " type " + ping.GetType());
136
137         float rttSum = 0.0f;
138         int replyCount = 0;
139
140
141         // PhotonPing.StartPing() requires a plain IP address without port (on all but Windows 8 platforms).
142         // So: remove port and do the DNS-resolving if needed
143         string cleanIpOfRegion = region.HostAndPort;
144         int indexOfColon = cleanIpOfRegion.LastIndexOf(':');
145         if (indexOfColon > 1)
146         {
147             cleanIpOfRegion = cleanIpOfRegion.Substring(0, indexOfColon);
148         }
149         cleanIpOfRegion = ResolveHost(cleanIpOfRegion);
150         //Debug.Log("Resolved and port-less IP is: " + cleanIpOfRegion);
151
152
153         for (int i = 0; i < Attempts; i++)
154         {
155             bool overtime = false;
156             Stopwatch sw = new Stopwatch();
157             sw.Start();
158
159             try
160             {
161                 ping.StartPing(cleanIpOfRegion);
162             }
163             catch (Exception e)
164             {
165                 Debug.Log("catched: " + e);
166                 this.PingsRunning--;
167                 break;
168             }
169
170
171             while (!ping.Done())
172             {
173                 if (sw.ElapsedMilliseconds >= MaxMilliseconsPerPing)
174                 {
175                     overtime = true;
176                     break;
177                 }
178                 yield return 0; // keep this loop tight, to avoid adding local lag to rtt.
179             }
180             int rtt = (int)sw.ElapsedMilliseconds;
181
182
183             if (IgnoreInitialAttempt && i == 0)
184             {
185                 // do nothing.
186             }
187             else if (ping.Successful && !overtime)
188             {
189                 rttSum += rtt;
190                 replyCount++;
191                 region.Ping = (int)((rttSum) / replyCount);
192                 //Debug.Log("region " + region.Code + " RTT " + region.Ping + " success: " + ping.Successful + " over: " + overtime);
193             }
194
195             yield return new WaitForSeconds(0.1f);
196         }
197
198         this.PingsRunning--;
199
200         //Debug.Log("this.PingsRunning: " + this.PingsRunning + " this debug: " + ping.DebugString);
201         yield return null;
202     }
File name: SocketUdp.cs Copy
91         public override PhotonSocketError Send(byte[] data, int length)
92         {
93             lock (this.syncer)
94             {
95                 if (!this.sock.Connected)
96                 {
97                     return PhotonSocketError.Skipped;
98                 }
99
100                 try
101                 {
102                     sock.Send(data, 0, length, SocketFlags.None);
103                 }
104                 catch
105                 {
106                     return PhotonSocketError.Exception;
107                 }
108             }
109
110             return PhotonSocketError.Success;
111         }
File name: DeleteMembers.cs Copy
20         private void button1_Click(object sender, EventArgs e)
21         {
22             try
23             {
24                 SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True");
25                 con.Open();
26
27                 string str = "DELETE FROM members WHERE m_id = '" + textBox1.Text + "'";
28
29                 SqlCommand cmd = new SqlCommand(str, con);
30                 cmd.ExecuteNonQuery();
31                 con.Close();
32                 MessageBox.Show(" Members Record Deleted Successfully");
33
34                 using (SqlConnection newcon = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True"))
35                 {
36                     string str1 = "SELECT * from members";
37                     SqlCommand cmd1 = new SqlCommand(str1, newcon);
38                     SqlDataAdapter da = new SqlDataAdapter(cmd1);
39                     DataTable dt = new DataTable();
40                     da.Fill(dt);
41                     dataGridView1.DataSource = new BindingSource(dt, null);
42
43                 }
44             }
45
46             catch (SqlException ex)
47             {
48                 MessageBox.Show(ex.Message);
49                 MessageBox.Show("Please Enter Employee Id..");
50             }
51         }
File name: Equipment.cs Copy
20         private void button1_Click(object sender, EventArgs e)
21         {
22             SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True");
23             con.Open();
24
25             try
26             {
27                 string str = " INSERT INTO equipment(name,description,used,cost) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "'); ";
28
29                 SqlCommand cmd = new SqlCommand(str, con);
30                 cmd.ExecuteNonQuery();
31
32                 string str1 = "select max(eqp_id) from equipment;";
33
34                 SqlCommand cmd1 = new SqlCommand(str1, con);
35                 SqlDataReader dr = cmd1.ExecuteReader();
36                 if (dr.Read())
37                 {
38                     MessageBox.Show("" + textBox1.Text + "'s Equipment Details is Inserted Successfully.. ");
39                     this.Hide();
40
41                 }
42                 this.Close();
43             }
44             catch (SqlException excep)
45             {
46                 MessageBox.Show(excep.Message);
47             }
48             con.Close();
49         }
File name: NewMember.cs Copy
25         private void button1_Click(object sender, EventArgs e)
26         {
27             SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True");
28             con.Open();
29             string gender = string.Empty;
30             if (radioButton1.Checked)
31             {
32                 gender = "Male";
33             }
34             else if (radioButton2.Checked)
35             {
36                 gender = "Female";
37             }
38             try
39             {
40                 string str = " INSERT INTO members(f_name,l_name,gender,dob,mobile,email,jod,time,address,mem_time) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + gender + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + comboBox1.Text + "','" + textBox7.Text + "','" + comboBox2.Text + "'); ";
41
42                 SqlCommand cmd = new SqlCommand(str, con);
43                 cmd.ExecuteNonQuery();
44
45                 string str1 = "select max(m_id) from members ;";
46
47                 SqlCommand cmd1 = new SqlCommand(str1, con);
48                 SqlDataReader dr = cmd1.ExecuteReader();
49                 if (dr.Read())
50                 {
51                     MessageBox.Show("" + textBox1.Text + "'s Details is Inserted Successfully.. " + textBox1.Text + "'s Id is " + dr.GetInt32(0) + ".", "Important Message");
52                     this.Hide();
53
54                 }
55                 this.Close();
56             }
57             catch (SqlException excep)
58             {
59                 MessageBox.Show(excep.Message);
60             }
61             con.Close();
62         }
File name: NewStaff.cs Copy
20         private void button1_Click(object sender, EventArgs e)
21         {
22             SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True");
23             con.Open();
24             string gender = string.Empty;
25             if (radioButton1.Checked)
26             {
27                 gender = "Male";
28             }
29             else if (radioButton2.Checked)
30             {
31                 gender = "Female";
32             }
33             try
34             {
35                 string str = " INSERT INTO staff(f_name,l_name,gender,dob,mobile,email,jod,street,city) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + gender + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" +textBox8.Text + "'); ";
36
37                 SqlCommand cmd = new SqlCommand(str, con);
38                 cmd.ExecuteNonQuery();
39
40                 string str1 = "select max(stf_id) from staff;";
41
42                 SqlCommand cmd1 = new SqlCommand(str1, con);
43                 SqlDataReader dr = cmd1.ExecuteReader();
44                 if (dr.Read())
45                 {
46                     MessageBox.Show("" + textBox1.Text + "'s Details is Inserted Successfully.. " + textBox1.Text + "'s Id is " + dr.GetInt32(0) + ".", "Important Message");
47                     this.Hide();
48
49                 }
50                 this.Close();
51             }
52             catch (SqlException excep)
53             {
54                 MessageBox.Show(excep.Message);
55             }
56             con.Close();
57         }
File name: Register.cs Copy
20         private void button1_Click(object sender, EventArgs e)
21         {
22             SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\Sem.4\C# Projects\GymManagementSystem in C#\GymManagementSystem\Gym.mdf;Integrated Security=True;User Instance=True");
23             con.Open();
24             string gender = string.Empty;
25             if (radioButton1.Checked)
26             {
27                 gender = "Male";
28             }
29             else if (radioButton2.Checked)
30             {
31                 gender = "Female";
32             }
33             try
34             {
35                 string str = " INSERT INTO employee(emp_username,name,password,gender,email,mobile,address,date) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + gender + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "'); ";
36
37                 SqlCommand cmd = new SqlCommand(str, con);
38                 cmd.ExecuteNonQuery();
39
40                 string str1 = "select max(emp_id) from employee ;";
41
42                 SqlCommand cmd1 = new SqlCommand(str1, con);
43                 SqlDataReader dr = cmd1.ExecuteReader();
44                 if (dr.Read())
45                 {
46                     MessageBox.Show("" + textBox1.Text + "'s Details is Inserted Successfully.. " + textBox1.Text + "'s Id is " + dr.GetInt32(0) + ".", "Important Message");
47                     this.Hide();
48                     Home obj1 = new Home();
49                     obj1.ShowDialog();
50                 }
51                 this.Close();
52             }
53             catch (SqlException excep)
54             {
55                 MessageBox.Show(excep.Message);
56             }
57             con.Close();
58         }

Download file with original file name:Success

Success 124 lượt xem

Gõ tìm kiếm nhanh...