Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
dear all expert
i plan to multiple users dynamic scheduling every user separate scheduling time how to implement. i have done for single user email sent massage scheduling. but how did multiple user and dynamic scheduling email sent .
Solved! Go to Solution.
Try below code to dynamically create scheduler thing.
------------------------------------------------------------------------
var ThingName = "yourThingName";
var params = {
name: ThingName /* STRING */,
description: undefined /* STRING */,
thingTemplateName: 'Scheduler' /* THINGTEMPLATENAME */,
projectName: 'PTCDefaultProject' /* PROJECTNAME */,
tags: undefined /* TAGS */
};
try{
Resources["EntityServices"].CreateThing(params);
logger.warn("Thing Created: "+ThingName);
Things[ThingName].EnableThing();
updateThing();
Things[ThingName].RestartThing();
Things[ThingName].EnableScheduler();
}
catch(e){
logger.warn("Exception"+e);
}
function updateThing(){
var configtable = Things[ThingName].GetConfigurationTable({tableName: "Settings"});
// update configuration with service parameters
configtable.schedule = '0 0/10 * * * ?';
configtable.runAsUser = 'Administrator';
configtable.enabled = true;
// set new configuration table
var par= {
configurationTable: configtable /* INFOTABLE */,
persistent: true /* BOOLEAN */,
tableName: "Settings" /* STRING */
};
Things[ThingName].SetConfigurationTable(par);
}
Could you please elaborate on your use case?
Also, give some information on the below question
1. How many users will be using this feature
2. How do users define scheduling time from UI / Mashup?
/ VR
hi @Velkumar
answer question
1.N number of users use feature. , (Multiple user multiple chose the (hour,day,week,year,) all are separate configuration )
2, define user from UI/mashup ( hour ,week ,month ,year ) scheduling save value to SQL server
use case. Elaboration:
n number of users continuously joint in database, each user some configuration need configuration means report sent to the mail time periods(hour,day,month,year) this store value from sql server , N0 user one hour sent mail N1 user two hours N3 user one day N4 user week N5 user month N6 user year N number of user all are (hour, day,week ,month ,year) based
for example :
n1 user sent mail every one hour
n2 user sent mail end of day
n3 user sent mail weekly once
n4 user sent mail monthly once
n5 user sent mail yearly once
requirement
i attempted to single user scheduling (hour,day,month,year) sent mail successfully. run on this concept. ,but n number of user how to implement scheduling.
With Regards
Hariharasuthan
hi Hariharasuthan
You can create a scheduler entity first. After you save that entity, click the pen mark like the follwing screenshot. There will be a popup window where you can configure sheduler every year/month/day/hour...
Next step you need to prepare you own thing service which send the user email. Let's call <thing1.service1>. And create a thing subscription which will be trggered by scheduler and perform <thing1.service1>. Settings as below picture.
hi @wcui
i have done in single user sent e-mail (day,week,month,year) but I need multiuser configuration,
N number of user and N number CREON value ,also how is it create manually?
this image in same CRON value in ALL user right ?
but different Cron value and different user and sent mail common but content is different
Requriement :
Dynamic create Thing(scheduler entity) script write code
multiple scheduler entity creates dynamic code then. applying E-mail services
a[0]={user1, Cron 1,service1 }
a[n]={userN, Cron N,service1 },,,
Thanks
Hariharasuthan
Above image is only scheduler defination, not related to email sending. Thingworx Mail extension provides the ability to read and send e-mails from ThingWorx through external SMTP mail servers. You need to write your own email sending service.
Below is how to create thing entity dynamically with snippet codes.
i have done e-mail service and also sent mail working process successfully. but i create dynamic scheduler
how to create thing entity dynamically with snippet codes?
answer :
step1:DATABASE CALLING FROM VALUES
name1=VALUE1
description1=VALUE2
thingTemplateName1=VALUE3
projectName1=VALUE4
runAsUser1=VALUE5
schedule1=VALUE6
step2:ASSIGN TO VALUE FROM RESOURE ENTITY
let params = {
name: name1 /* STRING */,
description: description1 /* STRING */,
thingTemplateName:thingTemplateName1 /* THINGTEMPLATENAME */,
projectName:projectName1/* PROJECTNAME */,
runAsUser:runAsUser1
schedule=schedule1
};
let result=params;
Resources["EntityServices"].CreateThing(params);
step3: THEN SERVICE APPLY EMAIL
ME.Sentmail( pram)
{..............
.........
}
for example a[0] -{ name1,description1,thingTemplateName1,projectName:projectName1,runAsUser1,schedule1}
a[n]={similarly }
my requirement ; 1. N(multiple) number of user, for example 90 user
2. each user need to scheduler , all are not same CRON value . for example : user1 need monthly triggering event, user2 every hour triggering event , user3 every week triggering event upto userN , CRON(hour,week,month,year ) this combination of triggering event all are user .
3.event means (sentmail) this is my own email service , but email service done ,
this is my requirement.
Try below code to dynamically create scheduler thing.
------------------------------------------------------------------------
var ThingName = "yourThingName";
var params = {
name: ThingName /* STRING */,
description: undefined /* STRING */,
thingTemplateName: 'Scheduler' /* THINGTEMPLATENAME */,
projectName: 'PTCDefaultProject' /* PROJECTNAME */,
tags: undefined /* TAGS */
};
try{
Resources["EntityServices"].CreateThing(params);
logger.warn("Thing Created: "+ThingName);
Things[ThingName].EnableThing();
updateThing();
Things[ThingName].RestartThing();
Things[ThingName].EnableScheduler();
}
catch(e){
logger.warn("Exception"+e);
}
function updateThing(){
var configtable = Things[ThingName].GetConfigurationTable({tableName: "Settings"});
// update configuration with service parameters
configtable.schedule = '0 0/10 * * * ?';
configtable.runAsUser = 'Administrator';
configtable.enabled = true;
// set new configuration table
var par= {
configurationTable: configtable /* INFOTABLE */,
persistent: true /* BOOLEAN */,
tableName: "Settings" /* STRING */
};
Things[ThingName].SetConfigurationTable(par);
}
let params = {
name:"TestingScheduler" /* STRING */,
description: "samplething" /* STRING */,
thingTemplateName:"Scheduler" /* THINGTEMPLATENAME */,
projectName:"MailserverGoogle" /* PROJECTNAME */,
runAsUser:"Hariharasuthan",
schedule="0 0/1 * * * ?";
};
let result=params;
Resources["EntityServices"].CreateThing(params);
this both can not update in Thing(scheduler entity)
schedule="0 0/1 * * * ?";
runAsUser = "Hariharasuthan";