I am quite newbie to yii. I am working on a project.
I have written a function to send automatic reminder to clients
say this function is at url :
http://somedomain.com/index.php/somecontroller/someaction
I want to set the cron for this url.
one method is that I should write GET cron_job_url.
But I dont want to use the url for my cron.I only want to use physical path of the controller and action. Is this possible with yii ?
If you want to use a cron job, I'd suggest to write a yiic command instead of calling a URL. It's very simple and you don't have to deal with URL access permissions.
Create a new class that extends from CConsoleCommand and implement either a run() method or some actions as you would in a controller. You can find more information on console commands here. You have to save the command to the protected/commands directory and the class name must end in Command.
If your command is called DemoCommand then you can call it from a cron job as /path/to/your/webroot/protected/yiic demo.
Related
I am new to Workfusion RPA.
I have created one business process from IDE and when i run manually it is working perfectly fine.
Now my Question is:
1. Can we export any executable file so that i can execute it from command prompt?
2. Is there any way we can expose REST api for that business process, so that i can call from any other application?.
please help in this
Thank you in advance
one approach you can take is you can schedule business process to continuesly execute and read a file from directory,cloud storage or sharepoint and you can write rest service or script to change a flag in the file that way you can control the business process execution if the flag is false bp will end in next schedule again it will read the file
There is REST API available to launch and control business processes.
Documentation can be retrieved through such URL:
https://workfusion_deployment_hostname/workfusion/api/swagger-ui.html
task_management section, /v2/workfusion/task/file method. Request body can be as simple as this:
{
"campaignUuid": "b8b95933-....",
"mainData": "column1,column2\nvalue1,value2"
}
I need to access the location of the change log file so that I can get the URL of other files that are in the same directory from a custom task.
The Change interface has a setter for the ChangeSet object which can be used to get the change log file, but the CustomChangeTask interface does not have this method.
From my understanding I need to use CustomChangeTask as my task does not generate SQL.
This is my question. I have decided to implement AbstractChange. It works just fine doing that and returning an empty array of SqlStatements.
I'm new to Liferay, and I need to create hook which will intercept file and process it before save to the filesystem. Is it possible to do with hooks or I need to make ext?
I'd expect this to work in a hook. Create a hook that intercepts DLFileEntryLocalService, e.g. addFileEntry. Do your job in that method and if you want to approve this to be added to the database, call super.addFileEntry(...) which will take care of the default behaviour.
You'll have to identify if there are more methods that can add a document to the library.
Is it possible to execute yii class or instance methods in yii shell.
Say for example, i want to print all the records of a table, the command for this is Post::model()->findAll. But can I execute this in the yii shell, in the context of the yii web app.
Also, is it possible to access the components of an yii application (like db) in the yii shell.
In short i could like to execute some yii methods in the context of the yii application (much like executing small javascript statements in the firebug console).
Edit 1
Found one solution as mentioned below:
php C:\xampp\htdocs\trackstar\protected\yiic shell C:\xampp\htdocs\trackstar\protected\config\main.php
and then execute the yii commands.
Edit 2
echo Project::model()->findByPk(3);
is giving error object of class project cant be converted to string. Is there any way to print or pretty print the yii objects in the console.
This has nothing to do with Yii. It's a php questions. Anyways, you can try this -
var_dump(Project::model->findByPk(3));
// or
print_r(Project::model->findByPk(3));
or better still use CVarDumper from yii -
CVarDumper::dump(Project::model->findByPk(3);
Documentation on CVarDumper - http://www.yiiframework.com/doc/api/1.1/CVarDumper
My application scrapes information from various sites using Mechanize. Naturally, each site requires custom Mechanize code. Each site is stored in my database, including the url to scrape and the string name of an .rb file containing that site's Mechanize code. For this case, let's assume the scripts are available in the assets folder.
I would like to call http://example.com/site/:id, then have the show action dynamically choose which Mechanize script to run (say, #site.name + ".rb" ). The script will massage the data into a common model, so all sites can use the same show template.
I can't find a way to dynamically load a .rb script within an action and obtain the result. It may be easier to have the scripts return a JSON string, which I can parse before passing on to the template, but I can't see a solution for that either. Ideally, the script will run in the action's scope. The ugly solution is an enormous if-else chain (testing the site name to determine which code block to run), but there must be a better way.
Any suggestions would be greatly appreciated, as would any general solutions to running different code dependent upon the properties of database objects.
If you have all the code in your app already why are you eval'ing Ruby code?
Create classes like:
class GoogleSpider < Spider; end
class NewYorkTimesSpider < Spider; end
class SomeOtherSpider < Spider; end
And the site class will hold the class name that will be used, so you would be able to easily do something like this in your controller action:
def show
#site = Site.find(params[:id])
# name contains SomeOtherSpider
#process_output = #site.name.constantize.new.process
# do something with the output here
end
And then you don't need to mess around evaluating Ruby code, just call the class needed. You can even make them all singletons or keep them all in a hash for faster access.