123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using System;
- using System.Reflection;
- using System.Windows.Forms;
- using Newtonsoft.Json.Linq;
- namespace prBrowser
- {
- public class RemoteLoader : MarshalByRefObject
- {
- public string GetValue(string input)
- {
-
- JObject jObject = new JObject();
- string retstring = "";
- string directory = "";
- try
- {
- JObject jsonObj = JObject.Parse(input);
- string inputDir = "";
- string clsName = "";
- string funcName = "";
- string dllInput = "";
- if (jsonObj["inputDir"] != null)
- {
- inputDir = jsonObj["inputDir"]!.ToString();
- directory = inputDir.Replace("/", ".").Replace("\\", ".");
- string spcfolder = Application.StartupPath;
- spcfolder = spcfolder.Replace("\\", "/");
-
-
- if (inputDir.IndexOf("GetIP.dll") !=-1)
- {
- inputDir = "/GetIP.dll";
- }
- inputDir = spcfolder + inputDir;
- }
- if (jsonObj["clsName"] != null)
- {
- clsName = jsonObj["clsName"]!.ToString();
- }
- if (jsonObj["funcName"] != null)
- {
- funcName = jsonObj["funcName"]!.ToString();
- }
- if (jsonObj["dllInput"] != null)
- {
- dllInput = jsonObj["dllInput"]!.ToString();
- }
- object[] temParts = null;
- if (dllInput != "")
- {
- temParts = new object[1] { dllInput };
- }
- string path = inputDir;
- Assembly assem = Assembly.LoadFrom(path);
- Type clsType = assem.GetType(clsName);
- MethodInfo pMtInfo = clsType.GetMethod(funcName);
- object tObj = Activator.CreateInstance(clsType);
- retstring = (string)pMtInfo.Invoke(tObj, temParts);
- }
- catch (Exception ex)
- {
- jObject.Add("errorCode", (JToken)"-1");
- string Messageerr = ex.Message;
- if (ex.InnerException != null)
- { Messageerr = ex.InnerException.Message; }
- jObject.Add("errorMessage", (JToken)Messageerr);
- retstring = jObject.ToString();
- }
- return retstring;
- }
-
-
-
-
-
- private void CopyDir(string srcPath, string aimPath)
- {
- try
- {
-
- if (aimPath[aimPath.Length - 1] != System.IO.Path.DirectorySeparatorChar)
- {
- aimPath += System.IO.Path.DirectorySeparatorChar;
- }
-
- if (!System.IO.Directory.Exists(aimPath))
- {
- System.IO.Directory.CreateDirectory(aimPath);
- }
-
-
-
- string[] fileList = System.IO.Directory.GetFileSystemEntries(srcPath);
-
- foreach (string file in fileList)
- {
-
- if (System.IO.Directory.Exists(file))
- {
- CopyDir(file, aimPath + System.IO.Path.GetFileName(file));
- }
-
- else
- {
- System.IO.File.Copy(file, aimPath + System.IO.Path.GetFileName(file), true);
- }
- }
- }
- catch (Exception e)
- {
- throw;
- }
- }
- }
- }
|