Exemplo n.º 1
0
        private void PreparingYachtLink(YachtItem item, YachtSearchModel searchModel)
        {
            string yachtId = Terminator.Encrypt(item.YachtID);

            var passParams = new YachtPassParamsModel(0, 0, searchModel);
            //string paramsData = passParams.EncryptData();
            string detailLink = Url.RouteUrl("YachtDetail", new { id = yachtId });

            detailLink += CommonHelper.ConvertToUrlParameter(passParams).ToLower();
            item.CustomProperties["DetailLink"] = detailLink;
        }
Exemplo n.º 2
0
        private async Task PreparingYachtCustomProperties(YachtItem item)
        {
            if (item.FileStreamFid > 0)
            {
                item.CustomProperties["FileThumbUrl"] = await _fileStreamService.GetFileById(item.FileStreamFid.Value, AQBooking.YachtPortal.Core.Enum.ThumbRatioEnum.half);
            }
            else
            {
                item.CustomProperties["FileThumbUrl"] = Url.Content(CommonValueConstant.NO_IMAGE_PATH);
            }
            item.CustomProperties["PricingType"] = item.PricingTypeResKey != null?_languageService.GetResource(item.PricingTypeResKey) ?? "" : "";

            if (item.FromPrice != null)
            {
                item.CustomProperties["PriceFromText"] = item.FromPrice?.FormatCurrency(item.CultureCode);
            }
        }
Exemplo n.º 3
0
        private void ProcessCommand(string command)
        {
            try
            {
                int yachtId;
                if (int.TryParse(Regex.Replace(command, " .*", ""), out yachtId))
                {
                    command = Regex.Replace(command, "^" + yachtId + " ", "");
                    switch (Regex.Replace(command, " .*", "").ToUpperInvariant())
                    {
                        case "HEADING":
                            if (yachtList != null)
                            {
                                yachtList[yachtId].Heading = (float)Convert.ToDouble(command.Replace("HEADING ", ""));
                            }
                            break;
                        case "LOCATION":
                            try
                            {
                                if (yachtList != null && yachtList[yachtId] != null)
                                {
                                    yachtList[yachtId].Location = Geospatial.Location.Parse(Regex.Replace(command, "LOCATION ", "", RegexOptions.IgnoreCase), Geospatial.LocationStyles.Iso, CultureInfo.CurrentCulture);
                                    AddBreadcrumb(yachtId);
                                    UpdateYachtImage(yachtId);
                                    UpdateMap();
                                }
                            }
                            catch { }
                            break;
                        case "SAILDIRECTION":
                            if (yachtList != null && yachtList[yachtId] != null)
                            {
                                yachtList[yachtId].SailDirection = (float)Convert.ToDouble(command.Replace("SAILDIRECTION ", ""));
                            }
                            break;
                        case "WAYPOINTS":
                            listViewWaypoints.Items.Clear();
                            foreach (var waypoint in Regex.Split(Regex.Replace(command, "WAYPOINTS ", "", RegexOptions.IgnoreCase), ";"))
                            {
                                int waypointId;
                                if (int.TryParse(Regex.Replace(waypoint, "=.*", ""), out waypointId))
                                {
                                    Geospatial.Location location;
                                    if (Geospatial.Location.TryParse(waypoint.Replace(waypointId + "=", ""), Geospatial.LocationStyles.Iso, CultureInfo.CurrentCulture, out location))
                                    {
                                        try
                                        {
                                            ListViewItem item = listViewWaypoints.Items.Add(waypointId.ToString());
                                            item.SubItems.Add(location.Latitude.ToString());
                                            item.SubItems.Add(location.Longitude.ToString());
                                            item.Tag = location;
                                        }
                                        catch
                                        {
                                        }
                                    }
                                }
                            }
                            listViewWaypoints.Sort();
                            foreach (ListViewItem item in listViewWaypoints.Items)
                            {
                                Geospatial.Location location = item.Tag as Geospatial.Location;
                                if (location != null)
                                {
                                    yachtList[yachtId].Waypoints.Add(location);
                                }
                            }
                            AddWaypoints();
                            break;
                        case "WINDANGLE":
                            if (yachtList != null)
                            {
                                yachtList[yachtId].WindAngle = (float)Convert.ToDouble(command.Replace("WINDANGLE ", ""));
                            }
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    switch (Regex.Replace(command, " .*", "").ToUpperInvariant())
                    {
                        case "YACHTS":
                            YachtItem currentlySelectedYacht = listBoxYachts.SelectedItem as YachtItem;
                            listBoxYachts.Items.Clear();
                            foreach (var item in Regex.Split(Regex.Replace(command, "YACHTS ", "", RegexOptions.IgnoreCase), ";"))
                            {
                                if (!string.IsNullOrEmpty(item))
                                {
                                    YachtItem yachtItem = new YachtItem(item);

                                    if (currentlySelectedYacht != null)
                                    {
                                        if (currentlySelectedYacht.Id == yachtItem.Id)
                                        {
                                            listBoxYachts.SelectedIndex = listBoxYachts.Items.Add(currentlySelectedYacht);
                                        }
                                        else
                                        {
                                            listBoxYachts.Items.Add(yachtItem);
                                            if (!yachtList.ContainsKey(yachtItem.Id))
                                            {
                                                try
                                                {
                                                    yachtList.Add(yachtItem.Id, yachtItem);
                                                }
                                                catch
                                                {
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        listBoxYachts.Items.Add(yachtItem);
                                        if (!yachtList.ContainsKey(yachtItem.Id))
                                        {
                                            try
                                            {
                                                yachtList.Add(yachtItem.Id, yachtItem);
                                            }
                                            catch
                                            {
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        case "REMOVED":
                            int id = Convert.ToInt32(command.Replace("REMOVED ", ""));
                            if (yachtList.ContainsKey(id))
                            {
                                yachtList.Remove(id);
                            }
                            fvLayer.DeleteAllObjects(fvLayerHandle);
                            fvLayer.Refresh(fvLayerHandle);
                            break;
                        default:
                            break;
                    }
                }
            }
            catch
            {
            }
        }