Você está na página 1de 25

Soyouwanttowriteareport

Part1:Settingupasitecoredevelopment
environmentfromscratch
Ifyoualreadyknowhowtodothis,goaheadandskiptoPart2(onceitsout).

PrerequisitesandFirstInstance

First,goaheadandmakesureacompatibleeditionofMongoDbisinstalled.Imrunning
3.0.3sotakethatasyouwill.
Ifyouinstallfromthemongoinstaller,youmaywanttoenablemongodbasawindows
service.Thefollowingcommandlinewilldoso:
mongod.exe --install --verbose --logpath "C:\Logs\Mongo\Log.txt"
--serviceName "Mongo 3.0.3 (27017)" --serviceDisplayName "Mongo
3.0.3 (27017)" --serviceDescription "Mongo 3.0.3 (27017)"
--dbpath "D:\Data\MongoDb"
AlsoVisualStudio
AndSQLServer
AndSitecoreRocks

IdRecommendTDSbyHedgehog,butthisllworkwithoutit.Youjustwontbeableto
versionandsyncandallthatjazz.
ForusingtheSIMtool(describedshortly)youllneedtochangetheuserthatthesql
serverserviceisrunningunder.Opentheservices.mscmanagementconsole.Then
openthepropertiesofthesqlserverservice.GototheLogOntabandchangetheLog
onasaccounttoLocalSystemaccount

DownloadthelatestSitecoreInstanceManagerTool(SIM.Tool)
https://marketplace.sitecore.net/modules/sitecore_instance_manager.aspx
SetUpyourfoldersforusingSIM
Websites/SIMThefolderwhereyourinstalledinstancesofsitecorewillbe

SitecoreThebasefolderforyourtools,repos,andlicenses

ReposWheretoputyourzipsofSitecoreforinstall

SIM.1.4YourinstallationfolderforSIM

ImgonnaassumeyoureaDeveloper,settingupalocaldevelopmentenvironment.So
Imnottooconcernedaboutenvironmentsecuritymorethanitworks,andyouwontbe
hackedfromtheoutside.SoopenupSSMSandselecttheinstanceyoullbeworking
on.UnderSecurityLogins.AddtheNTAUTHORITY\NETWORKSERVICEuserand
setthemtothefollowingserverroles:

SonowopenupSIMandmakesureyourconfigurationmatchesthatfromabove.

Alrightnowinstallaninstance:

Asanote,thiswillmodifyyourhostsfile.Feelfreetoupdateitfurtherifyouwanta
prettierURL.Actually,Iwouldrecommendit.
Whenyoutrytobrowsetoyournewsitecoresite,youllgetaloginfailedforuser.
GotoyourWEBSITES\SIM\<instance>\Website\App_Configfolderandmodifythe
ConnectionString.configfile.ChangealltheIntegrated_Security=FalseitemstoTrue.
Also,ifyoudidanythingotherthanthedefaultinstallforMongoDb,updateappropriately.

Nowyoursitewillcomeupallpretty.Alright!Nowletsgetthingsstarted.Forthis
demonstration(whichstartsinpart2),wellbecollectinguserfeedbackforeachpagewe
visit(ModifiedContactFacet).Andthen,wellbeSPEAKingabouttheExperience
Analyticsofthematter.Howwelldoourvisitorslikeourpage?

TheVisualStudioProject

StartanewASP.NETWebApplication(OpeningVisualStudioasanADMINISTRATOR)

StartanewEmptyprojectwithreferences.DontgohostingitinAzureortestingit,
unlessyourollthatway.Butthatsnotmybusiness.

Goaheadandtakeacopyofyourweb.configfromthesitecoreinstanceandplaceitin
yournewproject.Andafterthat
Openupthepropertiesonyourproject.SwitchtheFrameworkto4.5

GoaheadandaddaViewsfoldertotheprojectthenaddanewview.

Andfillitinwithsomethingwecantest:

Okay.LetsdoublecheckourNuGetpackages.Visualstudiohasahabitofincludingthe
MVCpackageswhenweaddaMVCobject.RemoveanypackagesrelatedtoRazor,
MVC,etc.Dontworry.Everythingwillstillcompile,andwelladdreferencesasweneed
themthatarecompatiblewithourSitecoreinstance.

NowRightClickonyourprojectandselectpublish.

SelectCustom
EnteraName

SetthepublishmethodtoFileSystemandtheTargetLocationtotheinstanceyousetup
earlier.

SettheConfigurationtoDebug.AndfortheloveofallthingsContentManaged,DONT
selectthedeleteoption.

NowPublish!!

SettingupSitecoretoRenderourMVCView
TheDesktopandDatabases

Bringupyoursite(
http://mongoreportdemo/sitecore/
)andifallwentwellyoushouldbe
atthedashboard.

GototheDesktop.(Strictlyspeakingthisstepisskippable,butifyouveneverworked
withsitecoreyoullbemissinganimportantlesson.)

Inthebottomrighthandcornerofthedesktopisanicon.Clickit.

Ifyoulike,goaheadandselecttheShowDatabaseNamethatwayyouknowwhich
oneyoureworkingon.Nowforthebeginnerslessoninsitecore.Sitecoreusesmultiple
databases.Core,Master,andWebarethedefaultstostartwith.Also,theresa
reportingdatabasehangingoutinSQLServertoo,butyoudontneedtoselectit.Ifyou
wanttolearnmoreaboutwhateachofthesedatabasesdo.Youllneedanotherarticle,
thatsnotcoveredhere.Whatiscovered

Clickonthesitecorestartbutton.AndselectContentEditor

Now,thecontenteditorisavailablefromLaunchpadbutselectingwhichdatabase
youreworkingfromisnt.Theresthelesson.Okay,contenteditor

GettingReadyforMVC

YouregoingtohavetoaddanewLayoutforMVCPages.Goto
sitecore>Layout>Layoutsandrightclicktoinsertnewlayout.LetsnameitSample

MVCLayout.

ThenplaceitunderthebaseLayoutsfolder,thenfinallyselectthelocation.
Website>layouts.Create!

NowundertheDatasettingsinournewlayout.Updatethelinkfrom.aspxto.cshtml.

Openthefilesystemandgotoyourwebsiteinstance.Renametheactualfilehereas

well.

LetsaddthisnewfiletoourVisualStudioprojectsowecanmodifyitandpublishit

whenwewant.

TheFileshouldhavethefollowingcontents:
@inheritsSystem.Web.Mvc.WebViewPage
@usingSitecore.Mvc
@{
Layout=null
}
<!DOCTYPEhtmlPUBLIC"//W3C//DTDXHTML1.0Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd">
<htmllang="en"xml:lang="en"xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
@Html.Sitecore().Field("title",new{DisableWebEdit=true})
</title>
<metahttpequiv="ContentType"content="text/htmlcharset=UTF8"/>
<linkhref="/default.css"rel="stylesheet"/>
</head>
<body>
<divid="MainPanel">@Html.Sitecore().Placeholder("main")</div>
</body>
</html>

Sogoaheadandpublishagaintomakesurethelayoutfileiscorrect.

AddingourDemoLaunchRendering

Undersitecore>Layout>Renderingsgoaheadandrightclickinsertanewfolderforour
stuff.IcalleditMongoReportDemo.Ialsolikecreatingfolderfordifferenttypesof
renderings.SounderMongoReportDemogoaheadandcreateaViewRenderings
folder.
UnderournewfolderrightclickinsertanewViewRenderingandnameitafterourview
wecreated.DemoLaunch

ThenfillinthepathundertheDatasection.

Gotothesitecore>Contentsectionandinsertfromtemplate.

ThenfromtheRibbon,selectPRESENTATION,thenDetailstobringuptheLayout
Details.

UndertheDefaultSectionClickonEdit
UnderLayout,selectSampleMVCLayout.

ThenunderControls,addanewControl.SelectyourDemoLaunchRendering,andadd
ittothemainplaceholder.

Nowwhenyouopen
http://mongoreportdemo/DemoLaunch
youshouldbegreetedwith

Ifyoumadeitthisfar,congratulations!Youvecompletedpart1,andnowhavealocal
developmentinstancetiedtoyourVisualStudioproject.Inpart2,wellbeexploringthe
configurationoffacetsandtheyarestoredinMongoDB/xDB.

Você também pode gostar