2013年7月4日 星期四

[MSSQL]複製資料庫發生錯誤

今天複製資料庫發生錯誤

SQL Server Scheduled Job 'XXXXXXXXXXXXXXXX' (0xF616BAAEEFCFC24EAADBBA69CD284D8E) - Status: Failed - Invoked on: 2013-07-05 14:20:42 - Message: The job failed.  The Job was invoked by User XX.  The last step to run was step 1 (XXXXXXXXXXXXXXXX).

處理的過程:

首先需要開啟SQL Server Agent服務

注意:

Log On as:
Built-in Account:選擇Local System


這樣就可以正確複製了!!

2013年6月14日 星期五

[Tools]LiveReload使用於Windows上

對一位前端工程師或是網頁設計師來說,一邊改HTML一邊按F5重整網頁是每天最常做的事情
推薦一個好用軟體幫大家節省按F5的時間,只要按下儲存他就會馬上自動更新
那就是LiveReload

一、安裝
首先到官網http://livereload.com/下載Windows的最新版本,

Try LiveReload 0.8.5.1 Alpha

接下來安裝就對了

二、如何使用

安裝完畢後,可從程式及裡面打開它,接下來選擇Add也就是選擇你的HTML放置的目錄位置,
比如說我放在C:\inetpub\wwwroot\LiveReloadTest


接下來安裝browser extensions或是照他上面給的script加入載
前面

這裡我使用的是Chrome
安裝完畢後瀏覽器會有一個新的按鈕

按鈕如果是實心狀態表示啟動,空心則為關閉

接下來我們可以開始進入操作

首先打開瀏覽器將我們的網頁開啟,並開啟編輯工具

注意一點是我是把網頁放在IIS裡面
所以我試過直接打開檔案的方式,按鈕是無法啟用的
我直接打localhost/LiveReloadTest/Index.html的方式按鈕才可以啟用

如果要使用開啟檔案的方式瀏覽網頁,請把2裡面的Script加到Body
前面,一樣可以使用

希望大家看得懂...

2013年6月6日 星期四

[IOS]使用WebView載入Google地圖

if (DEVICE_IS_IPHONE5)
{
 width = 320;
 height = 504
}
else {
  width = 320;
  height = 460
}

//不包含狀態列
CGRect fullScreenRect = [[UIScreen mainScreen] applicationFrame]; if(fullScreenRect.origin.y == 20)
{
 width = fullScreenRect.size.width;
 height = fullScreenRect.size.height;
}
else{
 height = fullScreenRect.size.width;
 width = fullScreenRect.size.height;
}

NSString *htmlString = [NSString stringWithFormat:@"<html>\ <head>\ <meta id=\"viewport\" name=\"viewport\" content=\"width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;\">\ <script src='http://maps.google.com/maps/api/js?sensor=false' type='text/javascript'></script>\ </head>\ <body onload=\"new google.maps.StreetViewPanorama(document.getElementById('p'),{position:new google.maps.LatLng(%f, %f),pov: {heading: 270,pitch:0,zoom:1}});\" style='padding:0px;margin:0px;'>\ <div id='p' style='height:%f;width:%f;'></div>\ </body>\ </html>",lat, lon , height , width];

[webView loadHTMLString:htmlString baseURL:nil];

[IOS]設定NavigationController的ButtonItem方式


方法一

UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];


[backBtn setTitle:@"返回" forState:UIControlStateNormal];


backBtn.frame = CGRectMake(0, 0, 40, 40);


[backBtn addTarget:self action:@selector(GoTop) forControlEvents:UIControlEventTouchUpInside];


UIBarButtonItem *layerBtnItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];


self.navigationController.navigationBar.topItem.leftBarButtonItem = layerBtnItem;



方法二

UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];


[backBtn setTitle:@"返回" forState:UIControlStateNormal];


backBtn.frame = CGRectMake(0, 0, 40, 40);


[backBtn addTarget:self action:@selector(GoTop) forControlEvents:UIControlEventTouchUpInside];


UIBarButtonItem *layerBtnItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];

self.navigationController.navigationItem.leftBarButtonItem=layerBtnItem;


2013年6月5日 星期三

[IOS][ArcGIS] 尋找AGSLayer

使用的SDK版本ArcGIS API fo IOS 2.3.2









目前找Layer的方法有幾種


1.透過名稱


UIView<AGSLayerView>* lyrPushCaseView = [self.mapView.mapLayerViews valueForKey:@"住宅推案 ];

AGSLayer* pushCaseLayer = lyrPushCaseView.agsLayer;

if ([pushCaseLayer isKindOfClass:[AGSDynamicMapServiceLayer class]]) {
    lyrPushCaseView.hidden = NO;
}



2.透過Index


NSArray *layerLists = [delegate.mapView mapLayers];
AGSDynamicMapServiceLayer *layerGroup = [layerLists objectAtIndex:2];

[IOS]UIImage+Resize


以下是筆記,這是蠻常用到的功能所以我把他加到Category裡面方便可以重複使用

建立一個新的項目選擇Category ,名稱輸入Resize類別選擇UIImage

UIImage+Resize.h

@interface UIImage (Resize)

+ (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize;

@end

記得是宣告為靜態方法

UIImage+Resize.m

#import "UIImage+Resize.h"

@implementation UIImage (Resize)

+ (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize {

UIGraphicsBeginImageContext( newSize );

[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];

UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext(); return newImage; }

@end

使用UIGraphicsBeginImageContext需加入

#import <QuartzCore/QuartzCore.h>

使用方法

UIImage *popimg = [UIImage imageWithImage:[UIImage imageNamed:@"xxx.png"] scaledToSize:CGSizeMake(50, 50)];

2013年3月6日 星期三

[AO]ArcObject BaseCommand

今天開始來寫第一個在ArcGIS上的Command,以下是我將工作流程做紀錄,如果有任何錯誤請給予指導,謝謝

建立新專案 

首先我們開啟一個新的專案,範本請選擇ArcGIS=>Extending ArcObjects,目前只支援到.NET Framework3.5,所以請選擇.NET Framework3.5不然會沒有範本可以選擇喔,今天我們要針對ArcMap做開發,所以請選擇ClassLibrary(ArcMap),輸入該專案的名稱,輸入完畢後請點確認按鈕開啟專案。


加入參考 點選確定後,將會跳出選擇參考的視窗,我們可以從Desktop ArcMap底下找尋所要使用的References,典擊兩下即會加入參考,選擇完畢後點選Finish


進到專案後,我們在專案上點右鍵加入參考,選擇.NET頁籤裡面的System.Drawing後點擊確認加入專案

刪除Class1.cs檔案

因為預設會幫我們加入該檔案,但是我們用不著,所以我們就把它刪了吧!點擊右鍵即可刪除!

建立 command

在專案按右鍵選擇新增項目後,我們到ArcGIS的Extending ArcObjects選擇BaseCommand項目,並輸入該項目名稱,我們輸入ZoomToLayer.cs完畢後,請點擊新增按鈕


接下來會詢問該Coommand的類型,因為我們這次要用在ArcMap,所以就選他囉!




撰寫Code


建立完後,我們首先需要修改的就是該項目的相關屬性,類別,標題,訊息,提示資訊,該項目唯一名稱
 base.m_category = "Eric"; //localizable text
 base.m_caption = "Zoom To Layer 標題";  //localizable text
 base.m_message = "Zoom To Layer 左下角的訊息";  //localizable text 
 base.m_toolTip = "Zoom To Layer";  //localizable text 
 base.m_name = "Eric_ZoomToLayer";   //unique id, non-localizable (e.g. "MyCategory_ArcMapCommand")
接下來我們可以透過ArcGIS的小工具快速幫我們建立常用的程式碼,我們在codebehind上面點擊右鍵,選擇 ArcGIS Snippet Finder,並輸入Zoom關鍵字去搜尋,搜尋後選擇我們要用到的程式碼select Zoom to Active Layer in TOC.snippet


        
#region "Zoom to Active Layer in TOC"
///Zooms to the selected layer in the TOC associated with the active view./// 
///An IMxDocument interface
///  
///
public void ZoomToActiveLayerInTOC(IMxDocument mxDocument)
{
    if (mxDocument == null)
    {
        return;
    }
    IActiveView activeView = mxDocument.ActiveView;
    // Get the TOC
    IContentsView IContentsView = mxDocument.CurrentContentsView;
    // Get the selected layer
    System.Object selectedItem = IContentsView.SelectedItem;
    if (!(selectedItem is ILayer))
    {
        return;
    }
    ILayer layer = selectedItem as ILayer;
    // Zoom to the extent of the layer and refresh the map
    activeView.Extent = layer.AreaOfInterest;
    activeView.Refresh();
}
#endregion

 
#region "Get MxDocument from ArcMap"
///Get MxDocument from ArcMap.
///An IApplication interface that is the ArcMap application.
///An IMxDocument interface.
///
public IMxDocument GetMxDocumentFromArcMap(IApplication application)
{
    if (application == null)
    {
        return null;
    }
    IDocument document = application.Document;
    IMxDocument mxDocument = (IMxDocument)(document); // Explicit Cast
    return mxDocument;
}
#endregion

最後在點擊事件中加入該段程式碼
       
/// /////////public override void OnClick()
{
    IMxDocument mxDocument = GetMxDocumentFromArcMap(m_application);
    ZoomToActiveLayerInTOC(mxDocument);
}