public Result_DrivingEntity ApiDriving(DrivingEntity drivingData) { try { string resultStr = ObjectToString.EntityToString(drivingData); MyConfig config = new MyConfig(); config = ConfigHelper <MyConfig> .Init(config); if (config.Url == null || config.Url == "") { config.Url = configUrl; } string strResult = HttpHelper.HttpPost(config.Url, resultStr); if (drivingData.output.ToUpper() == "JSON") { return(JsonConvert.DeserializeObject <Result_DrivingEntity>(strResult)); } else if (drivingData.output.ToUpper() == "XML") { return(XMLHelper <Result_DrivingEntity> .DeserializeToObject(strResult.Replace("response", "Result_DrivingEntity").Replace("paths", "pathlist").Replace("steps", "steplist").Replace("type=\"list\"", ""))); } return(new Result_DrivingEntity()); } catch (Exception ex) { return(null); } }
public static int Main() { ObjectToString test = new ObjectToString(); TestLibrary.TestFramework.BeginTestCase("ObjectToString"); if (test.RunTests()) { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("PASS"); return 100; } else { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("FAIL"); return 0; } }
public static int Main() { ObjectToString test = new ObjectToString(); TestLibrary.TestFramework.BeginTestCase("ObjectToString"); if (test.RunTests()) { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("PASS"); return(100); } else { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("FAIL"); return(0); } }
public async Task ProcessMessage(string serverID, IChatResponseToken icrt, string senderID, string input) { // Make the initial command case insensitive var firstCommand = input.Split(" ")[0].ToLower(); // Switch statement for all commands that are constant switch (firstCommand) { case "-help": await icrt.Respond(@"Command list: `-ping` Will return if Sergen is alive. `-ip` Will respond the ip of the main. `-version` Will return 1.0.0 because I'm too lazy to fix the version. `-running` Will return all the running game servers for this discord server. `-possible` Will return all possible game servers. `-run {Game Server}` Will start a game server of that type. `-stop {Game Server}` Will stop a game server of that type. `-allowlist` Will show you your current allowlist. `-allowlist enable/disable` Will enable/disable the allowlist. `-allowlist add @user` Will enable that user to control servers. `-allowlist remove @user` Will stop that user from controlling servers. "); break; case "-ping": var processingTime = DateTime.Now.Subtract(icrt.SendTime); await icrt.Respond(processingTime.Milliseconds + "ms"); break; case "-ip": await icrt.Respond($"My IP Address is: {await _ipGetter.GetIp()}"); break; case "-whoami": await icrt.Respond($"You are: {_context.GetUsername(senderID)}"); break; case "-version": System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; await icrt.Respond($"My version is: {version}"); break; case "-running": var allcontainers = ObjectToString.Convert(await _containerInterface.GetRunningContainers(serverID)); await icrt.Respond($"Running containers are: {allcontainers}"); break; case "-possible": var servers = _serverStore.GetAllServers(GetContainerInterfaceType()); var serverNames = servers.Select(s => s.ServerName).ToList(); var serverStringList = ObjectToString.Convert(serverNames); await icrt.Respond($"Possible game servers are: {serverStringList}"); break; } if (input.StartsWith("-run ") || input.StartsWith("-start ")) { if (await VerifyUser(serverID, senderID, icrt)) { await AttemptRun(serverID, input, icrt); } return; } if (input.StartsWith("-stop ")) { if (await VerifyUser(serverID, senderID, icrt)) { await AttemptStop(serverID, input, icrt); } return; } if (input.StartsWith("-allowlist")) { if (await _allowList.IsUserAllowedToManage(serverID, senderID)) { if (input.StartsWith("-allowlist add ")) { await _allowList.AddUser(serverID, input.Replace("-allowlist add ", "")); await icrt.Respond("User added."); return; } if (input.StartsWith("-allowlist remove ")) { await _allowList.RemoveUser(serverID, input.Replace("-allowlist remove ", "")); await icrt.Respond("User removed."); return; } if (input.StartsWith("-allowlist enable")) { await _allowList.SetAllowListStatus(serverID, true); await icrt.Respond("Allow list enabled."); return; } if (input.StartsWith("-allowlist disable")) { await _allowList.SetAllowListStatus(serverID, false); await icrt.Respond("Allow list disabled."); return; } var allowList = await _allowList.GetAllowList(serverID); var rawAllowList = string.Join("\n", allowList.Select(x => x.ToString()).ToArray()); await icrt.Respond("Allow list:\n" + rawAllowList); return; } await icrt.Respond("I'm not allowed to talk to you, ask your server admin to allowlist you!"); } }
public static void Fax0utFillClass(PropertiesFaxDialog dialog, int faxID, DataRow dr) { try { var resources = new ResourceManager(typeof(FaxFillClass)); if (dr == null) { return; } // наличие документа int imageID = 0; object obj = dr[Environment.FaxOutData.DocImageIDField]; if (obj != null && !obj.Equals(DBNull.Value)) { imageID = (int)obj; } FaxPropertyControl fpc; if (imageID > 0) { fpc = new FaxPropertiButtonControl("", resources.GetString("FaxSaved"), 2); ((FaxPropertiButtonControl)fpc).FaxID = faxID; } else { fpc = new FaxPropertyControl("", resources.GetString("FaxNotSave")); } dialog.PutControl(fpc); // описание fpc = new FaxPropertyControl(resources.GetString("Description"), (string)dr[Environment.FaxOutData.DescriptionField]); dialog.PutControl(fpc); // отправлен var date = (DateTime)dr[Environment.FaxOutData.DateField]; fpc = new FaxPropertyControl(resources.GetString("FaxOut"), ObjectToString.Convert(date.ToLocalTime())); dialog.PutControl(fpc); // отправитель fpc = new FaxPropertyControl(resources.GetString("Sender"), (string)dr[Environment.FaxOutData.SenderField]); dialog.PutControl(fpc); // получатель if (Equals(dr[Environment.FaxOutData.RecipField], dr[Environment.FaxOutData.RecvAddressField])) { fpc = new FaxPropertiButtonControl(resources.GetString("Recip"), (string)dr[Environment.FaxOutData.RecipField], 1); } else { fpc = new FaxPropertyControl(resources.GetString("Recip"), (string)dr[Environment.FaxOutData.RecipField]); } dialog.PutControl(fpc); // телефон получателя fpc = new FaxPropertyControl(resources.GetString("RecvAddress"), (string)dr[Environment.FaxOutData.RecvAddressField]); dialog.PutControl(fpc); // CSID fpc = new FaxPropertyControl("CSID:", (string)dr[Environment.FaxOutData.CSIDField]); dialog.PutControl(fpc); // Modem fpc = new FaxPropertyControl(resources.GetString("ModemID"), dr[Environment.FaxOutData.ModemIDField].ToString()); dialog.PutControl(fpc); // скорость передачи string speed = dr[Environment.FaxOutData.SpeedField].ToString(); fpc = new FaxPropertyControl(resources.GetString("Speed"), speed + ((speed.Length > 0) ? " " + resources.GetString("baud") : "")); dialog.PutControl(fpc); // время передачи string duration = dr[Environment.FaxOutData.DurationField].ToString(); fpc = new FaxPropertyControl(resources.GetString("Time"), duration + ((duration.Length > 0) ? " " + resources.GetString("Second") : "")); dialog.PutControl(fpc); // отправлено страниц fpc = new FaxPropertyControl(resources.GetString("PageSentCount"), dr[Environment.FaxOutData.PageSentCountField].ToString()); dialog.PutControl(fpc); // изменил var empID = (int)dr[Environment.FaxInData.EditorField]; var emp = new Employee(empID, Environment.EmpData); fpc = empID > 0 ? new FaxPropertyEdiorControl(resources.GetString("Editor"), emp.LongName, empID) : new FaxPropertyControl(resources.GetString("Editor"), emp.LongName); dialog.PutControl(fpc); // изменено DateTime editDate = (DateTime)dr[Environment.FaxInData.EditedField] + LocalObject.GetTimeDiff(); fpc = new FaxPropertyControl(resources.GetString("Edited"), editDate.ToString()); dialog.PutControl(fpc); dialog.Text = resources.GetString("FaxOutText"); dialog.ResizeForm(); } catch (Exception ex) { Lib.Win.Data.Env.WriteToLog(ex); } }