Sunday, February 24, 2013

Custom Timer Jobs of Copying List Items to Database using Entity Framework


In this article we can try creating a custom Timer Job in SharePoint.? The tools we are going to use are following:

?? Visual Studio 2010
?? SharePoint DevTools from CodePlex

We can start with analysing what is a Timer Job.

What is a Timer Job?


A Timer Job is a periodically executed task inside the SharePoint Server.? It allows us by providing a task execution environment.



For example we can execute tasks like: Sending Emails on every hour, Data Updating on every day, creation of reports on every week etc.

Default Timer Jobs inside SharePoint


There are many Timer Jobs inside SharePoint which do the internal tasks like:
?? Sending emails
?? Validating sites
?? Delete unused sites
?? Health analysis
?? Product versioning
?? Diagnostics
These tasks will be having execution periods like:
1.? Minute
2.? Hour
3.? Day
4.? Week
5.? Month

Manage Timer Jobs


You can see the Timer Jobs from Central Administration > Monitoring > Manager Timer Jobs


Following is the list of some Timer Job Definitions:


You can select each Job Definition and change the schedule or disable it.

Creating a Custom Timer Job Definition


Now we are ready with the basics to proceed with creating a Custom Timer Job.

Scenario


We have a list named Products which is custom template.? Any new product arriving has to be posted to an SQL Server database so that the company website can show it to potential customers.

So the activities involved are the following:

1.? Create Products List inside SharePoint
2.? Create Product Table inside Database
3.? Create the Timer Job Definition
4.? Create Event Receiver
5.? Create the Database Insert Method
6.? Deploy the Timer Job
7.? View the Results

Step 1: Create Products List inside SharePoint

Here is the List Definition: (the list template with data is attached with the article)


You can see that the core columns of the list are:

Column
Description
Title
The name of the Product
Description
About the Product
Price
The price of the Product



The HasPosted column determines whether the item is copied to the Products database.?

After installing the list from template you will can see it is having 2 items:


Step 2: Create Product Table inside Database

Now we need to create the destination database and table.? Following is the table definition.? (the table sql is attached with the article)


Step 3: Create the Timer Job

In this step we can go ahead and create the Timer Job.? For this you require Visual Studio 2010 and the SharePoint templates installed.

Open Visual Studio and create a new Empty SharePoint Project as shown below:


In the next page select your server and use Deploy as Farm solution option:


Click the Finish button after entering the options.

Now add a new class and derive it from SPJobDefinition as shown below.

using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using Microsoft.SharePoint.Administration;
 
 namespace SPTimerJobExample
 {
     public class ProductsJobDefinition : SPJobDefinition
     {
     }
 }

Now replace the above file with the following content.

using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using Microsoft.SharePoint.Administration;
 using Microsoft.SharePoint;
 
 namespace SPTimerJobExample
 {
     public class ProductsTimerJob : SPJobDefinition
     {
         public ProductsTimerJob()
             : base()
         {
 
         }
 
         public ProductsTimerJob(string jobName, SPService service, SPServer server, SPJobLockType lockType)
             : base(jobName, service, server, lockType)
         {
             this.Title = "Products Timer Job";
         }
 
         public ProductsTimerJob(string jobName, SPWebApplication webapp)
             : base(jobName, webapp, null, SPJobLockType.ContentDatabase)
         {
             this.Title = "Products Timer Job";
         }
 
         public override void Execute(Guid targetInstanceId)
         {
             SPWebApplication webapp = this.Parent as SPWebApplication;
             SPContentDatabase contentDb = webapp.ContentDatabases[targetInstanceId];
 
             SPList list = contentDb.Sites[0].RootWeb.Lists["Products"];
 
             CopyItems(list);
         }
 
         private void CopyItems(SPList list)
         {
             foreach (SPListItem item in list.Items)
             {
                 bool hasPosted = (bool)item["HasPosted"];
 
                 if (!hasPosted)
                 {
                     new DbManager().Insert(item);
 
                     item["HasPosted"] = true;
                     item.Update();
                 }
             }
         }
     }
 }

The above code is performing the following activities:

1.? Get the list of items from Products where HasPosted is false
2.? Insert the Product into Database
3.? Mark the item HasPosted to true

We need to include the DbManager class file and will be done in the upcoming step.

Step 4: Create Event Receiver

Now we have to create an event receiver which performs the installation or uninstallation of the Job Definiton.

In the Solution Explorer right click on Feature and use the Add Feature item.

In the appearing dialog change the title to Products Job Definition and the Scope to Site

Now right click on the Solution Explorer > Feature 1 and click Add Event Receiver

Inside the class content of Feature1.EventReceiver.cs place the following code.

??

 const string JobName = "Products Timer Job";
 
         public override void FeatureActivated(SPFeatureReceiverProperties properties)
         {
             SPSite site = properties.Feature.Parent as SPSite;
 
             DeleteJob(site); // Delete Job if already Exists
 
             CreateJob(site); // Create new Job
         }
 
         private static void DeleteJob(SPSite site)
         {
             foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
                if (job.Name == JobName)
                     job.Delete();
         }
 
         private static void CreateJob(SPSite site)
         {
             ProductsTimerJob job = new ProductsTimerJob(JobName, site.WebApplication);
 
             SPMinuteSchedule schedule = new SPMinuteSchedule();
             schedule.BeginSecond = 0;
             schedule.EndSecond = 5;
             schedule.Interval = 5;
 
             job.Schedule = schedule;
             job.Update();
         }
 
         public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
         {
             DeleteJob(properties.Feature.Parent as SPSite); // Delete the Job
         }

You need to add the using as well:

using Microsoft.SharePoint.Administration;



Step 5: Create the Database Insert Method

In this step we can complete the DbManager class file.? Here we are using Entity Framework associated with .Net 3.5 version.

For this add a new Entity Data Model into the project and map to the Product table which we have created in previous step.


Now create a class file named DbManage.cs and replace it with the following content.


using System;
 
 namespace SPTimerJobExample
 {
     public class DbManager
     {
         public void Insert(Microsoft.SharePoint.SPListItem item)
         {
             using (ProductionModel context = new ProductionModel(GetConnectionString()))
             {
                 Product product = new Product();
                 product.Title = item["Title"].ToString();
                 product.Description = item["Description"].ToString();
                 product.Url = item["Url"].ToString();
                 product.Price = (double)item["Price"];
                 product.PostedOn = DateTime.Today;
 
                 context.AddToProducts(product);
 
                 context.SaveChanges();
             }
         }
 
         public string GetConnectionString()
         {
             string connectionString = new System.Data.EntityClient.EntityConnectionStringBuilder
             {
                 Metadata = "res://*",
                 Provider = "System.Data.SqlClient",
                 ProviderConnectionString = new System.Data.SqlClient.SqlConnectionStringBuilder
                 {
                     InitialCatalog = "YOUR-DB-NAME-HERE",
                     DataSource = @"YOUR-SERVER-NAME-HERE",
                     IntegratedSecurity = false,
                     UserID = "YOUR-USER-ID-HERE",   
                     Password = "YOUR-PASSWORD-HERE",          
                 }.ConnectionString
             }.ConnectionString;
 
             return connectionString;
         }
     }
 }

The above code contains the Insert() method to insert new record into the Product table.

For the time being I am hard coding the connection string.? You need to specify the correct user credentials in the GetConnectionString() method.

Note: Please note that the connection string is loaded from the executing application's configuration file.? In the case of Timer Jobs the configuration file will be OWSTIMER.exe.config residing in the 14hive folder.

Step 6: Deploy the Timer Job

Now we are ready to deploy the Timer Job into the SharePoint Site.? For this right click on the solution and click the Deploy option.

If you get the Deploy Succeeded message we are good.

Step 7: View the Results

Now we can go to the Central Administration to see our Timer Job.? For this open Central Administration web site and go to Monitoring > Review Job Definitions


On clicking the Review Job Definitions link you can see our item as shown below:


Click on the item and in the appearing page click the button Run Now


You can see that the Timer Job is set for 5 Minutes according to our code.

Now we can go back to the Products list and see that the HasPosted is set to True.


Going to the SQL Server Table we can see both the records are inserted there.

?


Troubleshooting Tips

While developing timer jobs, you might need to delete the assembly and feature as well.? Please note the following points for troubleshooting guidance:

?? Features are deployed to the 14hive folder
?? The assembly gets deployed to GAC folder
?? You can use RETRACT option from? Visual Studio
?? You can use GACUTIL to uninstall the assembly
?? You can remove the Feature from 14hive folder

For troubleshooting the Farm Solutions or User Solutions you can use:

?? Central Administration > System Settings > Manage Farm Solutions
?? Central Administration > System Settings > Manage User Solutions


You can Retract or undo the last Retract schedule there.

For checking the Job Status or History you can use:

?? Central Administration > Monitoring >? Check Job Status > Timer Job Status
?? Central Administration > Monitoring >? Check Job Status >? Timer Job History

These screens will show the Success / Failure status of the jobs and any errors associated.? For example an invalid connection string problem is identified as shown below:


Debugging Tips



In some cases the Timer Service hold the old version of assembly.? So the new changes you have done through Visual Studio may not get reflect immediately.? You can change the assembly version and view the GAC to ensure the correct version was deployed.


Plus you can restart the SharePoint 2010 Timer Service from services.msc


Note: In the case of Integrated Security as True in connection strings, the authenticated user would be the Service Account user assigned in the service.

References


Technet on Timer Jobs
Code on Timer Jobs
Solution Removal using PowerShell

Summary


In this article we have explored the Timer Job feature of SharePoint and creating a custom timer job. ?Following are the key points to be remembered:

?? Timer Jobs can be scheduled for automating jobs inside SharePoint 2010
?? SPJobDefinition is the base class for Timer Job
?? Create Event Receiver Feature to create or delete the timer job
?? SPFeatureReceiver is the base class for event receiver
?? The feature gets deployed in the 14hive folder
?? OWSTIMER.EXE is the process executing Timer Jobs

The associated source code along with the list template with data is attached.? You can download and try running it.

Source: http://feedproxy.google.com/~r/DotNetSparkArticles/~3/Vp-ppQeCWhQ/5351-custom-timer-jobs-copying-list-items-to.aspx

breaking dawn part 2 trailer mississippi state chris carpenter chris carpenter dick cheney hcg drops reason rally

First-year Blue Eagle coach embraces program

CLOVER --?

The Clover High School boys basketball team?s loss to No. 1 ranked Irmo in the first round of the state 4A playoffs in no way dampened the spirit of first-year head basketball coach Bailey Jackson.

Jackson spoke in positive tones in describing the direction of the program.

Jackson, a Clover native who had a successful coaching stint at Fort Mill before returning to Blue Eagle Country, said this year?s Clover team far exceeded expectations and gained valuable experience during the course of the season.

?Even though we lost to Irmo in the first round of the state playoffs, we were able to finish fourth in the region and win the Comporium Classic at Andrew Jackson High School in December,? said Jackson. ?Only one player, Taylor Hoover, had any significant varsity playing time prior to the season.

The CHS coach noted that Hoover was the only player to start a varsity game when the season began.

?In addition to Taylor, senior Jevon Blake played a huge role in our success,? said Jackson. ?He got better throughout the season and ended up being one of our better defenders.?

Jackson lauded seniors Jordan Hill and Kevious Cole for coming to practice each day with great attitudes and working hard to make everyone around them better.

?Obviously, we return a great deal of our scoring with junior Alex Thompson (9ppg), sophomore Bryce Allen (9ppg), and sophomore Arnaldo Toro (10.5 ppg),? said Jackson. ?We return great defenders in junior Ladarius Adams and sophomore RJ Moore.?

Said Jackson: ?This was year one of building our program into one of the best in the state. We want to strive for excellence each day and get better with everything we do.?

Jackson also said he wants the CHS basketball program to be the best, noting that this year was a great way to start.

?I cannot say enough about these guys and how much they improved throughout the season,? he said. ?We had ups and downs but they came back each day with the right attitude and accepted our coaching.

?Many of these players have had very little success on the basketball court and got excited about competing at a higher level than they had before. It was a pleasure to work with them this year and I look forward to the future.?

Source: http://www.lakewyliepilot.com/2013/02/21/1818933/first-year-blue-eagle-coach-embraces.html

cesar chavez winning lotto numbers lottery tickets mega lottery sag aftra mega mill power ball

Thursday, February 21, 2013

Stem cell 'homing' signal may help treat heart failure patients

Feb. 21, 2013 ? In the first human study of its kind, researchers activated heart failure patients' stem cells with gene therapy to improve their symptoms, heart function and quality of life, according to a study in the American Heart Association journal Circulation Research.

Researchers delivered a gene that encodes a factor called SDF-1 to activate stem cells like a "homing" signal.

The study is unique because researchers introduced the "homing" factor to draw stem cells to the site of injury and enhance the body's stem cell-based repair process. Generally, researchers extract and expand the number of cells, then deliver them back to the subject.

"We believe stem cells are always trying to repair tissue, but they don't do it well -- not because we lack stem cells but, rather, the signals that regulate our stem cells are impaired," said Marc S. Penn, M.D., Ph.D., Director of Research at Summa Cardiovascular Institute in Akron, Ohio, and lead author and professor of medicine at Northeast Ohio Medical University in Rootstown, Ohio.

SDF-1 is a naturally occurring protein, secreted by cells, that guides the movement of other cells. Previous research by Penn and colleagues has shown SDF-1 activates and recruits the body's stem cells, allowing them to heal damaged tissue. However, the effect may be short-lived. For example, SDF-1 that's naturally expressed after a heart attack lasts only a week.

In the study, researchers attempted to re-establish and extend the time that SDF-1 could stimulate patients' stem cells. Study participants' average age was 66 years.

Researchers injected one of three doses of the SDF-1 gene (5mg, 15mg or 30mg) into the hearts of 17 patients with symptomatic heart failure and monitored them for up to a year. Four months after treatment, they found:

  • Patients improved their average distance by 40 meters during a six-minute walking test.
  • Patients reported improved quality of life.
  • The heart's pumping ability improved, particularly for those receiving the two highest doses of SDF-1 compared to the lowest dose.
  • No apparent side effects occurred with treatment.

"We found 50 percent of patients receiving the two highest doses still had positive effects one year after treatment with their heart failure classification improving by at least one level," Penn said. "They still had evidence of damage, but they functioned better and were feeling better."

The findings indicate people's stem cells have the potential to induce healing without having to be taken out of the body, Penn said.

"Our study also shows gene therapy has the potential to help people heal their own hearts."

At the start of the study, participants didn't have significant reversible heart damage, but lacked blood flow in the areas bordering their damaged heart tissue.

The study's results -- consistent with other animal and laboratory studies of SDF-1 -- suggest that SDF-1 gene injections can increase blood flow around an area of damaged tissue, which has been deemed irreversible by other testing.

Researchers are now comparing results from heart failure patients receiving SDF-1 with patients who aren't. If the trial goes well, the therapy could be widely available to heart failure patients within four to five years, Penn said.

Co-authors are Farrell O.Mendelsohn, M.D.; Gary L. Schaer, M.D.; Warren Sherman, M.D.; MaryJane Farr, M.D.; Joseph Pastore, Ph.D.; Didier Rouy, M.D., Ph.D.; Ruth Clemens, M.P.H.; Rahul Aras, Ph.D., and Douglas W. Losordo, M.D.

Share this story on Facebook, Twitter, and Google:

Other social bookmarking and sharing tools:


Story Source:

The above story is reprinted from materials provided by American Heart Association.

Note: Materials may be edited for content and length. For further information, please contact the source cited above.


Note: If no author is given, the source is cited instead.

Disclaimer: This article is not intended to provide medical advice, diagnosis or treatment. Views expressed here do not necessarily reflect those of ScienceDaily or its staff.

Source: http://feeds.sciencedaily.com/~r/sciencedaily/health_medicine/genes/~3/yX7noIwbMMI/130221194233.htm

andy cohen andy cohen mozambique oosthuizen great expectations jake owen oosthuizen louis

Tint World Welcomes New Franchisees and Prepares For Multiple ...

Tint World welcomes new franchisees and begins the development process of their upcoming stores.

Weston, FL (PRWEB) February 20, 2013 - Tint World, the leading window tinting and car audio automotive styling franchise that was recently named as one of the top 500 franchises for 2013 by Entrepreneur Online, is marking the year with a plethora of new franchisees along with the exciting development process of their stores openings.

Recently, several new Tint World franchisees from across the nation arrived at Tint World Franchise headquarters in Florida for their training in preparation for their own stores that they will soon be operating. These new franchisees include:

  • Paul Sawhney from Sparrows Point, MD
  • Amish Patel from Marrietta, GA
  • Mike Jones from North Palm Beach, FL
  • Evan Peel from Olathe, KS
  • Max Madani-Zadeh from Houston, TX
  • John Miller from Tampa, FL
  • Mitzi Hemstreet from Pittsburgh, PA
  • Mike Edwards from Stuart, FL
  • Jason Celetti and Jesse Moreno from Coral Gables, FL

Whether a new franchisee has years of experience or no experience at all in the automotive industry, the Tint World training program is a fundamental component in becoming a successful Tint World owner and operator. The rigorous 3-week training program details everything a franchisee needs to know about running a Tint World store?from product knowledge onwindow tinting, audio/video, auto detailing and more to every-day store operations?in order to fully satisfy a customer?s needs according to Tint World?s standards.

Essentially, the Tint World training program builds a solid foundation of knowledge and experience for all upcoming franchisees, elevating their comprehension of not just Tint World, but the automotive industry as a whole.

With the addition of fresh faces in the franchise as well as upcoming stores opening this year, Tint World CEO/President Charles Bonfiglio expressed that, ?It?s very exciting to welcome new franchisees to the Tint World team and help them develop stores, some of which are in locations new to the franchise.?

The current set of franchisees reflects Tint World?s continuous growth and expansion across the country with the first store set to open in Maryland in March of this year under Paul Sawhney?s management. 8 more store openings are planned to follow through July. International franchise stores in Riyad, Saudi Arabia and Abu Dhabi, UAE are also planned to open by the summer.

With several stores slated to open throughout the year, interest of the automotive franchise has been persistently rising and is now more than ever making a name for itself as the one-stop-shop store for everything automotive appearance related.

About Tint World?

Established 1982 in Tamarac, Florida, Tint World? is now the leading franchised provider of automotive, residential, commercial, and marine window tinting and security film services in the US. Tint World? Automotive Styling Centers also offer auto security, mobile electronics, performance and styling accessories, custom wheels and tire packages, auto detailing, and reconditioning services.

Contact:

Charles Bonfiglio
Tint World
http://www.tintworld.com
(800) 767-8468

###

Social Reach:

Viewer Response:

Source: http://www.franchising.com/news/20130220_tint_world_welcomes_new_franchisees_and_prepares_f.html

fred thompson fred thompson red hook romney tax return the tree of life movie academy award nominees 2012 2012 oscar nominations

Friday, February 15, 2013

Russell Brand Reveals Future WEDDING Plans! Do They Include Katy Perry?!

russell brand talks marriage katy perry again

Cheeky British comedian Russell Brand divorced from his boobalicious ladylove Katy Perry over a year ago?

But does he ever plan on legally committing to another woman (or man) again?!

During a recent interview Russell revealed:

"Probably. I suppose so, if I meet the right man or woman."

LOLz! Well good to know he's open to BOTH genders!

But we somehow can't picture Russell settling down one day ? unless of course it's with Katy Perry and, unfortunately, that candy-coated ship has sailed away?

And it sank STRAIGHT to the Ocean's bottom!

Ch-ch-check out some snaps of Russell and Katy Kat back when they were together (below) and imagine what might have been? if Russell hadn't been so selfish!

Naaaah, we're just kidding. Kinda. ;)

[Image via WENN.]

Tags: divorce, interview, katy perry, love, marriage, russell brand, wedding

Source: http://perezhilton.com/2013-02-15-russell-brand-talks-future-wedding-plans-katy-perry

office max office max jcp Sports Authority Hollister old navy walmart black friday

Lazy Eye? Turn Off the Lights

For youtube videos, paste embed code directly in the text box

-

Members do not need to provide an address

-

Rate Article

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0 Select Comment Validation Method
Member
Name/URL (Guest)
FaceBook (Guest) Member Commenting:


Authenticate with Facebook before submitting

OR


Make your LabSpaces comments count. Start earning LabSpaces points by becoming a member! Learn more. Please verify that you are human: Register for LabSpaces
Make your LabSpaces comments count. Start earning LabSpaces points by becoming a member! Learn more.

Please authenticate before trying to post a comment.

If you would like to remain anonymous, please enter a new name and link below


Friends

Source: http://www.labspaces.net/126841/Lazy_Eye__Turn_Off_the_Lights

cotton bowl Fiscal cliff deal kathy griffin jadeveon clowney orange bowl Rose Parade 2013 rex ryan