Set the custom timer job that copy the data in the same list

Hi
How to set the custom timer job that copy the data in the same list
Thanks,

hello
please it is wrong to copy all of the list3 item in list1 as the example as below is a copy of one item.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
//This namespace is used for the SPJobDefinition class
using Microsoft.SharePoint.Administration;
namespace GENERAL_CustomTimerJob
//To create a custom timer job, first add a class to your SharePoint project and
//inherit from SPJobDefinition. Implement the constructors and override the Execute
//method as shown below. To install your timer job, and set the schedule, you must
//add a Feature and a Feature receiver.
class GENERAL_CustomTimerJob :
SPJobDefinition
#region Constructors
//You must implement all three constructors
public GENERAL_CustomTimerJob()
base()
public GENERAL_CustomTimerJob(string jobName,
SPService service,
SPServer server, SPJobLockType targetType)
base(jobName, service, server, targetType)
public GENERAL_CustomTimerJob(string jobName,
SPWebApplication webApplication)
base(jobName, webApplication,
null, SPJobLockType.ContentDatabase)
//Set the title of the job, which will be shown in the Central Admin UI
this.Title = "Simple Example Timer Job";
#endregion
//Override the Execute method to run code.
public override
void Execute(Guid targetInstanceId)
//Get the Web Application in which this Timer Job runs
SPWebApplication webApp =
this.Parent as
SPWebApplication;
//Get the site collection
SPSiteCollection timerSiteCollection = webApp.ContentDatabases[targetInstanceId].Sites;
//Get the Announcements list in the RootWeb of each SPSite
SPList timerJobList =
null;
foreach (SPSite site
in timerSiteCollection)
                timerJobList = site.RootWeb.Lists.TryGetList("List3");
if (timerJobList != null)
string sourceUrl = "http://aydi-pc";
string destinationUrl =
"http://aydi-pc/sites/Site1/";
string sourceList = "List3";
string destinationList =
"List1";
using (SPSite sourceSite =
new SPSite(sourceUrl))
using (SPWeb sourceWeb = sourceSite.OpenWeb())
using (SPSite destSite =
new SPSite(destinationUrl))
                                using
(SPWeb destWeb = destSite.OpenWeb())
SPList ObjSourcelist = sourceWeb.Lists.TryGetList(sourceList);
SPList ObjDestinationlist = destWeb.Lists.TryGetList(destinationList);
SPListItem newItem = ObjDestinationlist.Items.Add();
SPListItemCollection items = ObjSourcelist.Items;
                                    if
(items.Count > 0)
foreach (SPListItem item
in items)
newItem["Title"] = item["Title"];
newItem["Nom"] = item["Nom"];
newItem["Prenom"] = item["Prenom"];
newItem.Update();

Similar Messages

  • Custom Timer Jobs not visible in Central Admin Job Definitions

    I have multiple custom timer jobs which I was using on old farm, and it was successfully working and was visible in the Central Admin Job Definitions.
    But ever since I moved to new farm, by restoring the site collections from old to new farm, and deployed the custom timer jobs on new farm, they are not visible in Central Admin Job Definitions.
    I tried to change the scope of the solution to "Web Application", and deployed it's wsp in new farm, then also they are not visible in Job Definitions. But I can see them in "Farm Solutions", they have been successfully deployed.
    Please suggest what should I do.

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    SPWeb wb = properties.Feature.Parent as SPWeb;
    if (wb == null)
    throw new SPException("Error obtaining reference to context Site ");
    // make sure the job isn't already registered
    foreach (SPJobDefinition job in wb.Site.WebApplication.JobDefinitions)
    if (job.Name == List_JOB_NAME)
    job.Delete();
    RSS listLoggerJob = new RSS(List_JOB_NAME, wb.Site.WebApplication);
    SPHourlySchedule schedule = new SPHourlySchedule();
    schedule.BeginMinute = 0;
    schedule.EndMinute = 59;
    listLoggerJob.Schedule = schedule;
    listLoggerJob.Update();
    public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    SPWeb wb = properties.Feature.Parent as SPWeb;
    // delete the job
    foreach (SPJobDefinition job in wb.Site.WebApplication.JobDefinitions)
    if (job.Name == List_JOB_NAME)
    job.Delete();

  • Migrate Inplace Custom Timer Job to Online

    Hi All,
    I am pretty new in SharePoint Online, we have planned to migrate all SharePoint 2010 In-place contents to SharePoint Online. We  have few timer jobs deployed in our farm and do not have access to Online servers to migrate custom timer jobs.
    Hence what should be the best strategy to migrate these?
    Regards,
    Ripon Kundu

    Timer jobs cannot be migrated or created in Office 365. You do not have the access to run those things.
    You'll have to re-design your solution.

  • How do I set a custom time & date format in the top bar?

    Hello guys,
    Very embarassing question, because I've had Apple's for all of my life (starting with the original Apple Macintosh) but I still haven't figured out one thing
    How do I set a custom time & date format in the top bar?
    When I go to System Preferences > Language & Text > Formats I can set different formats. I have no idea where you will see these, but I know that it's not the top bar where the time and date is being displayed. Because no matter what I enter, the format in the top bar will stay the same. I can only choose things like 24-Hour clock or not, blinking dots and so on in the Time & Date settings from the System Preferences.
    Can anyone here point me in the right direction? I see you can even choose to display the week of the year - I'd love to do that!
    All help appreciated!
    Greetings

    Language & Text system preferences, Formats tab, customize dates.
    There are also many third party menu item utilities that can.  Search Macupdate.com for some.
    One search yielded iClock Pro.  Although I never used it I would think it allows customization.  The link I gave you is to the Macupdate download page for that app.  On that same page is a Similar Software section which has other apps that can do the same thing. 
    One listed is iStat Menus.  The primary use for iStat Menus is not for displaying date/time but it does do that.  And I know it can do what you want because I use iStat Menus to track temperature sensors n my machine and, like you, I want to customize the menu time/date.  So I use it instead of the apple clock.  It does have the customization features I think you are looking for.

  • I recently wanted to update my phone and so when i put it in recovery mode and tried to set it up it said that i had to enter the apple id that i used to set up the phone the first time but i dont know the information to my old account what do i do?

    I recently wanted to update my phone and so when i put it in recovery mode and tried to set it up it said that i had to enter the apple id that i used to set up the phone the first time but i dont know the information to my old account what can i do?

    You will need to remember or find the id that you used, without it you won't be able to re-activate your phone - if you are on the activation screen then does that show the first letter of the id and the email provider's name ?
    Do you know if you have any of the account's downloads in computer's iTunes library - if you do then you can get the id form that : Recovering a forgotten iTunes Store account name.
    If not then see if you can find it via http://appleid.apple.com : Apple ID: How to find your Apple ID.

  • Custom Timer Job to execute WCF web service error - Could not find default endpoint element that references contract

    Hi,
    I am currently creating custom timer job to call WCF web service to perform nighty job to update employee document library metadata. If I update regular list/library items it updates correctly on a specified interval basis. However when I try to integrate
    the WCF client, it throws error shown below :
    Could not find default endpoint element that references contract EmployeeServiceReference.
    EmployeeServiceClient in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
    I followed exact instructions Andrew Connell has provided but included my logic in execute()
    public
    override
    void Execute(Guid
    targetInstanceId)
    var empClient =
    new
    'ServiceReference.EmployeeServiceClient();
    var employee = empClient.EmployeesMethod();
    I have tried all approaches to manually adding app.config settings in sharepoing web.config but still it throws the error mentioned. It seems that application config and sharepoint site config binding issue still exist and cannot be resolved.
    <system.serviceModel>
    <bindings>
    <basicHttpBinding>
    <binding
    name="BasicHttpBinding_EmployeeService"
    />
    </basicHttpBinding>
    <netTcpBinding>
    <binding
    name="CustomBinding_EmployeeService">
    <security>
    <transport
    protectionLevel="None"
    />
    </security>
    </binding>
    </netTcpBinding>
    <wsHttpBinding>
    <binding
    name="WSHttpBinding_EmployeeService">
    <security
    mode="None"
    />
    </binding>
    </wsHttpBinding>
    </bindings>
    <client>
    <endpoint
    address="http://services.mycomp.com/EmployeeService.svc"
    binding="wsHttpBinding"
    bindingConfiguration="WSHttpBinding_EmployeeService"
    contract="EmployeeServiceReference.EmployeeService"
    name="WSHttpBinding_EmployeeService"
    />
    <endpoint
    address="http://services.mycomp.com/EmployeeService.svc/soap"
    binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_EmployeeService"
    contract="EmployeeServiceReference.EmployeeService"
    name="BasicHttpBinding_EmployeeService"
    />
    <endpoint
    address="net.tcp://crmapp.mycomp.com:5050/EmployeeService.svc/tcp"
    binding="netTcpBinding"
    bindingConfiguration="CustomBinding_EmployeeService"
    contract="EmployeeServiceReference.EmployeeService"
    name="CustomBinding_EmployeeService">
    <identity>
    <userPrincipalName
    value="[email protected]"
    />
    </identity>
    </endpoint>
    </client>
    </system.serviceModel>
    Will you please help resolving this issue?

    Hi,
    You can use any of the three approaches:-
    1) Access web application's web.config programmatically in Execute() method.
    http://praveenkasireddy.wordpress.com/2012/12/14/access-web-application-configuration-values-in-timer-job-sharepoint/
    2) Store the configuration in xml and upload it to SharePoint document library then read from there
    http://www.sharepointdynamics.net/2011/08/using-an-xml-settings-file-to-store-values-for-your-sharepoint-projects/
    3) Programmatically configure a WCF endpoint.
    http://msdn.microsoft.com/en-us/library/ff647110.aspx
    Regards, Shruti

  • Every time I sync my iPhone with iPhoto I end up getting duplicate photos on my iPhone. The other problem is that I can not delete the dups on my iPhone.   Does anyone have an answer to this problem?

    Every time I sync my iPhone with iPhoto I end up getting duplicate photos on my iPhone. The other problem is that I can not delete the dups on my iPhone.   Does anyone have an answer to this problem?

    Mike whether I create a folder within the Pictures Folder that iTunes uses to sync photographs or just copy them into the main folder the result is the same, I end up with Photo Library plus another album containing an identical set of pictures as contained in Photo Library.
    The User Manual for iOS5 states ...
    You can create, rename, and delete albums on iPhone to help you organize your photos and videos.
    Create a album: When viewing albums, tap Edit, then tap Add. Select photos to add to the new album, then tap Done. Note: Albums created on iPhone aren’t synced back to your computer.
    Rename an album Tap Edit, then select an album.
    Rearrange albums Tap Edit, then drag up or down.
    Delete an album Tap Edit, then tap the delete sign.
    Yes I can Add a new Album, but cannot delete an album already created. The delete sign does not appear.
    In iTunes the only folder that I can see listed is the man one into which iTunes stores pictures, which I have named iPhone Photos.
    When I look on my PC this iPhone Photos folder contains another folder named iPod Photo Cache and a multitude of folders created by iTunes, the named F00, F01,F02 etc etc. and a Photo Database file.
    Now whether I create a seperate folder within iPhone Photos to store my favourite photos in, or just copy them all into the iPhone Photos folder without being encased within another folder, or create a folder inside the iPod Photo Cache folder the result is the same ...
    I end up with Photo Library plus another album containing an identical set of pictures as contained in Photo Library.
    I am going around in ever decreasing circles here and getting nowhere fast!! 

  • Each time I open my Firefox browser, the tab from the last time opens. I have the browser set to open on my home page, not to the tab from the last time. I keep trying to save the setting for the browser to open on my home page but it doesn't.

    Each time I open my Firefox browser, the tab from the last time opens. I have the browser set to open on my home page, not to the tab from the last time. I keep trying to save the setting for the browser to open on my home page but it doesn't.

    Try to create a new profile as a test to check if your current profile is causing the problems.
    See "Basic Troubleshooting: Make a new profile":
    *https://support.mozilla.org/kb/Basic+Troubleshooting#w_8-make-a-new-profile
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
    If the new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
    See:
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox
    Do a malware check with some malware scanning programs on the Windows computer.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br /><br />
    *http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    *http://www.superantispyware.com/ - SuperAntispyware
    *http://www.microsoft.com/security/scanner/en-us/default.aspx - Microsoft Safety Scanner
    *http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    *http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    You can also do a check for a rootkit infection with TDSSKiller.
    *http://support.kaspersky.com/viruses/solutions?qid=208280684
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Is there a way to create dependency on the real-time jobs

    Hi,
    We have around 80 real-time services running and loading the changed data into the target.
    The process being used is
    IBM Informix > IBM CDC > JMS (xml messages) > DS real-time services > Oracle EDW.
    While using the above process,  when ever there is change in the fact table and the dimension table, both the real-time services are loading the data at the same time into the target. This is causing issues in looking up data with the timing issue.
    Is there a way where we can create a dependency and resolve the timing issue and make sure the lookup table is loaded and then the master table is loaded?
    Please let me know.
    Thanks,
    C

    Hello
    With the design you curently have, you will have potential sequencing issues.  There is no magic in Data Services to solve this.
    You might want to consider building more complex real-time jobs that accept more complex data structures and have logic to process the data in dependency order.
    Michael

  • A "designer" file being worked on a machine, is checked-in regularly, if at any point of time the latest version of that file is taken on the same machine, all the data gets deleted

    A “designer” file being worked on a machine, is checked-in regularly, if at any point of time the latest version of that file is taken on the same machine, all the data gets deleted

    Hi,
    Could you provide us more information to help you?
    If you have resolved the issue, it would be better if you can post the solution here, which will help others.
    Thanks,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Hi, I'm trying to set up my Time Machine, but I get this message: The server may not exist or it is unavailable at this time. Check the server name or IP address, check your network connection, and then try again. how to resolve?

    Hi, I'm trying to set up my Time Machine, but I get this message: The server may not exist or it is unavailable at this time. Check the server name or IP address, check your network connection, and then try again. how to resolve?

    Did you reboot the TC? That is always the first step.
    Reboot the whole network if that is not enough.
    If you still have issues.. come back to us but generally the best way is to factory reset the TC and start over.
    We need a bit more info on the whole network layout and what OS you are running. What model TC you have??

  • The SSP Timer Job Distribution List Import Job was not run.

    The SSP Timer Job Distribution List Import Job was not run.   Reason: Logon failure: the user has not been granted the requested logon type at this computer
    We are facing the above mentioned problem . I have added the service account in backup operates and did everything like update farm credentils , update managed account etc , but still no luck . Please note that we haven't done any chnages to the account
    Application pool is keeping going into stop mode when we try to access the site . Both CA and webapplication are down with the error as Service Unavailble . Please help
    Srini

    sounds like the account can only be used on certain COMPUTERS ("has not been granted the requested logon type
    at this computer")... check active directory.
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • Running Time Machine for the first time, how that I make sure that some information I have in the external drive does not get erase in the prosess

    Running Time Machine for the first time, how that I make sure that some information I have in the external drive does not get erase in the prosess

    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Note: This is now your Library. It's not a Back Up, and you need another disk for backing up.
    Regards
    TD

  • When I am writing an email, I get an alert message that says "The message could not be copied or moved to the drafts folder. Writing to the folder failed. To ga

    When I am writing an email, I get an alert message that says “The message could not be copied or moved to the drafts folder. Writing to the folder failed. To gain disc space, choose Empty Deleted and choose Compact Folders and try again.”
    If I do that, I get a message saying “There was an error copying to the Sent folder,, retry?”
    If I retry it sends the uncompleted email. All I can do is keep deleting the message and carry on. Then the whole business might repeat itself.
    Help!
    Frank

    Because the location for each song in your library is on your hard drive.  If the hard drive isn't there, how can iTunes play it?
    You'll have to move/copy the music from your hard drive to your computer's hard drive.
    Basically, EASIEST way to do all this, if you don't care about your play counts, etc...
    -Delete EVERYTHING from iTunes, so that your library is now empty.
    -Go to "Advanced" inside of the "Preferences" window, found in the "Edit" drop-down.  You can also access Preferences by pressing Ctrl+, (Press Ctrl and the comma key)
    -Change your iTunes Media Folder Location to something simple, but on your computer. I use C:/iTunes.  Make sure "Keep iTunes Media Folder Organized" and "Copy files to...." are both checked.  You can close Preferences now.
    -Now, drag and drop your music from your hard drive into your iTunes library.  iTunes will automatically add the music to your library, as you would expect, and also creates a copy of each file to place into that iTunes Media Folder you just created.
    Shouldn't have any more problems...

  • HT201269 I downloaded the iOS7, lost all the custom ring tones that I had on my phone, how do i get them back.  when I sync my phone, itunes says that they have been selected, but they don't show up on my phone

    I downloaded the iOS7, lost all the custom ring tones that I had on my phone.  the iTunes sync page says that they have all been selected but they don't show up in my phone? Help?

    I had the same problem and was able to fix it. Go to your iTunes and click on the Tones folder on the left under library. Some of my ring tones had an exclamation mark next to it and those were the ones that did not sync. You have to click on those and find it in your computer. Once the exclamation mark is gone, go to Tones section of your device in iTunes, make sure you select the tones you want synced, and click apply. I hope that helps you!

Maybe you are looking for