protected void Page_Load(object sender, EventArgs e) { SuperOfficeAuthHelper.Authorize(); // First choose the correct installation: SuperOffice.Configuration.ConfigFile.WebServices.RemoteBaseURL = SuperOfficeAuthHelper.Context.NetServerUrl; var contPar = Request.QueryString["ContactId"]; int contId = Convert.ToInt32(contPar); using (var contAgent = new ContactAgent()) { var cont = contAgent.GetContactEntity(contId); var addr = cont.Address; string address = string.Empty; if (addr.LocalizedAddress != null && addr.LocalizedAddress.Length > 1) { if (addr.LocalizedAddress[0] != null) { address = addr.LocalizedAddress[0].Aggregate(address, (current, addrLine) => current.Add(addrLine.Value, ", ")); } if (addr.LocalizedAddress[1] != null) { address = addr.LocalizedAddress[1].Aggregate(address, (current, addrLine) => current.Add(addrLine.Value, ", ")); } address = address.Add(cont.Country.EnglishName, ", "); string lat, lng; GoogleMaps.GeocodeAddress(address, out lat, out lng ); var contactName = System.Web.HttpUtility.JavaScriptStringEncode(cont.Name); var script = "<script>\nfunction initializeMarkers() {\n"; script += string.Format("AddMarker(map, '{0}', '{1}', '{2}' );\n", contactName, lat, lng); script += "}\n</script>"; loadMarkersScript.Text = script; } } }
public string GetScript(int mainId) { using (var newArcAgt = new ArchiveAgent()) { //Setting the Parameters var archiveColumns = new string[] { Keyid, Contactid, Name, Department, Namedepartment , StreetaddressLine1, StreetaddressLine2, StreetaddressLine3 , StreetaddressCounty, StreetaddressCity, StreetaddressZip , PostalAddressLine1, PostalAddressLine2, PostalAddressLine3 , PostalAddressCounty, PostalAddressCity, PostalAddressZip , Country }; //Parameter - restriction - Archive restrictions var archiveRest = GetArchiveRestrictionInfos(mainId); //Parameter - page - Page number, page 0 is the first page int page = 0; //Parameter - pageSize – Number of records displayed per page const int pageSize = 10; // Get a page of results for an archive list, explicitly specifying // the restrictions, orderby and chosen columns ArchiveListItem[] arcLstItm = null; var script = "function initializeMarkers() {\n"; var placedCompanies = new HashSet <int>(); // Because we only want to register a place once. do { arcLstItm = newArcAgt.GetArchiveListByColumns( Archive, archiveColumns, new ArchiveOrderByInfo[0], archiveRest, null, page++, pageSize); foreach (ArchiveListItem archiveRow in arcLstItm) { int contactId = CultureDataFormatter.ParseEncodedInt(archiveRow.ColumnData[Contactid].DisplayValue); if (!placedCompanies.Contains(contactId)) { placedCompanies.Add(contactId); string address = string.Empty; address = address.Add(archiveRow.ColumnData[StreetaddressLine1].DisplayValue, ", "); address = address.Add(archiveRow.ColumnData[StreetaddressLine2].DisplayValue, ", "); address = address.Add(archiveRow.ColumnData[StreetaddressLine3].DisplayValue, ", "); address = address.Add(archiveRow.ColumnData[StreetaddressZip].DisplayValue, ", "); address = address.Add(archiveRow.ColumnData[StreetaddressCity].DisplayValue, ", "); if (address.IsNullOrEmpty()) { address = address.Add(archiveRow.ColumnData[PostalAddressLine1].DisplayValue, ", "); address = address.Add(archiveRow.ColumnData[PostalAddressLine2].DisplayValue, ", "); address = address.Add(archiveRow.ColumnData[PostalAddressLine3].DisplayValue, ", "); address = address.Add(archiveRow.ColumnData[PostalAddressZip].DisplayValue, ", "); address = address.Add(archiveRow.ColumnData[PostalAddressCity].DisplayValue, ", "); } address = address.Add(archiveRow.ColumnData[Country].DisplayValue, ", "); string lat, lng; GoogleMaps.GeocodeAddress(address, out lat, out lng ); var tooltip = System.Web.HttpUtility.JavaScriptStringEncode(archiveRow.ColumnData[Namedepartment].DisplayValue); script += string.Format("AddMarker(map, '{0}', {1}, {2} );\n", tooltip, lat, lng); } } } while(arcLstItm.Length != 0); script += "}"; return(script); } }