cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Alert or Notification to Thingworx on newly created or generated file in .Net sdk Virtual Directory.

gvyakaranam
12-Amethyst

Alert or Notification to Thingworx on newly created or generated file in .Net sdk Virtual Directory.

I am beginner to Thingworx .Net SDK.

 

Is any mechanism to identify and alert file name to thingworx or Edge, once new file created or generated in Virtual Directory in client.

 

If no direct built-in functions or services, kindly let me know the best resolution to achieve it.

 

Thanks

Gopi

4 REPLIES 4
mgoel
17-Peridot
(To:gvyakaranam)

@gvyakaranam 

 

Thanks for reaching out to us. 

Could you please clarify it more, what do you mean by creating a file in Virtual directory. Are you talking about creating new entities?

 

Regards,

Mohit

gvyakaranam
12-Amethyst
(To:mgoel)

@mgoel 

Thanks for reaching me.

 

It mean that, if any new file found in the virtual Directory (in client's file system like C:\UploadFiles), it needs to be notified to thingworx platform with filename, so thingworx can process the file immediately.

 

Thanks

Gopi

Hi,

 

You can write down a code in .net SDK which keeps an eny on a particular folder if new file is added there or not.

 

    FileSystemWatcher watcher = new FileSystemWatcher();
    watcher.Path = pathToWatch;

    watcher.Created += new FileSystemEventHandler(OnChanged);
    watcher.Renamed += new RenamedEventHandler(OnRenamed);

    watcher.EnableRaisingEvents = true;

 

Now, either you can use some property by setting it to some value or you can use events to raise alerts.

 

The example below triggers an event that returns an error message with a timestamp:
ValueCollection eventInfo = new ValueCollection();
eventInfo.Add("ErrorMessage", new StringPrimitive("There was an error…"));
base.queueEvent("ErrorEvent", DateTime.Now, eventInfo);
 
Regards
Shyam
mgoel
17-Peridot
(To:gvyakaranam)

@gvyakaranam 

 

If you feel previous response on this thread was resolution of your question, please mark it as accepted solution for the benefit of other community users.

 

Regards,

Mohit

Announcements


Top Tags