private static XDocument TalkOutIn(string requestPath, IPAddress serverIP) { XDocument resXml = null; using (Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { IPEndPoint epThere = new IPEndPoint(serverIP, port); try { IAsyncResult result = s.BeginConnect(epThere, null, null); bool success = result.AsyncWaitHandle.WaitOne(3000, true); if (s.Connected) { s.SendFile(requestPath); resXml = UR.ReceiveXML(s); s.Shutdown(SocketShutdown.Both); s.EndConnect(result); } else { throw new ApplicationException("Failed to connect server."); } } catch (Exception e) { MessageBox.Show("Can`t connect.\n" + e.Message); if (s.Connected) { s.Shutdown(SocketShutdown.Both); } } } return(resXml); }
void WorkerThread() { mustStop = false; IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, port); Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { listener.Bind(endPoint); listener.Listen(10); while (!mustStop) { using (Socket handler = listener.Accept()) { XDocument docReq = UR.ReceiveXML(handler); handler.SendFile(HandleRequest(docReq)); handler.Shutdown(SocketShutdown.Both); } } } catch (Exception e) { UR.WriteLog(e.ToString()); } }
public static List <Process> GetProcesses(string path) { List <Process> res = new List <Process>(); path = Regex.Replace(path, @"(?<!\\)\\(?!\\)", @"\\"); string query = "select Description, ExecutablePath, KernelModeTime from win32_process" + " WHERE ExecutablePath LIKE '" + path.Trim(' ') + "%'"; UR.WriteLog(query); ObjectQuery Q = new ObjectQuery(query); ManagementObjectSearcher sh = new ManagementObjectSearcher(scop, Q); try { ManagementObjectCollection col = sh.Get(); foreach (ManagementObject m in col) { res.Add(new Process(m["Description"].ToString(), m["ExecutablePath"].ToString(), uint.Parse(m["KernelModeTime"].ToString()))); } } catch (Exception e) { UR.WriteLog(e.Message); } return(res); }
public Profile(string nick) { InitializeComponent(); this.Nick = nick; pr = new PR(); ur = new UR(); }
/// <summary> /// Save ROM Changes /// </summary> public void Save() { UR.Do ( () => { /* * // UNFORTUNATELY, SERIALIZING ANONYMOUS LAMBDA EXPRESSIONS AIN'T OK * // I might have another idea though, TODO i guess * * FileStream s = File.Open("UR.bin", FileMode.OpenOrCreate); * BinaryFormatter b = new BinaryFormatter(); * b.Serialize(s, UR); * s.Close(); */ UR.RedoStack.Clear(); UR.BackupStack.Clear(); File.WriteAllBytes(ROMName + "_TEST.smc", ROM); }, () => { }, false ); }
public void Other() { RemindersTX.color = new Color32(26, 28, 46, 255); ImportantTX.color = new Color32(148, 148, 148, 255); UpcomingTX.color = new Color32(148, 148, 148, 255); foreach (GameObject IR in ImportantReminders) { if (IR.activeSelf == false) { IR.SetActive(true); } } foreach (GameObject UR in UpcomingReminders) { if (UR.activeSelf == false) { UR.SetActive(true); } } foreach (GameObject OR in OtherReminders) { if (OR.activeSelf == false) { OR.SetActive(true); } } }
public void Follow(string nick1, string nick2) { UR ur = new UR(); ur.AddFollowing(nick1, nick2); ur.AddFollower(nick2, nick1); }
// Macros /// <summary> /// overidden: Reads a byte /// /// Advances the position. /// </summary> /// <returns>the read byte</returns> public new byte ReadByte() { #if DEBUG || BINARYMETADATA LastPosition = Position; #endif return(UR.ReadByte()); }
public ucFindPerson(string nick) { InitializeComponent(); us = new US(); ur = new UR(); this.Nick = nick; }
public ucChangePass(string nick) { us = new US(); ur = new UR(); InitializeComponent(); this.Nick = nick; }
public ucEditProfile(string nick) { InitializeComponent(); FillComboBox(); uS = new US(); ur = new UR(); this.Nick = nick; }
public CommWindow(ObjectId id1, ObjectId id2, string nick, string nick2) { uR = new UR(); uS = new PR(); this.Nick = nick; this.Nick2 = nick2; InitializeComponent(); this.Id1 = id1; this.Id2 = id2; }
public ucMyData(string nick) { this.Nick = nick; InitializeComponent(); uR = new UR(); User user = new User(); user = uR.GetUserByNick(Nick); TB1.Text = user.person.Name; TB2.Text = user.person.Surname; TB3.Text = user.person.Mail; }
protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity <User>(d => d.HasKey(u => u.ID)); // Getting user by his ID modelBuilder.Entity <Details>(d => d.HasKey(i => i.ID)); // Getting details by ID at user with this ID modelBuilder.Entity <User>().HasOne(u => u.Details).WithOne(d => d.User).HasForeignKey <Details>(d => d.UserID).OnDelete(DeleteBehavior.Cascade); // Cascading delete data from DB modelBuilder.Entity <UserRole>(UR => { UR.HasKey(ur => new { ur.UserID, ur.RoleID }); // Finding this role by key UserRole + RoleID UR.HasOne(ur => ur.Role).WithMany(rl => rl.UserRoles).HasForeignKey(ur => ur.RoleID).IsRequired(); // Get Role from UserRoles by RoleID UR.HasOne(ur => ur.User).WithMany(rl => rl.UserRoles).HasForeignKey(ur => ur.UserID).IsRequired(); // Get User from UserRoles by UserID }); // This labmda to get user role :) }
static void Main(string[] args) { try { Console.Clear(); Console.ResetColor(); // If you have a license key, please put it here UR.RegisterLicense(licensee: null, key: null); Console.WriteLine(" _ _ _ _ ______ _ _ "); Console.WriteLine("| | | | (_) | | | ___ \\ | | | | "); Console.WriteLine("| | | |_ __ ___ _____ _ __ ___ __ _| | | |_/ /___ | |__ ___ | |_ ___ "); Console.WriteLine("| | | | '_ \\| \\ \\ / / _ \\ '__/ __|/ _` | | | // _ \\| '_ \\ / _ \\| __/ __| "); Console.WriteLine("| |_| | | | | |\\ V / __/ | \\__ \\ (_| | | | |\\ \\ (_) | |_) | (_) | |_\\__ \\ "); Console.WriteLine(" \\___/|_| |_|_| \\_/ \\___|_| |___/\\__,_|_| \\_| \\_\\___/|_.__/ \\___/ \\__|___/ "); Console.WriteLine(" _____ _ _____ _ "); Console.WriteLine("/ __ \\ | | | ___| | | "); Console.WriteLine("| / \\/ ___ _ __ ___ ___ | | ___ | |____ ____ _ _ __ ___ _ __ | | ___ "); Console.WriteLine("| | / _ \\| '_ \\/ __|/ _ \\| |/ _ \\ | __\\ \\/ / _` | '_ ` _ \\| '_ \\| |/ _ \\"); Console.WriteLine("| \\__/\\ (_) | | | \\__ \\ (_) | | __/ | |___> < (_| | | | | | | |_) | | __/"); Console.WriteLine(" \\____/\\___/|_| |_|___/\\___/|_|\\___| \\____/_/\\_\\__,_|_| |_| |_| .__/|_|\\___|"); Console.WriteLine(" | | "); Console.WriteLine(" |_| "); Console.WriteLine(); Console.WriteLine(UR.LicenseInfo.ToString()); Console.WriteLine(); Console.Write("Please enter robot IP or hostname : "); var ip = Console.ReadLine(); _ur = new UR(); _ur.CartesianInfoReceived += CartesianInfoReceived; _ur.Connect(ip); Console.WriteLine("Connecting..."); Console.ReadKey(); _ur.Disconnect(); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Message); Console.ReadKey(); } }
internal void DisposeBuffer() { if (UR != null) { UR.Dispose(); UR = null; } if (UW != null) { UW.Dispose(); UW = null; } // Closed by the above, but this is just for ensurance. Dispose(); }
/// <summary> /// Applies a Patch to the ROM using Asar /// </summary> /// <param name="patch">Path to Patch</param> /// <param name="caller"></param> public void Patch(string patch, [CallerMemberName] string caller = "") { UR.Do ( () => { Asar.Init(); Asar.Patch(patch, ref _ROM); Asar.Close(); }, () => { // oh god what do i even do here... }, caller == "Main" ); }
public SearchWindow(string nick, string nick2) { InitializeComponent(); PersonNickName = nick; PersonNickName2 = nick2; // repository = new UR(); services = new US(); postServices = new PS(); postRepository = new PR(); // user = new User(); user = repository.GetUserByNick(PersonNickName); UserName.Content = user.person.Name; UserSurname.Content = user.person.Surname; UserMail.Content = user.person.Mail; // currentPost = new Posts(); posts = new List <Posts>(); posts = postRepository.GetPostsByUserId(repository.GetUserId(PersonNickName)); if (posts != null && posts.Count > 0) { currentPost = posts[indexOfPost]; DG1.ItemsSource = currentPost.comment; isAnyPosts = true; } else { Main.Content = "No posts yet"; } // if (tempLike) { btnLike.Background = Brushes.Green; tempLike = true; } user = repository.GetUserByNick(PersonNickName2); if (services.CheckAlreadyFollow(user.Nick, PersonNickName)) { btnFollow.Background = Brushes.Green; } }
/// <summary> /// Writes HEX data to ROM /// </summary> /// <param name="HexStr">String of HEX characters, make sure its an even length</param> /// <param name="PcAddr">PC Address to start writing at</param> /// <param name="caller"></param> public void HexWrite(string HexStr, uint PcAddr, [CallerMemberName] string caller = "") { string UndoStr = ""; UR.Do ( () => { byte[] HexArr = Utils.Hex.HexStrToByteArr(HexStr); UndoStr += Utils.Hex.ByteArrToHexStr(ROM, HexStr.Length / 2, (int)PcAddr); HexArr.CopyTo(ROM, PcAddr); }, () => { HexWrite(UndoStr, PcAddr); }, caller == "Main" ); }
public static string TerminateProcess(Process p) { string res = String.Empty; string path = Regex.Replace(p.Path, @"(?<!\\)\\(?!\\)", @"\\"); string query = "select * from win32_process" + " WHERE Description ='" + p.Description + "' AND ExecutablePath = '" + path + "'"; UR.WriteLog(query); ObjectQuery Q = new ObjectQuery(query); ManagementObjectSearcher sherlok = new ManagementObjectSearcher(scop, Q); try { ManagementObjectCollection col = sherlok.Get(); foreach (ManagementObject m in col) { int reason = int.Parse(m.InvokeMethod("Terminate", null).ToString()); switch (reason) { case 0: res = "Succesfylly terminated " + p.Description; break; case 2: res = "Access denied"; break; case 3: res = "Insufficient privilege"; break; case 8: res = "Unknown failure"; break; case 9: res = "Path not found"; break; case 21: res = "Invalid parameter"; break; default: res = "Terminate failed with error code " + reason.ToString(); break; } } } catch (Exception e) { UR.WriteLog(e.Message); res = e.Message; } return(res); }
private static string HandleRequest(XDocument reqXml) { string answerPath = String.Empty; XDocument answer = new XDocument(); if (reqXml == null) { UR.WriteLog(String.Format("{0} - reqXml = null", DateTime.Now)); answer = new XDocument(new XElement("error", "Ya washe hz")); answerPath = localPath + UR.Res1; } else if (reqXml.Root.Name == "path") { reqXml.Save(localPath + UR.Req1); answerPath = localPath + UR.Res1; string path = reqXml.Element("path").IsEmpty ? "" : reqXml.Element("path").Value; List <Process> res = GetProcesses(path); answer = new XDocument(new XElement("processes")); if (res.Count > 0) { foreach (Process p in res) { answer.Element("processes").Add(p.ToXml()); } } } else if (reqXml.Root.Name == "process") { reqXml.Save(localPath + UR.Req2); answerPath = localPath + UR.Res2; Process proc = new Process(reqXml.Element("process")); answer = new XDocument(new XElement("mesg", TerminateProcess(proc))); } answer.Declaration = new XDeclaration("1.0", "utf-8", null); answer.Save(answerPath); return(answerPath); }
//public void DeleteAllByID(string id) //{ // UR ur = new UR(); // ur.Delete(id); // ur.FollowDelete(id); //} public bool CheckAlreadyFollow(string nickname, string usernickname) { UR ur = new UR(); User user = new User(); user = ur.GetUserByNick(nickname); if (user != null && user.Following != null) { foreach (var el in user.Following) { if (el == usernickname) { return(true); } } } else { return(false); } return(false); }
public UnsolResponse(string aiName, List <KeyValuePair <string, string> > aiData, TreeNode tn, SlaveTypes sType, int sNo) { string strRoutineName = "UnsolResponse"; try { slaveType = sType; slaveNo = sNo; try { ainType = (UR)Enum.Parse(typeof(UR), aiName); } catch (System.ArgumentException) { } if (aiData != null && aiData.Count > 0) //Parse n store values... { foreach (KeyValuePair <string, string> aikp in aiData) { try { if (this.GetType().GetProperty(aikp.Key) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(aikp.Key).SetValue(this, aikp.Value); } } catch (System.NullReferenceException) { } } } } catch (Exception ex) { MessageBox.Show(strRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public UnsolResponse(XmlNode aiNode, SlaveTypes sType, int sNo, bool imported) { string strRoutineName = "UnsolResponse"; try { slaveType = sType; slaveNo = sNo; if (aiNode.Attributes != null) { try { ainType = (UR)Enum.Parse(typeof(UR), aiNode.Name); } catch (System.ArgumentException) { } foreach (XmlAttribute item in aiNode.Attributes) { try { if (this.GetType().GetProperty(item.Name) != null) //Ajay: 03/07/2018 { this.GetType().GetProperty(item.Name).SetValue(this, item.Value); } } catch (System.NullReferenceException) { } } } } catch (Exception Ex) { MessageBox.Show(strRoutineName + ": " + "Error: " + Ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ucMyProfile(string nick) { this.Nick = nick; InitializeComponent(); uR = new UR(); pR = new PR(); Posts pr = new Posts(); User ur = new User(); ur = uR.GetUserByNick(Nick); List <string> List1 = new List <string>(); List <string> List2 = new List <string>(); List1 = ur.Followers; List2 = ur.Following; List <Posts> lis = new List <Posts>(); lis = pR.GetPostsByUserId(uR.GetUserId(Nick)); dataGridView1.ItemsSource = List1; dataGridView2.ItemsSource = List2; dataGridView3.ItemsSource = lis; }
/// <summary> /// Same as ReadIndex, just a placeholder for UE3 compatibly. /// </summary> /// <returns></returns> public int ReadObjectIndex() { return(UR.ReadIndex()); }
/// <summary> /// Reads a string with no known length, ends when the first \0 char is reached. /// /// Advances the position. /// </summary> /// <returns>the read string</returns> public string ReadASCIIString() { return(UR.ReadAnsi()); }
/// <summary> /// Reads a Signed Integer of 64bits /// /// Advances the position. /// </summary> /// <returns>the read long</returns> public long ReadInt64() { return(UR.ReadInt64()); }
/// <summary> /// Reads a Name/String with no known size, expecting that the next bytes are the size of the string. /// /// Advances the position. /// </summary> /// <returns>the read string without the end \0 char</returns> public string ReadText() { return(UR.ReadText()); }
/// <summary> /// Reads a Signed Integer of 32bits /// /// Advances the position. /// </summary> /// <returns>the read int</returns> public int ReadInt32() { return(UR.ReadInt32()); }