/// <summary>
    /// Call Create Group from lookup results.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCreateGroup_OnClick(object sender, EventArgs e)
    {
        if (ExecDistanceSearch() > 0)
        {
            if (!string.IsNullOrEmpty(createGroupName.Value))
            {
                string groupName = createGroupName.Value;

                double lat, lon;
                GetLatLonForLocation(out lat, out lon);

                var groupId = DistanceSearchHelper.CreateAccountDistanceGroup(groupName,
                                                                              lat, lon, Convert.ToDouble(cbxDistance.Text),
                                                                              pklType.PickListValue, pklSubType.PickListValue,
                                                                              Convert.ToInt32((!(cbxNumResults.Text == GetLocalResourceObject("Results_All").ToString() || cbxNumResults.Text == "")) ? cbxNumResults.Text : "0"),
                                                                              CurrentRegion.IsMetric);

                //Redirect to location of group.
                Response.Redirect(string.Format("Account.aspx?gid={0}", groupId));
            }
            else
            {
                // Invalid Group Name
                DialogService.ShowMessage(GetLocalResourceObject("Error_NoGroupName").ToString());
            }
        }
        else
        {
            // No values to create a group with
            DialogService.ShowMessage(GetLocalResourceObject("Error_NoResults").ToString());
        }
    }
示例#2
0
    private IList <DistanceDTO> GetGroupData(string entityType, string groupId, string orderBy, bool sortAsc, int count, IList <string> selections)
    {
        // Group Query
        switch (entityType.ToUpper())
        {
        case "IACCOUNT":
        {
            return(DistanceSearchHelper.AccountGroupSearch(
                       groupId,
                       orderBy,
                       sortAsc,
                       count,
                       0,
                       selections));
        }

        case "ICONTACT":
        {
            return(DistanceSearchHelper.ContactGroupSearch(
                       groupId,
                       orderBy,
                       sortAsc,
                       count,
                       0,
                       selections));
        }

        default:
            return(null);
        }
    }
示例#3
0
    /// <summary>
    /// Execute the distance search and create the result set.
    /// </summary>
    public IList <DistanceDTO> ExecShowMap()
    {
        if (!ValidateInputs())
        {
            //Show Error
            return(null);
        }

        IList <DistanceDTO> results = null;

        // Perform the search on either account or contact
        if (rbAccts.Checked)
        {
            // Account Group Search
            results = DistanceSearchHelper.AccountGroupSearch(cbxGroupName.SelectedValue,
                                                              Page.Session["m_sortExpression"].ToString(),
                                                              ((SortDirection)Page.Session["m_sortDirection"] == SortDirection.Ascending),
                                                              0, 0, null);
        }
        else
        {
            // Contact Group Search
            results = DistanceSearchHelper.ContactGroupSearch(cbxGroupName.SelectedValue,
                                                              Page.Session["m_sortExpression"].ToString(),
                                                              ((SortDirection)Page.Session["m_sortDirection"] == SortDirection.Ascending),
                                                              0, 0, null);
        }

        dgPostalCodeResults.DataSource = null;
        dgPostalCodeResults.DataSource = results;
        //Display datagrid.
        dgPostalCodeResults.DataBind();

        return(results);
    }
    /// <summary>
    /// Execute the distance search and creates the result set.
    /// </summary>
    public int ExecDistanceSearch()
    {
        ValidateInputs();

        //We use the alias AccountName to remain consistent with App Architect syntax.
        double lat, lon;

        GetLatLonForLocation(out lat, out lon);

        var results = DistanceSearchHelper.AccountDistanceSearch(lat, lon, Convert.ToDouble(cbxDistance.Text),
                                                                 pklType.PickListValue, pklSubType.PickListValue,
                                                                 Page.Session["m_sortExpression"].ToString(),
                                                                 ((SortDirection)Page.Session["m_sortDirection"] == SortDirection.Ascending),
                                                                 (!(cbxNumResults.Text == GetLocalResourceObject("Results_All").ToString() || cbxNumResults.Text == "")) ? Convert.ToInt32(cbxNumResults.Text) : 0,
                                                                 0, CurrentRegion.IsMetric);

        dgPostalCodeResults.DataSource = null;
        dgPostalCodeResults.DataSource = results;
        dgPostalCodeResults.DataBind();

        return((results != null) ? results.Count : 0);
    }
示例#5
0
    /// <summary>
    /// This provides the data
    /// </summary>
    /// <returns></returns>
    protected string GenerateDataScript()
    {
        IList <DistanceDTO> results = null;
        StringBuilder       script  = new StringBuilder();

        string fromLoc        = Request.QueryString["from"];
        double fromLat        = Convert.ToDouble(Request.QueryString["fromlat"] ?? "0");
        double fromLon        = Convert.ToDouble(Request.QueryString["fromlon"] ?? "0");
        string entityType     = Request.QueryString["type"];
        double distance       = Convert.ToDouble(Request.QueryString["dist"] ?? "0");
        string accountType    = Request.QueryString["atype"];
        string accountSubType = Request.QueryString["asub"];
        string sortBy         = Request.QueryString["sort"];
        bool   sortAsc        = Convert.ToBoolean(Request.QueryString["asc"] ?? true.ToString());
        int    count          = Convert.ToInt32(Request.QueryString["cnt"] ?? "0");

        string         selected   = Request.QueryString["selected"];
        IList <string> selections = null;

        if (!string.IsNullOrEmpty(selected))
        {
            selections = new List <string>(selected.Split(';'));
        }

        // Contact Prox Search
        string contactType   = Request.QueryString["ctype"];
        string contactStatus = Request.QueryString["cstat"];

        // Map Group
        string group = Request.QueryString["grp"];

        if (entityType == null)
        {
            throw new Exception(GetLocalResourceObject("Error_EntityType_Null").ToString());
        }

        if (fromLoc != null && Request.QueryString["fromlat"] != null && Request.QueryString["fromlon"] != null)
        {
            script.AppendFormat("data.addPoint({{latitude: {0}, longitude: {1}, name: '{2}', description: '', address: '', type: 'poi', id: 'poi'}}, true);\n",
                                fromLat.ToString(CultureInfo.GetCultureInfo("en-US")), fromLon.ToString(CultureInfo.GetCultureInfo("en-US")),
                                PortalUtil.JavaScriptEncode(fromLoc, true));
        }

        if (string.IsNullOrEmpty(group))
        {
            // Use the query from the prox search page
            switch (entityType.ToUpper())
            {
            case "IACCOUNT":
            {
                results = DistanceSearchHelper.AccountDistanceSearch(
                    fromLat, fromLon, distance, accountType, accountSubType,
                    sortBy, sortAsc, count, 0, CurrentRegion.IsMetric);
                break;
            }

            case "ICONTACT":
            {
                results = DistanceSearchHelper.ContactDistanceSearch(
                    fromLat, fromLon, distance, contactType, contactStatus,
                    sortBy, sortAsc, count, 0, CurrentRegion.IsMetric);
                break;
            }
            }
        }
        else
        {
            results = GetGroupData(entityType, group, sortBy, sortAsc, count, selections);
        }

        // Add the points to the map
        if (results != null && results.Count > 0)
        {
            foreach (var dist in results)
            {
                // '*' is appended to descriptions when no geolocation data is avaialble.
                script.Append(
                    string.Format("data.addPoint(new SlxDataPoint({{latitude: {0}, longitude: {1}, name: '{2}', address: '{3}', description: '{7}', id: '{4}', entityid: '{5}', url: '{6}', type: 'data'}}), true);\n",
                                  (dist.GeocodeLatitude.HasValue) ? dist.GeocodeLatitude.Value.ToString(CultureInfo.GetCultureInfo("en-US")) : "0.0",
                                  (dist.GeocodeLongitude.HasValue) ? dist.GeocodeLongitude.Value.ToString(CultureInfo.GetCultureInfo("en-US")) : "0.0",
                                  PortalUtil.JavaScriptEncode(string.Format("{0}{1}", (entityType.ToUpper().Equals("IACCOUNT")) ? dist.AccountName : dist.NameLF, (dist.GeocodeLatitude.HasValue) ? string.Empty : "*"), true),
                                  PortalUtil.JavaScriptEncode(dist.DisplayAddress, true),
                                  PortalUtil.JavaScriptEncode(dist.AddressId, true),
                                  PortalUtil.JavaScriptEncode((entityType.ToUpper().Equals("IACCOUNT")) ? dist.AccountId : dist.ContactId, true),
                                  GetEntityUrl(entityType, dist.AccountId, dist.ContactId),
                                  ((dist.GeocodeLatitude.HasValue) ? string.Empty : "<em>" + GetLocalResourceObject("AddressFailedToGeocode").ToString() + "</em><br/><br/>") + GetDescription(dist.MainPhone, dist.AccountManagerLF)));
            }
        }

        return(script.ToString());
    }