computer
New member
- Joined
- Jul 1, 2016
- Messages
- 1
- Programming Experience
- Beginner
I try to create app . scenario is i have a folder in that folder there is some files so every file is taking update in every 15 mint check image
in image currenlt there is 3 files so every file update in every 5 seconds when this fully update then next file is create so i want when there is no update in file in every 5 seconds then i want to insert data in table otherwise not
i try this
public static void Main()
{
while (true)
{
try
{
string abcPath, defPath = "";
abcPath= ConfigurationManager.AppSettings.Get("abcPath");
defPath = ConfigurationManager.AppSettings.Get("defPath");
DateTime abc = File.GetLastAccessTime(abcPath);
DateTime def = File.GetLastAccessTime(defPath);
Console.WriteLine("the last access time for abc{0}", abc);
Console.WriteLine("the last access time for def{0}", def);
TimeSpan timediff = DateTime.Now - abc;
TimeSpan timediff1 = DateTime.Now - def;
if( timediff.TotalMinutes > 5)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var u = db.tbl_urgent_contacts;
foreach (var a in u)
{
tbl_OutBox tb = new tbl_OutBox();
tb.FromSIM_No = a.SimNo;
tb.ToSIM_No = a.SimNo;
tb.ToText = "Check abc";
tb.Reply = "NA";
tb.Response = "NA";
tb.RegNo = "NA";
tb.Datetd = DateTime.Now;
tb.FFID = "NA";
tb.UserId = "You";
tb.FromText = "Check abc";
db.tbl_OutBoxes.InsertOnSubmit(tb);
db.SubmitChanges();
}
}
if (timediff1.TotalMinutes > 5)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var u = db.tbl_urgent_contacts;
foreach (var a in u)
{
tbl_OutBox tb = new tbl_OutBox();
tb.FromSIM_No = a.SimNo;
tb.ToSIM_No = a.SimNo;
tb.ToText = "Check def";
tb.Reply = "NA";
tb.Response = "NA";
tb.RegNo = "NA";
tb.Datetd = DateTime.Now;
tb.FFID = "NA";
tb.UserId = "You";
tb.FromText = "Check def";
db.tbl_OutBoxes.InsertOnSubmit(tb);
db.SubmitChanges();
}
}
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
Thread.Sleep(4000);
}
}when i try this and when i set breakpoint i see that within 5 seconds data is send to table where as i want after seconds data is send to table when there is no update in file any solution
in image currenlt there is 3 files so every file update in every 5 seconds when this fully update then next file is create so i want when there is no update in file in every 5 seconds then i want to insert data in table otherwise not
i try this
public static void Main()
{
while (true)
{
try
{
string abcPath, defPath = "";
abcPath= ConfigurationManager.AppSettings.Get("abcPath");
defPath = ConfigurationManager.AppSettings.Get("defPath");
DateTime abc = File.GetLastAccessTime(abcPath);
DateTime def = File.GetLastAccessTime(defPath);
Console.WriteLine("the last access time for abc{0}", abc);
Console.WriteLine("the last access time for def{0}", def);
TimeSpan timediff = DateTime.Now - abc;
TimeSpan timediff1 = DateTime.Now - def;
if( timediff.TotalMinutes > 5)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var u = db.tbl_urgent_contacts;
foreach (var a in u)
{
tbl_OutBox tb = new tbl_OutBox();
tb.FromSIM_No = a.SimNo;
tb.ToSIM_No = a.SimNo;
tb.ToText = "Check abc";
tb.Reply = "NA";
tb.Response = "NA";
tb.RegNo = "NA";
tb.Datetd = DateTime.Now;
tb.FFID = "NA";
tb.UserId = "You";
tb.FromText = "Check abc";
db.tbl_OutBoxes.InsertOnSubmit(tb);
db.SubmitChanges();
}
}
if (timediff1.TotalMinutes > 5)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var u = db.tbl_urgent_contacts;
foreach (var a in u)
{
tbl_OutBox tb = new tbl_OutBox();
tb.FromSIM_No = a.SimNo;
tb.ToSIM_No = a.SimNo;
tb.ToText = "Check def";
tb.Reply = "NA";
tb.Response = "NA";
tb.RegNo = "NA";
tb.Datetd = DateTime.Now;
tb.FFID = "NA";
tb.UserId = "You";
tb.FromText = "Check def";
db.tbl_OutBoxes.InsertOnSubmit(tb);
db.SubmitChanges();
}
}
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
Thread.Sleep(4000);
}
}when i try this and when i set breakpoint i see that within 5 seconds data is send to table where as i want after seconds data is send to table when there is no update in file any solution
Last edited: