Beispiel #1
0
        public string[] GetColumnsFromCookie(string cookieName, string columnsDelimiter)
        {
            string[] cols = null;

            CookieManager cookieManager = CookieManager.Instance();

            CookieCollection cookieCollection = cookieManager.GetCookieCollectionByUserId(_connectionId);

            if (cookieCollection == null)
            {
                GenerateColumnsToBeDisplayed(null);
                cookieCollection = cookieManager.GetCookieCollectionByUserId(_connectionId);
            }

            Cookie cookieColumnNames;

            if (cookieCollection[cookieName] == null)
            {
                GenerateColumnsToBeDisplayed(null);
            }

            cookieColumnNames = cookieCollection[cookieName];

            if (cookieColumnNames != null)
            {
                cols = cookieColumnNames.Value.Split(new string[] { columnsDelimiter }, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                MyLogger.Write("GetColumnsFromCookie - Cookie does not exist: " + cookieName, "GetCatalogues", LoggingCategory.Warning);
            }

            return(cols);
        }
Beispiel #2
0
        public void AddNewCookie(string CookieName, string CookieValue)
        {
            string myZillaUrl = MyZillaSettingsDataSet.GetInstance().GetUrlForConnection(_connectionId);
            string domain     = myZillaUrl.Substring(myZillaUrl.IndexOf("://") + 3).TrimEnd('/');

            CookieManager.Instance().AddNewCookieToCookieCollection(_connectionId, new Cookie(CookieName, CookieValue, "", domain));
        }
Beispiel #3
0
 public bool ContainsCookie(string CookieName)
 {
     return(CookieManager.Instance().CookieCollectionContainsCookieByUserId(CookieName, _connectionId));
 }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="htmlContent"></param>
        public void ParseHtmlForColumnListValues(object htmlContent)
        {
            string content = htmlContent.ToString();

            int startFormIndex = content.IndexOf("<form action=\"colchange.cgi\"");

            if (startFormIndex >= 0)
            {
                int endFormIndex = content.IndexOf("</form>", startFormIndex);

                string formXML = content.Substring(startFormIndex, endFormIndex + "</form>".Length - startFormIndex - 1);

                Hashtable labels = new Hashtable();

                string cookieValue    = String.Empty;
                string cookieValueAll = String.Empty;
                string delim          = String.Empty;

                int index = formXML.IndexOf("<input type=\"checkbox\"");

                while (index > 0)
                {
                    int    endIndex           = formXML.IndexOf(">", index);
                    string input              = GetStringBetween(formXML, "<input type=\"checkbox\"", ">", index, true);//formXML.Substring(index, endIndex - index + 1);
                    string nameAttributeValue = GetStringBetween(input, "name=\"", "\"", 0, false);
                    string isChecked          = GetStringBetween(input, "checked=\'", "\'", 0, false);
                    nameAttributeValue = nameAttributeValue.Replace("column_", String.Empty);

                    if (isChecked != null && isChecked.Length > 0)
                    {
                        //isChecked can have values: 0-not used, 1-used and visible, 2-used but invisible

                        isChecked    = "1";
                        cookieValue += delim + nameAttributeValue;

                        if (cookieValue.Length > 0)
                        {
                            delim = "%20";
                        }
                    }
                    else
                    {
                        if (nameAttributeValue == "bug_severity")
                        {
                            cookieValue += delim + nameAttributeValue;
                            isChecked    = "2";
                        }
                        else
                        {
                            isChecked = "0";
                        }
                    }

                    index = formXML.IndexOf("<label for=", endIndex);
                    string forAttributeValue = GetStringBetween(formXML, "for=\"", "\"", index, false);
                    string forText           = GetStringBetween(formXML, "\">", "</label>", index, false);
                    labels.Add(forAttributeValue, forText.TrimEnd(new char[] { ' ', '\n' }));

                    cookieValueAll += labels[nameAttributeValue] + "&" + nameAttributeValue;

                    cookieValueAll += "&" + isChecked + "@";

                    index = formXML.IndexOf("<input type=\"checkbox\"", index);
                }

                bool bugSeverityIsVisible = (cookieValue.IndexOf("bug_severity") >= 0);

                if (!bugSeverityIsVisible)
                {
                    cookieValue += "bug_severity";
                }

                string myZillaUrl = MyZillaSettingsDataSet.GetInstance().GetUrlForConnection(_connectionId);
                string domain     = myZillaUrl.Substring(myZillaUrl.IndexOf("://") + 3).TrimEnd('/');

                if (!CookieManager.Instance().CookieCollectionContainsCookieByUserId("COLUMNLIST", _connectionId))
                {
                    CookieManager.Instance().AddNewCookieToCookieCollection(_connectionId, new Cookie("COLUMNLIST", cookieValue, "", domain));
                }
                CookieManager.Instance().AddNewCookieToCookieCollection(_connectionId, new Cookie("COLUMNLISTALL", cookieValueAll, "", domain));
            }

            return;
        }