Here are the examples of the csharp api string.ToString() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2893 Examples
19
View Source File : BotMainWindow.xaml.cs
License : GNU General Public License v3.0
Project Creator : 00000vish
License : GNU General Public License v3.0
Project Creator : 00000vish
private void initLogics()
{
if (File.Exists(STEAM_GAME_CONTROLLER))
{
if (!File.Exists(gameListFile))
{
do
{
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
} while (!SteamBotController.loggedIn);
generateGames();
}
getGamesFromFile();
}
else
{
System.Windows.Forms.MessageBox.Show("FILES MISSING >> download at \n https://github.com/vishwenga/Steam-Boost/."
+ " \n\n\n MISSING FOLDER >> \n\n"
+ Environment.CurrentDirectory.ToString() + STEAM_BOOST_DIRECTORY
+ " \n\n\n MISSING FILES IN FOLDER >> \n\n"
+ Environment.CurrentDirectory.ToString() + STEAM_GAME_CONTROLLER + "\n\n"
+ Environment.CurrentDirectory.ToString() + SAM_GAME + "\n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\CSteamworks.dll \n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\Newtonsoft.Json.dll \n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\Newtonsoft.Json.xml \n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\steam_api.dll \n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\Steamworks.NET.dll \n\n");
Close();
}
}
19
View Source File : Settings.xaml.cs
License : GNU General Public License v3.0
Project Creator : 00000vish
License : GNU General Public License v3.0
Project Creator : 00000vish
private void settingsChanged(object sender, RoutedEventArgs e)
{
CheckBox item = (CheckBox)sender;
//encryption
SteamTwoProperties.jsonSetting.encryptedSetting = (bool)enableEncryption.IsChecked;
if (SteamTwoProperties.jsonSetting.encryptedSetting == true && item.Name.ToString().Equals("enableEncryption"))
{
changeKeyClicked();
}
//auto start
SteamTwoProperties.jsonSetting.autoStartSetting = (bool)autoStart.IsChecked;
if (SteamTwoProperties.jsonSetting.autoStartSetting == true && item.Name.ToString().Equals("autoStart"))
{
createRegKey();
}
else if (SteamTwoProperties.jsonSetting.autoStartSetting != true && item.Name.ToString().Equals("autoStart"))
{
deleteRegKey();
}
SteamTwoProperties.jsonSetting.forwardCheckSetting = (bool)Forward2.IsChecked;
SteamTwoProperties.jsonSetting.autoLoginSetting = (bool)autoLogin.IsChecked;
SteamTwoProperties.jsonSetting.badAttemptSetting = (bool)badAttempt.IsChecked;
SteamTwoProperties.jsonSetting.multipleBotSetting = (bool)multipleBots.IsChecked;
SteamTwoProperties.jsonSetting.copyPreplacedwordSetting = (bool)copyPreplacedword.IsChecked;
SteamTwoProperties.jsonSetting.closeStemLaunchSetting = (bool)closeStemLaunch.IsChecked;
SteamTwoProperties.jsonSetting.chatComSetting = (bool)chatCommandButton.IsChecked;
SteamTwoProperties.jsonSetting.chatSetting = (bool)enableChat.IsChecked;
SteamTwoProperties.jsonSetting.autoAddFriendSetting = (bool)autoAddFriends.IsChecked;
SteamTwoProperties.jsonSetting.notifyOnMessageSetting = (bool)notifyOnMessage.IsChecked;
SteamTwoProperties.updateSettingFile();
updateGUI();
}
19
View Source File : ToolWindow.xaml.cs
License : GNU General Public License v3.0
Project Creator : 00000vish
License : GNU General Public License v3.0
Project Creator : 00000vish
private void initLogics()
{
if (File.Exists(STEAM_GAME_CONTROLLER))
{
if (!File.Exists(GAME_LIST_FILE))
{
generateGames();
}
getGamesFromFile();
}
else
{
System.Windows.Forms.MessageBox.Show("FILES MISSING >> download at \n https://github.com/vishwenga/Steam-Boost/."
+ " \n\n\n MISSING FOLDER >> \n\n"
+ Environment.CurrentDirectory.ToString() + STEAM_BOOST_DIRECTORY
+ " \n\n\n MISSING FILES IN FOLDER >> \n\n"
+ Environment.CurrentDirectory.ToString() + STEAM_GAME_CONTROLLER + "\n\n"
+ Environment.CurrentDirectory.ToString() + SAM_GAME + "\n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\CSteamworks.dll \n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\Newtonsoft.Json.dll \n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\Newtonsoft.Json.xml \n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\steam_api.dll \n\n"
+ Environment.CurrentDirectory.ToString() + "\\steamBoost\\Steamworks.NET.dll \n\n");
Close();
}
}
19
View Source File : MessageController.cs
License : Apache License 2.0
Project Creator : 0nise
License : Apache License 2.0
Project Creator : 0nise
public static MessageModel main(String message,string fromQQ) {
string resultContent = "\n无数据";
string content = message;
MessageModel messageModel = null;
if (message == null || message == "" || message.Length == 0)
{
messageModel = new MessageModel(sendMessage: MessageConstant.HELP_CONTENT, isAdmin: false, code: "");
return messageModel;
}
resultContent = "\n无数据";
message = executeCodeReplace(message);
message = message.Trim();
if (message.Length == 0 || message == "")
{
messageModel = new MessageModel(sendMessage: MessageConstant.HELP_CONTENT, isAdmin: false, code: "");
return messageModel;
}
else if (message.Contains(MessageConstant.RANDOM_CONTENT_replacedLE)) {
// 标题查询随机文章
message = message.Replace(MessageConstant.RANDOM_CONTENT_replacedLE, "").Trim();
resultContent = DBHelperMySQL.GetContentRandomByreplacedle(message);
// 标题查询随机课程
string clreplacedContent = DBHelperMySQL.getClreplacedRandomByreplacedle(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_CONTENT_replacedLE);
}
else if (message.Contains(MessageConstant.DESC_CONTENT_replacedLE)) {
// 标题查询最新文章
message = message.Replace(MessageConstant.DESC_CONTENT_replacedLE, "").Trim();
string clreplacedContent = "";
if (message.Length == 0 || message == "" || "".Equals(message) || message == null)
{
// 调用每日最新
resultContent = DBHelperMySQL.getContentDateByToday();
// 标题查询最新课程
clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle("");
}
else
{
resultContent = DBHelperMySQL.getContentDateByreplacedle(message);
clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle(message);
}
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_replacedLE);
}
else if (message.Contains(MessageConstant.DESC_CONTENT_AUTHOR)) {
// 作者查询最新文章
message = message.Replace(MessageConstant.DESC_CONTENT_AUTHOR, "").Trim();
resultContent = DBHelperMySQL.getContentDateByAuthor(message);
// 作者查询最新课程
string clreplacedContent = DBHelperMySQL.getClreplacedDateByAuthor(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_AUTHOR);
} else if (message.Contains(MessageConstant.RANDOM_CONTENT_AUTHOR)) {
// 作者查询随机文章
message = message.Replace(MessageConstant.RANDOM_CONTENT_AUTHOR, "").Trim();
resultContent = DBHelperMySQL.getContentRandomByAuthor(message);
// 作者查询随机课程
string clreplacedContent = DBHelperMySQL.getClreplacedRandomByAuthor(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_CONTENT_AUTHOR);
}
else if (message.Contains(MessageConstant.DESC_CONTENT_TODAY) || message.Contains(MessageConstant.DESC_CONTENT))
{
// 今日最新
message = message.Replace(MessageConstant.DESC_CONTENT_TODAY, "").Trim();
resultContent = DBHelperMySQL.getContentDateByToday();
string clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle("");
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_TODAY);
} else if (message.Contains(MessageConstant.GONG_GAO)) {
// 公告处理
bool flag = DBHelperMySQL.isAdmin(fromQQ);
// 判断是否管理员
if (flag) {
message = message.Replace(MessageConstant.GONG_GAO, "来自i春秋机器人的智能推送\n");
resultContent = message;
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: true, code: MessageConstant.GONG_GAO);
}
else {
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.GONG_GAO);
}
}
else if (message.Contains(MessageConstant.AITE_ALL))
{
// 艾特全体处理
bool flag = DBHelperMySQL.isAdmin(fromQQ);
if (flag)
{
message = message.Replace(MessageConstant.AITE_ALL, "来自i春秋机器人的智能推送\n");
resultContent = message;
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: true, code: MessageConstant.AITE_ALL);
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.AITE_ALL);
}
}
else if (message.Contains(MessageConstant.HELP) || message.Contains(MessageConstant.HELP_TWO))
{
// Help 帮助等指令
resultContent = MessageConstant.HELP_CONTENT;
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HELP_TWO);
} else if (message.Contains(MessageConstant.DESC_VIDEO)) {
// 标题查询最新教程
message = message.Replace(MessageConstant.DESC_VIDEO, "").Trim();
resultContent = DBHelperMySQL.getCourseDateByreplacedle(message);
// 标题查询最新课程
string clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_VIDEO);
}
else if (message.Contains(MessageConstant.RANDOM_VIDEO))
{
// 标题查询随机教程
message = message.Replace(MessageConstant.RANDOM_VIDEO, "").Trim();
resultContent = DBHelperMySQL.getCourseRandomByreplacedle(message);
// 标题查询随机课程
string clreplacedContent = DBHelperMySQL.getClreplacedRandomByreplacedle(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_VIDEO);
}
else if (message.Contains(MessageConstant.TEST))
{
// 测试命令
resultContent = " [CQ:image,file=photo.jpg]";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.TEST);
} else if (message.Contains(MessageConstant.SELECT_MONEY)) {
string tmpStr = message.Replace(MessageConstant.SELECT_MONEY, "").Trim();
// 判断是否为管理员
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
string money = "";
if (tmpStr.Length > 0 && isAdmin)
{
// 查询余额
money = DBHelperMySQL.getBlankMoney(tmpStr);
}
else
{
// 查询余额
money = DBHelperMySQL.getBlankMoney(fromQQ);
}
if (money == "" || money == null || money.Length == 0)
{
resultContent = "没有数据,请联系QQ:758841765 给予昵称QQ等信息。";
}
else
{
resultContent = "\n当前余额为 " + money;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.SELECT_MONEY);
}
else if (message.Contains(MessageConstant.HISTORY_MONEY))
{
// 提现记录
string historyMoney = DBHelperMySQL.getBlankHistory(fromQQ);
// 查询当前余额
string money = DBHelperMySQL.getBlankMoney(fromQQ);
if (money == "" || money == null || money.Length == 0) {
resultContent = "没有数据,请联系QQ:758841765 给予昵称QQ等信息。";
}
else {
resultContent = "\n当前余额为 " + money + "\n";
// 查询历史记录
resultContent += "提现记录\n";
resultContent += "金额\t\t时间\n" + historyMoney;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HISTORY_MONEY);
}
else if (message.Contains(MessageConstant.APPLY_MONEY))
{
// 申请提现
resultContent = "请联系【坏蛋】,QQ号:286894635。\n[CQ:at,qq=286894635]";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.APPLY_MONEY);
} else if (message.Contains(MessageConstant.ABOUT)) {
resultContent = "i春秋社区机器人,研发人员为:0nise,产品设计为:坏蛋!";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.ABOUT);
} else if (message.Contains(MessageConstant.UPDATE_MONEY)) {
// 更新金额
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin) {
try
{
decimal tmpMoney = 0.0M;
// 提现
if (message.Contains(MessageConstant.PUT_FORWARD))
{
int moneyIndex = message.IndexOf(MessageConstant.PUT_FORWARD + ":");
int index = message.IndexOf(MessageConstant.UPDATE_MONEY);
if (moneyIndex >= 0 && index >= 0)
{
decimal money = Convert.ToDecimal(message.Substring(moneyIndex).Replace("提现:", "").Replace(" ", ""));
if (money > tmpMoney)
{
string qq = message.Replace(message.Substring(moneyIndex), "").Replace(MessageConstant.UPDATE_MONEY, "").Replace(" ", "");
resultContent = DBHelperMySQL.updateBlank(qq, money,"0");
}
else
{
resultContent = "提现金额必须大于0!";
}
}
}
// 加钱
else if (message.Contains(MessageConstant.ADD_MONEY))
{
int moneyIndex = message.IndexOf(MessageConstant.ADD_MONEY + ":");
int index = message.IndexOf(MessageConstant.ADD_MONEY);
if (moneyIndex >= 0 && index >= 0)
{
decimal money = Convert.ToDecimal(message.Substring(moneyIndex).Replace("加钱:", "").Replace(" ", ""));
if (money > tmpMoney)
{
string qq = message.Replace(message.Substring(moneyIndex), "").Replace(MessageConstant.UPDATE_MONEY, "").Replace(" ", "");
resultContent = DBHelperMySQL.updateBlank(qq, money,"1");
}
else
{
resultContent = "加钱金额必须大于0!";
}
}
}
}
catch (Exception)
{
resultContent = "更新失败。";
}
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.UPDATE_MONEY);
}
else if (message.Contains(MessageConstant.TODAY_COUNT))
{
// 今日使用数量
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin)
{
int count = DBHelperMySQL.getToday();
resultContent = "今日使用人数达"+count+"人";
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.TODAY_COUNT);
}
else if (message.Contains(MessageConstant.USER_TOTAL))
{
// 总人数
// 判定是否为管理员
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin)
{
int count = DBHelperMySQL.getUserTotal();
DateTime dt = DateTime.Now;
// 获取日期
string date = dt.ToLongDateString().ToString();
resultContent = "截止" + date + ",机器人历史使用人数达"+count+"人。";
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.USER_TOTAL);
}
else if (message.Contains(MessageConstant.THIS_WEEK))
{
// 七日使用
// 判定是否为管理员
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin)
{
Hashtable hashtable = DBHelperMySQL.getThisWeek();
resultContent = "";
foreach (Object item in hashtable.Keys)
{
string dateData = item.ToString();
string count = hashtable[item].ToString();
resultContent += dateData + " 使用人数为:" + count + "人;\n";
}
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.USER_TOTAL);
}
else if (message.Contains(MessageConstant.QUN_TOTAL))
{
// 群数量
// 判定是否为管理员
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin)
{
resultContent = "群数量";
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.QUN_TOTAL);
}
else if (message.Contains(MessageConstant.MONEY_DESC))
{
// 财富榜
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
// 检索是否为做作家团
if (DBHelperMySQL.exitsUser(fromQQ) || isAdmin)
{
resultContent = DBHelperMySQL.Top30Money();
}
else
{
resultContent = "您不是作家团成员!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.MONEY_DESC);
}
else
{
// 其他内容
resultContent = MessageConstant.HELP_CONTENT;
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: "");
}
if (resultContent == "" || resultContent == null || resultContent.Length == 0) {
messageModel.SendMessage = "\n无数据";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HELP);
}
// 记录用户操作数据
DBHelperMySQL.addUserData(fromQQ, content, resultContent);
return messageModel;
}
19
View Source File : MessageController.cs
License : Apache License 2.0
Project Creator : 0nise
License : Apache License 2.0
Project Creator : 0nise
public static MessageModel main(String message,string fromQQ) {
string resultContent = "\n无数据";
string content = message;
MessageModel messageModel = null;
if (message == null || message == "" || message.Length == 0)
{
messageModel = new MessageModel(sendMessage: MessageConstant.HELP_CONTENT, isAdmin: false, code: "");
return messageModel;
}
resultContent = "\n无数据";
message = executeCodeReplace(message);
message = message.Trim();
if (message.Length == 0 || message == "")
{
messageModel = new MessageModel(sendMessage: MessageConstant.HELP_CONTENT, isAdmin: false, code: "");
return messageModel;
}
else if (message.Contains(MessageConstant.RANDOM_CONTENT_replacedLE)) {
// 标题查询随机文章
message = message.Replace(MessageConstant.RANDOM_CONTENT_replacedLE, "").Trim();
resultContent = DBHelperMySQL.GetContentRandomByreplacedle(message);
// 标题查询随机课程
string clreplacedContent = DBHelperMySQL.getClreplacedRandomByreplacedle(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_CONTENT_replacedLE);
}
else if (message.Contains(MessageConstant.DESC_CONTENT_replacedLE)) {
// 标题查询最新文章
message = message.Replace(MessageConstant.DESC_CONTENT_replacedLE, "").Trim();
string clreplacedContent = "";
if (message.Length == 0 || message == "" || "".Equals(message) || message == null)
{
// 调用每日最新
resultContent = DBHelperMySQL.getContentDateByToday();
// 标题查询最新课程
clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle("");
}
else
{
resultContent = DBHelperMySQL.getContentDateByreplacedle(message);
clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle(message);
}
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_replacedLE);
}
else if (message.Contains(MessageConstant.DESC_CONTENT_AUTHOR)) {
// 作者查询最新文章
message = message.Replace(MessageConstant.DESC_CONTENT_AUTHOR, "").Trim();
resultContent = DBHelperMySQL.getContentDateByAuthor(message);
// 作者查询最新课程
string clreplacedContent = DBHelperMySQL.getClreplacedDateByAuthor(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_AUTHOR);
} else if (message.Contains(MessageConstant.RANDOM_CONTENT_AUTHOR)) {
// 作者查询随机文章
message = message.Replace(MessageConstant.RANDOM_CONTENT_AUTHOR, "").Trim();
resultContent = DBHelperMySQL.getContentRandomByAuthor(message);
// 作者查询随机课程
string clreplacedContent = DBHelperMySQL.getClreplacedRandomByAuthor(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_CONTENT_AUTHOR);
}
else if (message.Contains(MessageConstant.DESC_CONTENT_TODAY) || message.Contains(MessageConstant.DESC_CONTENT))
{
// 今日最新
message = message.Replace(MessageConstant.DESC_CONTENT_TODAY, "").Trim();
resultContent = DBHelperMySQL.getContentDateByToday();
string clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle("");
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_CONTENT_TODAY);
} else if (message.Contains(MessageConstant.GONG_GAO)) {
// 公告处理
bool flag = DBHelperMySQL.isAdmin(fromQQ);
// 判断是否管理员
if (flag) {
message = message.Replace(MessageConstant.GONG_GAO, "来自i春秋机器人的智能推送\n");
resultContent = message;
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: true, code: MessageConstant.GONG_GAO);
}
else {
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.GONG_GAO);
}
}
else if (message.Contains(MessageConstant.AITE_ALL))
{
// 艾特全体处理
bool flag = DBHelperMySQL.isAdmin(fromQQ);
if (flag)
{
message = message.Replace(MessageConstant.AITE_ALL, "来自i春秋机器人的智能推送\n");
resultContent = message;
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: true, code: MessageConstant.AITE_ALL);
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.AITE_ALL);
}
}
else if (message.Contains(MessageConstant.HELP) || message.Contains(MessageConstant.HELP_TWO))
{
// Help 帮助等指令
resultContent = MessageConstant.HELP_CONTENT;
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HELP_TWO);
} else if (message.Contains(MessageConstant.DESC_VIDEO)) {
// 标题查询最新教程
message = message.Replace(MessageConstant.DESC_VIDEO, "").Trim();
resultContent = DBHelperMySQL.getCourseDateByreplacedle(message);
// 标题查询最新课程
string clreplacedContent = DBHelperMySQL.getClreplacedDateByreplacedle(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.DESC_VIDEO);
}
else if (message.Contains(MessageConstant.RANDOM_VIDEO))
{
// 标题查询随机教程
message = message.Replace(MessageConstant.RANDOM_VIDEO, "").Trim();
resultContent = DBHelperMySQL.getCourseRandomByreplacedle(message);
// 标题查询随机课程
string clreplacedContent = DBHelperMySQL.getClreplacedRandomByreplacedle(message);
if (clreplacedContent.Length > 0 && !"".Equals(clreplacedContent))
{
resultContent += clreplacedContent;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.RANDOM_VIDEO);
}
else if (message.Contains(MessageConstant.TEST))
{
// 测试命令
resultContent = " [CQ:image,file=photo.jpg]";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.TEST);
} else if (message.Contains(MessageConstant.SELECT_MONEY)) {
// 查询余额
string money = DBHelperMySQL.getBlankMoney(fromQQ);
if (money == "" || money == null || money.Length == 0)
{
resultContent = "没有数据,请联系QQ:758841765 给予昵称QQ等信息。";
}
else
{
resultContent = "\n当前余额为 " + money;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.SELECT_MONEY);
}
else if (message.Contains(MessageConstant.HISTORY_MONEY))
{
// 提现记录
string historyMoney = DBHelperMySQL.getBlankHistory(fromQQ);
// 查询当前余额
string money = DBHelperMySQL.getBlankMoney(fromQQ);
if (money == "" || money == null || money.Length == 0) {
resultContent = "没有数据,请联系QQ:758841765 给予昵称QQ等信息。";
}
else {
resultContent = "\n当前余额为 " + money + "\n";
// 查询历史记录
resultContent += "提现记录\n";
resultContent += "金额\t\t时间\n" + historyMoney;
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HISTORY_MONEY);
}
else if (message.Contains(MessageConstant.APPLY_MONEY))
{
// 申请提现
resultContent = "请联系【坏蛋】,QQ号:286894635。\n[CQ:at,qq=286894635]";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.APPLY_MONEY);
} else if (message.Contains(MessageConstant.ABOUT)) {
resultContent = "i春秋社区机器人,研发人员为:0nise!";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.ABOUT);
} else if (message.Contains(MessageConstant.UPDATE_MONEY)) {
// 更新金额
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin) {
try
{
int moneyIndex = message.IndexOf("提现:");
int index = message.IndexOf(MessageConstant.UPDATE_MONEY);
if (moneyIndex >= 0 && index >= 0)
{
decimal money = Convert.ToDecimal(message.Substring(moneyIndex).Replace("提现:", "").Replace(" ",""));
string qq = message.Replace(message.Substring(moneyIndex), "").Replace(MessageConstant.UPDATE_MONEY, "").Replace(" ", "");
resultContent = DBHelperMySQL.updateBlank(qq,money);
}
}
catch (Exception)
{
resultContent = "更新失败。";
}
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.UPDATE_MONEY);
}
else if (message.Contains(MessageConstant.TODAY_COUNT))
{
// 今日使用数量
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin)
{
int count = DBHelperMySQL.getToday();
resultContent = "今日使用人数达"+count+"人";
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.TODAY_COUNT);
}
else if (message.Contains(MessageConstant.USER_TOTAL))
{
// 总人数
// 判定是否为管理员
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin)
{
int count = DBHelperMySQL.getUserTotal();
DateTime dt = DateTime.Now;
// 获取日期
string date = dt.ToLongDateString().ToString();
resultContent = "截止" + date + ",机器人历史使用人数达"+count+"人。";
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.USER_TOTAL);
}
else if (message.Contains(MessageConstant.THIS_WEEK))
{
// 七日使用
// 判定是否为管理员
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin)
{
Hashtable hashtable = DBHelperMySQL.getThisWeek();
resultContent = "";
foreach (Object item in hashtable.Keys)
{
string dateData = item.ToString();
string count = hashtable[item].ToString();
resultContent += dateData + " 使用人数为:" + count + "人;\n";
}
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.USER_TOTAL);
}
else if (message.Contains(MessageConstant.QUN_TOTAL))
{
// 群数量
// 判定是否为管理员
bool isAdmin = DBHelperMySQL.isAdmin(fromQQ);
if (isAdmin)
{
resultContent = "群数量";
}
else
{
resultContent = "您不是管理员!请联系坏蛋,QQ286894635!";
}
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: isAdmin, code: MessageConstant.QUN_TOTAL);
}
else
{
// 其他内容
resultContent = MessageConstant.HELP_CONTENT;
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: "");
}
if (resultContent == "" || resultContent == null || resultContent.Length == 0) {
messageModel.SendMessage = "\n无数据";
messageModel = new MessageModel(sendMessage: resultContent, isAdmin: false, code: MessageConstant.HELP);
}
// 记录用户操作数据
DBHelperMySQL.addUserData(fromQQ, content, resultContent);
return messageModel;
}
19
View Source File : ConfigTools.cs
License : Apache License 2.0
Project Creator : 0nise
License : Apache License 2.0
Project Creator : 0nise
public static string getValue(string key) {
return ConfigurationManager.AppSettings[key].ToString();
}
19
View Source File : ICollectionResolver.cs
License : MIT License
Project Creator : 1996v
License : MIT License
Project Creator : 1996v
private static void GenerateDeserializeWithCore(bool isImplGenerICollec, Type itemType, Func<Expression, Expression> ctor)
{
/*
if (reader.TryReadNullWithEnsureArray1BuildInType(BssomType.Int8Code))/TryReadNullWithEnsureArray1NativeType(NativeBssomType.CharCode)/TryReadNullWithEnsureBuildInType(BssomType.Array2)
return default;
context.option.Security.DepthStep(ref reader);
reader.SkipVariableNumber();
int len = reader.ReadVariableNumber();
T t = new T(len);
Fill<T>(ref t,ref reader,ref context,len);
context.Depth--;
return t;
*/
bool isArray1Type = Array1FormatterHelper.IsArray1Type(itemType, out bool isNativeType, out byte typeCode, out string typeCodeName);
Type t = typeof(T);
List<Expression> ary = new List<Expression>(7);
LabelTarget returnTarget = Expression.Label(t, "returnLable");
if (isArray1Type)
{
if (isNativeType)
{
//if (reader.ryReadNullWithEnsureArray1NativeType(NativeType))
// goto label;
ary.Add(Expression.IfThen(CommonExpressionMeta.Call_Reader_TryReadNullWithEnsureArray1NativeType(typeCode), Expression.Return(returnTarget, Expression.Default(t))));
}
else
{
//if (reader.Call_Reader_TryReadNullWithEnsureArray1BuildInType(BuildInType))
// goto label;
ary.Add(Expression.IfThen(CommonExpressionMeta.Call_Reader_TryReadNullWithEnsureArray1BuildInType(typeCode), Expression.Return(returnTarget, Expression.Default(t))));
}
}
else
{
//if (reader.TryReadNullWithEnsureBuildInType(BssomType.Array2))
// goto label;
ary.Add(Expression.IfThen(CommonExpressionMeta.Call_Reader_TryReadNullWithEnsureBuildInType(BssomType.Array2), Expression.Return(returnTarget, Expression.Default(t))));
}
//context.option.Security.DepthStep(ref reader);
ary.Add(CommonExpressionMeta.Call_DeserializeContext_Option_Security_DepthStep);
//reader.SkipVariableNumber();
ary.Add(CommonExpressionMeta.Call_Reader_SkipVariableNumber);
//int len = reader.ReadVariableNumber();
ParameterExpression len = Expression.Variable(typeof(int));
ary.Add(Expression.replacedign(len, CommonExpressionMeta.Call_Reader_ReadVariableNumber));
//T t = ctor(len);
ParameterExpression instance = Expression.Variable(t);
ary.Add(Expression.replacedign(instance, ctor(len)));
MethodInfo method = null;
if (isImplGenerICollec == false)
{
//IColloctionFormatterHelper.Fill_ImplIList<T>(ref t,ref reader,ref context,len)
method = typeof(Array2FormatterHelper).GetMethod(nameof(Array2FormatterHelper.Fill_ImplIList), BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(t);
}
else
{
if (isArray1Type)
{
//IColloctionFormatterHelper.Fill{TypeCodeName}<T>(ref t,ref reader,ref context,len)
method = typeof(Array1FormatterHelper).GetMethod(Array1FormatterHelper.FillPrefix + typeCodeName.ToString().Replace("Code", ""), BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(t);
}
else
{
//IColloctionFormatterHelper.Fill_ImplICollection<T,TElement>(ref t,ref reader,ref context,len)
method = typeof(Array2FormatterHelper).GetMethod(nameof(Array2FormatterHelper.Fill_ImplICollection), BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(new Type[] { t, itemType });
}
}
ary.Add(Expression.Call(null, method, instance, CommonExpressionMeta.Par_Reader, CommonExpressionMeta.Par_DeserializeContext, len));
//context.Depth--;
ary.Add(CommonExpressionMeta.Call_DeserializeContext_Depth_Decrementreplacedign);
//return t;
ary.Add(Expression.Return(returnTarget, instance));
//label default(T)
ary.Add(Expression.Label(returnTarget, instance));
BlockExpression block = Expression.Block(new ParameterExpression[] { instance, len }, ary);
Deserialize = Expression.Lambda<Deserialize<T>>(block, CommonExpressionMeta.Par_Reader, CommonExpressionMeta.Par_DeserializeContext).Compile();
}
19
View Source File : FauxDeployCMAgent.cs
License : GNU General Public License v3.0
Project Creator : 1RedOne
License : GNU General Public License v3.0
Project Creator : 1RedOne
public static void SendDiscovery(string CMServerName, string clientName, string domainName, string SiteCode,
string CertPath, SecureString preplaced, SmsClientId clientId, ILog log, bool enumerateAndAddCustomDdr = false)
{
using (MessageCertificateX509Volatile certificate = new MessageCertificateX509Volatile(CertPath, preplaced))
{
//X509Certificate2 thisCert = new X509Certificate2(CertPath, preplaced);
log.Info($"Got SMSID from registration of: {clientId}");
// create base DDR Message
ConfigMgrDataDiscoveryRecordMessage ddrMessage = new ConfigMgrDataDiscoveryRecordMessage
{
// Add necessary discovery data
SmsId = clientId,
ADSiteName = "Default-First-Site-Name", //Changed from 'My-AD-SiteName
SiteCode = SiteCode,
DomainName = domainName,
NetBiosName = clientName
};
ddrMessage.Discover();
// Add our certificate for message signing
ddrMessage.AddCertificateToMessage(certificate, CertificatePurposes.Signing);
ddrMessage.AddCertificateToMessage(certificate, CertificatePurposes.Encryption);
ddrMessage.Settings.HostName = CMServerName;
ddrMessage.Settings.Compression = MessageCompression.Zlib;
ddrMessage.Settings.ReplyCompression = MessageCompression.Zlib;
Debug.WriteLine("Sending [" + ddrMessage.DdrInstances.Count + "] instances of Discovery data to CM");
if (enumerateAndAddCustomDdr)
{
//see current value for the DDR message
var OSSetting = ddrMessage.DdrInstances.OfType<InventoryInstance>().Where(m => m.Clreplaced == "CCM_DiscoveryData");
////retrieve actual setting
string osCaption = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>()
select x.GetPropertyValue("Caption")).FirstOrDefault().ToString();
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
////retrieve reported value
xmlDoc.LoadXml(ddrMessage.DdrInstances.OfType<InventoryInstance>().FirstOrDefault(m => m.Clreplaced == "CCM_DiscoveryData")?.InstanceDataXml.ToString());
////Set OS to correct setting
xmlDoc.SelectSingleNode("/CCM_DiscoveryData/PlatformID").InnerText = "Microsoft Windows NT Server 10.0";
////Remove the instance
ddrMessage.DdrInstances.Remove(ddrMessage.DdrInstances.OfType<InventoryInstance>().FirstOrDefault(m => m.Clreplaced == "CCM_DiscoveryData"));
CMFauxStatusViewClreplacedesFixedOSRecord FixedOSRecord = new CMFauxStatusViewClreplacedesFixedOSRecord
{
PlatformId = osCaption
};
InventoryInstance instance = new InventoryInstance(FixedOSRecord);
////Add new instance
ddrMessage.DdrInstances.Add(instance);
}
ddrMessage.SendMessage(Sender);
ConfigMgrHardwareInventoryMessage hinvMessage = new ConfigMgrHardwareInventoryMessage();
hinvMessage.Settings.HostName = CMServerName;
hinvMessage.SmsId = clientId;
hinvMessage.Settings.Compression = MessageCompression.Zlib;
hinvMessage.Settings.ReplyCompression = MessageCompression.Zlib;
//hinvMessage.Settings.Security.EncryptMessage = true;
hinvMessage.Discover();
var Clreplacedes = CMFauxStatusViewClreplacedes.GetWMIClreplacedes();
foreach (string Clreplaced in Clreplacedes)
{
try { hinvMessage.AddInstancesToInventory(WmiClreplacedToInventoryReportInstance.WmiClreplacedToInventoryInstances(@"root\cimv2", Clreplaced)); }
catch { log.Info($"!!!Adding clreplaced : [{Clreplaced}] :( not found on this system"); }
}
var SMSClreplacedes = new List<string> { "SMS_Processor", "CCM_System", "SMS_LogicalDisk" };
foreach (string Clreplaced in SMSClreplacedes)
{
log.Info($"---Adding clreplaced : [{Clreplaced}]");
try { hinvMessage.AddInstancesToInventory(WmiClreplacedToInventoryReportInstance.WmiClreplacedToInventoryInstances(@"root\cimv2\sms", Clreplaced)); }
catch { log.Info($"!!!Adding clreplaced : [{Clreplaced}] :( not found on this system"); }
}
hinvMessage.AddCertificateToMessage(certificate, CertificatePurposes.Signing | CertificatePurposes.Encryption);
hinvMessage.Validate(Sender);
hinvMessage.SendMessage(Sender);
};
}
19
View Source File : RedisReader.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public long ReadInt(bool checkType = true)
{
if (checkType)
ExpectType(RedisMessage.Int);
string line = ReadLine();
return Int64.Parse(line.ToString());
}
19
View Source File : Utils.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
public static string GetVersion()
{
try
{
string location = GetExePath();
return string.Format("v2rayN - V{0} - {1}",
FileVersionInfo.GetVersionInfo(location).FileVersion.ToString(),
File.GetLastWriteTime(location).ToString("yyyy/MM/dd"));
}
catch (Exception ex)
{
SaveLog(ex.Message, ex);
return string.Empty;
}
}
19
View Source File : UpdateHandle.cs
License : GNU General Public License v3.0
Project Creator : 2dust
License : GNU General Public License v3.0
Project Creator : 2dust
private void responseHandler(string type, string redirectUrl)
{
try
{
string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);
string curVersion;
string message;
string url;
if (type == "v2fly")
{
curVersion = "v" + getCoreVersion(type);
message = string.Format(UIRes.I18N("IsLatestCore"), curVersion);
string osBit = Environment.Is64BitProcess ? "64" : "32";
url = string.Format(v2flyCoreUrl, version, osBit);
}
else if (type == "xray")
{
curVersion = "v" + getCoreVersion(type);
message = string.Format(UIRes.I18N("IsLatestCore"), curVersion);
string osBit = Environment.Is64BitProcess ? "64" : "32";
url = string.Format(xrayCoreUrl, version, osBit);
}
else if (type == "v2rayN")
{
curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString();
message = string.Format(UIRes.I18N("IsLatestN"), curVersion);
url = string.Format(nUrl, version);
}
else
{
throw new ArgumentException("Type");
}
if (curVersion == version)
{
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(false, message));
return;
}
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, url));
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
_updateFunc(false, ex.Message);
}
}
19
View Source File : WorkOffsetsWindow.xaml.cs
License : MIT License
Project Creator : 3RD-Dimension
License : MIT License
Project Creator : 3RD-Dimension
public void parseG5xOffsets(string recievedG5x)
{
// Need someway to ignore this until the machine is idle and not operating
if (recievedG5x.StartsWith("[G54:") || recievedG5x.StartsWith("[G55:") || recievedG5x.StartsWith("[G56:") || recievedG5x.StartsWith("[G57:") || recievedG5x.StartsWith("[G58:") || recievedG5x.StartsWith("[G59:"))
{
// Splitting each recieved axis and value
string label;
string[] axes;
recievedG5x = recievedG5x.Remove(0, 1); // remove the leading [
recievedG5x = recievedG5x.Remove(recievedG5x.Length - 1, 1); // remove the trailing "] <vbLf>"
label = recievedG5x.Substring(0, 3);
recievedG5x = recievedG5x.Remove(0, 4); // finally remove the label:
axes = recievedG5x.Split(',');
switch (label)
{
case "G54":
{
G54X.Text = axes[0].ToString();
G54Y.Text = axes[1].ToString();
G54Z.Text = axes[2].ToString();
break;
}
case "G55":
{
G55X.Text = axes[0].ToString();
G55Y.Text = axes[1].ToString();
G55Z.Text = axes[2].ToString();
break;
}
case "G56":
{
G56X.Text = axes[0].ToString();
G56Y.Text = axes[1].ToString();
G56Z.Text = axes[2].ToString();
break;
}
case "G57":
{
G57X.Text = axes[0].ToString();
G57Y.Text = axes[1].ToString();
G57Z.Text = axes[2].ToString();
break;
}
case "G58":
{
G58X.Text = axes[0].ToString();
G58Y.Text = axes[1].ToString();
G58Z.Text = axes[2].ToString();
break;
}
case "G59":
{
G59X.Text = axes[0].ToString();
G59Y.Text = axes[1].ToString();
G59Z.Text = axes[2].ToString();
break;
}
}
}
else
{
return;
}
}
19
View Source File : GrblSettingsWindow.xaml.cs
License : MIT License
Project Creator : 3RD-Dimension
License : MIT License
Project Creator : 3RD-Dimension
public void LineReceived(string line)
{
// Recieve GRBL Controller Version number and display - $i
// Recieved in format [VER: ... and [OPT:
if (!line.StartsWith("$") && !line.StartsWith("[VER:") && !line.StartsWith("[OPT:"))
return;
if (line.StartsWith("$"))
{
try
{
Match m = settingParser.Match(line);
int number = int.Parse(m.Groups[1].Value);
double value = double.Parse(m.Groups[2].Value, Util.Constants.DecimalParseFormat);
// Value = Setting Value, Number = Setting Code
if (!CurrentSettings.ContainsKey(number))
{
RowDefinition rowDef = new RowDefinition();
rowDef.Height = new GridLength(25);
gridMain.RowDefinitions.Add(rowDef);
TextBox valBox = new TextBox // Value of Setting Textbox
{
Text = value.ToString(Util.Constants.DecimalOutputFormat),
VerticalAlignment = VerticalAlignment.Center
};
// Define Mouseclick for textbox to open GRBLStepsCalcWindow for setting $100, $101, $102
if (number == 100) { valBox.Name = "Set100"; valBox.MouseDoubleClick += openStepsCalc; }
else if (number == 101) { valBox.Name = "Set101"; valBox.MouseDoubleClick += openStepsCalc; }
else if (number == 102) { valBox.Name = "Set102"; valBox.MouseDoubleClick += openStepsCalc; }
Grid.SetRow(valBox, gridMain.RowDefinitions.Count - 1);
Grid.SetColumn(valBox, 1);
gridMain.Children.Add(valBox);
TextBlock num = new TextBlock
{
Text = $"${number}=",
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Center
};
Grid.SetRow(num, gridMain.RowDefinitions.Count - 1);
Grid.SetColumn(num, 0);
gridMain.Children.Add(num);
if (Util.GrblCodeTranslator.Settings.ContainsKey(number))
{
Tuple<string, string, string> labels = Util.GrblCodeTranslator.Settings[number];
TextBlock name = new TextBlock
{
Text = labels.Item1,
VerticalAlignment = VerticalAlignment.Center
};
Grid.SetRow(name, gridMain.RowDefinitions.Count - 1);
Grid.SetColumn(name, 0);
gridMain.Children.Add(name);
TextBlock unit = new TextBlock
{
Text = labels.Item2,
VerticalAlignment = VerticalAlignment.Center
};
Grid.SetRow(unit, gridMain.RowDefinitions.Count - 1);
Grid.SetColumn(unit, 2);
gridMain.Children.Add(unit);
valBox.ToolTip = $"{labels.Item1} ({labels.Item2}):\n{labels.Item3}";
}
CurrentSettings.Add(number, value);
SettingsBoxes.Add(number, valBox);
}
else
{
SettingsBoxes[number].Text = value.ToString(Util.Constants.DecimalOutputFormat);
CurrentSettings[number] = value;
}
}
catch { }
}
// If the line starts with [VER: then we know we are getting the version and options
else if (line.StartsWith("[VER:") || line.StartsWith("[OPT:"))
{
// Frist need to remove front [ and rear ]
string VerOptInput; // Input string
string[] VerOptTrimmed;
VerOptInput = line.Remove(0, 1); // Remove [ from the start
VerOptInput = VerOptInput.Remove(VerOptInput.Length - 1);
// Next, split the values in half at the : - we only want VER/OPT and then the values
VerOptTrimmed = VerOptInput.Split(':');
// Now we fill in the boxes depending on which one
switch (VerOptTrimmed[0])
{
case "VER":
controllerInfo += "Version: " + VerOptTrimmed[1];
break;
case "OPT":
// First we have to split commas
string[] optSplit;
optSplit = VerOptTrimmed[1].Split(','); // Splits Options into 3. 0=Options, 1=blockBufferSize, 2=rxBufferSize
var individualChar = optSplit[0].ToCharArray();// Now split optSplit[0] into each option character
controllerInfo += " | Options: " + VerOptTrimmed[1]; // Full Options Non-Decoded String
foreach (char c in individualChar)
{
// Lookup what each code is and display.... buildCodes Dictionary
if (Util.GrblCodeTranslator.BuildCodes.ContainsKey(c.ToString()))
{
// Now lets try and create and append to a string and then bind it to a ToolTip? or some other way
controllerInfo += Environment.NewLine + Util.GrblCodeTranslator.BuildCodes[c.ToString()];
}
}
controllerInfo += Environment.NewLine + "Block Buffer Size: " + optSplit[1];
controllerInfo += Environment.NewLine + "RX Buffer Size: " + optSplit[2];
GRBL_Controller_Info.Text = controllerInfo.ToString();
break;
}
}
}
19
View Source File : BlendshapePrinter.cs
License : MIT License
Project Creator : 734843327
License : MIT License
Project Creator : 734843327
void OnGUI()
{
if (shapeEnabled) {
string blendshapes = "";
string shapeNames = "";
string valueNames = "";
foreach(KeyValuePair<string,float> kvp in currentBlendShapes) {
blendshapes += " [";
blendshapes += kvp.Key.ToString ();
blendshapes += ":";
blendshapes += kvp.Value.ToString ();
blendshapes += "]\n";
shapeNames += "\"";
shapeNames += kvp.Key.ToString ();
shapeNames += "\",\n";
valueNames += kvp.Value.ToString ();
valueNames += "\n";
}
GUILayout.BeginHorizontal (GUILayout.ExpandHeight(true));
GUILayout.Box (blendshapes);
GUILayout.EndHorizontal ();
Debug.Log (shapeNames);
Debug.Log (valueNames);
}
}
19
View Source File : GH_Cloud.cs
License : GNU Lesser General Public License v3.0
Project Creator : 9and3
License : GNU Lesser General Public License v3.0
Project Creator : 9and3
public override string ToString() {
return string.Format("PointCloud {0} HasNormals {1} HasColors {2}", this.m_value.Count, this.m_value.ContainsNormals, this.m_value.ContainsColors).ToString();
}
19
View Source File : UnityStudioCLI.cs
License : MIT License
Project Creator : 91Act
License : MIT License
Project Creator : 91Act
static void Main()
{
var args = Environment.GetCommandLineArgs();
if (args.Length > 1)
{
var cmd = args[1];
var abPath = "";
switch (cmd)
{
case "--list":
if (args.Length>2){
abPath = args[2];
enableDebugPrint = false;
UnityStudio.LoadBundleFile(abPath,false,"");
return;
}
break;
case "--dump":
/*
Extract files inside replacedetbundle file to savePath.
*/
var savePath = "";
if (args.Length>2){
abPath = args[2];
if (args.Length>3){
savePath = args[3];
}
UnityStudio.LoadBundleFile(abPath,true,savePath);
return;
}
break;
default:
break;
}
}
Console.WriteLine("Unrecognized command:");
for(int i=0;i<args.Length;i++){
Console.WriteLine("CMD["+i+"]="+args[i].ToString());
}
}
19
View Source File : AccelGUI.cs
License : MIT License
Project Creator : a1xd
License : MIT License
Project Creator : a1xd
public void UpdateActiveSettingsFromFields()
{
string error_message;
try
{
ButtonDelay(WriteButton);
if (!Settings.TryActivate(MakeSettingsFromFields(), out string errors))
{
error_message = errors.ToString();
}
else
{
RefreshActive();
Settings.SetActiveHandles();
return;
}
}
catch (ApplicationException e)
{
error_message = e.Message;
}
using (var form = new MessageDialog(error_message, "bad input"))
{
form.ShowDialog();
}
}
19
View Source File : FormAbnLookup.cs
License : MIT License
Project Creator : ABN-SFLookupTechnicalSupport
License : MIT License
Project Creator : ABN-SFLookupTechnicalSupport
private void buttonReset_Click(object sender, EventArgs e) {
int index = 0;
try {
foreach (Control control in tabPageXmlSearch.Controls) {
if (control is TextBox) {
control.Text = (initialControlValue[index].ToString());
index++;
}
}
}
catch (Exception exp) {
ShowException(exp.ToString());
}
InitialiseControls();
}
19
View Source File : DataEntry.cs
License : MIT License
Project Creator : absurd-joy
License : MIT License
Project Creator : absurd-joy
void processNetPackets()
{
Packet incomingPacket = Net.ReadPacket();
while (incomingPacket != null)
{
byte[] rawBits = new byte[incomingPacket.Size];
incomingPacket.ReadBytes(rawBits);
chatPacket newMessage = chatPacket.Deserialize(rawBits);
printOutputLine("Chat Text: " + newMessage.textString.ToString());
printOutputLine("Received Packet from UserID: " + incomingPacket.SenderID.ToString());
printOutputLine("Received Packet ID: " + newMessage.packetID.ToString());
// Look to see if there's another packet waiting
incomingPacket = Net.ReadPacket();
}
}
19
View Source File : LogTrace.cs
License : GNU Affero General Public License v3.0
Project Creator : active-logic
License : GNU Affero General Public License v3.0
Project Creator : active-logic
public bool Matches(object scope, string reason)
=> (this.scope.ToString()).Equals(scope)
&& this.reason == TraceFormat.ReasonField(reason);
19
View Source File : DateIncrement.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
public static string GetDateIDGivenIncrementsOnInputDateId(string dateId, DateIncrement increment)
{
var year = int.Parse(dateId.ToString().Substring(0, 4));
var month = int.Parse(dateId.ToString().Substring(4, 2));
var day = int.Parse(dateId.ToString().Substring(6, 2));
if (increment.type == DateIncrementTypes.Year)
{
year = year + increment.increments > 99 ? year + increment.increments - 99 : year + increment.increments;
}
if (increment.type == DateIncrementTypes.Month)
{
if (month + increment.increments > 12)
{
year = year + 1;
}
month = month + increment.increments > 12 ? month + increment.increments - 12 : month + increment.increments;
}
if (increment.type == DateIncrementTypes.Day)
{
day = day + increment.increments > 30 ? day + increment.increments - 30 : day + increment.increments;
}
return (DoubleCharacterOut(year.ToString()) + DoubleCharacterOut(month.ToString()) + DoubleCharacterOut(day.ToString()));
}
19
View Source File : DateIncrement.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
public static string GetDateIDGivenIncrements(string dateIdA, string dateIdB)
{
var year = 0m;
var month = 0m;
var day = 0m;
var yearA = int.Parse(dateIdA.ToString().Substring(0, 2));
var monthA = int.Parse(dateIdA.ToString().Substring(2, 2));
var dayA = int.Parse(dateIdA.ToString().Substring(4, 2));
var yearB = int.Parse(dateIdB.ToString().Substring(0, 2));
var monthB = int.Parse(dateIdB.ToString().Substring(2, 2));
var dayB = int.Parse(dateIdB.ToString().Substring(4, 2));
year = yearB - yearA > 24 ? yearB - yearA - 24 : yearB - yearA;
month = monthB - monthA > 60 ? monthB - monthA - 60 : monthB - monthA;
day = dayB - dayA > 60 ? dayB - dayA : dayB - dayA;
return (DoubleCharacterOut(year.ToString()) + DoubleCharacterOut(month.ToString()) + DoubleCharacterOut(day.ToString()));
}
19
View Source File : TimeIncrement.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
public static string GetTimeIDGivenIncrements(string timeIdA, string timeIdB)
{
var hour = 0m;
var minute = 0m;
var second = 0m;
var miliSecond = 0m;
var hourA = int.Parse(timeIdA.ToString().Substring(0, 2));
var minuteA = int.Parse(timeIdA.ToString().Substring(2, 2));
var secondA = int.Parse(timeIdA.ToString().Substring(4, 2));
var miliSecondA = int.Parse(timeIdA.ToString().Substring(6, 2));
var hourB = int.Parse(timeIdB.ToString().Substring(0, 2));
var minuteB = int.Parse(timeIdB.ToString().Substring(2, 2));
var secondB = int.Parse(timeIdB.ToString().Substring(4, 2));
var miliSecondB = int.Parse(timeIdB.ToString().Substring(6, 2));
hour = hourB - hourA > 24 ? hourB - hourA - 24 : hourB - hourA;
minute = minuteB - minuteA > 60 ? minuteB - minuteA - 60 : minuteB - minuteA;
second = secondB - secondA > 60 ? secondB - secondA : secondB - secondA;
miliSecond = miliSecondB = miliSecondA > 1000 ? miliSecondB = miliSecondA : miliSecondB = miliSecondA;
return (DoubleCharacterOut(hour.ToString()) + DoubleCharacterOut(minute.ToString()) + DoubleCharacterOut(second.ToString()) + DoubleCharacterOut(miliSecond.ToString()));
}
19
View Source File : TimeIncrement.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
public static string GetTimeIDGivenIncrementsOnInputTimeId(string timeId, TimeIncrement increment)
{
var hour = int.Parse(timeId.ToString().Substring(0, 2));
var minute = int.Parse(timeId.ToString().Substring(2, 2));
var second = int.Parse(timeId.ToString().Substring(4, 2));
var milliSecond = int.Parse(timeId.ToString().Substring(6, 4));
if (increment.type == TimeIncrementTypes.Hour)
{
hour = hour + increment.increments > 24 ? hour + increment.increments - 24 : hour + increment.increments;
}
if (increment.type == TimeIncrementTypes.Minute)
{
minute = minute + increment.increments > 60 ? minute + increment.increments - 60 : minute + increment.increments;
}
if (increment.type == TimeIncrementTypes.Second)
{
second = second + increment.increments > 60 ? second + increment.increments - 60 : second + increment.increments;
}
if (increment.type == TimeIncrementTypes.MilliSecond)
{
milliSecond = milliSecond + increment.increments > 1000 ? milliSecond + increment.increments - 1000 : milliSecond + increment.increments;
}
return (DoubleCharacterOut(hour.ToString()) + DoubleCharacterOut(minute.ToString()) + DoubleCharacterOut(second.ToString()));
}
19
View Source File : HazardPDFCalculator.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
License : BSD 3-Clause "New" or "Revised" License
Project Creator : ActuarialIntelligence
public IList<HazardPdfCdfHazardTriplet> Calculate(string populationGroup, int currentState)
{
var stateTransitionCodes = new List<string>();
var returnObject = new List<HazardPdfCdfHazardTriplet>();
Console.WriteLine("Calculating Transition:" + transitionCode);
var observationList = hazardReader.GetData(populationGroup, dateFrom, dateTo,
new Domain.Date.DateIncrement(DateIncrementTypes.Month, 1), transitionCode, currentState, 1);
//var nelsonAalen = new KaplanMeier(observationList);
//var nResult = nelsonAalen.GetSurvivalValueUpToPeriod(periods);
var hazard = new Hazard(observationList);
var hzd = hazard.GetHazardFunctionOverEachPeriod();
var pdf = hazard.GetPDF();
var cdf = hazard.SurvivalFunction();
returnObject.Add(new HazardPdfCdfHazardTriplet(pdf, cdf, hzd, dateFrom, transitionCode, populationGroup.ToString()));
return returnObject;
}
19
View Source File : ObjectCacheExtensions.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
private static IEnumerable<XElement> GetContentValues(FormattedValueCollection attributes)
{
return attributes.OrderBy(a => a.Key).Select(a => new XElement("label", new XAttribute("name", a.Key), new XText(a.Value.ToString())));
}
19
View Source File : CrmSubscriptionMessageFactory.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public static ICrmSubscriptionMessage Create(BrokeredMessage message)
{
if (message == null)
return null;
string messageBody = message.GetBody<string>();
if (messageBody == null)
return null;
ADXTrace.Instance.TraceWarning(TraceCategory.Application, string.Format("Message Body for Subscription message is {0} ", messageBody.ToString()));
ICrmSubscriptionMessage subscriptionMessage = CrmSubscriptionMessageFactory.Create(messageBody, message);
if (subscriptionMessage != null)
{
CmsEventSource.Log.LatencyInfo(subscriptionMessage);
}
return subscriptionMessage;
}
19
View Source File : SaleToPoiMessageSerializer.cs
License : MIT License
Project Creator : Adyen
License : MIT License
Project Creator : Adyen
private string GetMessagePayloadJSon(JToken saleToPoiMessageWithoutRootJToken, string messageCategory, string messageType)
{
var messagePayloadTypedJson = saleToPoiMessageWithoutRootJToken.SelectToken(messageCategory + messageType.ToString());
if (messagePayloadTypedJson == null)
{
return saleToPoiMessageWithoutRootJToken.SelectToken("MessagePayload").ToString();
}
return messagePayloadTypedJson.ToString();
}
19
View Source File : MessagePayloadSerializerFactory.cs
License : MIT License
Project Creator : Adyen
License : MIT License
Project Creator : Adyen
private string CreateMessagePayloadFullName(string messageCategory, string messageType)
{
var nameSpaceSeparator = ".";
var messagePayloadName = messageCategory.ToString() + messageType;
var nexoDomainNameSpace = typeof(PaymentRequest).Namespace;
return string.Concat(nexoDomainNameSpace, nameSpaceSeparator, messagePayloadName);
}
19
View Source File : ConfigFile.cs
License : GNU General Public License v3.0
Project Creator : aelariane
License : GNU General Public License v3.0
Project Creator : aelariane
public void StoreValues()
{
foreach (var pair in booleans)
{
RefreshValue(pair.Key, pair.Value.ToString());
}
foreach (var pair in floats)
{
RefreshValue(pair.Key, pair.Value.ToString());
}
foreach (var pair in integers)
{
RefreshValue(pair.Key, pair.Value.ToString());
}
foreach (var pair in strings)
{
RefreshValue(pair.Key, pair.Value.ToString());
}
}
19
View Source File : UnityKeyedComponentResolver.cs
License : Apache License 2.0
Project Creator : agoda-com
License : Apache License 2.0
Project Creator : agoda-com
public T Resolve(string key)
{
return _container.Resolve<T>(key.ToString());
}
19
View Source File : UnityKeyedComponentResolver.cs
License : Apache License 2.0
Project Creator : agoda-com
License : Apache License 2.0
Project Creator : agoda-com
public bool IsRegistered(string key)
{
return _container.IsRegistered<T>(key.ToString());
}
19
View Source File : UserStore.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
protected override Task<TUser> FindUserAsync(string userId, CancellationToken cancellationToken)
=> FindByIdAsync(userId.ToString(), cancellationToken);
19
View Source File : UserOnlyStore.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
protected override Task<TUser> FindUserAsync(string userId, CancellationToken cancellationToken)
{
return FindByIdAsync(userId.ToString(), cancellationToken);
}
19
View Source File : BarcodesViewModel.cs
License : MIT License
Project Creator : ahmed-abdelrazek
License : MIT License
Project Creator : ahmed-abdelrazek
public async Task OnLoadedAsync()
{
await Task.Run(() =>
{
foreach (var item in Enum.GetNames(typeof(RotateFlipType)))
{
if (item.ToString().Trim().ToLower() == "rotatenoneflipnone")
{
continue;
}
RotateTypes.Add(item.ToString());
}
SelectedRotate = "Rotate180FlipXY";
Encoders = new List<Enumeration<byte>>();
foreach (var type in Enum.GetValues(typeof(BarCodeEncoders)))
{
Encoders.Add(new Enumeration<byte>
{
Id = (byte)type,
Name = Enumerations.GetEnumDescription((BarCodeEncoders)type).ToString()
});
}
SelectedEncoder = "Code 128";
});
}
19
View Source File : LicensePacker.cs
License : MIT License
Project Creator : AhmedMinegames
License : MIT License
Project Creator : AhmedMinegames
[STAThread]
static void Main()
{
try
{
bool IsPresent = false;
CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref IsPresent);
if (Debugger.IsAttached || IsDebuggerPresent() || IsPresent || CloseHandleAntiDebug())
{
Environment.Exit(0);
}
else
{
if (!File.Exists(Environment.CurrentDirectory + @"\SOS13"))
{
MessageBox.Show("Please Make a SOS13 file in the current program directory and enter the program license to it to continue.", "License Not Found", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
}
else
{
IntPtr NtdllModule = GetModuleHandle("ntdll.dll");
IntPtr DbgUiRemoteBreakinAddress = GetProcAddress(NtdllModule, "DbgUiRemoteBreakin");
IntPtr DbgUiConnectToDbgAddress = GetProcAddress(NtdllModule, "DbgUiConnectToDbg");
byte[] Int3InvaildCode = { 0xCC };
WriteProcessMemory(Process.GetCurrentProcess().Handle, DbgUiRemoteBreakinAddress, Int3InvaildCode, 6, 0);
WriteProcessMemory(Process.GetCurrentProcess().Handle, DbgUiConnectToDbgAddress, Int3InvaildCode, 6, 0);
string License = File.ReadAllText(Environment.CurrentDirectory + @"\SOS13");
if (string.IsNullOrEmpty(License))
{
Environment.Exit(0);
}
else
{
StringBuilder NewLicense = new StringBuilder();
for (int c = 0; c < License.Length; c++)
NewLicense.Append((char)((uint)License[c] ^ (uint)Convert.FromBase64String("decryptkeyencryption")[c % 4]));
StringBuilder ROT13Encoding = new StringBuilder();
Regex regex = new Regex("[A-Za-z]");
foreach (char KSXZ in NewLicense.ToString())
{
if (regex.IsMatch(KSXZ.ToString()))
{
int C = ((KSXZ & 223) - 52) % 26 + (KSXZ & 32) + 65;
ROT13Encoding.Append((char)C);
}
}
StringBuilder sb = new StringBuilder(); foreach (char c in ROT13Encoding.ToString().ToCharArray()) { sb.Append(Convert.ToString(c, 2).PadLeft(8, '0')); }
var GetTextToHEX = Encoding.Unicode.GetBytes(sb.ToString());
var BuildHEX = new StringBuilder();
foreach (var FinalHEX in GetTextToHEX)
{
BuildHEX.Append(FinalHEX.ToString("X2"));
}
string HashedKey = UTF8Encoding.UTF8.GetString(MD5.Create().ComputeHash(UTF8Encoding.UTF8.GetBytes(BuildHEX.ToString())));
HMACMD5 HMACMD = new HMACMD5();
HMACMD.Key = UTF8Encoding.UTF8.GetBytes("LXSO12");
string HashedKey2 = UTF8Encoding.UTF8.GetString(HMACMD.ComputeHash(UTF8Encoding.UTF8.GetBytes(HashedKey)));
string DecryptedProgram = TqMIJUcgsXjVgxqJ(ProgramToDecrypt, HashedKey2.ToString(), IV);
byte[] ProgramToRun = Convert.FromBase64String(DecryptedProgram);
replacedembly RunInMemory = replacedembly.Load(ProgramToRun);
RunInMemory.EntryPoint.Invoke(null, null);
}
}
}
}
catch (CryptographicException)
{
MessageBox.Show("Sorry, but looks like your license key are invalid.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
}
19
View Source File : USBPacker.cs
License : MIT License
Project Creator : AhmedMinegames
License : MIT License
Project Creator : AhmedMinegames
[STAThread]
private static void Main()
{
try
{
bool IsPresent = false;
Program.CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref IsPresent);
if (Debugger.IsAttached || Program.IsDebuggerPresent() || IsPresent || Program.CloseHandleAntiDebug())
{
Environment.Exit(0);
}
else
{
IntPtr moduleHandle = Program.GetModuleHandle("ntdll.dll");
IntPtr procAddress1 = Program.GetProcAddress(moduleHandle, "DbgUiRemoteBreakin");
IntPtr procAddress2 = Program.GetProcAddress(moduleHandle, "DbgUiConnectToDbg");
byte[] Buffer = new byte[1] { (byte)204 };
Program.WriteProcessMemory(Process.GetCurrentProcess().Handle, procAddress1, Buffer, 6U, 0);
Program.WriteProcessMemory(Process.GetCurrentProcess().Handle, procAddress2, Buffer, 6U, 0);
string USBHWID = GetUSBHardwareID();
StringBuilder DecryptEncryptionKey = new StringBuilder();
for (int c = 0; c < USBHWID.ToString().Length; c++)
DecryptEncryptionKey.Append((char)((uint)USBHWID[c] ^ (uint)Convert.FromBase64String("SOS12")[c % 4]));
replacedembly.Load(Convert.FromBase64String(Program.TqMIJUcgsXjVgxqJ(Program.ProgramToDecrypt, Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(DecryptEncryptionKey.ToString())), Program.IV))).EntryPoint.Invoke((object)null, (object[])null);
}
}
catch
{
MessageBox.Show("Sorry But looks like you are not authorized to use this program.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand);
}
}
19
View Source File : Main.cs
License : MIT License
Project Creator : AhmedMinegames
License : MIT License
Project Creator : AhmedMinegames
private void LicensePacking(string FileToPack, string Output)
{
var Options = new Dictionary<string, string>();
Options.Add("CompilerVersion", "v4.0");
Options.Add("language", "c#");
var codeProvider = new CSharpCodeProvider(Options);
CompilerParameters parameters = new CompilerParameters();
parameters.CompilerOptions = "/target:winexe";
parameters.GenerateExecutable = true;
parameters.Outputreplacedembly = Output;
parameters.IncludeDebugInformation = false;
string[] Librarys = { "System", "System.Windows.Forms", "System.Management", "System.Net", "System.Core", "System.Net.Http", "System.Runtime", "System.Runtime.InteropServices" };
foreach (string Library in Librarys)
{
parameters.Referencedreplacedemblies.Add(Library + ".dll");
}
byte[] CodeToProtect = File.ReadAllBytes(FileToPack);
string RandomIV = RandomPreplacedword(16);
AesAlgorithms EncryptingBytes = new AesAlgorithms();
string RandomKey = RandomPreplacedword(4);
Random rnd = new Random();
int RandomINT = rnd.Next(6, 13);
string RandomHashingKey = RandomPreplacedword(RandomINT);
StringBuilder ROT13Encoding = new StringBuilder();
Regex regex = new Regex("[A-Za-z]");
foreach (char KSXZ in XOREncryptionKeys(textBox3.Text, RandomKey))
{
if (regex.IsMatch(KSXZ.ToString()))
{
int C = ((KSXZ & 223) - 52) % 26 + (KSXZ & 32) + 65;
ROT13Encoding.Append((char)C);
}
}
StringBuilder sb = new StringBuilder(); foreach (char c in ROT13Encoding.ToString().ToCharArray()) { sb.Append(Convert.ToString(c, 2).PadLeft(8, '0')); }
var GetTextToHEX = Encoding.Unicode.GetBytes(sb.ToString());
var BuildHEX = new StringBuilder();
foreach (var FinalHEX in GetTextToHEX)
{
BuildHEX.Append(FinalHEX.ToString("X2"));
}
string HashedKey = UTF8Encoding.UTF8.GetString(MD5.Create().ComputeHash(UTF8Encoding.UTF8.GetBytes(BuildHEX.ToString())));
HMACMD5 HMACMD = new HMACMD5();
HMACMD.Key = UTF8Encoding.UTF8.GetBytes("LXSO12".Replace(UTF8Encoding.UTF8.GetString(Convert.FromBase64String("TFhTTzEy")), RandomHashingKey));
string HashedKey2 = UTF8Encoding.UTF8.GetString(HMACMD.ComputeHash(UTF8Encoding.UTF8.GetBytes(HashedKey)));
string Final = EncryptingBytes.AesTextEncryption(Convert.ToBase64String(CodeToProtect), HashedKey2.ToString(), RandomIV);
string LicensePacker = Resource1.LicensePacker;
string NewLicensePackerCode = LicensePacker.Replace("DecME", Final).Replace("THISISIV", RandomIV).Replace("LicensePacker", "namespace " + RandomName(14));
string MyShinyNewPacker = NewLicensePackerCode.Replace("decryptkeyencryption", Convert.ToBase64String(Encoding.UTF8.GetBytes(RandomKey))).Replace("SOS13", textBox4.Text).Replace(UTF8Encoding.UTF8.GetString(Convert.FromBase64String("TFhTTzEy")), RandomHashingKey);
codeProvider.CompilereplacedemblyFromSource(parameters, MyShinyNewPacker);
}
19
View Source File : Http.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : airzero24
License : BSD 3-Clause "New" or "Revised" License
Project Creator : airzero24
public static bool CheckIn()
{
try
{
#if DEFAULT_EKE
Crypto.GenRsaKeys();
Utils.GetStage GetStage = new Utils.GetStage
{
action = "staging_rsa",
pub_key = Crypto.GetPubKey(),
session_id = Utils.GetSessionId()
};
Config.SessionId = GetStage.session_id;
string SerializedData = Crypto.EncryptStage(Utils.GetStage.ToJson(GetStage));
var result = Get(SerializedData);
string final_result = Crypto.Decrypt(result);
Utils.StageResponse StageResponse = Utils.StageResponse.FromJson(final_result);
Config.tempUUID = StageResponse.uuid;
Config.Psk = Convert.ToBase64String(Crypto.RsaDecrypt(Convert.FromBase64String(StageResponse.session_key)));
#endif
Utils.CheckIn CheckIn = new Utils.CheckIn
{
action = "checkin",
ip = Utils.GetIPAddress(),
os = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", "").ToString() + " " + Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", ""),
user = Environment.UserName.ToString(),
host = Environment.MachineName.ToString(),
domain = Environment.UserDomainName.ToString(),
pid = Process.GetCurrentProcess().Id,
uuid = Config.PayloadUUID,
architecture = Utils.GetArch()
};
#if DEFAULT
string FinalSerializedData = Convert.ToBase64String(Encoding.UTF8.GetBytes(Config.PayloadUUID + Utils.CheckIn.ToJson(CheckIn)));
#elif (DEFAULT_PSK || DEFAULT_EKE)
string FinalSerializedData = Crypto.EncryptCheckin(Utils.CheckIn.ToJson(CheckIn));
#endif
var new_result = Get(FinalSerializedData);
#if (DEFAULT_PSK || DEFAULT_EKE)
string last_result = Crypto.Decrypt(new_result);
#endif
#if DEFAULT
Utils.CheckInResponse CheckInResponse = Utils.CheckInResponse.FromJson(new_result);
#elif (DEFAULT_PSK || DEFAULT_EKE)
Utils.CheckInResponse CheckInResponse = Utils.CheckInResponse.FromJson(last_result);
#endif
Config.UUID = CheckInResponse.id;
if (CheckInResponse.status == "success")
{
return true;
}
else
{
return false;
}
}
catch
{
return false;
}
}
19
View Source File : Modules.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : airzero24
License : BSD 3-Clause "New" or "Revised" License
Project Creator : airzero24
public static bool SetConfig(string arg)
{
string[] args = arg.Split();
try
{
switch (args[0].ToString())
{
case "domain":
if(args[1] == "add")
{
Utils.Server server = new Utils.Server
{
domain = args[2],
count = 0
};
Config.Servers.Add(server);
break;
}
else if (args[1] == "remove")
{
if (Config.Servers.Count == 1)
{
break;
}
else
{
foreach (Utils.Server server in Config.Servers)
{
if (server.domain == args[2])
{
Config.Servers.Remove(server);
}
}
break;
}
}
else
{
break;
}
case "sleep":
Config.Sleep = int.Parse(args[1]);
break;
case "jitter":
Config.Jitter = int.Parse(args[1]);
break;
case "kill_date":
Config.KillDate = args[1];
break;
case "host_header":
Config.HostHeader = args[1];
break;
case "user_agent":
string ua = string.Join(" ", args);
Config.UserAgent = ua.Substring(11);
break;
case "param":
Config.Param = args[1];
break;
case "proxy":
switch (args[1])
{
case "use_default":
if (args[2].ToLower() == "false")
{
Config.DefaultProxy = false;
}
else
{
Config.DefaultProxy = true;
}
break;
case "address":
Config.ProxyAddress = args[2];
break;
case "username":
Config.ProxyUser = args[2];
break;
case "preplacedword":
Config.ProxyPreplacedword = args[2];
break;
default:
return false;
}
break;
default:
return false;
}
return true;
}
catch
{
return false;
}
}
19
View Source File : EmailAttachMultipleDocuments.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
protected override void Execute(CodeActivityContext context)
{
this.AttachmentCount.Set(context, 0);
int max = this.MaxAttachments.Get(context);
if (max > 20 || max < 1)
{
max = 20;
}
List<Enreplacedy> notes = base.RetrieveAnnotationEnreplacedy(context, new Microsoft.Xrm.Sdk.Query.ColumnSet("filename", "mimetype", "doreplacedentbody"), max);
var potentialAttachments = notes.Select(note => new
{
FileName = note["filename"].ToString(),
MimeType = note["mimetype"],
DoreplacedentBody = note["doreplacedentbody"]
}).ToList();
if (!String.IsNullOrWhiteSpace(this.FileNameCantHave.Get(context)))
{
List<string> portions = this.FileNameCantHave.Get(context).ToLower().Split('|').ToList();
portions.ForEach(p => potentialAttachments.RemoveAll(pa => pa.FileName.ToLower().Contains(p)));
}
if (potentialAttachments.Any())
{
IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.InitiatingUserId);
foreach (var a in potentialAttachments)
{
Enreplacedy attachment = new Enreplacedy("activitymimeattachment");
attachment["objectid"] = new EnreplacedyReference("email", this.Email.Get(context).Id);
attachment["objecttypecode"] = "email";
attachment["filename"] = a.FileName.ToString();
attachment["mimetype"] = a.MimeType;
attachment["body"] = a.DoreplacedentBody;
service.Create(attachment);
}
this.AttachmentCount.Set(context, potentialAttachments.Count());
}
}
19
View Source File : ActionMods.cs
License : MIT License
Project Creator : AlbertMN
License : MIT License
Project Creator : AlbertMN
private static string GetPythonPath(string requiredVersion = "", string maxVersion = "") {
string[] possiblePythonLocations = new string[3] {
@"HKLM\SOFTWARE\Python\PythonCore\",
@"HKCU\SOFTWARE\Python\PythonCore\",
@"HKLM\SOFTWARE\Wow6432Node\Python\PythonCore\"
};
//Version number, install path
Dictionary<string, string> pythonLocations = new Dictionary<string, string>();
foreach (string possibleLocation in possiblePythonLocations) {
string regKey = possibleLocation.Substring(0, 4), actualPath = possibleLocation.Substring(5);
RegistryKey theKey = (regKey == "HKLM" ? Registry.LocalMachine : Registry.CurrentUser);
RegistryKey theValue = theKey.OpenSubKey(actualPath);
foreach (var v in theValue.GetSubKeyNames()) {
RegistryKey productKey = theValue.OpenSubKey(v);
if (productKey != null) {
try {
string pythonExePath = productKey.OpenSubKey("InstallPath").GetValue("ExecutablePath").ToString();
if (pythonExePath != null && pythonExePath != "") {
//Console.WriteLine("Got python version; " + v + " at path; " + pythonExePath);
pythonLocations.Add(v.ToString(), pythonExePath);
}
} catch {
//Install path doesn't exist
}
}
}
}
if (pythonLocations.Count > 0) {
System.Version desiredVersion = new System.Version(requiredVersion == "" ? "0.0.1" : requiredVersion),
maxPVersion = new System.Version(maxVersion == "" ? "999.999.999" : maxVersion);
string highestVersion = "", highestVersionPath = "";
foreach (KeyValuePair<string, string> pVersion in pythonLocations) {
//TODO; if on 64-bit machine, prefer the 64 bit version over 32 and vice versa
int index = pVersion.Key.IndexOf("-"); //For x-32 and x-64 in version numbers
string formattedVersion = index > 0 ? pVersion.Key.Substring(0, index) : pVersion.Key;
System.Version thisVersion = new System.Version(formattedVersion);
int comparison = desiredVersion.CompareTo(thisVersion),
maxComparison = maxPVersion.CompareTo(thisVersion);
if (comparison <= 0) {
//Version is greater or equal
if (maxComparison >= 0) {
desiredVersion = thisVersion;
highestVersion = pVersion.Key;
highestVersionPath = pVersion.Value;
} else {
//Console.WriteLine("Version is too high; " + maxComparison.ToString());
}
} else {
//Console.WriteLine("Version (" + pVersion.Key + ") is not within the spectrum.");
}
}
return highestVersionPath;
}
return "";
}
19
View Source File : DependencyChecker.cs
License : GNU General Public License v3.0
Project Creator : Albo1125
License : GNU General Public License v3.0
Project Creator : Albo1125
private static bool CheckForRageVersion(float MinimumVersion)
{
string RPHFile = "RAGEPluginHook.exe";
string[] files = Directory.GetFiles(Path.GetDirectoryName(replacedembly.GetExecutingreplacedembly().Location), "*.exe", SearchOption.TopDirectoryOnly);
foreach (string file in files)
{
if (Path.GetFileName(file).ToLower() == "ragepluginhook.exe")
{
RPHFile = file;
break;
}
}
var versionInfo = FileVersionInfo.GetVersionInfo(RPHFile);
float Rageversion;
try
{
Rageversion = float.Parse(versionInfo.ProductVersion.Substring(0, 4), CultureInfo.InvariantCulture);
Game.LogTrivial("Albo1125.Common detected RAGEPluginHook version: " + Rageversion.ToString());
//If user's RPH version is older than the minimum
if (Rageversion < MinimumVersion)
{
CorrectRPHVersion = false;
}
//If user's RPH version is (above) the specified minimum
else
{
CorrectRPHVersion = true;
}
}
catch (Exception e)
{
//If for whatever reason the version couldn't be found.
Game.LogTrivial(e.ToString());
Game.LogTrivial("Unable to detect your Rage installation.");
if (File.Exists("RAGEPluginHook.exe"))
{
Game.LogTrivial("RAGEPluginHook.exe exists");
}
else { Game.LogTrivial("RAGEPluginHook doesn't exist."); }
Game.LogTrivial("Rage Version: " + versionInfo.ProductVersion.ToString());
Game.DisplayNotification("Albo1125.Common was unable to detect RPH installation. Please send me your logfile.");
CorrectRPHVersion = false;
}
return CorrectRPHVersion;
}
19
View Source File : MainProgram.cs
License : MIT License
Project Creator : AlbertMN
License : MIT License
Project Creator : AlbertMN
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[STAThread]
static void Main(string[] args) {
Console.WriteLine("Log location; " + logFilePath);
CheckSettings();
var config = new NLog.Config.LoggingConfiguration();
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = logFilePath };
var logconsole = new NLog.Targets.ConsoleTarget("logconsole");
config.AddRule(LogLevel.Info, LogLevel.Fatal, logconsole);
config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);
NLog.LogManager.Configuration = config;
void ActualMain() {
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
//Upgrade settings
if (Properties.Settings.Default.UpdateSettings) {
/* Copy old setting-files in case the Evidence type and Evidence Hash has changed (which it does sometimes) - easier than creating a whole new settings system */
try {
Configuration accConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
string currentFolder = new DirectoryInfo(accConfiguration.FilePath).Parent.Parent.FullName;
string[] directories = Directory.GetDirectories(new DirectoryInfo(currentFolder).Parent.FullName);
foreach (string dir in directories) {
if (dir != currentFolder.ToString()) {
var directoriesInDir = Directory.GetDirectories(dir);
foreach (string childDir in directoriesInDir) {
string checkPath = Path.Combine(currentFolder, Path.GetFileName(childDir));
if (!Directory.Exists(checkPath)) {
string checkFile = Path.Combine(childDir, "user.config");
if (File.Exists(checkFile)) {
bool xmlHasError = false;
try {
XmlDoreplacedent xml = new XmlDoreplacedent();
xml.Load(checkFile);
xml.Validate(null);
} catch {
xmlHasError = true;
DoDebug("XML doreplacedent validation failed (is invalid): " + checkFile);
}
if (!xmlHasError) {
Directory.CreateDirectory(checkPath);
File.Copy(checkFile, Path.Combine(checkPath, "user.config"), true);
}
}
}
}
}
}
} catch (Exception e) {
Console.WriteLine("Error getting settings from older versions of ACC; " + e.Message);
}
/* End "copy settings" */
try {
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UpdateSettings = false;
Properties.Settings.Default.Save();
} catch {
DoDebug("Failed to upgrade from old settings file.");
}
Console.WriteLine("Upgraded settings to match last version");
}
if (Properties.Settings.Default.LastUpdated == DateTime.MinValue) {
Properties.Settings.Default.LastUpdated = DateTime.Now;
}
//Create action mod path
if (!Directory.Exists(actionModsPath)) {
Directory.CreateDirectory(actionModsPath);
}
//Translator
string tempDir = Path.Combine(currentLocation, "Translations");
if (Directory.Exists(tempDir)) {
Translator.translationFolder = Path.Combine(currentLocation, "Translations");
Translator.languagesArray = Translator.GetLanguages();
} else {
MessageBox.Show("Missing the translations folder. Reinstall the software to fix this issue.", messageBoxreplacedle);
}
string lang = Properties.Settings.Default.ActiveLanguage;
if (Array.Exists(Translator.languagesArray, element => element == lang)) {
DoDebug("ACC running with language \"" + lang + "\"");
Translator.SetLanguage(lang);
} else {
DoDebug("Invalid language chosen (" + lang + ")");
Properties.Settings.Default.ActiveLanguage = "English";
Translator.SetLanguage("English");
}
//End translator
sysIcon = new SysTrayIcon();
Properties.Settings.Default.TimesOpened += 1;
Properties.Settings.Default.Save();
SetupDataFolder();
if (File.Exists(logFilePath)) {
try {
File.WriteAllText(logFilePath, string.Empty);
} catch {
// Don't let this being DENIED crash the software
Console.WriteLine("Failed to empty the log");
}
} else {
Console.WriteLine("Trying to create log");
CreateLogFile();
}
//Check if software already runs, if so kill this instance
var otherACCs = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(currentLocationFull));
if (otherACCs.Length > 1) {
//Try kill the _other_ process instead
foreach (Process p in otherACCs) {
if (p.Id != Process.GetCurrentProcess().Id) {
try {
p.Kill();
DoDebug("Other ACC instance was running. Killed it.");
} catch {
DoDebug("Could not kill other process of ACC; access denied");
}
}
}
}
Application.EnableVisualStyles();
DoDebug("[ACC begun (v" + softwareVersion + ")]");
if (Properties.Settings.Default.CheckForUpdates) {
if (HasInternet()) {
new Thread(() => {
new SoftwareUpdater().Check();
}).Start();
} else {
DoDebug("Couldn't check for new update as PC does not have access to the internet");
}
}
//On console close: hide NotifyIcon
Application.ApplicationExit += new EventHandler(OnApplicationExit);
handler = new ConsoleEventDelegate(ConsoleEventCallback);
SetConsoleCtrlHandler(handler, true);
//Create shortcut folder if doesn't exist
if (!Directory.Exists(shortcutLocation)) {
Directory.CreateDirectory(shortcutLocation);
}
if (!File.Exists(Path.Combine(shortcutLocation, @"example.txt"))) {
//Create example-file
try {
using (StreamWriter sw = File.CreateText(Path.Combine(shortcutLocation, @"example.txt"))) {
sw.WriteLine("This is an example file.");
sw.WriteLine("If you haven't already, make your replacedistant open this file!");
}
} catch {
DoDebug("Could not create or write to example file");
}
}
//Delete all old action files
if (Directory.Exists(CheckPath())) {
DoDebug("Deleting all files in action folder");
foreach (string file in Directory.GetFiles(CheckPath(), "*." + Properties.Settings.Default.ActionFileExtension)) {
int timeout = 0;
if (File.Exists(file)) {
while (ActionChecker.FileInUse(file) && timeout < 5) {
timeout++;
Thread.Sleep(500);
}
if (timeout >= 5) {
DoDebug("Failed to delete file at " + file + " as file appears to be in use (and has been for 2.5 seconds)");
} else {
try {
File.Delete(file);
} catch (Exception e) {
DoDebug("Failed to delete file at " + file + "; " + e.Message);
}
}
}
}
DoDebug("Old action files removed - moving on...");
}
//SetupListener();
watcher = new FileSystemWatcher() {
Path = CheckPath(),
NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName,
Filter = "*." + Properties.Settings.Default.ActionFileExtension,
EnableRaisingEvents = true
};
watcher.Changed += new FileSystemEventHandler(new ActionChecker().FileFound);
watcher.Created += new FileSystemEventHandler(new ActionChecker().FileFound);
watcher.Renamed += new RenamedEventHandler(new ActionChecker().FileFound);
watcher.Deleted += new FileSystemEventHandler(new ActionChecker().FileFound);
watcher.Error += delegate { DoDebug("Something wen't wrong"); };
DoDebug("\n[" + messageBoxreplacedle + "] Initiated. \nListening in: \"" + CheckPath() + "\" for \"." + Properties.Settings.Default.ActionFileExtension + "\" extensions");
sysIcon.TrayIcon.Icon = Properties.Resources.ACC_icon_light;
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software", true);
if (Registry.GetValue(key.Name + @"\replacedistantComputerControl", "FirstTime", null) == null) {
SetStartup(true);
key.CreateSubKey("replacedistantComputerControl");
key = key.OpenSubKey("replacedistantComputerControl", true);
key.SetValue("FirstTime", false);
ShowGettingStarted();
DoDebug("Starting setup guide (first time opening ACC - wuhu!)");
} else {
if (!Properties.Settings.Default.HasCompletedTutorial) {
ShowGettingStarted();
DoDebug("Didn't finish setup guide last time, opening again");
}
}
SetRegKey("ActionFolder", CheckPath());
SetRegKey("ActionExtension", Properties.Settings.Default.ActionFileExtension);
testActionWindow = new TestActionWindow();
//If newly updated
if (Properties.Settings.Default.LastKnownVersion != softwareVersion) {
//Up(or down)-grade, display version notes
DoDebug("ACC has been updated");
if (Properties.Settings.Default.LastKnownVersion != "" && new System.Version(Properties.Settings.Default.LastKnownVersion) < new System.Version("1.4.3")) {
//Had issues before; fixed now
DoDebug("Upgraded to 1.4.3, fixed startup - now starting with Windows");
try {
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rk.DeleteValue(appName, false);
} catch {
DoDebug("Failed to remove old start with win run");
}
SetStartup(true);
} else {
if (ACCStartsWithWindows()) {
SetStartup(true);
}
}
Properties.Settings.Default.LastUpdated = DateTime.Now;
if (gettingStarted != null) {
DoDebug("'AboutVersion' window awaits, as 'Getting Started' is showing");
aboutVersionAwaiting = true;
} else {
Properties.Settings.Default.LastKnownVersion = softwareVersion;
new NewVersion().Show();
}
Properties.Settings.Default.Save();
}
//Check if software starts with Windows
if (!ACCStartsWithWindows())
sysIcon.AddOpenOnStartupMenu();
/* 'Evalufied' user feedback implementation */
if ((DateTime.Now - Properties.Settings.Default.LastUpdated).TotalDays >= 7 && Properties.Settings.Default.TimesOpened >= 7
&& gettingStarted == null
&& !Properties.Settings.Default.HasPromptedFeedback) {
//User has had the software/update for at least 7 days, and has opened the software more than 7 times - time to ask for feedback
//(also the "getting started" window is not showing)
if (HasInternet()) {
try {
WebRequest request = WebRequest.Create("https://evalufied.dk/");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response == null || response.StatusCode != HttpStatusCode.OK) {
DoDebug("'Evalufied' is down - won't show faulty feedback window");
} else {
DoDebug("Showing 'User Feedback' window");
Properties.Settings.Default.HasPromptedFeedback = true;
Properties.Settings.Default.Save();
new UserFeedback().Show();
}
} catch {
DoDebug("Failed to check for 'Evalufied'-availability");
}
} else {
DoDebug("No internet connection, not showing user feedback window");
}
}
//Action mods implementation
ActionMods.CheckMods();
TaskSchedulerSetup();
hreplacedtarted = true;
SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch); //On wake up from sleep
Application.Run();
}
if (sentryToken != "super_secret") {
//Tracking issues with Sentry.IO - not forked from GitHub (official version)
bool sentryOK = false;
try {
if (Properties.Settings.Default.UID != "") {
Properties.Settings.Default.UID = Guid.NewGuid().ToString();
Properties.Settings.Default.Save();
}
if (Properties.Settings.Default.UID != "") {
SentrySdk.ConfigureScope(scope => {
scope.User = new Sentry.Protocol.User {
Id = Properties.Settings.Default.UID
};
});
}
using (SentrySdk.Init(sentryToken)) {
sentryOK = true;
}
} catch {
//Sentry failed. Error sentry's side or invalid key - don't let this stop the app from running
DoDebug("Sentry initiation failed");
ActualMain();
}
if (sentryOK) {
try {
using (SentrySdk.Init(sentryToken)) {
DoDebug("Sentry initiated");
ActualMain();
}
} catch {
ActualMain();
}
}
} else {
//Code is (most likely) forked - skip issue tracking
ActualMain();
}
}
19
View Source File : ScopedStyle.cs
License : GNU General Public License v3.0
Project Creator : alexandrereyes
License : GNU General Public License v3.0
Project Creator : alexandrereyes
public string CssClreplacedesMixed(string nonScopedCssClreplacedes, params string[] scopedCssClreplacedes)
{
var cssClreplaced = new List<string>();
if (!string.IsNullOrWhiteSpace(nonScopedCssClreplacedes))
cssClreplaced.Add(nonScopedCssClreplacedes.Trim());
cssClreplaced.AddRange(
scopedCssClreplacedes
.Where(w => !string.IsNullOrWhiteSpace(w))
.Select(c => $"{c.Trim()}{Configuration.CssSelectorToReplace}".Replace(Configuration.CssSelectorToReplace, Id.ToString()))
);
return cssClreplaced.Aggregate((a, b) => $"{a} {b}");
}
19
View Source File : State.cs
License : GNU General Public License v3.0
Project Creator : alexandrereyes
License : GNU General Public License v3.0
Project Creator : alexandrereyes
internal async Task<bool> InitializeComponent(ScopedStyle component, string embeddedCssPath, ComponentBase parent)
{
if (component.ReuseCss && component.Parent != null)
{
if (_renderedStyles.ContainsKey(component.Id))
return false;
}
if (!_cssBag.Styles.TryGetValue(embeddedCssPath, out string css))
{
if (parent != null)
embeddedCssPath = $"{parent.GetType().Namespace}.{embeddedCssPath}";
if (!_cssBag.Styles.TryGetValue(embeddedCssPath, out css))
{
throw new ArgumentException($"Embedded css path {embeddedCssPath} not found. Did you set the build action of the file as EmbeddedResource on Visual Studio?");
}
}
_renderedStyles.Add(component.Id, css);
await _jsInterop.InnerHTML(
_configuration.StyleHtmlTagName,
_renderedStyles
.Select(s => s.Value.Replace(_configuration.CssSelectorToReplace, s.Key.ToString()))
.Aggregate((a, b) => $"{a} {b}")
);
return true;
}
19
View Source File : USPSBaseProvider.cs
License : MIT License
Project Creator : alexeybusygin
License : MIT License
Project Creator : alexeybusygin
protected void ParseErrors(XElement response)
{
if (response?.Descendants("Error")?.Any() ?? false)
{
var errors = response
.Descendants("Error")
.Select(item => new Error()
{
Description = item.Element("Description")?.Value?.ToString(),
Source = item.Element("Source")?.Value?.ToString(),
HelpContext = item.Element("HelpContext")?.Value?.ToString(),
HelpFile = item.Element("HelpFile")?.Value?.ToString(),
Number = item.Element("Number")?.Value?.ToString()
});
foreach (var err in errors)
{
AddError(err);
}
}
}
19
View Source File : DelegateType.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
protected internal override void Serialize(XmlElement node)
{
base.Serialize(node);
XmlElement returnTypeNode = node.OwnerDoreplacedent.CreateElement("ReturnType");
returnTypeNode.InnerText = ReturnType.ToString();
node.AppendChild(returnTypeNode);
foreach (Parameter parameter in argumentList)
{
XmlElement paramNode = node.OwnerDoreplacedent.CreateElement("Param");
paramNode.InnerText = parameter.ToString();
node.AppendChild(paramNode);
}
}
19
View Source File : AssociationRelationship.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
protected internal override void Serialize(XmlElement node)
{
base.Serialize(node);
XmlElement directionNode = node.OwnerDoreplacedent.CreateElement("Direction");
directionNode.InnerText = Direction.ToString();
node.AppendChild(directionNode);
XmlElement aggregationNode = node.OwnerDoreplacedent.CreateElement("replacedociationType");
aggregationNode.InnerText = replacedociationType.ToString();
node.AppendChild(aggregationNode);
if (StartRole != null)
{
XmlElement roleNode = node.OwnerDoreplacedent.CreateElement("StartRole");
roleNode.InnerText = StartRole.ToString();
node.AppendChild(roleNode);
}
if (EndRole != null)
{
XmlElement roleNode = node.OwnerDoreplacedent.CreateElement("EndRole");
roleNode.InnerText = EndRole.ToString();
node.AppendChild(roleNode);
}
if (StartMultiplicity != null)
{
XmlElement multiplicityNode = node.OwnerDoreplacedent.CreateElement("StartMultiplicity");
multiplicityNode.InnerText = StartMultiplicity.ToString();
node.AppendChild(multiplicityNode);
}
if (EndMultiplicity != null)
{
XmlElement multiplicityNode = node.OwnerDoreplacedent.CreateElement("EndMultiplicity");
multiplicityNode.InnerText = EndMultiplicity.ToString();
node.AppendChild(multiplicityNode);
}
}
19
View Source File : Relationship.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
protected internal virtual void Serialize(XmlElement node)
{
if (node == null)
throw new ArgumentNullException("node");
if (SupportsLabel && Label != null)
{
XmlElement labelNode = node.OwnerDoreplacedent.CreateElement("Label");
labelNode.InnerText = Label.ToString();
node.AppendChild(labelNode);
}
OnSerializing(new SerializeEventArgs(node));
}
See More Examples