How to Schedule Windows service using Task Scheduler?

using task scheduler we can schedule our service please follow this Doc

Advertisements

how to find SQL Server Configuration Manager

SQL Server Configuration Manager is a snap-in for the Microsoft Management Console program and not a stand-alone program, SQL Server Configuration Manager not does not appear as an application when running Windows 8. To open SQL Server Configuration Manager, in the Search charm, under Apps, type SQLServerManager11.msc (for SQL Server 2012) or SQLServerManager10.msc for (SQL Server 2008), and then press Enter.More Info.

 

how to insert data in MySQL using python scrapy

Download python 2.7
And follow all below link instruction
http://doc.scrapy.org/en/0.24/intro/install.html

Then create a new project
Open command prompts
Write D: and click enter button
Then type
cd D:\AnuragSharma\Project\2324_Scrapy and click enter button
Type command on command prompt
scrapy startproject amazoncrawler
Then you see in this path the one project is created with essential files as amazoncrawler
Then open below file
D:\AnuragSharma\Project\2324_Scrapy\amazoncrawler\amazoncrawler\items.py
And paste some bunch of line


import scrapy
class AmazoncrawlerItem(scrapy.Item):
# define the fields for your item here like:
title = scrapy.Field()
link = scrapy.Field()
desc = scrapy.Field(serializer=str)
pass

Then open below file
D:\AnuragSharma\Project\2324_Scrapy\amazoncrawler\amazoncrawler\spiders\__init__.py
And paste some bunch of line

import scrapy
from amazoncrawler.items import AmazoncrawlerItem
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors import LinkExtractor

class AmazonAllDepartmentSpider(scrapy.Spider):
name = “amazon”
allowed_domains = [“amazon.com”]
start_urls = [
http://www.amazon.com/gp/site-directory/ref=nav_sad/187-3757581-3331414”
]
def parse(self, response):
for sel in response.xpath(‘//ul/li’):
item = AmazoncrawlerItem()
item[‘title’] = sel.xpath(‘a/text()’).extract()
item[‘link’] = sel.xpath(‘a/@href’).extract()
item[‘desc’] = sel.xpath(‘text()’).extract()
yield item

Then type
cd D:\AnuragSharma\Project\2324_Scrapy\amazoncrawler and click enter button
And type
scrapy crawl amazon -o items.csv -t csv
Then you see a new file generated with name item.csv
D:\AnuragSharma\Project\2324_Scrapy\amazoncrawler\items.csv
Then you see all detail in this file

Now if we want to add this data in mysql database
Then you have to download and install MySQLdb interface
https://pypi.python.org/pypi/MySQL-python/1.2.5

And you have to create database in mysql
qwerty_project
And create one table over there
ProductDepartment
With column name
ProductDepartmentLilnk

And write a some bunch of line code here
D:\AnuragSharma\Project\2324_Scrapy\amazoncrawler\amazoncrawler\pipelines.py

class AmazoncrawlerPipeline(object):
host = ‘qwerty.com’
user = ‘qwerty’
password = ‘qwerty123’
db = ‘amazon_project’

def __init__(self):
self.connection = MySQLdb.connect(self.host, self.user, self.password, self.db)
self.cursor = self.connection.cursor()

def process_item(self, item, spider):
try:
self.cursor.execute(“””INSERT INTO amazon_project.ProductDepartment (ProductDepartmentLilnk)
VALUES (%s)”””,
(
item[‘link’]))

self.connection.commit()

except MySQLdb.Error, e:
print “Error %d: %s” % (e.args[0], e.args[1])
return item

And put this line in setting file
D:\AnuragSharma\Project\2324_Scrapy\amazoncrawler\amazoncrawler\settings.py
ITEM_PIPELINES = [‘amazoncrawler.pipelines.AmazoncrawlerPipeline’]

Then run project from command prompt
scrapy crawl amazon

If you have any Question please let me know anraag@live.com

How to debug windows service in asp.net ?

When you create service you can see one default class is called Program.cs

you replace your existing class

static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new CustomerVendorService()
            };
            ServiceBase.Run(ServicesToRun);
        }
    }

with new class

static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
#if DEBUG
            CustomerVendorService oCustomerVendorService = new        CustomerVendorService();
            oCustomerVendorService.DebugService();
            System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
#else
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new CustomerVendorService()
            };
            ServiceBase.Run(ServicesToRun);
#endif
        }
    }

and in you service1.cs class you have to write some code like that

public void DebugService()
        {
            OnStart(null);
        }
        protected override void OnStart(string[] args)
        {
            Vendor(); // whatever you want to call from these function
        }

when you replace your code with new one then run (F5) windows application

then you can see you can debug your application