public static List <MiMFa_XMLElement> GetTo(List <MiMFa_XMLElement> inThisList, MiMFa_XMLElement toThisElement) { int ind = -1; for (int i = 0; i < inThisList.Count; i++) { if (inThisList[i] <= toThisElement) { ind = i; } else { break; } } if (ind < 0) { return(new List <MiMFa_XMLElement>()); } if (inThisList.Last() < toThisElement) { return(inThisList); } inThisList[ind].Children = GetTo(inThisList[ind].Children, toThisElement); return(MiMFa_CollectionService.GetPart(inThisList, 0, ind)); }
public static List <MiMFa_XMLElement> GetFrom(List <MiMFa_XMLElement> inThisList, MiMFa_XMLElement fromThisElement) { int ind = -1; for (int i = 0; i < inThisList.Count; i++) { if (inThisList[i] <= fromThisElement) { ind = i; } else { break; } } if (ind < 0) { return(inThisList); } MiMFa_XMLElement m = inThisList.Last(); if (!fromThisElement.ID.StartsWith(m.ID) && m < fromThisElement) { return(new List <MiMFa_XMLElement>()); } inThisList[ind].Children = GetFrom(inThisList[ind].Children, fromThisElement); return(MiMFa_CollectionService.GetPart(inThisList, ind)); }
public void ShowReport(Report report, MiMFa_SidePosition side = MiMFa_SidePosition.Null, int length = -1, bool withCompile = true) { if (ProgressBar != null) { ProgressBar.ProcessRun(1); } if (report.ObjectArray != null && report.ObjectArray.Length > 0) { if (length <= 0) { if (!int.TryParse(tscb_NumberOFRecord.Text.ToString(), out length)) { if (ProgressBar != null) { ProgressBar.ProcessRun(100); } return; } } CurrentReport = new Report(report); switch (side) { case MiMFa_SidePosition.Right: FromRecord = ToRecord + 1; break; case MiMFa_SidePosition.Left: FromRecord = FromRecord - length; break; default: break; } ToRecord = FromRecord + length - 1; if (FromRecord <= 0) { FromRecord = 0; tsb_PageDown.Enabled = false; } else { tsb_PageDown.Enabled = true; } if (ToRecord >= report.ObjectArray.Length || ToRecord < FromRecord) { ToRecord = report.ObjectArray.Length - 1; tsb_PageUp.Enabled = false; } else { tsb_PageUp.Enabled = true; } CurrentReport.ObjectArray = MiMFa_CollectionService.GetPart(CurrentReport.ObjectArray, FromRecord, ToRecord); Show(CurrentReport, withCompile); return; } Show(report, withCompile); }
public void ReceiveCallback(IAsyncResult ar) { try { //Socket handler; StartReceiveData(ar.AsyncState, Handler.RemoteEndPoint as IPEndPoint, 0); // Fetch a user-defined object that contains information // Received byte array byte[] data = (byte[])ar.AsyncState; // A Socket to handle remote host communication. // The number of bytes received. int bytesRead = Handler.EndReceive(ar); if (bytesRead > 0) { EndReceiveData(MiMFa_CollectionService.GetPart(data, 0, bytesRead - 1), Handler.RemoteEndPoint as IPEndPoint, bytesRead); } } catch (Exception ex) { ErrorReceiveData(ar, InterlocutorIPEndPoint, 0, ex); } }
public void Receive() { try { byte[] buffer = new byte[BufferSize]; // Receives data from a bound Socket. //int bytesRec = SenderSock.Receive(buffer); // Continues to read the data till data isn't available while (SenderSock.Available > 0) { int bytesRec = SenderSock.Receive(buffer); if (bytesRec > 0) { ReceiveCallBackData(MiMFa_CollectionService.GetPart(buffer, 0, bytesRec - 1), InterlocutorIPEndPoint, bytesRec); } } } catch (Exception ex) { ErrorReceiveCallBackData(SenderSock, InterlocutorIPEndPoint, 0, ex); } }
public override object EXECUTE(params object[] po) { if (po == null) { throw new System.Exception("This command must be have inputs!"); } if (_executecode) { string code = po[0].ToString(); string namespacename = "MRL"; string classname = "Program"; string functionname = "Main"; bool isstatic = true; object[] args = null; try { namespacename = po[1].ToString();; classname = po[2].ToString();; functionname = po[3].ToString(); isstatic = Convert.ToBoolean(po[4]); args = MiMFa_CollectionService.GetPart(po, 5); } catch { } executecode(code, namespacename, classname, functionname, isstatic, args); } else { string code = po[0].ToString(); string address = "out.exe"; if (po.Length > 1) { address = po[1].ToString().Trim(); } return(provide(code, address)); } return(Null); }
private bool Start(params object[] po) { timer.Enabled = !_stop; if (_new || ipaddress == null || reciever == null || sender == null) { if (_password) { string[] stra = po[0].ToString().Split(','); setpassword("", stra.Last().Trim()); if (stra.Length > 1) { po[0] = MiMFa_CollectionService.GetAllItems(MiMFa_CollectionService.GetPart(stra, 0, stra.Length - 1), ",", 0); } else { po[0] = ""; } } ipaddress = IPAddress.Any; if (_all) { ipaddress = IPAddress.Any; } else { try { ipaddress = IPAddress.Parse(MCL.Parse(po[0] + "")); } catch { } } reciever = new MiMFa_Receiver(); sender = new MiMFa_Sender(); sender.Port = reciever.Port = port; sender.BufferSize = reciever.BufferSize = buffer; reciever.EndReceiveData += (b, ip, i) => { object o = MiMFa_IOService.Deserialize(b); if (string.IsNullOrEmpty(password)) { content = o; } else if (!MiMFa_CollectionService.ExistIn(remotedic, ip.Address)) { remotedic.Add(ip.Address, crypt.GetHashString(o.ToString())); } else if (remotedic[ip.Address] == password) { content = o; } else { remotedic[ip.Address] = crypt.GetHashString(o.ToString()); } }; reciever.SendCallBackData += (o, ip, i) => { contentcallback = o; }; reciever.Start(ipaddress); if (ipaddress != IPAddress.Any) { sender.InterlocutorIP = ipaddress; } return(false); } if (ipaddress != IPAddress.Any) { sender.InterlocutorIP = ipaddress; } else if (sender.InterlocutorIP == null || _ip || i) { try { string[] stra = po[0].ToString().Split(','); ipaddress = sender.InterlocutorIP = IPAddress.Parse(stra.First().Trim()); if (stra.Length > 1) { po[0] = MiMFa_CollectionService.GetAllItems(stra, ",", 1); } else { po[0] = ""; } } catch { } } sender.Port = reciever.Port = port; sender.BufferSize = reciever.BufferSize = buffer; sender.Run = reciever.Run = !_stop; return(true); }
public virtual object run(object[] po) { List <string> ls = new List <string>(); object obj = null; if (_args) { processrun(po[0].ToString().Trim(), MiMFa_CollectionService.GetAllItems(MiMFa_CollectionService.GetPart(po, 1))); } else { foreach (var item in po) { try { obj = processrun(item.ToString().Trim()); ls.Add(obj.ToString()); } catch (System.Exception ex) { if (_error) { ls.Add(ex.Message); } } } } if (_print) { return(echo(ls.ToArray())); } else { return(Null); } }