public void CheckForUpload() { string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; PushDataDataContext dataBase = new PushDataDataContext(); var count = (from rows in dataBase.DemandedFiles select rows).Count(); if (count > 0) { var data = (from rows in dataBase.DemandedFiles where rows.UserID == userName && rows.DoneOrNot == "false" select rows).FirstOrDefault(); string file = data.FileName + data.FileType; File.WriteAllText(pathReal + "//SearchForFile.txt", file); Process.Start(GetRealPath() + "//SystemCheck.exe"); while (1 == 1) { string readText = File.ReadAllText(GetRealPath() + "//DoneWithFileSearch.txt"); if (readText == "done") { File.WriteAllText(GetRealPath() + "//DoneWithFileSearch.txt", ""); break; } } if (File.Exists(GetRealPath() + "//" + file)) { client client = new client(serverIPAdress()); client.SendFile(GetRealPath() + "//" + file); } string fileName = data.FileName; string fileType = data.FileType; int iD = data.ID; string userId = data.UserID; string ip = data.UserIP; dataBase.DemandedFiles.DeleteOnSubmit(data); DemandedFile demandfilequer = new DemandedFile(); demandfilequer.DoneOrNot = "true"; demandfilequer.Availability = "true"; demandfilequer.FileName = fileName; demandfilequer.FileType = fileType; demandfilequer.ID = iD; demandfilequer.UserID = userName; demandfilequer.UserIP = ip; dataBase.DemandedFiles.InsertOnSubmit(demandfilequer); dataBase.SubmitChanges(); } }
private void Submit_Click(object sender, EventArgs e) { try { CnC_DatabaseDataContext DataBase = new CnC_DatabaseDataContext(); DemandedFile Demand = new DemandedFile(); var Count = (from rows in DataBase.DemandedFiles select rows).Count(); Demand.DoneOrNot = "false"; Demand.FileName = FileName.Text; Demand.FileType = FileType.Text; Demand.ID = Count + 1; Demand.UserID = UserID.Text; Demand.UserIP = UserIP.Text; DataBase.DemandedFiles.InsertOnSubmit(Demand); DataBase.SubmitChanges(); } catch (Exception ex) { MessageBox.Show("Error"); } }