由cron自动激活数据流配置文件

时间:2016-04-22 14:44:27

标签: php magento magento-1.9

我想通过cron运行我的数据流导入配置文件,而无需在Cron.php或crontab文件中进行操作。当我手动启动时,我的个人资料正在运行。 此适配器从csv文件导入有关产品的数据。 我试图通过以下方式运行此配置文件:

x <- c("banana","republic")
sub(".(.)$","\\1",x)
[1] "banaa"   "republc"

但是在cron动作之后我没有任何效果。运行方法无法正常工作。 文件位于正确的位置。个人资料的ID正确,个人资料已加载。

1 个答案:

答案 0 :(得分:0)

我找到了答案。如果要运行导入配置文件,则应在public class Portal extends AppCompatActivity { private static final String TAG = "com.example.StateChange"; ImageButton imgButton; private static final int PICTURE_SELECTED = 1; static ArrayList<Bitmap> posts = new ArrayList<Bitmap>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(com.example.bernine.practicalsessions.R.layout.activity_portal); imgButton = (ImageButton) findViewById(com.example.bernine.practicalsessions.R.id.imageButton1); Log.i(TAG, "onCreate"); } public void cancelAction(View view) { this.finish(); //to prevent having too many activities on the stack rather than creating an intent to open the MainActivity class } public void submitAction(View view) { EditText title = (EditText) findViewById(R.id.post_title_input); String tit = title.getText().toString(); EditText description = (EditText)findViewById((R.id.editText)); String desc = description.getText().toString(); Bitmap img = yourSelectedImage; if(tit==null && tit.length()==0) //not recognised { Toast.makeText(getApplicationContext(), "Title should not be empty", Toast.LENGTH_LONG).show(); }else if(desc==null && desc.length()==0) //not recognised { Toast.makeText(getApplicationContext(), "Description should not be empty", Toast.LENGTH_LONG).show(); }else if(img==null) { Toast.makeText(getApplicationContext(), "Image should be selected", Toast.LENGTH_LONG).show(); }else { // Post p = new Post(tit,desc,img); // posts.add(p); posts.add(img); Toast.makeText(getApplicationContext(), "Image Saved", Toast.LENGTH_LONG).show(); Intent i = new Intent(this, News.class); startActivity(i); } } //---Method to start the intent upon clicking the imageButton--- public void galleryIntent(View view) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(intent, PICTURE_SELECTED); } Bitmap yourSelectedImage; @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); BitmapFactory.Options options; if (resultCode == RESULT_OK && requestCode == PICTURE_SELECTED) { try { options = new BitmapFactory.Options(); options.inSampleSize = 4; Uri selectedImage = data.getData(); String[] filePath = {MediaStore.Images.Media.DATA}; Cursor cursor = getContentResolver().query(selectedImage, filePath, null, null, null); cursor.moveToFirst(); String mImagePath = cursor.getString(cursor.getColumnIndex(filePath[0])); InputStream stream = getContentResolver().openInputStream(selectedImage); yourSelectedImage = BitmapFactory.decodeStream(stream, null, options); stream.close(); //---orientation--- try { int rotate = 0; try { ExifInterface exif = new ExifInterface( mImagePath); int orientation = exif.getAttributeInt( ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotate = 270; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; } } catch (Exception e) { e.printStackTrace(); } Matrix matrix = new Matrix(); matrix.postRotate(rotate); yourSelectedImage = Bitmap.createBitmap(yourSelectedImage , 0, 0, yourSelectedImage.getWidth(), yourSelectedImage.getHeight(), matrix, true); } catch (Exception e) {} //---end of orientation--- imgButton.setScaleType(ImageView.ScaleType.FIT_CENTER); imgButton.setImageBitmap(yourSelectedImage); } catch (Exception e) { Toast.makeText(getApplicationContext(), "Could not open file.", Toast.LENGTH_LONG).show(); } } else { Toast.makeText(getApplicationContext(), "Image was not selected", Toast.LENGTH_LONG).show(); } Log.i(TAG, "onActivityResult"); } } 之后使用此代码:

public class News extends AppCompatActivity {
    //Here the viewPager is connected to the PagerAdapter class
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news);

        //This component will be used to page between the various fragments created.
        final ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
        viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager(), News.this));

        //the tabLayout is given the viewPager to connect to the pager with the tabs
        TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
        tabLayout.setupWithViewPager(viewPager);
        //the following was used so the tabs fill up the width of the screen being responsive for all devices and orientations
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);

    }

}