2013年10月31日星期四

Python2.5 Query ArcGIS point feature class, Read and Write csv

import csv
import datetime
import arcgisscripting
gp = arcgisscripting.create(9.3)

# Set workspace.
gp.Workspace = r"C:\Users\Administrator\AppData\Roaming\ESRI\ArcCatalog\MYDB.sde"
dsList = gp.ListDatasets("TARGET_DATASET", "")
fcList = gp.ListFeatureClasses("TARGET_FEATURE_CLASS", "", dsList[0])

# Create Search cursor for feature class.
cur = gp.SearchCursor(fcList[0], '"COUNTRY" = \'CHINA\'')
row = cur.Next()

# Write csv
csv_file = open("C:\\" + datetime.datetime.now().strftime('%Y%m%d') + ".csv", "wb")
writer = csv.writer(csv_file, delimiter=",")

while row:
    feat = row.Shape
    pnt = feat.GetPart(0)
   
    writer.writerow((row.CITY, str(pnt.x)[1:6], str(pnt.Y)[1:6]))
    row = cur.Next()

# Read other csv  then append to the newly created csv 
other_csv_file = open("D:\\other.csv", 'rt')
try:
    reader = csv.reader(other_csv_file)
    for row in reader:
        writer.writerow(row)
finally:
    other_csv_file.close()

csv_file.close()

Python2.5 Convert datetime format

import datetime
 
mydate = datetime.datetime.strptime('12/31/2013', '%m/%d/%Y')
mydate = mydate.strftime('%Y%m%d')
 
'20131231'

2013年10月18日星期五

C# Debug an ASP Project with Visual Studio 2003

When I try to debug the project, it always say "Unable to find project on the web server. Unable to set server into correct debugging state.".

In order to debug the ASP project, I have to change the following setting:
  • In VS 2003:
    
    -------------
       Project - properties
          Configuration Properties
             Debugging
                - Enable ASP Debugging
                - Enable ASP.NET Debugging
    
  • In the IIS:
    
    ----------------------
       Default Website - Properties
          Home Directory Tab
             Application Settings - Configuration Button
                Debugging Tab
                   - Enable ASP server-side script debugging
    
       Website (the project you want to debug) - Properties
          Directory tab
             Application Settings - Create Button
    
    This sets an application name for the Website and changes the icon from a default folder icon to a Website icon.
  • Add IIS process account to Debugger Users group:
    
    ---------------------------------------------------
       In Computer Management:
          System Tools
             Local Users and Groups
                Groups
                   Debugger Users - properties
                      Add user IWAM_machine-name (the "Launch IIS process account")
    
  • Now, to debug in VS 2003:
    
    ------------------------
       right-click the .asp page that the application should start from
          select "Set as Start Page"