public ActionResult GridViewPartialDelete(System.String BI) { var model = db.Students; var model2 = db.Ispits; //skidaju se navodnici jer ih devexpress stavlja iz nekog razloga BI = BI.TrimStart(' ', '"'); BI = BI.TrimEnd(' ', '"'); if (BI != null) { try { //var item = model.FirstOrDefault(it => it.BI == BI); var item = model.Where(x => x.BI == BI).FirstOrDefault(); if (item != null) { model.Remove(item); List <Ispit> listOfIspits = model2.Where(x => x.BI == BI).ToList(); //brisemo sve ispite tog studenta foreach (Ispit ispit in listOfIspits) { model2.Remove(ispit); } } db.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } return(PartialView("_GridViewPartial", model.ToList())); }
/// <summary> /// Get this resource /// </summary> /// <param name="resource"> /// A String with SubResources. /// If this is simply '/' then return the collection as returned by the get command. /// If it's a path like '/elementName' then return the element. /// </param> public IRestNode getResource(String resource) { resource = resource.TrimStart('/'); int param = resource.IndexOf(' '); if (param > 0) { resource = resource.Substring(0, param); } IRestNode pNode = m_root; while (pNode != null && resource.Length > 0) { int index = resource.IndexOf('/'); if (index > 0) { // test for data String test = resource.Substring(0, index); int end = test.IndexOf(' '); //if (end != -1) //{ // index = end; //} pNode = pNode.OnElement(resource.Substring(0, index)); resource = resource.Substring(index, resource.Length - index).TrimStart('/').Trim(); } else { pNode.OnElement(resource); return pNode; } } return pNode; }
/// <summary> /// 从指定的path中去除掉rootPath部分, /// </summary> /// <param name="rootPath">需要剔除的根路径</param> /// <param name="pathFull">被处理的path</param> /// <returns>返回多个路径列表(从子命名空间依次到跟命名空间)</returns> public static IList GetPathList(String rootPath, String pathFull) { String mypath = strUtil.TrimStart(pathFull, rootPath); String[] arrPath; if (strUtil.HasText(mypath)) { mypath = mypath.TrimStart('.'); arrPath = mypath.Split('.'); } else { arrPath = new String[] { } }; IList list = new ArrayList(); list.Add(""); String result = ""; for (int i = 0; i < arrPath.Length; i++) { result = result + "." + arrPath[i]; result = result.TrimStart('.'); result = result.Replace(".", "/"); list.Add(result); } IList results = new ArrayList(); for (int i = list.Count - 1; i >= 0; i--) { results.Add(list[i].ToString()); } return(results); }
public static Boolean IsValidTrQueryString(String queryString, BraintreeService service) { string[] delimeters = new string[1]; delimeters[0] = "&hash="; String[] dataSections = queryString.TrimStart('?').Split(delimeters, StringSplitOptions.None); return dataSections[1] == new Crypto().HmacHash(service.PrivateKey, dataSections[0]).ToLower(); }
private void FindRing(object sender, System.EventArgs e) { try { System.String query = rc_ringSearch.Text; rc_ringResults.Items.Clear(); if (!query.TrimStart().TrimEnd().Equals("")) { foreach (var ring in MatchConfiguration.LoadRings()) { if (query.ToLower().Equals(ring.name.ToLower()) || ring.name.ToLower().Contains(query.ToLower())) { rc_ringResults.Items.Add(ring.name); } } } if (rc_ringResults.Items.Count > 0) { rc_ringResults.SelectedIndex = 0; return; } } catch (Exception ex) { L.D("FindRingError: " + ex); } }
public async Task TestManifest() { var stream = new MemoryStream(); var cli = new SpeechClient(); cli.SetStream(stream); await cli.SendManifest(); stream.Seek(0, SeekOrigin.Begin); var reader = new StreamReader(stream); var size = Convert.ToInt32(reader.ReadLine()); var outp = new char[size]; reader.ReadBlock(outp, 0, size); var str = new String(outp); var re = new Regex(@"^([A-Z_]*)"); Assert.IsTrue(re.Match(str).Value == "APP_MANIFEST"); var jsonstr = str.TrimStart(re.Match(str).Value.ToCharArray()); var jsonstream = new MemoryStream(Encoding.UTF8.GetBytes(jsonstr)); var ser = new DataContractJsonSerializer(typeof(Manifest)); Manifest jsonobj = (Manifest)ser.ReadObject(jsonstream); Assert.IsTrue(jsonobj.Version == "0.0.1"); Assert.IsTrue(jsonobj.Name == "speech-recognizer"); Assert.IsTrue(jsonobj.DisplayName == "Mycroft Networked Speech Recognizer"); Assert.IsTrue(jsonobj.Description == "Lets applications register speech triggers for Mycroft to look for."); Assert.IsTrue(jsonobj.InstanceId == "primary"); }
private void FindBGM(object sender, System.EventArgs e) { try { System.String query = rc_bgmSearch.Text; rc_bgmResult.Items.Clear(); if (!query.TrimStart().TrimEnd().Equals("")) { foreach (var bgm in MatchConfiguration.LoadBGMs()) { if (query.ToLower().Equals(bgm.ToLower()) || bgm.ToLower().Contains(query.ToLower())) { rc_bgmResult.Items.Add(bgm); } } } if (rc_bgmResult.Items.Count > 0) { rc_bgmResult.SelectedIndex = 0; return; } } catch (Exception ex) { L.D("FindBGMError: " + ex); } }
public ActionResult GridViewPartialDelete(System.String BI, System.String PredmetId) { var model = db.Ispits; BI = BI.TrimStart(' ', '"'); BI = BI.TrimEnd(' ', '"'); PredmetId = PredmetId.TrimStart(' ', '"'); PredmetId = PredmetId.TrimEnd(' ', '"'); if (BI != null) { try { var item = model.Where(x => x.BI == BI && x.PredmetId == PredmetId).FirstOrDefault(); if (item != null) { model.Remove(item); } db.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } return(PartialView("_GridViewPartial", model.ToList())); }
private String FormatValue(System.String Text) { Text = Text.Trim(); Text = Text.TrimStart(new Char[] { '.' }); return(Text); }
private CssContext CreateInstanceCssContext(String selector) { CssContext ctx = null; selector = selector.TrimStart(); if (selector.StartsWith("@")) { ctx = new CssMediaContext(selector) { OnOpen = VisitBeginAtRule, OnClose = VisitEndAtRule }; } else { ctx = new CssSelectorContext(selector) { OnOpen = VisitBeginSelector, OnClose = VisitEndSelector, OnVisitProperty = VisitProperty }; } return ctx; }
public TransparentRedirectRequest(String queryString, BraintreeService service) { queryString = queryString.TrimStart('?'); Dictionary<String, String> paramMap = new Dictionary<String, String>(); String[] queryParams = queryString.Split('&'); foreach (String queryParam in queryParams) { String[] items = queryParam.Split('='); paramMap[items[0]] = items[1]; } String message = null; if (paramMap.ContainsKey("bt_message")) { message = HttpUtility.UrlDecode(paramMap["bt_message"]); } BraintreeService.ThrowExceptionIfErrorStatusCode((HttpStatusCode)Int32.Parse(paramMap["http_status"]), message); if (!TrUtil.IsValidTrQueryString(queryString, service)) { throw new ForgedQueryStringException(); } Id = paramMap["id"]; }
static Func<float[], float> ParseColumnExpression(String str) { str = str.TrimStart(); Func<float[], float> head = x => 0; if (str.Length == 0) return head; if (str[0] == '(') { int c = 0, i; for (i = 0; i < str.Length; ++i) { if (str[i] == '(') ++c; if (str[i] == ')') { --c; if (c == 0) { break; } } } head = ParseColumnExpression(str.Substring(1, i - 1)); str = str.Substring(i + 1); } else if (char.IsDigit(str[0])) { String number = ""; while (str.Length > 0 && char.IsDigit(str[0])) { number += str[0]; str = str.Substring(1); } int val = int.Parse(number); head = x => val; } else if (char.IsLetter(str[0])) { int digit = str[0] - 'a'; head = x => x[digit]; str = str.Substring(1).TrimStart(); } if (str.Length == 0) return head; switch (str[0]) { case '+': return x => head(x) + ParseColumnExpression(str.Substring(1))(x); case '-': return x => head(x) - ParseColumnExpression(str.Substring(1))(x); case '*': return x => head(x) * ParseColumnExpression(str.Substring(1))(x); case '/': return x => { float denom = ParseColumnExpression(str.Substring(1))(x); return denom != 0 ? head(x) / denom : 0; }; } return head; }
public static string ToCapit(String name) { string clone = name.TrimStart('_'); return String.Format("{0}{1}", Char.ToUpper(clone[0]), clone.Substring(1,clone.Length-1) ); }
/// <summary> /// 判断字符串是否是小数或整数 /// </summary> /// <param name="str"></param> /// <returns></returns> public static Boolean IsDecimal( String str ) { if (strUtil.IsNullOrEmpty( str )) return false; if (str.StartsWith( "-" )) return isDecimal_private( str.TrimStart( '-' ) ); else return isDecimal_private( str ); }
public static String GetApplicationPath(String partialUrl) { /* Remove the leading / character, since the last character in the String returned by GetApplicationPath is guaranteed to be a / character. */ return HttpUtils.GetApplicationPath() + partialUrl.TrimStart("/".ToCharArray()); }
/// <summary> /// 根据IDOC编号从SAP系统里读取一个idoc /// </summary> /// <param name="idocNumber"></param> /// <returns></returns> public Idoc GetIodcFromSapDataBase(String idocNumber) { SAPINT.Utils.ReadTable idocReadItem = null; SAPINT.Utils.ReadTable idocReadHeader = null; DataTable dtIdocItem = new DataTable(); DataTable dtIdocHeder = new DataTable(); idocNumber = idocNumber.TrimStart('0'); String criteria = idocNumber.PadLeft(16, '0'); criteria = String.Format("DOCNUM = '{0}'", criteria); String readTableFunction = ConfigFileTool.SAPGlobalSettings.GetReadTableFunction(); idocReadItem = new Utils.ReadTable(SystemName); idocReadItem.TableName = "EDID4"; idocReadItem.SetCustomFunctionName(readTableFunction); idocReadItem.AddCriteria(criteria); idocReadItem.Run(); dtIdocItem = idocReadItem.Result; if (dtIdocItem.Rows.Count == 0) { idocReadItem = new Utils.ReadTable(SystemName); idocReadItem.TableName = "EDID2"; idocReadItem.SetCustomFunctionName(readTableFunction); idocReadItem.AddCriteria(criteria); idocReadItem.Run(); dtIdocItem = idocReadItem.Result; } if (dtIdocItem.Rows.Count == 0) { idocReadItem = new Utils.ReadTable(SystemName); idocReadItem.TableName = "EDIDD_OLD"; idocReadItem.SetCustomFunctionName(readTableFunction); idocReadItem.AddCriteria(criteria); idocReadItem.Run(); dtIdocItem = idocReadItem.Result; } if (dtIdocItem.Rows.Count == 0) { throw new SAPException(String.Format("无法找到IDOC{0}明细", idocNumber)); } //读取IDOC头 idocReadHeader = new Utils.ReadTable(SystemName); idocReadHeader.TableName = "EDIDC"; idocReadHeader.SetCustomFunctionName(readTableFunction); idocReadHeader.AddCriteria(criteria); idocReadHeader.Run(); dtIdocHeder = idocReadHeader.Result; if (dtIdocHeder.Rows.Count != 1) { throw new SAPException(String.Format("无法找到IDOC{0}抬头定义", idocNumber)); } Idoc idoc = ProcessSingleIdocFromDataTable(dtIdocHeder, dtIdocItem); return idoc; }
public static String GetFullPath(String applicationDirPath, String relativeOrAbsolutePath) { if (String.IsNullOrEmpty(relativeOrAbsolutePath) || relativeOrAbsolutePath.StartsWith(Path.DirectorySeparatorChar.ToString())) { return Path.Combine(applicationDirPath, relativeOrAbsolutePath.TrimStart(Path.DirectorySeparatorChar)); } else { return relativeOrAbsolutePath; } }
/// <summary> /// convert the query string into the dictionary /// </summary> /// <param name="query">?p1=v1...</param> /// <returns>dictionary</returns> public static Dictionary<string, string> QueryParamsToDictionary(String query) { return String.IsNullOrEmpty(query) ? new Dictionary<string, string>() : query .TrimStart(new[] { ' ', '?' }) .Split(new[] { '&' }) .Select(item => item.Split(new[] { '=' })) .Where(array => array.Length == 2) .ToDictionary(array => array[0].Trim(), array => array[1].Trim()); }
public static String GetBaseDomain(String hostedRegion) { var baseHost = ConfigurationManager.AppSettings["core.base-domain"]; if (String.IsNullOrEmpty(hostedRegion)) return baseHost; if (String.IsNullOrEmpty(baseHost)) return baseHost; if (baseHost.IndexOf('.') == -1) return baseHost; var subdomain = baseHost.Remove(baseHost.IndexOf('.')); return hostedRegion.StartsWith(subdomain + ".") ? hostedRegion : String.Join(".", new[] { subdomain, hostedRegion.TrimStart('.') }); }
private ISystemProcess StartProcess(String binary, String arguments) { binary = binary.TrimStart(); //-1 or 0 if (binary.IndexOf(" ") > 0) { var splitBinary = binary.Split(new char[] { ' ' }); binary = splitBinary[0]; arguments = String.Join(" ",splitBinary.Skip(1).ToArray()) + " " + arguments; } return _system.System.StartProcess(binary, arguments); }
/// <summary> /// Combines several path elements /// </summary> /// <param name="left"></param> /// <param name="right"></param> /// <returns></returns> public static String Combine(String left, String right) { // remove delimiter right = right.TrimStart(Delimiter); left = left.TrimEnd(Delimiter); // build the path if (right.Length == 0) return left; else return left + Delimiter + right; }
public Dictionary<String, String> fromJSON(String json) { Dictionary<String, String> dict = new Dictionary<String, String>(); Char[] splits = new Char[1]; splits[0] = ','; if (!String.IsNullOrEmpty(json)) { json = json.Trim(); // Remove leading and trailing breakets if (json.StartsWith("{")) { json = json.Remove(0, 1); json = json.TrimStart(); } if (json.EndsWith("}")) { json = json.Remove(json.Length - 1); json = json.TrimEnd(); } String[] jsonItems = json.Split(splits, StringSplitOptions.RemoveEmptyEntries); // iterate all comma-separeted key-value-pairs for (int i = 0; i < jsonItems.Length; i++) { String currentPart = jsonItems[i]; // check if it's a 'real' item-separator or maybe a comma inside a 'marked' string if (checkForConsistentQuotes(currentPart) && currentPart.Contains(":")) { processKeyValuePair(dict, currentPart); } // we splitted inside a string, so do some error-handling else if (i < jsonItems.Length - 1) { // add upcoming parts as long as we do not have a 'working' part do { i++; currentPart += "," + jsonItems[i]; } while (!(checkForConsistentQuotes(currentPart) && currentPart.Contains(":"))); processKeyValuePair(dict, currentPart); } } } return dict; }
public String PathCombine(String path1, String path2) { path1 = path1.TrimEnd("/\\".ToCharArray()); path2 = path2.TrimStart("/\\".ToCharArray()); if(Environment.OSVersion.Platform == PlatformID.Win32NT) { path1 = path1.Replace("/","\\"); path2 = path2.Replace("/","\\"); } if(string.IsNullOrWhiteSpace(path1) || string.IsNullOrEmpty(path1)) return path2; else return String.Format("{0}{1}{2}",path1,Path.DirectorySeparatorChar,path2); }
public static String TrimLeadingZeros(this String Expr) { String result = Expr; if (result.IsNullOrEmpty()) { return(result); } result = result.TrimStart(new Char[] { '0' }); return(result); }
private static String ApplyFlag(String flag, int? padwidth, String str) { var result = str; switch (flag) { case "-": result = str.TrimStart('0'); break; case "^": result = str.ToUpper(); break; case "_": result = PadLeft(str.TrimStart('0'), padwidth, ' '); break; case "0": result = PadLeft(str.TrimStart('0'), padwidth, '0'); break; // default: do nothing. } return result; }
/// <summary> /// Parses an url query string like ?variable=value&anotherVariable /// </summary> /// <returns>The query string.</returns> /// <param name="query">Query.</param> public static Dictionary<string, string> ParseQueryString(String query) { Dictionary<String, String> queryDict = new Dictionary<string, string>(); foreach (String token in query.TrimStart(new char[] { '?' }).Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries)) { string[] parts = token.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2) queryDict[parts[0].Trim()] = WWW.UnEscapeURL(parts[1]).Trim(); else queryDict[parts[0].Trim()] = ""; } return queryDict; }
public Command(String text) { if (String.IsNullOrEmpty(text)) { throw new ArgumentNullException("text"); } if (!text.StartsWith("/")) { text = "/say " + text.TrimStart(); } this.Text = text; }
//private List<Parameter> GetParams(String source) //{ // try // { // source = TrimParameterString(source); // return GetAllData(source); // } // catch (Exception ex) // { // Console.WriteLine("Input " + source); // throw ex; // } //} private List<Parameter> GetParametersForRDS(String source) { try { if (!String.IsNullOrEmpty(source)) return GetAllData(source.TrimStart('[').TrimEnd(']')); else return new List<Parameter>(); } catch (Exception ex) { Console.WriteLine("RDS " + source); throw ex; } }
/// <summary> /// 判断字符串是否是小数或整数 /// </summary> /// <param name="str"></param> /// <returns></returns> public static Boolean IsDecimal(String str) { if (strUtil.IsNullOrEmpty(str)) { return(false); } if (str.StartsWith("-")) { return(isDecimal_private(str.TrimStart('-'))); } else { return(isDecimal_private(str)); } }
public static Icon GetIconFromExtension(String Ext) { if (iconsInfo == null) iconsInfo = GetFileTypeAndIcon(); Ext = '.' + Ext.TrimStart('.'); object o = iconsInfo[Ext]; if (o != null) { string fileAndParam = o.ToString(); if (!String.IsNullOrEmpty(fileAndParam)) return RegisteredFileType.ExtractIconFromFile(fileAndParam, true); } return null; }
/// <summary> /// Get this resource /// </summary> /// <param name="resource"> /// A String with SubResources. /// If this is simply '/' then return the collection as returned by the get command. /// If it's a path like '/elementName' then return the element. /// </param> public IRestNode getResource(String resource) { resource.TrimStart('/'); IRestNode pNode = m_root; while (pNode != null && resource.Length > 0) { int index = resource.IndexOf('/'); if (index != -1) { pNode = pNode.OnElement(resource.Substring(0, index)); resource = resource.Substring(index, resource.Length - index); } } return pNode; }
private static String getMenuFriendUrl( String url, IMember owner ) { // 检查网站菜单中的部分 SiteMenuService menuService = new SiteMenuService(); List<IMenu> menus = menuService.GetList( owner ); foreach (IMenu menu in menus) { if (strUtil.IsNullOrEmpty( menu.RawUrl )) continue; if (strUtil.IsNullOrEmpty( menu.Url )) continue; if (menu.RawUrl.Equals( strUtil.TrimEnd( url.TrimStart( '/' ), MvcConfig.Instance.UrlExt ) )) { String key = "/" + menu.Url + MvcConfig.Instance.UrlExt; // 缓存中的key是完整的网址 return key; } } return null; }
private int DecodeInt( String _value, int _default ) { if ( _value.Length == 0 ) { return _default; } int ret; if ( Int32.TryParse( _value.TrimStart( '0' ), out ret ) ) { return ret; } else { return _default; } }
public Form2() { InitializeComponent(); try { StreamReader sr = new StreamReader(appdata + "\\launchersettings.txt"); line = sr.ReadLine(); while (line != null) { if (line.Contains("r=")) { ramtoc = line.TrimStart('r', '='); } line = sr.ReadLine(); } sr.Close(); } catch { MessageBox.Show("Váratlan hiba!"); } switch (ramtoc) { case "1024": radioButton1.Checked = true; break; case "2048": radioButton2.Checked = true; break; case "4096": radioButton5.Checked = true; break; case "8192": radioButton3.Checked = true; break; case "12288": radioButton4.Checked = true; break; case "16384": radioButton6.Checked = true; break; default: break; } }
// 访问最新主题和帖子的时候,检查论坛是否更新过 // 需要检查的页面:/Forum1/Recent/Post private Boolean forumExpired( String key ) { String[] arrItem = key.TrimStart( '/' ).Split( '/' ); int appId = cvt.ToInt( strUtil.TrimStart( arrItem[0], "Forum" ) ); // 主题最后更新时间 String fkey = "forum_" + appId; DateTime ts = this.cacher.GetTimestamp( fkey ); if (isTimeNull( ts )) return false; // 没有更新过 // 缓存加入时间 DateTime created = this.cacher.GetTimestamp( key ); if (isTimeNull( created )) return true; if (ts >= created) return true; return false; }
private void FindWrestler(object sender, System.EventArgs e) { try { System.String query = uk_wrestlerSearch.Text; uk_wrestlerResults.Items.Clear(); if (!query.TrimStart().TrimEnd().Equals("")) { foreach (WresIDGroup wrestler in wrestlerList) { if (query.ToLower().Equals(wrestler.Name.ToLower()) || wrestler.Name.ToLower().Contains(query.ToLower())) { uk_wrestlerResults.Items.Add(wrestler); } } } if (uk_wrestlerResults.Items.Count > 0) { uk_wrestlerResults.SelectedIndex = 0; return; } else { foreach (WresIDGroup wrestler in wrestlerList) { uk_wrestlerResults.Items.Add(wrestler); } } } catch (Exception ex) { L.D("FindWrestlerError: " + ex.Message); } }
//Before calling this, the record is initialized, and command_source/source_name are filled public void completeRecord(AdKat_Record record, String message) { try { //Initial split of command by whitespace String[] splitMessage = message.Split(' '); if (splitMessage.Length < 1) { this.DebugWrite("Completely blank command entered", 5); this.sendMessageToSource(record, "You entered a completely blank command."); return; } String commandString = splitMessage[0].ToLower(); DebugWrite("Raw Command: " + commandString, 6); String remainingMessage = message.TrimStart(splitMessage[0].ToCharArray()).Trim(); //GATE 1: Add general data record.server_id = this.server_id; record.record_time = DateTime.Now; //GATE 2: Add Command AdKat_CommandType commandType = this.getCommand(commandString); if (commandType == AdKat_CommandType.Default) { //If command not parsable, return without creating DebugWrite("Command not parsable", 6); return; } record.command_type = commandType; record.command_action = commandType; DebugWrite("Command type: " + record.command_type, 6); //GATE 3: Check Access Rights //Check for server command case if (record.source_name == "server") { record.source_name = "PRoConAdmin"; record.command_source = AdKat_CommandSource.Console; } //Check if player has the right to perform what he's asking, only perform for InGame actions else if (record.command_source == AdKat_CommandSource.InGame && !this.hasAccess(record.source_name, record.command_type)) { DebugWrite("No rights to call command", 6); this.sendMessageToSource(record, "Cannot use class " + this.AdKat_CommandAccessRank[record.command_type] + " command, " + record.command_type + ". You are access class " + this.getAccessLevel(record.source_name) + "."); //Return without creating if player doesn't have rights to do it return; } //GATE 4: Add specific data based on command type. //Items that need filling before record processing: //target_name //target_guid //target_playerInfo //record_message switch (record.command_type) { #region MovePlayer case AdKat_CommandType.MovePlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 1); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 1: record.record_message = "MovePlayer"; record.target_name = parameters[0]; //Handle based on report ID if possible if (!this.handleRoundReport(record)) { this.completeTargetInformation(record, false); } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region ForceMovePlayer case AdKat_CommandType.ForceMovePlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 1); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 1: record.record_message = "ForceMovePlayer"; record.target_name = parameters[0]; //Handle based on report ID if possible if (!this.handleRoundReport(record)) { this.completeTargetInformation(record, false); } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region Teamswap case AdKat_CommandType.Teamswap: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //May only call this command from in-game if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "TeamSwap"; record.target_name = record.source_name; this.completeTargetInformation(record, false); } break; #endregion #region KillPlayer case AdKat_CommandType.KillPlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 1: record.target_name = parameters[0]; //Handle based on report ID as only option if (!this.handleRoundReport(record)) { this.sendMessageToSource(record, "No reason given, unable to submit."); } break; case 2: record.target_name = parameters[0]; //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[1], this.requirePreMessageUse); if (record.record_message == null) { this.sendMessageToSource(record, "Invalid PreMessage ID, valid PreMessage IDs are 1-" + this.preMessageList.Count); break; } //Handle based on report ID if possible if (!this.handleRoundReport(record)) { if (record.record_message.Length >= this.requiredReasonLength) { this.completeTargetInformation(record, false); } else { this.sendMessageToSource(record, "Reason too short, unable to submit."); } } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region KickPlayer case AdKat_CommandType.KickPlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 1: record.target_name = parameters[0]; //Handle based on report ID as only option if (!this.handleRoundReport(record)) { this.sendMessageToSource(record, "No reason given, unable to submit."); } break; case 2: record.target_name = parameters[0]; //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[1], this.requirePreMessageUse); if (record.record_message == null) { this.sendMessageToSource(record, "Invalid PreMessage ID, valid PreMessage IDs are 1-" + this.preMessageList.Count); break; } //Handle based on report ID if possible if (!this.handleRoundReport(record)) { if (record.record_message.Length >= this.requiredReasonLength) { this.completeTargetInformation(record, false); } else { this.sendMessageToSource(record, "Reason too short, unable to submit."); } } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region TempBanPlayer case AdKat_CommandType.TempBanPlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 3); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } this.sendMessageToSource(record, "No parameters given, unable to submit."); break; case 1: int record_duration = 0; DebugWrite("Raw Duration: " + parameters[0], 6); if (!Int32.TryParse(parameters[0], out record_duration)) { this.sendMessageToSource(record, "Invalid time given, unable to submit."); return; } record.command_numeric = record_duration; //Target is source record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 2: DebugWrite("Raw Duration: " + parameters[0], 6); if (Int32.TryParse(parameters[0], out record_duration)) { record.command_numeric = record_duration; record.target_name = parameters[1]; DebugWrite("target: " + record.target_name, 6); //Handle based on report ID as only option if (!this.handleRoundReport(record)) { this.sendMessageToSource(record, "No reason given, unable to submit."); } } else { this.sendMessageToSource(record, "Invalid time given, unable to submit."); } break; case 3: DebugWrite("Raw Duration: " + parameters[0], 6); if (Int32.TryParse(parameters[0], out record_duration)) { record.command_numeric = record_duration; record.target_name = parameters[1]; DebugWrite("target: " + record.target_name, 6); //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[2], this.requirePreMessageUse); if (record.record_message == null) { this.sendMessageToSource(record, "Invalid PreMessage ID, valid PreMessage IDs are 1-" + this.preMessageList.Count); break; } DebugWrite("reason: " + record.record_message, 6); //Handle based on report ID if possible if (!this.handleRoundReport(record)) { if (record.record_message.Length >= this.requiredReasonLength) { this.completeTargetInformation(record, false); } else { this.sendMessageToSource(record, "Reason too short, unable to submit."); } } } else { this.sendMessageToSource(record, "Invalid time given, unable to submit."); } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region PermabanPlayer case AdKat_CommandType.PermabanPlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 1: record.target_name = parameters[0]; //Handle based on report ID as only option if (!this.handleRoundReport(record)) { this.sendMessageToSource(record, "No reason given, unable to submit."); } break; case 2: record.target_name = parameters[0]; //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[1], this.requirePreMessageUse); if (record.record_message == null) { this.sendMessageToSource(record, "Invalid PreMessage ID, valid PreMessage IDs are 1-" + this.preMessageList.Count); break; } //Handle based on report ID if possible if (!this.handleRoundReport(record)) { if (record.record_message.Length >= this.requiredReasonLength) { this.completeTargetInformation(record, false); } else { this.sendMessageToSource(record, "Reason too short, unable to submit."); } } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region PunishPlayer case AdKat_CommandType.PunishPlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 1: record.target_name = parameters[0]; //Handle based on report ID as only option if (!this.handleRoundReport(record)) { this.sendMessageToSource(record, "No reason given, unable to submit."); } break; case 2: record.target_name = parameters[0]; //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[1], this.requirePreMessageUse); if (record.record_message == null) { this.sendMessageToSource(record, "Invalid PreMessage ID, valid PreMessage IDs are 1-" + this.preMessageList.Count); break; } //Handle based on report ID if possible if (!this.handleRoundReport(record)) { if (record.record_message.Length >= this.requiredReasonLength) { this.completeTargetInformation(record, false); } else { this.sendMessageToSource(record, "Reason too short, unable to submit."); } } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region ForgivePlayer case AdKat_CommandType.ForgivePlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 1: record.target_name = parameters[0]; //Handle based on report ID as only option if (!this.handleRoundReport(record)) { this.sendMessageToSource(record, "No reason given, unable to submit."); } break; case 2: record.target_name = parameters[0]; //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[1], this.requirePreMessageUse); if (record.record_message == null) { this.sendMessageToSource(record, "Invalid PreMessage ID, valid PreMessage IDs are 1-" + this.preMessageList.Count); break; } //Handle based on report ID if possible if (!this.handleRoundReport(record)) { if (record.record_message.Length >= this.requiredReasonLength) { this.completeTargetInformation(record, false); } else { this.sendMessageToSource(record, "Reason too short, unable to submit."); } } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region MutePlayer case AdKat_CommandType.MutePlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 1: record.target_name = parameters[0]; //Handle based on report ID as only option if (!this.handleRoundReport(record)) { this.sendMessageToSource(record, "No reason given, unable to submit."); } break; case 2: record.target_name = parameters[0]; //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[1], this.requirePreMessageUse); if (record.record_message == null) { this.sendMessageToSource(record, "Invalid PreMessage ID, valid PreMessage IDs are 1-" + this.preMessageList.Count); break; } //Handle based on report ID if possible if (!this.handleRoundReport(record)) { if (record.record_message.Length >= this.requiredReasonLength) { this.completeTargetInformation(record, false); } else { this.sendMessageToSource(record, "Reason too short, unable to submit."); } } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region RoundWhitelistPlayer case AdKat_CommandType.RoundWhitelistPlayer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: if (record.command_source != AdKat_CommandSource.InGame) { this.sendMessageToSource(record, "You can't use a self-inflicting command from outside the game."); break; } record.record_message = "Self-Inflicted"; record.target_name = record.source_name; this.completeTargetInformation(record, true); break; case 1: record.target_name = parameters[0]; //Handle based on report ID as only option if (!this.handleRoundReport(record)) { this.sendMessageToSource(record, "No reason given, unable to submit."); } break; case 2: record.target_name = parameters[0]; //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[1], false); //Handle based on report ID if possible if (!this.handleRoundReport(record)) { if (record.record_message.Length >= this.requiredReasonLength) { this.completeTargetInformation(record, false); } else { this.sendMessageToSource(record, "Reason too short, unable to submit."); } } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region ReportPlayer case AdKat_CommandType.ReportPlayer: { string command = this.m_strReportCommand; //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: this.sendMessageToSource(record, "Format must be: @" + command + " playername reason"); break; case 1: this.sendMessageToSource(record, "Format must be: @" + command + " playername reason"); break; case 2: record.target_name = parameters[0]; DebugWrite("target: " + record.target_name, 6); //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[1], false); DebugWrite("reason: " + record.record_message, 6); //Only 1 character reasons are required for reports and admin calls if (record.record_message.Length >= 1) { this.completeTargetInformation(record, false); } else { DebugWrite("reason too short", 6); this.sendMessageToSource(record, "Reason too short, unable to submit."); return; } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region CallAdmin case AdKat_CommandType.CallAdmin: { string command = this.m_strCallAdminCommand; //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: this.sendMessageToSource(record, "Format must be: @" + command + " playername reason"); break; case 1: this.sendMessageToSource(record, "Format must be: @" + command + " playername reason"); break; case 2: record.target_name = parameters[0]; DebugWrite("target: " + record.target_name, 6); //attempt to handle via pre-message ID record.record_message = this.getPreMessage(parameters[1], false); DebugWrite("reason: " + record.record_message, 6); //Only 1 character reasons are required for reports and admin calls if (record.record_message.Length >= 1) { this.completeTargetInformation(record, false); } else { DebugWrite("reason too short", 6); this.sendMessageToSource(record, "Reason too short, unable to submit."); return; } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region NukeServer case AdKat_CommandType.NukeServer: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: this.sendMessageToSource(record, "No parameters given, unable to submit."); break; case 1: string targetTeam = parameters[0]; record.record_message = "Nuke Server"; DebugWrite("target: " + targetTeam, 6); if (targetTeam.ToLower().Contains("us")) { record.target_name = "US Team"; record.record_message += " (US Team)"; } else if (targetTeam.ToLower().Contains("ru")) { record.target_name = "RU Team"; record.record_message += " (RU Team)"; } else if (targetTeam.ToLower().Contains("all")) { record.target_name = "Everyone"; record.record_message += " (Everyone)"; } else { this.sendMessageToSource(record, "Use 'US', 'RU', or 'ALL' as targets."); } //Have the admin confirm the action this.confirmActionWithSource(record); break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region KickAll case AdKat_CommandType.KickAll: this.cancelSourcePendingAction(record); record.target_name = "Non-Admins"; record.record_message = "Kick All Players"; this.confirmActionWithSource(record); break; #endregion #region EndLevel case AdKat_CommandType.EndLevel: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: this.sendMessageToSource(record, "No parameters given, unable to submit."); return; case 1: string targetTeam = parameters[0]; DebugWrite("target team: " + targetTeam, 6); record.record_message = "End Round"; if (targetTeam.ToLower().Contains("us")) { record.target_name = "US Team"; record.command_numeric = AdKats.USTeamID; record.record_message += " (US Win)"; } else if (targetTeam.ToLower().Contains("ru")) { record.target_name = "RU Team"; record.command_numeric = AdKats.RUTeamID; record.record_message += " (RU Win)"; } else { this.sendMessageToSource(record, "Use 'US' or 'RU' as team names to end round"); } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } //Have the admin confirm the action this.confirmActionWithSource(record); } break; #endregion #region RestartLevel case AdKat_CommandType.RestartLevel: this.cancelSourcePendingAction(record); record.target_name = "Server"; record.record_message = "Restart Round"; this.confirmActionWithSource(record); break; #endregion #region NextLevel case AdKat_CommandType.NextLevel: this.cancelSourcePendingAction(record); record.target_name = "Server"; record.record_message = "Run Next Map"; this.confirmActionWithSource(record); break; #endregion #region WhatIs case AdKat_CommandType.WhatIs: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 1); switch (parameters.Length) { case 0: this.sendMessageToSource(record, "No parameters given, unable to submit."); return; case 1: record.record_message = this.getPreMessage(parameters[0], true); if (record.record_message == null) { this.sendMessageToSource(record, "Invalid PreMessage ID, valid PreMessage IDs are 1-" + this.preMessageList.Count); } else { this.sendMessageToSource(record, record.record_message); } break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } //This type is not processed } break; #endregion #region AdminSay case AdKat_CommandType.AdminSay: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 1); switch (parameters.Length) { case 0: this.sendMessageToSource(record, "No parameters given, unable to submit."); return; case 1: record.record_message = this.getPreMessage(parameters[0], false); DebugWrite("message: " + record.record_message, 6); record.target_name = "Server"; break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } this.queueRecordForProcessing(record); } break; #endregion #region AdminYell case AdKat_CommandType.AdminYell: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 1); switch (parameters.Length) { case 0: this.sendMessageToSource(record, "No parameters given, unable to submit."); return; case 1: record.record_message = this.getPreMessage(parameters[0], false).ToUpper(); DebugWrite("message: " + record.record_message, 6); record.target_name = "Server"; break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } this.queueRecordForProcessing(record); } break; #endregion #region PlayerSay case AdKat_CommandType.PlayerSay: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: this.sendMessageToSource(record, "No parameters given, unable to submit."); return; case 1: this.sendMessageToSource(record, "No message given, unable to submit."); return; case 2: record.target_name = parameters[0]; DebugWrite("target: " + record.target_name, 6); record.record_message = this.getPreMessage(parameters[1], false); DebugWrite("message: " + record.record_message, 6); this.completeTargetInformation(record, false); break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region PlayerYell case AdKat_CommandType.PlayerYell: { //Remove previous commands awaiting confirmation this.cancelSourcePendingAction(record); //Parse parameters using max param count String[] parameters = this.parseParameters(remainingMessage, 2); switch (parameters.Length) { case 0: this.sendMessageToSource(record, "No parameters given, unable to submit."); return; case 1: this.sendMessageToSource(record, "No message given, unable to submit."); return; case 2: record.target_name = parameters[0]; DebugWrite("target: " + record.target_name, 6); record.record_message = this.getPreMessage(parameters[1], false).ToUpper(); DebugWrite("message: " + record.record_message, 6); this.completeTargetInformation(record, false); break; default: this.sendMessageToSource(record, "Invalid parameters, unable to submit."); return; } } break; #endregion #region ConfirmCommand case AdKat_CommandType.ConfirmCommand: this.DebugWrite("attempting to confirm command", 6); AdKat_Record recordAttempt = null; this.actionConfirmDic.TryGetValue(record.source_name, out recordAttempt); if (recordAttempt != null) { this.DebugWrite("command found, calling processing", 6); this.actionConfirmDic.Remove(record.source_name); this.queueRecordForProcessing(recordAttempt); } else { this.DebugWrite("no command to confirm", 6); this.sendMessageToSource(record, "No command to confirm."); } //This type is not processed break; #endregion #region CancelCommand case AdKat_CommandType.CancelCommand: this.DebugWrite("attempting to cancel command", 6); if (!this.actionConfirmDic.Remove(record.source_name)) { this.DebugWrite("no command to cancel", 6); this.sendMessageToSource(record, "No command to cancel."); } //This type is not processed break; #endregion default: break; } return; } catch (Exception e) { this.ConsoleException(e.ToString()); } }
private String getNamespace( String codeItem ) { // <%@ Import Namespace="System.Collections.Generic" %> if (codeItem.StartsWith( "@" ) == false) return null; if (codeItem.IndexOf( "Import" ) < 0) return null; if (codeItem.IndexOf( "Namespace" ) < 0) return null; String[] arrItem = codeItem.TrimStart( '@' ).Trim().Split( '"' ); if (arrItem.Length != 3) return null; return arrItem[1].Trim(); }
private static Route parseRoute( String apath ) { if (apath == null) return new Route(); Route x = new Route(); apath = processPageIndex( apath, x ); PathAppId xPath = processAppId( apath.TrimStart( '/' ) ); String path = xPath.Path; x.setAppId( xPath.AppId ); Dictionary<String, String> map = getMap(); foreach (KeyValuePair<String, String> kv in map) { if (isLinkToLow) { if (strUtil.EqualsIgnoreCase( path, kv.Key )) { // path=category // map.Add( "category", "wojilu.Test.Web.Mvc.TestPostController.List" ); return getEqualMap( kv, x ); } if (path.ToLower().StartsWith( kv.Key.ToLower() + separator )) { return getParseResult( path, kv.Value, x ); } } else { if (path.Equals( kv.Key )) { // path=category // map.Add( "category", "wojilu.Test.Web.Mvc.TestPostController.List" ); return getEqualMap( kv, x ); } if (path.StartsWith( kv.Key + separator )) { return getParseResult( path, kv.Value, x ); } } } return null; }