//Module ho tro private static projObject setParam(string code, string name, string po, string member, int ticket, string path) { projObject finalObject = new projObject(); List <Scan> scanList = new List <Scan>(); Scan scanDetail = new Scan(); scanDetail.resultItems = scanASP(path); scanDetail.scantime = DateTime.Now; scanDetail.No = 1; scanDetail.total = scanDetail.resultItems.Count; scanList.Add(scanDetail); List <String> lmember = new List <string>(); List <int> lticket = new List <int>(); lmember.Add(member); lticket.Add(ticket); finalObject.scans = scanList; finalObject.projectCode = code; finalObject.projectMember = lmember; finalObject.projectName = name; finalObject.projectOwner = po; finalObject.ticket = lticket; return(finalObject); }
static void Main(string[] args) { string code = ""; string name = ""; string po = ""; string member = ""; int ticket = 0; //C:\Users\dbui\Desktop\FashionShop2.0\FashionShop2.0.sln //string solutionPath = @"E:\Project\FashionShop2.0\FashionShop2.0.sln"; if ((args.Length == 0) || (args[0] == "-h")) { printHelp(); } else { if ((Array.IndexOf(args, "-g") != -1) && (args.Length == 1)) { Console.WriteLine(retrieveData()); } else if (args.Length == 12) { //Full Command: SVACLI.exe -u PATH -c CODE -n NAME -p PO -m MEMBER -t TICKET projObject finalObject = setParam(args[3], args[5], args[7], args[9], Convert.ToInt32(args[11]), args[1]); sendObject(finalObject); printJsonObject(finalObject); } else if ((Array.IndexOf(args, "-u") != -1) && (args.Length == 2)) { //string a = @"C:\Users\dbui\Desktop\SVA2.0\SVACLI\SVACLI\FashionShop2.0"; //printSimplifiedResult(scanASP(args[1])); //printJsonObject(setParam(code, name, po, member, ticket, args[1])); //printSimplifiedResult(finalObject.scans[0].resultItems); //sendObject(setParam(code, name, po, member, ticket, args[1])); //printSimplifiedResult(finalObject.scans[0].resultItems); Console.ReadLine(); } else { printHelp(); } } }
private void Scan_Click(object sender, EventArgs e) { //System.Diagnostics.Process.Start("SVAgent.exe","-u C:"); ProcessStartInfo info = new ProcessStartInfo(); Process process = new Process(); info.UseShellExecute = false; info.RedirectStandardOutput = true; info.CreateNoWindow = true; info.FileName = Directory.GetCurrentDirectory() + @"\SVACLI.exe"; //info.WorkingDirectory = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), info.FileName); /* application name : cmd.exe*/ /* Copy command arguments*/ info.Arguments = @"-u " + proPath + @" -c " + code.Text + @" -n " + name.Text + @" -p " + po.Text + @" -m duyb" + @" -t 420420"; /* Following setting will hide the command line window.*/ info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //MessageBox.Show(info.FileName); //Process process..WorkingDirectory = Path.GetDirectoryName(application.Filename); process = Process.Start(info); //string result = process.StandardOutput.ToString(); //MessageBox.Show(result); String resultjson = ""; while (!process.StandardOutput.EndOfStream) { string line = process.StandardOutput.ReadLine(); resultjson = resultjson + line; //Console.WriteLine(line); //MessageBox.Show(line); } //MessageBox.Show(resultjson); //Console.WriteLine(resultjson); projObject resultObject = JsonConvert.DeserializeObject <projObject>(resultjson); List <ResultItem> itemObject = resultObject.scans[0].resultItems; var list = new BindingList <ResultItem>(itemObject); resultGrid.DataSource = list; //MessageBox.Show(resultObject.scans.ToString()); //Console.WriteLine(resultjson.scans); //MessageBox.Show(proPath); process.Close(); }
private static void sendObject(projObject objectResult) { string url = @"http://10.60.156.82:8080/api/projObjects"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); string jsonContent = JsonConvert.SerializeObject(objectResult, Formatting.Indented); //j = "{"item.identify + "|" + item.displayTxt + "|" + item.pathFile + "|" + item.lineNumber + "|" + item.result; //lines[i] = j; //Console.WriteLine(jsonContent); Byte[] byteArray = encoding.GetBytes(jsonContent); request.ContentLength = byteArray.Length; request.ContentType = @"application/json"; using (Stream dataStream = request.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); } long length = 0; try { using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { length = response.ContentLength; } } catch (WebException ex) { // Log exception and throw as for GET example above } byteArray = null; //Console.WriteLine(item.identify + "|" + item.displayTxt + "|" + item.pathFile + "|" + item.lineNumber + "|" + item.result); }
private static void printJsonObject(projObject objectResult) { string jsonContent = JsonConvert.SerializeObject(objectResult, Formatting.Indented); Console.WriteLine(jsonContent); }