示例#1
0
        private void GenerateCAMLQuery()
        {
            System.Text.StringBuilder sb = new StringBuilder();
            sb.Append("<Where>");
            try
            {
                int count = this.QueryString.Count;

                string curFieldName = string.Empty;
                int    goodCount    = 0;
                for (int i = 0; i < count - 1; i++)
                {
                    curFieldName = QueryString.Keys[i];
                    if (curFieldName != null && this.List.Fields.TryGetFieldByStaticName(curFieldName) != null)
                    {
                        goodCount++;
                    }
                }

                for (int i = 0; i < goodCount - 1; i++)
                {
                    curFieldName = QueryString.Keys[i];
                    if (curFieldName != null && this.List.Fields.TryGetFieldByStaticName(curFieldName) != null)
                    {
                        sb.Append("<And>");
                    }
                }

                int index = 1;
                foreach (string part in QueryString.AllKeys)
                {
                    curFieldName = part;
                    if (part != null && this.List.Fields.TryGetFieldByStaticName(curFieldName) != null)
                    {
                        sb.Append("<Contains><FieldRef Name='" + part + "' /><Value Type='Text'>" + QueryString[part] + "</Value></Contains>");
                        if (count >= 2 && index > 1)
                        {
                            sb.Append("</And>");
                        }
                        index++;
                    }
                }
            }
            catch (Exception ex)
            {
                LogEngine.Log(ex, "Accessible Lists - FilterEngine");
            }
            sb.Append("</Where>");
            this._CAMLQuery = sb.ToString();
        }
示例#2
0
        public static string RenderField(string fieldValue, SPField field)
        {
            System.Text.StringBuilder sb = new StringBuilder();
            try
            {
                SPFieldType type = field.Type;
                switch (type)
                {
                // Nik20121108 - Handles both Hyperlink and Images
                case (SPFieldType.URL):
                    if (((SPFieldUrl)field).DisplayFormat == SPUrlFieldFormatType.Image)
                    {
                        string imageUrl    = fieldValue.Split(',')[0].Trim();
                        string imageAltTag = fieldValue.Split(',')[1].Trim();
                        sb.AppendLine("<div class=\"wet-boew-lightbox\">");
                        sb.AppendLine("<ul>");
                        sb.AppendLine("<li style=\"list-style-type:none !important;\">");
                        sb.AppendLine("<a class=\"lb-item\" href=\"" + imageUrl + "\" title=\"" + imageAltTag + "\" style=\"list-style-type:none !important;\">");
                        sb.AppendLine("<img class=\"image-actual\" src=\"" + imageUrl + "\" alt=\"" + imageAltTag + "\" style=\"list-style-type:none !important;\" />");
                        sb.AppendLine("</a>");
                        sb.AppendLine("</li>");
                        sb.AppendLine("</ul>");
                        sb.AppendLine("</div>");
                    }
                    else
                    {
                        sb.AppendLine("<a href=\"" + fieldValue.Split(',')[0] + "\">" + fieldValue.Split(',')[1] + "</a>");
                    }
                    break;

                case (SPFieldType.Text):
                case (SPFieldType.Note):
                case (SPFieldType.Number):
                    sb.AppendLine(fieldValue);
                    break;

                case (SPFieldType.DateTime):
                    if (((SPFieldDateTime)field).DisplayFormat == SPDateTimeFieldFormatType.DateOnly)
                    {
                        sb.AppendLine(fieldValue.Split(' ')[0]);
                    }
                    else
                    {
                        sb.AppendLine(fieldValue);
                    }
                    break;

                case (SPFieldType.Calculated):
                    fieldValue = fieldValue.Replace("string;#", "").Replace("datetime;#", "").Replace("number;#", "");
                    sb.AppendLine(fieldValue);
                    break;

                default:
                    sb.AppendLine(fieldValue);
                    break;
                }
            }
            catch (Exception ex)
            {
                LogEngine.Log(ex, "Accessible Lists");
            }

            return(sb.ToString());
        }