/// <summary> /// GridLookup 欄位值變更時儲存至 Session /// </summary> /// <param name="sender">sender</param> /// <param name="e">e</param> /// <param name="SessionType">欄位型態</param> /// <param name="index">Session 索引</param> public static void ValueChanged(object sender, EventArgs e, ParmType SessionType, int index) { string SessionName = "v"; SessionName += (SessionType == ParmType.Integer) ? "iparm" : "sparm"; SessionName += index.ToString(); object obj_value = (sender as ASPxGridLookup).Value; HttpContext.Current.Session[SessionName] = (obj_value == null) ? string.Empty : obj_value.ToString(); }
static void HandleCommand(string[] args) { int iport = 1235; // Can also be 1234 string hostname = "localhost"; string toSend = "myevent"; ProtocolType ptype = ProtocolType.Tcp; SocketType stype = SocketType.Stream; AddressFamily afam = AddressFamily.InterNetwork; ParmType parmtype = ParmType.Host; if (args.Length < 2) { WriteUsage(); return; } foreach (string parm in args) { if (parm.StartsWith("-")) { switch (parm[1]) { case '?': WriteUsage(); return; case 'i': case 'I': parmtype = ParmType.Host; break; case 'e': case 'E': parmtype = ParmType.Event; break; case 'p': case 'P': parmtype = ParmType.Port; break; case 'u': case 'U': ptype = ProtocolType.Udp; stype = SocketType.Dgram; parmtype = ParmType.None; break; case '6': afam = AddressFamily.InterNetworkV6; parmtype = ParmType.None; break; default: parmtype = ParmType.None; break; } } else { switch (parmtype) { case ParmType.Host: hostname = parm; parmtype = ParmType.Event; break; case ParmType.Port: iport = int.Parse(parm); parmtype = ParmType.None; break; case ParmType.Event: toSend = parm; parmtype = ParmType.Port; break; case ParmType.None: default: Console.WriteLine("Parameter: '" + parm + "' is not understood"); break; } } } string sptype = ptype.ToString(); Console.WriteLine("Sending \"{0}\" to {1} at port {2} using {3} on {4}", toSend, hostname, iport, sptype.ToUpper(), afam); Socket sock; IPAddress ipaddr; IPEndPoint ipe; try { sock = new Socket(afam, stype, ptype); ipaddr = IPAddress.Parse(hostname); ipe = new IPEndPoint(ipaddr, iport); } catch (Exception e) { Console.WriteLine(e.Message); return; } try { sock.Connect(ipe); } catch (Exception e) { Console.WriteLine(e.Message); return; } int n = 0; Byte[] bytesSent = Encoding.ASCII.GetBytes(toSend); try { n = sock.Send(bytesSent, bytesSent.Length, 0); } catch (Exception e) { Console.WriteLine(e.Message); sock.Close(); return; } if (n == bytesSent.Length) { Console.WriteLine("String sent to specified server & port."); } else { Console.WriteLine("Send error."); } sock.Close(); }
public static void Inserting(object sender, SqlDataSourceCommandEventArgs e, string ParameterName, ParmType SessionType, int index) { string SessionName = "v"; SessionName += (SessionType == ParmType.Integer) ? "iparm" : "sparm"; SessionName += index.ToString(); if (ParameterName.Substring(0, 1) != "@") { ParameterName = "@" + SessionName; } e.Command.Parameters[ParameterName].Value = HttpContext.Current.Session[SessionName].ToString(); }
public static void StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e, string ColumnName, ParmType SessionType, int index) { string SessionName = "v"; SessionName += (SessionType == ParmType.Integer) ? "iparm" : "sparm"; SessionName += index.ToString(); object obj_value = (sender as ASPxGridView).GetRowValuesByKeyValue(e.EditingKeyValue, ColumnName); HttpContext.Current.Session[SessionName] = (obj_value == null) ? string.Empty : obj_value.ToString(); }