Exemplo n.º 1
0
        public override string ToString()
        {
            string strUserID = "XX";

            if (UserIDLogedIn.HasValue && UserIDLogedIn.Value != Constants.ANONYMOUS_USERID.ToGuid())
            {
                strUserID = string.Concat("X", UserIDLogedIn);
            }

            System.Text.StringBuilder sb = new System.Text.StringBuilder(string.Format("OT{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}", (int)ObjectType, strUserID, (int)SortBy, CommunityID, UserID, TagID, (int)Direction, (int)QuerySourceType));

            if (SortBySecond != QuickSort.NotSorted)
            {
                sb.AppendFormat("-SS{0}_{1}", (int)SortBySecond, (int)DirectionSecond);
            }

            if (Featured != null)
            {
                sb.AppendFormat("-B{0}", Featured.Value);
            }

            if (WithCopy != null)
            {
                sb.AppendFormat("-C{0}", WithCopy.Value ? "1" : "0");
            }

            if (ObjectStatus != null)
            {
                sb.AppendFormat("-D1{0}", (int)ObjectStatus.Value);
            }

            if (ShowState != null)
            {
                sb.AppendFormat("-D2{0}", (int)ShowState.Value);
            }

            if (FromInserted != null)
            {
                sb.AppendFormat("-E{0}", FromInserted.Value.Date.Ticks);
            }

            if (ToInserted != null)
            {
                sb.AppendFormat("-F{0}", ToInserted.Value.Date.Ticks);
            }

            if (FromStartDate != null)
            {
                sb.AppendFormat("-G1{0}", FromStartDate.Value.Date.Ticks);
            }

            if (ToStartDate != null)
            {
                sb.AppendFormat("-G2{0}", ToStartDate.Value.Date.Ticks);
            }

            if (FromEndDate != null)
            {
                sb.AppendFormat("-H1{0}", FromEndDate.Value.Date.Ticks);
            }

            if (ToEndDate != null)
            {
                sb.AppendFormat("-H2{0}", ToEndDate.Value.Date.Ticks);
            }

            if (DateQueryMethode != null)
            {
                sb.AppendFormat("-I{0}", (int)DateQueryMethode.Value);
            }

            if (!string.IsNullOrEmpty(Country))
            {
                sb.AppendFormat("-J{0}", Country.ToLower());
            }

            if (!string.IsNullOrEmpty(Zip))
            {
                sb.AppendFormat("-K{0}", Zip.ToLower());
            }

            if (!string.IsNullOrEmpty(City))
            {
                sb.AppendFormat("-L{0}", City.ToLower());
            }

            if (DistanceKm != null && GeoLat != null && GeoLong != null)
            {
                sb.AppendFormat("-M{0}({1}{2})", DistanceKm.Value, GeoLat.Value, GeoLong.Value);
            }

            if (!string.IsNullOrEmpty(ParentObjectID))
            {
                sb.AppendFormat("-N{0}", ParentObjectID);
            }

            if (CheckUserRoleRight)
            {
                sb.AppendFormat("-O{0}", UserRole.ToLower());
            }

            if (PageSize > 0 || Amount > 0)
            {
                sb.AppendFormat("-P{0}", string.Format("{0}.{1}.{2}", PageNumber, PageSize, Amount));
            }

            if (!string.IsNullOrEmpty(Communities))
            {
                sb.AppendFormat("-R{0}", Communities.ToLower());
            }

            if (!string.IsNullOrEmpty(Tags1))
            {
                sb.AppendFormat("-S1{0}", Tags1.ToLower());
            }
            if (!string.IsNullOrEmpty(RawTags1))
            {
                sb.AppendFormat("-SR1{0}", RawTags1.ToLower());
            }

            if (!string.IsNullOrEmpty(Tags2))
            {
                sb.AppendFormat("-S2{0}", Tags2.ToLower());
            }
            if (!string.IsNullOrEmpty(RawTags2))
            {
                sb.AppendFormat("-SR2{0}", RawTags2.ToLower());
            }

            if (!string.IsNullOrEmpty(Tags3))
            {
                sb.AppendFormat("-S3{0}", Tags3.ToLower());
            }
            if (!string.IsNullOrEmpty(RawTags3))
            {
                sb.AppendFormat("-SR3{0}", RawTags3.ToLower());
            }

            if (!string.IsNullOrEmpty(ObjectTypes))
            {
                sb.AppendFormat("-T{0}", ObjectTypes.ToLower());
            }

            if (GroupID.HasValue)
            {
                sb.AppendFormat("-X1{0}", GroupID.Value);
            }

            if (CatalogSearchType != DBCatalogSearchType.None)
            {
                sb.AppendFormat("-X2{0}", (int)CatalogSearchType);
            }

            if (DisablePaging.HasValue)
            {
                sb.AppendFormat("-X3{0}", DisablePaging.Value ? "1" : "0");
            }

            if (CurrentObjectID.HasValue)
            {
                sb.AppendFormat("-XC4{0}", CurrentObjectID.Value);
            }

            if (ObjectID.HasValue)
            {
                sb.AppendFormat("-XO4{0}", ObjectID.Value);
            }

            if (OnlyConverted.HasValue)
            {
                sb.AppendFormat("-X5{0}", OnlyConverted.Value ? "1" : "0");
            }

            if (OnlyWithImage.HasValue)
            {
                sb.AppendFormat("-X6{0}", OnlyWithImage.Value ? "1" : "0");
            }

            if (IncludeGroups.HasValue)
            {
                sb.AppendFormat("-X7{0}", IncludeGroups.Value ? "1" : "0");
            }

            if (OnlyGeoTagged.HasValue)
            {
                sb.AppendFormat("-X8{0}", OnlyGeoTagged.Value ? "1" : "0");
            }

            if (!string.IsNullOrEmpty(nickname))
            {
                sb.AppendFormat("-X9{0}", nickname.ToLower());
            }

            if (!string.IsNullOrEmpty(title))
            {
                sb.AppendFormat("-X10{0}", title.ToLower());
            }

            if (!string.IsNullOrEmpty(description))
            {
                sb.AppendFormat("-X11{0}", description.ToLower());
            }

            if (!string.IsNullOrEmpty(userSearch))
            {
                sb.AppendFormat("-X12{0}", userSearch.ToLower());
            }

            if (!string.IsNullOrEmpty(generalSearch))
            {
                sb.AppendFormat("-X13{0}", generalSearch.ToLower());
            }

            if (!string.IsNullOrEmpty(oTypes))
            {
                sb.AppendFormat("-X14{0}", oTypes.ToLower());
            }

            if (!string.IsNullOrEmpty(cties))
            {
                sb.AppendFormat("-X15{0}", cties.ToLower());
            }

            if (!string.IsNullOrEmpty(titleLeftChar))
            {
                sb.AppendFormat("-X16{0}", titleLeftChar.ToLower());
            }

            if (!string.IsNullOrEmpty(excludeObjectIds))
            {
                sb.AppendFormat("-X17{0}", excludeObjectIds);
            }

            if (RelationParams != null)
            {
                sb.AppendFormat("-RP{0}", RelationParams.ToString());
            }

            if (MembershipParams != null)
            {
                sb.AppendFormat("-MP{0}", MembershipParams.ToString());
            }

            if (ViewLogParams != null)
            {
                sb.AppendFormat("-LP{0}", ViewLogParams.ToString());
            }



            //public ViewLogParams ViewLogParams { get; set; }


            return(sb.ToString());
        }
Exemplo n.º 2
0
        public virtual void FromNameValueCollection(NameValueCollection collection)
        {
            if (!string.IsNullOrEmpty(collection["OT"]))
            {
                ObjectType = Helper.GetObjectTypeNumericID(collection["OT"]);
            }
            if (!string.IsNullOrEmpty(collection["OTS"]))
            {
                ObjectType  = 0;
                ObjectTypes = QuickParameters.GetDelimitedObjectTypeIDs(collection["OTS"], ',');
            }
            string paramCtyId = string.Empty;

            if (collection["XCN"] != null)
            {
                paramCtyId = collection["XCN"];
            }
            else if (!string.IsNullOrEmpty(collection["CN"]))
            {
                paramCtyId = collection["CN"];
            }
            if (!string.IsNullOrEmpty(paramCtyId))
            {
                if (!paramCtyId.IsGuid())
                {
                    CommunityID = DataObjectCommunity.GetCommunityIDByVirtualURL(paramCtyId);
                }
                else
                {
                    CommunityID = paramCtyId.ToGuid();
                }
            }
            if (!string.IsNullOrEmpty(collection["CNS"]))
            {
                CommunityID = null;
                Communities = QuickParameters.GetDelimitedCommunityIDs(collection["CNS"], ',');
            }

            string paramUserId = string.Empty;

            if (collection["XUI"] != null)
            {
                paramUserId = collection["XUI"];
            }
            else if (!string.IsNullOrEmpty(collection["UI"]))
            {
                paramUserId = collection["UI"];
            }
            if (!string.IsNullOrEmpty(paramUserId))
            {
                if (!paramUserId.IsGuid())
                {
                    UserID = DataObjectUser.GetUserIDByNickname(paramUserId);
                }
                else
                {
                    UserID = paramUserId.ToGuid();
                }
            }

            if (!string.IsNullOrEmpty(collection["TG"]))
            {
                TagID = HttpUtility.UrlDecode(collection["TG"]).ToNullableGuid();
            }
            if (!string.IsNullOrEmpty(collection["TGL1"]))
            {
                TagID    = null;
                RawTags1 = collection["TGL1"];
                Tags1    = QuickParameters.GetDelimitedTagIds(HttpUtility.UrlDecode(collection["TGL1"]), ',');
            }
            if (!string.IsNullOrEmpty(collection["TGL2"]))
            {
                TagID    = null;
                RawTags2 = collection["TGL2"];
                Tags2    = QuickParameters.GetDelimitedTagIds(HttpUtility.UrlDecode(collection["TGL2"]), ',');
            }
            if (!string.IsNullOrEmpty(collection["TGL3"]))
            {
                TagID    = null;
                RawTags3 = collection["TGL3"];
                Tags3    = QuickParameters.GetDelimitedTagIds(HttpUtility.UrlDecode(collection["TGL3"]), ',');
            }

            if (!string.IsNullOrEmpty(collection["SO"]))
            {
                SortBy = (QuickSort)Enum.Parse(typeof(QuickSort), collection["SO"], true);
            }
            if (!string.IsNullOrEmpty(collection["SD"]))
            {
                Direction = (QuickSortDirection)Enum.Parse(typeof(QuickSortDirection), collection["SD"], true);
            }

            if (!string.IsNullOrEmpty(collection["SO2"]))
            {
                SortBySecond = (QuickSort)Enum.Parse(typeof(QuickSort), collection["SO2"], true);
            }
            if (!string.IsNullOrEmpty(collection["SD2"]))
            {
                DirectionSecond = (QuickSortDirection)Enum.Parse(typeof(QuickSortDirection), collection["SD2"], true);
            }

            if (!string.IsNullOrEmpty(collection["AM"]))
            {
                int temp;
                if (int.TryParse(collection["AM"], out temp))
                {
                    amount = temp;
                }
            }
            if (!string.IsNullOrEmpty(collection["PN"]))
            {
                int.TryParse(collection["PN"], out pageNumber);
            }
            if (!string.IsNullOrEmpty(collection["PS"]))
            {
                int.TryParse(collection["PS"], out pageSize);
                pageSize = Math.Min(pageSize, 100);
            }
            if (!string.IsNullOrEmpty(collection["SS"]))
            {
                ShowState = (ObjectShowState)Enum.Parse(typeof(ObjectShowState), collection["SS"], true);
            }
            if (!string.IsNullOrEmpty(collection["FI"]))
            {
                DateTime formInserted;
                if (DateTime.TryParse(collection["FI"], out formInserted))
                {
                    fromInserted = formInserted;
                }
            }
            if (!string.IsNullOrEmpty(collection["TI"]))
            {
                DateTime toInserted;
                if (DateTime.TryParse(collection["TI"], out toInserted))
                {
                    this.toInserted = toInserted;
                }
            }
            if (!string.IsNullOrEmpty(collection["FE"]))
            {
                int featured;
                if (int.TryParse(collection["FE"], out featured))
                {
                    this.featured = featured;
                }
            }
            if (!string.IsNullOrEmpty(collection["WC"]))
            {
                bool withCopy;
                if (bool.TryParse(collection["WC"], out withCopy))
                {
                    this.withCopy = withCopy;
                }
            }
            if (!string.IsNullOrEmpty(collection["FS"]))
            {
                DateTime fromStartDate;
                if (DateTime.TryParse(collection["FS"], out fromStartDate))
                {
                    this.fromStartDate = fromStartDate;
                }
            }
            if (!string.IsNullOrEmpty(collection["TS"]))
            {
                DateTime toEndDate;
                if (DateTime.TryParse(collection["TS"], out toEndDate))
                {
                    this.toEndDate = toEndDate;
                }
            }
            if (!string.IsNullOrEmpty(collection["TSD"]))
            {
                DateTime toStartDate;
                if (DateTime.TryParse(collection["TSD"], out toStartDate))
                {
                    this.toStartDate = toStartDate.GetStartOfDay();
                }
            }
            if (!string.IsNullOrEmpty(collection["FED"]))
            {
                DateTime fromEndDate;
                if (DateTime.TryParse(collection["FED"], out fromEndDate))
                {
                    this.fromEndDate = fromEndDate.GetEndOfDay();
                }
            }
            if (!string.IsNullOrEmpty(collection["DM"]))
            {
                DateQueryMethode = (QuickDateQueryMethode)Enum.Parse(typeof(QuickDateQueryMethode), collection["DM"], true);
            }
            if (!string.IsNullOrEmpty(collection["CO"]))
            {
                Country = collection["CO"];
            }
            if (!string.IsNullOrEmpty(collection["ZP"]))
            {
                Zip = collection["ZP"];
            }
            if (!string.IsNullOrEmpty(collection["CI"]))
            {
                City = HttpUtility.UrlDecode(collection["CI"]);
            }
            if (!string.IsNullOrEmpty(collection["GC"]))
            {
                string[] coordsList = collection["GC"].Split(new char[] { ',' });
                if (coordsList.Length == 2)
                {
                    GeoLat  = float.Parse(coordsList[0]);
                    GeoLong = float.Parse(coordsList[1]);
                }
            }
            if (!string.IsNullOrEmpty(collection["DI"]))
            {
                DistanceKm = float.Parse(collection["DI"]);
            }
            if (!string.IsNullOrEmpty(collection["OC"]))
            {
                bool onlyConverted;
                if (bool.TryParse(collection["OC"], out onlyConverted))
                {
                    this.onlyConverted = onlyConverted;
                }
            }
            if (!string.IsNullOrEmpty(collection["OI"]))
            {
                bool onlyWithImage;
                if (bool.TryParse(collection["OI"], out onlyWithImage))
                {
                    this.onlyWithImage = onlyWithImage;
                }
            }
            if (!string.IsNullOrEmpty(collection["NI"]))
            {
                Nickname = HttpUtility.UrlDecode(collection["NI"]);
            }
            if (!string.IsNullOrEmpty(collection["TL"]))
            {
                Title = HttpUtility.UrlDecode(collection["TL"]);
            }
            if (!string.IsNullOrEmpty(collection["DE"]))
            {
                Description = HttpUtility.UrlDecode(collection["DE"]);
            }
            if (!string.IsNullOrEmpty(collection["SU"]))
            {
                UserSearch = HttpUtility.UrlDecode(collection["SU"]);
            }
            if (!string.IsNullOrEmpty(collection["IG"]))
            {
                bool boolVal;
                if (bool.TryParse(collection["IG"], out boolVal))
                {
                    IncludeGroups = boolVal;
                }
            }
            if (!string.IsNullOrEmpty(collection["IC"]))
            {
                bool boolVal;
                if (bool.TryParse(collection["IC"], out boolVal))
                {
                    IgnoreCache = boolVal;
                }
            }
            if (!string.IsNullOrEmpty(collection["GT"]))
            {
                bool boolVal;
                if (bool.TryParse(collection["GT"], out boolVal))
                {
                    OnlyGeoTagged = boolVal;
                }
            }
            if (!string.IsNullOrEmpty(collection["SG"]))
            {
                GeneralSearch = HttpUtility.UrlDecode(collection["SG"]);
            }

            if (!string.IsNullOrEmpty(collection["OID"]))
            {
                ObjectID = collection["OID"].ToGuid();
            }

            if (!string.IsNullOrEmpty(collection["COID"]))
            {
                CurrentObjectID = collection["COID"].ToGuid();
            }

            if (!string.IsNullOrEmpty(collection["RPID"]))
            {
                if (RelationParams == null)
                {
                    RelationParams = new RelationParams();
                }
                RelationParams.ParentObjectID = collection["RPID"].ToGuid();
            }
        }