Ejemplo n.º 1
0
    private void Page_Load(System.Object sender, System.EventArgs e)
    {
        this.CreateChildControls();
            m_refMsg = m_refContentApi.EkMsgRef;
            RegisterResources();
            if (Request.QueryString["action"] != null)
            {
                if (Request.QueryString["action"] != "")
                {
                    m_strPageAction = Convert.ToString(Request.QueryString["action"]).ToLower().Trim();
                }
            }
            if (Request.QueryString["folder_id"] != null)
            {
                if (Request.QueryString["folder_id"] != "")
                {
                    m_intFolderId = Convert.ToInt64(Request.QueryString["folder_id"]);
                }
            }
            if (Request.QueryString["form_id"] != null)
            {
                if (Request.QueryString["form_id"] != "")
                {
                    m_intFormId = Convert.ToInt64(Request.QueryString["form_id"]);
                }
            }
            if (Request.QueryString["LangType"] != null)
            {
                if (Request.QueryString["LangType"] != "")
                {
                    ContentLanguage = Convert.ToInt32(Request.QueryString["LangType"]);
                    m_refContentApi.SetCookieValue("LastValidLanguageID", ContentLanguage.ToString());
                }
                else
                {
                    if (m_refContentApi.GetCookieValue("LastValidLanguageID") != "")
                    {
                        ContentLanguage = Convert.ToInt32(m_refContentApi.GetCookieValue("LastValidLanguageID"));
                    }
                }
            }
            else
            {
                if (m_refContentApi.GetCookieValue("LastValidLanguageID") != "")
                {
                    ContentLanguage = Convert.ToInt32(m_refContentApi.GetCookieValue("LastValidLanguageID"));
                }
            }
            if (ContentLanguage == Ektron.Cms.Common.EkConstants.CONTENT_LANGUAGES_UNDEFINED)
            {
                m_refContentApi.ContentLanguage = Ektron.Cms.Common.EkConstants.ALL_CONTENT_LANGUAGES;
            }
            else
            {
                m_refContentApi.ContentLanguage = ContentLanguage;
            }
            m_refModule = m_refContentApi.EkModuleRef;
            CurrentUserId = m_refContentApi.UserId;
            AppImgPath = m_refContentApi.AppImgPath;
            EnableMultilingual = m_refContentApi.EnableMultilingual;
            VerifyTrue = "<img src=\"" + m_refContentApi.AppPath + "images/UI/Icons/check.png\" border=\"0\" alt=\"Enabled\" title=\"Enabled\" />";
            VerifyFalse = "<img src=\"" + AppImgPath + "icon_redx.gif\" border=\"0\" alt=\"Disabled\" title=\"Disabled\" />";

            EmailArea.Text = m_refMailMsg.EmailJS();
            EmailArea.Text += m_refMailMsg.MakeEmailArea();
    }
Ejemplo n.º 2
0
    private void Page_Load(System.Object sender, System.EventArgs e)
    {
        //Make sure the user is logged in. If not forward user to login page.
        if ((m_refContentApi.EkContentRef).IsAllowed(0, 0, "users", "IsLoggedIn", m_refContentApi.UserId) == false)
        {
            string strUrl;
            Session["RedirectLnk"] = Request.Url.AbsoluteUri;
            strUrl = "login.aspx?fromLnkPg=1";
            this.Response.ContentType = "";
            this.Response.Redirect(strUrl, true);
        }

        //Put user code to initialize the page here
        int ContentLanguage = m_refContentApi.ContentLanguage;
        if (!(Request.QueryString["LangType"] == null))
        {
            if (Request.QueryString["LangType"] != "")
            {
                ContentLanguage = Convert.ToInt32(Request.QueryString["LangType"]);
                m_refContentApi.SetCookieValue("LastValidLanguageID", ContentLanguage.ToString());
            }
            else
            {
                if (m_refContentApi.GetCookieValue("LastValidLanguageID") != "")
                {
                    ContentLanguage = Convert.ToInt32(m_refContentApi.GetCookieValue("LastValidLanguageID"));
                }
            }
        }
        else
        {
            if (m_refContentApi.GetCookieValue("LastValidLanguageID") != "")
            {
                ContentLanguage = Convert.ToInt32(m_refContentApi.GetCookieValue("LastValidLanguageID"));
            }
        }
        if (ContentLanguage == (int)Ektron.Cms.Common.EkConstants.CONTENT_LANGUAGES_UNDEFINED)
        {
            m_refContentApi.ContentLanguage = Ektron.Cms.Common.EkConstants.ALL_CONTENT_LANGUAGES;
        }
        else
        {
            m_refContentApi.ContentLanguage = ContentLanguage;
        }
        if (!(Request.QueryString["fieldname"] == null))
        {
            FieldName = Request.QueryString["fieldname"];
        }
        QueryLang = ContentLanguage.ToString();
        if (!(Request.QueryString["qlang"] == null))
        {
            QueryLang = Request.QueryString["qlang"];
        }
        if (!String.IsNullOrEmpty(Request["form_id"]))
        {
            FormId = Convert.ToInt64(Request["form_id"]);
        }
        StartDate = Request["start_date"];
        EndDate = Request["end_date"];
        Flag = Request["flag"];
        DataType = Request["data_type"];
        ResultType = Request["result_type"];
        CurrentUserId = m_refContentApi.UserId;
        DisplayType = Request["display_type"];
        FormTitle = Request["form_title"];
        m_refMsg = m_refContentApi.EkMsgRef;
        Security_info = m_refContentApi.LoadPermissions(FormId, "content", 0);
        Response.AddHeader("content-disposition", "attachment; filename=Form_Data_Export.xls");
        objForm = m_refContentApi.EkModuleRef;
        gtForms = objForm.GetAllFormInfo();

        Collection objFormData = new Collection();
        Collection cDatas;
        objFormData.Add(FormId, "FORM_ID", null, null);
        objFormData.Add(CurrentUserId, "USER_ID", null, null);
        objFormData.Add(StartDate, "START_DATE", null, null);
        objFormData.Add(EndDate, "END_DATE", null, null);
        objFormData.Add(QueryLang, "Query_Language", null, null);
        objFormData.Add(FieldName, "Field_Name", null, null);
        cDatas = objForm.GetAllFormData(objFormData);
        if (cDatas.Count == 0)
        {
            FormResult.Text = "<table><tr><td>" + m_refMsg.GetMessage("msg no data report") + "</td></tr></table>";
            return;
        }

        if (Information.IsNumeric(DisplayType))
        {
            //The following lines of code are extracted from dotnetjohn.com on "Export DataSets to Excel"
            //http://www.dotnetjohn.com/articles.aspx?articleid=36
            //first let's clean up the response.object
            Response.Clear();
            Response.Charset = "";
            //set the response mime type for excel
            Response.ContentType = "application/vnd.ms-excel";
            //create a string writer
            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            //create an htmltextwriter which uses the stringwriter
            System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
            //instantiate a datagrid
            DataGrid dg = new DataGrid();
            //set the datagrid datasource to the dataset passed in
            dg.DataSource = objForm.GetAllFormRawData(objFormData).Tables[0];
            //bind the datagrid
            dg.DataBind();
            //tell the datagrid to render itself to our htmltextwriter
            dg.RenderControl(htmlWrite);
            //all that's left is to output the html
            Response.Write(stringWrite.ToString());
            Response.End();
        }
        else
        {
            FormResult.Text = LoadResult(objFormData, cDatas);
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        MsgHelper = AppUI.EkMsgRef;
        m_refLib = AppUI.EkLibraryRef;
        CurrentUserId = AppUI.UserId;
        AppImgPath = (string)AppUI.AppImgPath;
        sitePath = AppUI.SitePath;
        AppName = AppUI.AppName;
        AppeWebPath = AppUI.AppeWebPath;
        AppPath = (string)AppUI.AppPath;
        EnableMultilingual = AppUI.EnableMultilingual;
        catid = Convert.ToInt64(Request.QueryString["catid"]);
        if (AppUI.ContentLanguage == -1)
        {
            AppUI.ContentLanguage = Convert.ToInt32(AppUI.GetCookieValue("DefaultLanguage"));
        }

        if (!string.IsNullOrEmpty(Request.QueryString["LangType"]))
        {
            ContentLanguage = Convert.ToInt32(Request.QueryString["LangType"]);
            AppUI.SetCookieValue("LastValidLanguageID", Convert.ToString(ContentLanguage));
        }
        else
        {
            if (AppUI.GetCookieValue("LastValidLanguageID").ToString() != "")
            {
                ContentLanguage = System.Convert.ToInt32(AppUI.GetCookieValue("LastValidLanguageID"));
            }
        }
        AppUI.ContentLanguage = ContentLanguage;

        RI = AppUI.RequestInformationRef;
        RI.CallerId = Convert.ToInt64(Request.QueryString["uid"]);
        RI.CookieSite = Request.QueryString["siteid"];
        RI.UserId = Convert.ToInt64(Request.QueryString["uid"]);
        m_refContent = new EkContent(RI);
        m_refLib = new Ektron.Cms.Library.EkLibrary(RI);
        m_refModule = new Ektron.Cms.Modules.EkModule(RI);

        action = Strings.Trim(Request.QueryString["action"]);

        if (action == "logintest")
        {
            username = Request.QueryString["u"];
            password = Request.QueryString["p"];
            domain = Request.QueryString["d"];
            Login(username, password, domain);
        }
        else if (action == "categories")
        {
            string[] TestArray = new string[] { };
            object loopnumber;
            loopnumber = 0;
            foldertype = Request.QueryString["foldertype"];
            cFolders = m_refContent.GetFolderInfov2_0(0);
            OutputContentFolders("", 0, ref TestArray);
            if (ErrString != "")
            {
                Response.Write("<count>" + ((TestArray.Length - 1) - 0 + "</count>"));
            }
            else
            {
                if (foldertype == "all")
                {
                    Response.Write("<count>" + ((TestArray.Length - 1) - 0 + 1) + "</count>");
                    Response.Write("<catid>0</catid><catname>\\</catname>");
                }
                else
                {
                    Response.Write("<count>" + ((TestArray.Length - 1) - 0 - 1) + "</count>");
                }

            }
            for (int g = 0; g <= (TestArray.Length - 1) - 1; g++)
            {
                Response.Write(TestArray[g]);
            }

        }
        else if (action == "content")
        {
            Collection cTmp = new Collection();
            int intTotalPages = 0;
            object[] ContentArray;
            ContentArray = new object[1];
            loopcount = 0;
            cTmp.Add(catid, "FolderID", null, null);
            cTmp.Add("Title", "OrderBy", null, null);
            EkContentCol datacCol = m_refContent.GetAllViewableChildContentInfoV5_0(cTmp, 1, 0, ref intTotalPages);
            foreach (ContentBase item in datacCol)
            {
                Array.Resize(ref ContentArray, loopcount + 1 + 1);
                ContentArray[loopcount] = "<id>" + item.Id + "</id>" + "<title>" + item.Title + "</title>";
                loopcount++;
            }
            Response.Write("<count>" + ((ContentArray.Length - 1) - 0 + "</count>"));
            for (int h = 0; h <= (ContentArray.Length - 1) - 1; h++)
            {
                Response.Write(ContentArray[h]);
            }
        }
        else if (action == "collections")
        {
            string orderby = "title";
            NavArray = new object[1];
            loopcount = 0;
            gtNavs = m_refContent.GetAllCollectionsInfo(catid, orderby);
            foreach (Collection tempLoopVar_gtNav in (IEnumerable)gtNavs)
            {
                gtNav = tempLoopVar_gtNav;
                Array.Resize(ref NavArray, loopcount + 1 + 1);
                NavArray[loopcount] = "<id>" + gtNav["CollectionID"] + "</id>" + "<title>" + gtNav["CollectionTitle"] + "</title>";
                loopcount++;
            }
            Response.Write("<count>" + ((NavArray.Length - 1) - 0 + "</count>"));
            for (int h = 0; h <= (NavArray.Length - 1) - 1; h++)
            {
                Response.Write(NavArray[h]);
            }
            gtNavs = null;
        }
        else if (action == "collections_all")
        {
            NavArray = new object[1];
            loopcount = 0;
            uid = Convert.ToInt64(Request.QueryString["uid"]);
            siteid = Request.QueryString["siteid"];
            gtNavs = m_refContent.GetCollectionsReport(ref ErrorString);
            foreach (Collection tempLoopVar_gtNav in (IEnumerable)gtNavs)
            {
                gtNav = tempLoopVar_gtNav;
                Array.Resize(ref NavArray, loopcount + 1 + 1);
                NavArray[loopcount] = "<id>" + gtNav["CollectionID"] + "</id>" + "<title>id=" + gtNav["CollectionID"] + ", " + gtNav["CollectionTitle"] + "</title>";
                loopcount++;
            }
            Response.Write("<count>" + ((NavArray.Length - 1) - 0 + "</count>"));
            for (int h = 0; h <= (NavArray.Length - 1) - 1; h++)
            {
                Response.Write(NavArray[h]);
            }
            gtNavs = null;
        }
        else if (action == "calendar")
        {
            NavArray = new object[1];
            loopcount = 0;
            gtNavs = m_refModule.GetAllCalendarInfo();
            foreach (Collection tempLoopVar_gtNav in (IEnumerable)gtNavs)
            {
                gtNav = tempLoopVar_gtNav;
                Array.Resize(ref NavArray, loopcount + 1 + 1);
                NavArray[loopcount] = "<id>" + gtNav["CalendarID"] + "</id>" + "<title>id=" + gtNav["CalendarID"] + ", " + gtNav["CalendarTitle"] + "</title>";
                loopcount++;
            }
            Response.Write("<count>" + ((NavArray.Length - 1) - 0 + "</count>"));
            for (int h = 0; h <= (NavArray.Length - 1) - 1; h++)
            {
                Response.Write(NavArray[h]);
            }
            gtNavs = null;
        }
        else if (action == "ecmforms")
        {
            object gtForms;

            NavArray = new object[1];
            loopcount = 0;
            gtForms = m_refModule.GetAllFormInfo();

            foreach (Collection gtForm in (IEnumerable)gtForms)
            {
                Array.Resize(ref NavArray, loopcount + 1 + 1);
                NavArray[loopcount] = "<id>" + gtForm["FormID"] + "</id>" + "<title>id=" + gtForm["FormID"] + ", " + gtForm["FormTitle"] + "</title>";
                loopcount++;
            }
            Response.Write("<count>" + ((NavArray.Length - 1) - 0 + "</count>"));
            for (int h = 0; h <= (NavArray.Length - 1) - 1; h++)
            {
                Response.Write(NavArray[h]);
            }
            gtNavs = null;
        }
        else if (action == "editcontent")
        {
            Collection cEContent;
            object myxmlstring;
            object PageInfo;
            object myhtmlcontent;
            object stylesheetpath = null;
            object mywhynoteditstring;
            Collection canI;

            PageInfo = "src=\"http://" + Request.ServerVariables["Server_name"] + "/";
            cid = Convert.ToInt64(Request.QueryString["cid"]);

            canI = m_refContent.CanIv2_0(cid, "content");
            if (Convert.ToBoolean(canI["CanIEdit"]))
            {
                cEContent = m_refContent.GetContentForEditingv2_0(cid);
                myhtmlcontent = cEContent["ContentHtml"];
                if (Strings.Trim((string)(cEContent["StyleSheet"])) != "")
                {
                    stylesheetpath = "http://" + Convert.ToString(Request.ServerVariables["Server_name"]) + sitePath + cEContent["StyleSheet"];
                }
                myxmlstring = "<ektron_head_html><!--   Do not remove these xml tags <ektron_head><ektron_edit>yes</ektron_edit><ektron_content_id>" + cid + "</ektron_content_id> <ektron_title>" + cEContent["ContentTitle"] + "</ektron_title> <ektron_content_comment>" + cEContent["Comment"] + "</ektron_content_comment> <ektron_content_stylesheet>" + stylesheetpath + "</ektron_content_stylesheet> <ektron_folder_id>" + cEContent["FolderID"] + "</ektron_folder_id> <ektron_content_language>" + cEContent["ContentLanguage"] + "</ektron_content_language> <ektron_go_live>" + cEContent["GoLive"] + "</ektron_go_live> <ektron_end_date>" + cEContent["EndDate"] + "</ektron_end_date> <ektron_MetadataNumber>" + ((Collection)cEContent["ContentMetadata"]).Count + "</ektron_MetadataNumber> <ektron_PreviousState>" + cEContent["CurrentContentStatus"] + "</ektron_PreviousState> <ektron_iMaxContLength>" + cEContent["MaxContentSize"] + "</ektron_iMaxContLength> <ektron_content_Path>" + cEContent["Path"] + "</ektron_content_Path></ektron_head> --> </ektron_head_html> ";
                myxmlstring = myxmlstring + "<ektron_body_html>" + myhtmlcontent + "</ektron_body_html>";
            }
            else
            {
                if (Convert.ToString(canI["ContentState"]) == "CheckedOut")
                {
                    mywhynoteditstring = "You can not edit this cotent, content is checked out to: " + canI["UserName"];
                }
                else
                {
                    mywhynoteditstring = "You can not edit this this content.  The content state is:  " + canI["ContentState"] + "; The user is " + canI["UserName"];
                }
                myxmlstring = "<ektron_head_html><!--   <ektron_edit>" + mywhynoteditstring + "</ektron_edit> --></ektron_head_html>";
            }
            Response.Write(myxmlstring);
            canI = null;

        }
        else if (action == "publish_update_content")
        {
            ErrorString = "";
            myerrormsg = "";
            cid = Convert.ToInt64(Request.QueryString["cid"]);

            Collection cCont = m_refContent.GetContentByIDv2_0(cid);

            cCont.Remove("ContentHtml");
            cCont.Add(Strings.Replace(Request.Form["ContentHTML"], "<myektronand/>", "&", 1, -1, 0), "ContentHtml", null, null);
            cCont.Remove("ContentTitle");
            cCont.Add(Request.Form["content_title"], "ContentTitle", null, null);
            cCont.Remove("Comment");
            cCont.Add(Request.Form["content_comment"], "Comment", null, null);
            cCont.Remove("ContentID");
            cCont.Add(Request.Form["ektron_content_id"], "ContentID", null, null);
            cCont.Remove("FolderID");
            cCont.Add(Request.Form["folder"], "FolderID", null, null);
            cCont.Remove("ContentLanguage");
            cCont.Add(Request.Form["ektron_content_language"], "ContentLanguage", null, null);
            //cCont.Remove("SearchText")
            cCont.Add(Strings.Replace(Request.Form["searchhtml"], "<myektronand/>", "&", 1, -1, 0), "SearchText", null, null);
            cCont.Remove("GoLive");
            cCont.Add(Request.Form["go_live"], "GoLive", null, null);
            cCont.Remove("EndDate");
            cCont.Add(Request.Form["end_date"], "EndDate", null, null);
            cCont.Remove("ContentType");
            cCont.Add(1, "ContentType", null, null);
            cCont.Remove("LockedContentLink");
            cCont.Add(true, "LockedContentLink", null, null);

            try
            {
                ret = m_refContent.SaveContentv2_0(cCont);
                if (ErrorString != "")
                {
                    myerrormsg = ErrorString;
                }
                else
                {
                    ContentID = Convert.ToInt64(Request.Form["ektron_content_id"]);
                    ret = m_refContent.CheckIn(ContentID, "");
                    if (ErrorString != "")
                    {
                        myerrormsg = ErrorString;
                    }
                    else
                    {
                        if (ret == false)
                        {
                            ret = m_refContent.SubmitForPublicationv2_0(ContentID, Convert.ToInt64(Request.Form["ektron_folder_id"]), 0, "");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                myerrormsg = ex.Message.ToString();
            }

            if (myerrormsg != "")
            {
                Response.Write(myerrormsg);
            }
            else
            {
                Response.Write("Content has been saved");
            }

        }
        else if (action == "add_new_content")
        {
            cCont = new Collection();
            try
            {
                cCont.Add((object)Strings.Replace(Convert.ToString(Request.Form["ContentHTML"]), "<myektronand/>", "&", 1, -1, 0), "ContentHtml", null, null);
                cCont.Add(Request.Form["content_title"], "ContentTitle", null, null);
                cCont.Add(Request.Form["content_comment"], "Comment", null, null);
                cCont.Add(System.Convert.ToInt32(Request.Form["folder"]), "FolderID", null, null);
                cCont.Add(Request.Form["ektron_content_language"], "ContentLanguage", null, null);
                cCont.Add(Strings.Replace(Request.Form["searchhtml"], "<myektronand/>", "&", 1, -1, 0), "SearchText", null, null);
                cCont.Add(Request.Form["go_live"], "GoLive", null, null);
                cCont.Add(Request.Form["end_date"], "EndDate", null, null);
                cCont.Add(true, "AddToQlink", null, null);
                cCont.Add(1, "ContentType", null, null);

                ErrorString = "";
                ContentID = m_refContent.AddNewContentv2_0(cCont);
            }
            catch (Exception ex)
            {
                ErrorString = ex.Message.ToString();
            }
            if (ErrorString != "")
            {
                myerrormsg = ErrorString;
            }
            else
            {
                ret = m_refContent.CheckIn(ContentID, "");
                if (ErrorString != "")
                {
                    myerrormsg = " Error CheckIn= " + ErrorString;
                }
                else
                {
                    if (ret == false)
                    {
                        ret = m_refContent.SubmitForPublicationv2_0(ContentID, Convert.ToInt64(Request.Form["ektron_folder_id"]), 0, "");
                        if (ErrorString != "")
                        {
                            myerrormsg = "Error SubmitForPublicationv2_0= " + ErrorString;
                        }
                    }
                }
            }
            if (myerrormsg != "")
            {
                Response.Write(myerrormsg);
            }
            else
            {
                Response.Write("Content has been saved");
            }

        }
        else if (action == "foldertypexml")
        {
            long folderid;
            folderid = Convert.ToInt64(Request.Form["folderid"]);
            myFolders = m_refContent.GetFolderInfov2_0(folderid, false, false);
            if (((Collection)myFolders["XmlConfiguration"]).Count == 0)
            {
                Response.Write("<XmlConfiguration>no</XmlConfiguration>");
            }
            else
            {
                Response.Write("<XmlConfiguration>yes</XmlConfiguration>");
            }
            myFolders = null;
        }
        else if (action == "canIsave")
        {
            cid = Convert.ToInt64(Request.Form["cid"]);

            cConts = m_refContent.GetContentByIDv2_0(cid);
            UserRights = m_refContent.CanIv2_0(cid, "content");
            if (Convert.ToString(cConts["ContentStatus"]) == "O" && Convert.ToBoolean(UserRights["CanIEdit"]))
            {
                Response.Write("<canISave>yes</canISave>");
            }
            else
            {
                if (Convert.ToString(cConts["ContentStatus"]) == "O")
                {
                    Response.Write("<canISave>Did not save!!!!,  Check out by " + Convert.ToString(UserRights["UserName"]) + "</canISave>");
                }
                else
                {
                    Response.Write("<canISave>Did not save!!!  Content is not checked out to you, Its status is Status=" + Convert.ToString(cConts["ContentStatus"]) + " The user associated with this is " + Convert.ToString(UserRights["UserName"]) + "</canISave>");
                }
            }

        }
        else if (action == "AddFolder")
        {
            object bRet1;
            object tmpPath;
            Collection libSettings;
            cFolder = new Collection();
            cFolder.Add(Request.Form["foldername"], "FolderName", null, null);
            cFolder.Add(Request.Form["folderdescription"], "FolderDescription", null, null);
            cFolder.Add(Request.Form["ParentID"], "ParentID", null, null);
            cFolder.Add(Request.Form["templatefilename"], "TemplateFileName", null, null);
            cFolder.Add(Request.Form["stylesheet"], "StyleSheet", null, null);
            libSettings = m_refLib.GetLibrarySettingsv2_0();

            tmpPath = libSettings["ImageDirectory"];
            cFolder.Add(getPhysicalPath(tmpPath), "AbsImageDirectory", null, null);
            tmpPath = libSettings["FileDirectory"];
            cFolder.Add(getPhysicalPath(tmpPath), "AbsFileDirectory", null, null);
            libSettings = null;
            bRet1 = addLBpaths(cFolder, uid, siteid);
            cFolder.Add(true, "XmlInherited", null, null);
            cFolder.Add(0, "XmlConfiguration", null, null);
            cFolder.Add(1, "InheritMetadata", null, null); //break inherit button is check.
            cFolder.Add(0, "InheritMetadataFrom", null, null);
            ret = m_refContent.AddContentFolderv2_0(ref cFolder);
            Response.Write("Folder added");
        }
        else if (action == "metadata")
        {
            int loopcounter = 0;
            object cMetadataTypes;
            object[] MetaDataArray;
            MetaDataArray = new object[1];
            cMetadataTypes = m_refContent.GetMetadataTypes("Name");
            foreach (Collection cMetadataType in (IEnumerable)cMetadataTypes)
            {
                Array.Resize(ref MetaDataArray, loopcounter + 1 + 1);
                MetaDataArray[loopcounter] = "<meta>" + (cMetadataType["MetaTypeName"]) + "</meta>";
                loopcounter++;
            }
            Response.Write("<count>" + ((MetaDataArray.Length - 1) - 0 + "</count>"));
            for (int j = 0; j <= (MetaDataArray.Length - 1) - 1; j++)
            {
                Response.Write(MetaDataArray[j]);
            }
        }
        else if (action == "ecmmenus")
        {
            object FolderID;
            FolderID = 0;
            Response.Write(GetMenuList(FolderID.ToString(), "Title"));
        }
        else if (action == "ecmxmconfig")
        {
            Response.Write(GetXmlConfigurationList(""));
        }
        else if (action == "ecmlanguages")
        {
            Response.Write(GetLanguages());
        }
        else
        {
            Response.Write("DreamWeaver - No Action parameter");
        }
    }
Ejemplo n.º 4
0
    private void Page_Load(System.Object sender, System.EventArgs e)
    {
        //Put user code to initialize the page here
            int i;

            int lMapWidth = 600;
            int lMapHeight = 500;
            string strRptDisplay = "0";
            System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 10, FontStyle.Bold);
            Graphics objGraphics;
            int xPos = 200;
            int yPos = 300;
            int xInterval = 20;
            decimal dbPercent = 0;
            StringFormat SF = new StringFormat();
            SF.FormatFlags = StringFormatFlags.DirectionVertical;
            string[] arrValues = null;
            string[] arrFieldValues = null;
            string[] aTotalCount = null;
            string[] strFolderNames;
            string[] arrValueNames = new string[2];
            string strFromPage = "";
            string[] strFieldOptionNames = null;
            string[] strFieldNames = null;
            int arrValuesLength = 0;
            bool bShowPercent = false;
            PointF symbolLeg;
            PointF descLeg;
            int xDimension = 200;
            int yDimension = 200;
            long FormId;
            ArrayList arrItem;
            Collection cForm;
            ArrayList arrResult = new ArrayList();
            Hashtable hshQuestions = new Hashtable();
            int llResponses = 1;

            if (Request.QueryString["showLabels"] == null)
            {

                if (!(Request.QueryString["grpdisplay"] == null))
                {
                    strRptDisplay = Request.QueryString["grpdisplay"];
                    if (strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.Combined)))
                    {
                        bShowPercent = true;
                    }
                }

                if (!(Request.QueryString["form_page"] == null))
                {
                    strFromPage = Request.QueryString["form_page"];
                    FormId = System.Convert.ToInt64(Request.QueryString["FormId"]);
                    llResponses = System.Convert.ToInt32(Request.QueryString["responses"]);
                    if (strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.Pie)))
                    {
                        //the total will be re-calculated for the pie chart below
                        llResponses = 0;
                    }
                    else if (llResponses < 1) //it causes mathematical error if llResponses is <= 0
                    {
                        llResponses = 1;
                    }
                    objMod = m_refContentApi.EkModuleRef;

                    //originally from the formresponse.aspx.vb
                    cForm = objMod.GetFormById(FormId); //collection
                    arrResult = m_refContentApi.GetFormDataHistogramById(FormId); //array
                    hshQuestions = m_refContentApi.GetFormFieldQuestionsById(FormId); //hashtable

                    //chart.Visible = True

                    // Now we have the data get the values
                    //For Each item In FormStats
                    //strNames = "18-21,22-25,26-30,31-40,41-50,51-60,61-over:10k-20k,21k-30k,31k-40k:High School,Some College,Degree(Associates),Master,Doctoral,Professional"
                    //strStale = "10,30,25,10,5,5,15:10,50,40:10,10,10,10,10,10"
                    //strFieldNames = "Age range:Annual Income:Education level"

                    //EktComma is used to retain the commas in the fields and field option names
                    int idx;
                    int j;
                    int iOptionHit = 0;

                    //questions array
                    if (hshQuestions.Count > 0 && arrResult.Count > 0)
                    {
                        strFieldNames = new string[arrResult.Count - 1 + 1];
                        for (idx = 0; idx <= arrResult.Count - 1; idx++)
                        {
                            arrItem = (ArrayList)arrResult[idx];
                            if (arrItem.Count > 0)
                            {
                                //sFieldNames = sFieldNames & ":" & hshQuestions(cItem.Item(0).ToString().Replace(",", "EktComma"))
                                strFieldNames[idx] = Ektron.Cms.Common.EkFunctions.HtmlDecode(hshQuestions[arrItem[0].ToString()].ToString());
                            }
                        }
                    }

                    string sSubmit;
                    int iSubmit;
                    int iMaxSubmit = 0;
                    arrItem = null;
                    //For Each cItem In cResult
                    if (arrResult.Count > 0)
                    {
                        strFieldOptionNames = new string[arrResult.Count - 1 + 1];
                        arrFieldValues = new string[arrResult.Count - 1 + 1];
                        aTotalCount = new string[arrResult.Count - 1 + 1];
                        for (idx = 0; idx <= arrResult.Count - 1; idx++)
                        {
                            arrItem = (ArrayList)arrResult[idx];
                            if (arrItem.Count > 1)
                            {
                                for (j = 1; j <= arrItem.Count - 1; j++)
                                {
                                    //option text list
                                    strFieldOptionNames[idx] = (string) (strFieldOptionNames[idx] + arrItem[j].ToString().Substring(0, System.Convert.ToInt32(arrItem[j].ToString().LastIndexOf(",") - 5)) + "{sep}"); //Count = 5 chars
                                    sSubmit = (string) (arrItem[j].ToString().Substring(System.Convert.ToInt32(arrItem[j].ToString().LastIndexOf(",") + 1)));
                                    iSubmit = int.Parse(sSubmit.ToString().Substring(System.Convert.ToInt32(sSubmit.ToString().IndexOf("/") + 1)));
                                    iOptionHit = int.Parse(sSubmit.ToString().Substring(0, sSubmit.ToString().IndexOf("/")));
                                    if (iSubmit > iMaxSubmit)
                                    {
                                        iMaxSubmit = iSubmit;
                                    }
                                    //iOptionHit = arrItem.Item(j).ToString().Substring(arrItem.Item(j).ToString().LastIndexOf(",") + 1)
                                    if (strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.Pie)))
                                    {
                                        //option count list
                                        aTotalCount[idx] = Convert.ToString(Convert.ToInt32(aTotalCount[idx]) + iOptionHit);
                                        arrFieldValues[idx] = (string) (arrFieldValues[idx] + iOptionHit + ",");
                                    }
                                    else
                                    {
                                        //option count (in percent) list
                                        arrFieldValues[idx] = (string) (arrFieldValues[idx] + System.Convert.ToInt32((iOptionHit * 100) / llResponses) + ",");
                                    }
                                    iOptionHit = 0;
                                }
                                //option text list
                                strFieldOptionNames[idx] = (string) (strFieldOptionNames[idx].Substring(0, System.Convert.ToInt32(strFieldOptionNames[idx].Length - 5))); // {sep} = 5 chars
                                //option count (in percent) list
                                arrFieldValues[idx] = (string) (arrFieldValues[idx].Substring(0, System.Convert.ToInt32(arrFieldValues[idx].Length - 1)));
                            }
                        }
                        //sFieldOptionNames = Server.UrlEncode(sFieldOptionNames.Substring(0, sFieldOptionNames.Length - 1))
                        //sFieldOptionValues = sFieldOptionValues.Substring(0, sFieldOptionValues.Length - 1)
                        arrValuesLength = arrItem.Count + arrResult.Count;
                    }
                }

                if (strFromPage == "")
                {
                    arrValueNames[0] = "Updated Content";
                    arrValueNames[1] = "Stale Content";
                    arrValues = Request.QueryString["stale"].Split(",".ToCharArray());
                    arrValuesLength = arrValues.Length;
                }

                if (strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.DataTable)))
                {
                    strFolderNames = Request.QueryString["names"].Split(",".ToCharArray());
                }
                else if (strFromPage == "form_page")
                {
                    //strFieldOptionNames = Server.UrlDecode(Request.QueryString("fieldOptionNames")).Split(":")
                    //strFieldNames = Server.UrlDecode(Request.QueryString("fieldNames")).Split(":")
                    //arrFieldValues = Request.QueryString("FormValues").Split(":") 'Values for multiple fields separated by :
                    //arrValuesLength = Request.QueryString("FormValues").Split(",").Length + strFieldNames.Length
                }

                if (strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.DataTable)))
                {
                    lMapWidth = System.Convert.ToInt32(220 + (arrValuesLength * 40) + (arrValuesLength - 1) * 20);
                    yPos = 400;
                    lMapHeight = yPos + 20;
                }

                if ((strRptDisplay == "0") || (strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.Combined))))
                {
                    lMapHeight = System.Convert.ToInt32(220 + (arrValuesLength * 40) + (arrValuesLength - 1) * 20);
                }

                int NumOfLegends = 0;

                if ((strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.Pie)) && (strFromPage == "form_page")))
                {
                    lMapWidth = System.Convert.ToInt32(750 + (40 * arrValuesLength) + 700);
                    //lMapHeight = (225 * strFieldNames.Length)  'give 500 as padding
                    for (i = 0; i <= arrFieldValues.GetUpperBound(0); i++)
                    {
                        NumOfLegends = NumOfLegends + arrFieldValues[i].Split(",".ToCharArray()).GetLength(0);
                        if ((20 * NumOfLegends) > 400)
                        {
                            lMapHeight = lMapHeight + ((20 * NumOfLegends) + 30);
                        }
                        else
                        {
                            lMapHeight = lMapHeight + 450;
                        }
                    }
                    //If (300 * strFieldNames.Length) > ((20 * NumOfLegends) + (40 * strFieldNames.Length)) Then
                    //    lMapHeight = 300 * strFieldNames.Length
                    //Else
                    //    lMapHeight = (20 * NumOfLegends) + (40 * strFieldNames.Length)
                    //End If
                    yPos = lMapHeight;
                }
                System.Drawing.Bitmap objBitMap = new System.Drawing.Bitmap(lMapWidth, lMapHeight);

                objGraphics = Graphics.FromImage(objBitMap);

                objGraphics.Clear(Color.White);

                if (strFromPage == "")
                {
                    objGraphics.DrawString("Stale Content Report", drawFont, Brushes.Black, new PointF(5, 5));

                    symbolLeg = new PointF(lMapWidth - 190, 20);

                    descLeg = new PointF(lMapWidth - 165, 16);

                    for (i = 0; i <= arrValueNames.Length - 1; i++)
                    {

                        objGraphics.FillRectangle(new SolidBrush(GetColor(i % 2)), symbolLeg.X, symbolLeg.Y, 10, 10);
                        objGraphics.DrawRectangle(Pens.Black, symbolLeg.X, symbolLeg.Y, 10, 10);

                        objGraphics.DrawString((string) (arrValueNames[i].ToString()), drawFont, Brushes.Black, descLeg);

                        symbolLeg.Y += 15;

                        descLeg.Y += 15;

                    }
                }
                //Loop through the values to create the Bar Chart.

                if (strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.DataTable)))
                {
                    int j;
                    xPos = 50;
                    for (i = 0; i <= arrValuesLength - 1; i++)
                    {
                        // Vertical display
                        objGraphics.DrawLine(Pens.Black, xPos, 50, xPos, yPos); // Vertical axis
                        objGraphics.DrawString("Percent Stale Content ->", drawFont, Brushes.Black, new PointF(xPos, 20), SF);
                        objGraphics.DrawLine(Pens.Black, xPos, yPos, xPos + lMapWidth, yPos); // Horizontal axis

                        objGraphics.DrawString("Content Folders ->", drawFont, Brushes.Black, new PointF(xPos + lMapWidth - 180, yPos));

                        for (j = 0; j <= 10; j++)
                        {
                            objGraphics.DrawLine(Pens.Black, xPos - 2, yPos - (30 * j), xPos + 2, yPos - (30 * j));
                            objGraphics.DrawString( Convert.ToString((10 * j)), drawFont, Brushes.Black, new PointF(xPos - 25, yPos - (30 * j) - 5));
                            //objGraphics.DrawString("Test", drawFont, Brushes.Black, New PointF(xPos - 50, yPos - (30 * j) - 5))
                        }

                        //objGraphics.DrawString("yPos = " & yPos & " x =" & xPos + xInterval, drawFont, Brushes.Black, New PointF(xPos + xInterval, yPos - dbPercent))

                        if (System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1))) > 0)
                        {
                            dbPercent = (decimal) (System.Math.Round(System.Convert.ToDouble(((System.Convert.ToDouble(arrValues[i].Substring(0, System.Convert.ToInt32(arrValues[i].IndexOf(":"))))) / (System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1))))) * 100), 3));
                        }
                        else
                        {
                            dbPercent = 0;
                        }

                        objGraphics.FillRectangle(new SolidBrush(GetColor(0)), xPos + xInterval, Convert.ToSingle(Convert.ToDecimal(yPos) - (dbPercent * 3)), 20, System.Convert.ToInt32(dbPercent * 3));
                        objGraphics.DrawRectangle(Pens.Black, xPos + xInterval, Convert.ToSingle(Convert.ToDecimal(yPos) - (dbPercent * 3)), 20, System.Convert.ToInt32(dbPercent * 3));

                        if (System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1))) > 0)
                        {
                            dbPercent = (decimal) (System.Math.Round(System.Convert.ToDouble((((System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1)))) - System.Convert.ToDouble(arrValues[i].Substring(0, System.Convert.ToInt32(arrValues[i].IndexOf(":"))))) / (System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1))))) * 100), 3));
                        }

                        xInterval = xInterval + 20;
                        objGraphics.FillRectangle(new SolidBrush(GetColor(1)), xPos + xInterval, Convert.ToSingle(Convert.ToDecimal(yPos) - (dbPercent * 3)), 20, System.Convert.ToInt32(dbPercent * 3));
                        objGraphics.DrawRectangle(Pens.Black, xPos + xInterval,Convert.ToSingle(yPos), 20, System.Convert.ToInt32(dbPercent * 3));
                        //objGraphics.DrawString(strFolderNames(i).Substring(strFolderNames(i).LastIndexOf("\\") + 2), drawFont, Brushes.Black, New PointF(xPos + xInterval, yPos), SF)
                        xInterval = xInterval + 40;
                    }
                }
                else if ((strRptDisplay == "0") || ((strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.Combined))) && (strFromPage == "form_page")))
                {
                    // Horizontal display
                    if (strFromPage == "form_page")
                    {
                        int j;
                        bool bShowAxis = false;
                        //Dim dScale As Double

                        if (!(Request.QueryString["showAxis"] == null))
                        {
                            bShowAxis = System.Convert.ToBoolean(Request.QueryString["showAxis"]);
                        }

                        //If Not (Request.QueryString("scale") Is Nothing) Then
                        //    dScale = CDbl(Request.QueryString("scale"))
                        //End If

                        lMapHeight = yPos + (arrValuesLength * 40) + (arrValuesLength * 20);
                        //yPos = lMapHeight - 300
                        yPos = 20;
                        xPos = 0;
                        //objGraphics.DrawString("Responses - " & Request.QueryString("responses"), drawFont, Brushes.Black, New PointF(xPos + 100, yPos - 20))

                        for (j = 0; j <= strFieldOptionNames.Length - 1; j++)
                        {

                            strFolderNames = System.Text.RegularExpressions.Regex.Split((string) (strFieldOptionNames[j].ToString()), "{sep}");
                            arrValues = arrFieldValues[j].Split(",".ToCharArray());

                            //objGraphics.DrawString(strFieldNames(j).Replace("EktComma", ","), drawFont, Brushes.Black, New PointF(xPos + 50, yPos + 10)) ' The Bar title below the x axis
                            objGraphics.DrawString(strFieldNames[j], drawFont, Brushes.Black, new PointF(xPos + 50, yPos + 10)); // The Bar title below the x axis
                            yPos = yPos + 15;
                            if (bShowAxis)
                            {
                                objGraphics.DrawLine(Pens.Black, xPos, yPos + (arrValues.Length) * 40, xPos, yPos); // Vertical axis
                                objGraphics.DrawLine(Pens.Black, xPos, yPos + (arrValues.Length) * 40, xPos + lMapWidth, yPos + (arrValues.Length) * 40); // Horizontal axis

                                for (i = 0; i <= 10; i++)
                                {
                                    objGraphics.DrawLine(Pens.Black, xPos + (30 * i), System.Convert.ToInt32((yPos + (arrValues.Length) * 40) - 2), xPos + (30 * i), System.Convert.ToInt32((yPos + (arrValues.Length) * 40) + 2));
                                    objGraphics.DrawString( Convert.ToString((10 * i)), drawFont, Brushes.Black, new PointF(xPos + (30 * i), yPos + (arrValues.Length) * 40));
                                }
                            }
                            yPos = yPos + xInterval;
                            //xInterval = xInterval + (30 * arrValues.Length)
                            for (i = 0; i <= arrValues.Length - 1; i++)
                            {
                                //strFolderNames(i) = strFolderNames(i).ToString().Replace("EktComma", ",")
                                strFolderNames[i] = (string) (strFolderNames[i].ToString());
                                dbPercent = (decimal) (System.Math.Round(double.Parse(arrValues[i]), 3)); //* dScale (?)
                                objGraphics.FillRectangle(new SolidBrush(GetColor(i % 24)), xPos, yPos, System.Convert.ToInt32(dbPercent), 10);
                                objGraphics.DrawRectangle(Pens.Black, xPos, yPos, System.Convert.ToInt32(dbPercent), 10);
                                if (objGraphics.MeasureString(strFolderNames[i], drawFont).Width > xDimension)
                                {
                                    xDimension = System.Convert.ToInt32(objGraphics.MeasureString(strFolderNames[i], drawFont).Width);
                                }
                                if (bShowPercent)
                                {
                                    objGraphics.DrawString((string) (Ektron.Cms.Common.EkFunctions.HtmlDecode(strFolderNames[i]) + " (" + dbPercent.ToString() + "%)"), drawFont, Brushes.Black, new PointF(xPos, (yPos + 10)));
                                }
                                else
                                {
                                    objGraphics.DrawString(Ektron.Cms.Common.EkFunctions.HtmlDecode(strFolderNames[i]), drawFont, Brushes.Black, new PointF(xPos, yPos + 10));
                                }
                                //xInterval = xInterval - 30
                                yPos = yPos + 30;
                            }
                            //yPos = yPos + xInterval + 30
                            yPos = yPos + 10;
                            //xInterval = 20
                        }
                        yDimension = yPos;
                    }
                    else
                    {
                        lMapHeight = yPos + (arrValuesLength * 40) + (arrValuesLength * 20);
                        yPos = lMapHeight - 200;

                        objGraphics.DrawLine(Pens.Black, xPos, 50, xPos, yPos); // Vertical axis
                        objGraphics.DrawLine(Pens.Black, xPos, yPos, xPos + lMapWidth, yPos); // Horizontal axis
                        objGraphics.DrawString("Content Folders ->", drawFont, Brushes.Black, new PointF(xPos - 20, 10), SF);
                        objGraphics.DrawString("Percent Stale Content ->", drawFont, Brushes.Black, new PointF(lMapWidth - 180, yPos + 15));

                        for (i = 0; i <= 10; i++)
                        {
                            objGraphics.DrawLine(Pens.Black, xPos + (30 * i), yPos - 2, xPos + (30 * i), yPos + 2);
                            objGraphics.DrawString( Convert.ToString((10 * i)), drawFont, Brushes.Black, new PointF(xPos + (30 * i), yPos));
                        }

                        for (i = 0; i <= arrValuesLength - 1; i++)
                        {
                            if (System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1))) > 0)
                            {
                                dbPercent = (decimal) (System.Math.Round(System.Convert.ToDouble(((System.Convert.ToDouble(arrValues[i].Substring(0, System.Convert.ToInt32(arrValues[i].IndexOf(":"))))) / (System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1))))) * 100), 3));
                            }
                            else
                            {
                                dbPercent = 0;
                            }

                            objGraphics.FillRectangle(new SolidBrush(GetColor(0)), xPos, yPos - xInterval, System.Convert.ToInt32(dbPercent * 3), 20);
                            objGraphics.DrawRectangle(Pens.Black, xPos, yPos - xInterval, System.Convert.ToInt32(dbPercent * 3), 20);

                            if (System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1))) > 0)
                            {
                                dbPercent = (decimal) (System.Math.Round(System.Convert.ToDouble((((System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1)))) - System.Convert.ToDouble(arrValues[i].Substring(0, System.Convert.ToInt32(arrValues[i].IndexOf(":"))))) / (System.Convert.ToDouble(arrValues[i].Substring(System.Convert.ToInt32(arrValues[i].IndexOf(":") + 1))))) * 100), 3));
                            }

                            xInterval = xInterval + 20;
                            objGraphics.FillRectangle(new SolidBrush(GetColor(1)), xPos, yPos - xInterval, System.Convert.ToInt32(dbPercent * 3), 20);
                            objGraphics.DrawRectangle(Pens.Black, xPos, yPos - xInterval, System.Convert.ToInt32(dbPercent * 3), 20);

                            //objGraphics.DrawString(strFolderNames(i), drawFont, Brushes.Black, New PointF(xPos - 100, yPos - xInterval))
                            xInterval = xInterval + 40;
                        }
                    }

                }
                else if (strRptDisplay == Convert.ToString(Convert.ToInt32(Ektron.Cms.Common.EkEnumeration.CMSFormReportType.Pie)))
                {
                    float sglCurrentAngle = 0;
                    float sglTotalAngle = 0;
                    int llTotal = 0;
                    int j;
                    int idx;
                    int xMax = 0;
                    int yMax = 0;
                    decimal dPercent = (decimal) 0.0;
                    decimal dTotalCheck = (decimal) 0.0;
                    int QuestionBoxHeight = 15;
                    yPos = 0;
                    xPos = 0;
                    //objGraphics.DrawString("Responses - " & Request.QueryString("responses"), drawFont, Brushes.Black, New PointF(xPos + 100, yPos + 5))
                    if (strFieldOptionNames.Length > 0)
                    {
                        strFolderNames = new string[strFieldOptionNames.Length - 1 + 1];
                        for (j = 0; j <= strFieldOptionNames.Length - 1; j++)
                        {
                            strFolderNames = System.Text.RegularExpressions.Regex.Split((string) (strFieldOptionNames[j].ToString()), "{sep}");
                            arrValues = arrFieldValues[j].Split(",".ToCharArray());
                            llTotal = 0;
                            for (i = 0; i <= arrValues.Length - 1; i++)
                            {
                                llTotal = Convert.ToInt32(llTotal) + Convert.ToInt32(arrValues[i]);
                            }
                            if (Convert.ToInt32(aTotalCount[j]) > 0)
                            {
                                QuestionBoxHeight = System.Convert.ToInt32(((System.Convert.ToInt32(strFieldNames[j].Length / 50)) + 1) * 20);
                                objGraphics.DrawString((string) (strFieldNames[j].Replace("EktComma", ",")), drawFont, Brushes.Black, new RectangleF(xPos, yPos, 320, QuestionBoxHeight));
                            }
                            //Dim test As Integer = yPos
                            for (i = 0; i <= arrValues.Length - 1; i++)
                            {

                                //Current Value / (sum of all the Values) * 360 degree angle
                                if ( Convert.ToInt32(aTotalCount[j]) < 1)
                                {
                                    break;
                                }
                                sglCurrentAngle = System.Convert.ToSingle(Convert.ToDouble(Convert.ToDouble(arrValues[i]) / Convert.ToDouble(llTotal)) * 360);
                                //yPos = yPos + (i * 200)
                                //objGraphics.FillPie(New SolidBrush(GetColor(i Mod 16)), xPos, yPos - 230, 200, 200, sglTotalAngle, sglCurrentAngle)
                                //objGraphics.DrawString(strFieldNames(j), drawFont, Brushes.Black, New PointF(xPos + 75, yPos - 275))
                                //objGraphics.DrawPie(Pens.Black, xPos, yPos - 230, 200, 200, sglTotalAngle, sglCurrentAngle)
                                objGraphics.FillPie(new SolidBrush(GetColor(i % 24)), xPos, yPos + QuestionBoxHeight, 200, 200, System.Convert.ToInt32(sglTotalAngle), System.Convert.ToInt32(sglCurrentAngle));
                                //objGraphics.DrawString(strFieldNames(j).Replace("EktComma", ","), drawFont, Brushes.Black, New PointF(xPos, yPos))
                                objGraphics.DrawPie(Pens.Black, xPos, yPos + QuestionBoxHeight, 200, 200, System.Convert.ToInt32(sglTotalAngle), System.Convert.ToInt32(sglCurrentAngle));
                                yMax = yPos + QuestionBoxHeight + 200;
                                //objGraphics.DrawLine(Pens.Blue, xPos + 100, yPos + 175, xPos + 200, yPos + 200)
                                //objGraphics.DrawString("center = ", drawFont, Brushes.Black, New PointF(xPos + 100, yPos + 175))
                                //objGraphics.DrawString("angle = " & sglCurrentAngle.ToString(), drawFont, Brushes.Black, New PointF(xPos, test))

                                //test = test + 20
                                sglTotalAngle += sglCurrentAngle;
                            }
                            yPos = yPos + QuestionBoxHeight;
                            symbolLeg = new PointF(xPos + 210, yPos);
                            descLeg = new PointF(xPos + 220, yPos);
                            arrValueNames = System.Text.RegularExpressions.Regex.Split(strFieldOptionNames[j], "{sep}");
                            //reset check total for the next set of results
                            dTotalCheck = (decimal) 0.0;
                            for (idx = 0; idx <= arrValueNames.Length - 1; idx++)
                            {
                                if ( Convert.ToInt32(aTotalCount[j]) < 1)
                                {
                                    //to avoid division overflow
                                    break;
                                }
                                objGraphics.FillRectangle(new SolidBrush(GetColor(idx % 24)), symbolLeg.X, symbolLeg.Y, 10, 10);
                                objGraphics.DrawRectangle(Pens.Black, symbolLeg.X, symbolLeg.Y, 10, 10);
                                if (xMax < objGraphics.MeasureString((string) (arrValueNames[idx].ToString().Replace("EktComma", ",") + " (" + arrValues[idx] + " %)"), drawFont).Width)
                                {
                                    xMax = System.Convert.ToInt32(objGraphics.MeasureString((string) (arrValueNames[idx].ToString().Replace("EktComma", ",") + " (" + arrValues[idx] + " %)"), drawFont).Width + 10);
                                }
                                dPercent = decimal.Round(Convert.ToDecimal( Convert.ToDouble(arrValues[idx]) /Convert.ToDouble(aTotalCount[j]) * 100), 2);
                                //correct the percentage so if the total is over 100
                                dTotalCheck = dTotalCheck + dPercent;
                                if ( Convert.ToDouble(dTotalCheck) > 100.0 && dPercent > 0)
                                {
                                    dPercent =  Convert.ToDecimal(Convert.ToDouble(dPercent) - (Convert.ToDouble(dTotalCheck) - 100.0));
                                    //reset check total for the current set of results
                                    dTotalCheck = (decimal) 100.0;
                                }
                                objGraphics.DrawString((string) (Ektron.Cms.Common.EkFunctions.HtmlDecode((string) (arrValueNames[idx].ToString().Replace("EktComma", ","))) + " (" + dPercent + " %)"), drawFont, Brushes.Black, descLeg);
                                symbolLeg.Y += 20;
                                descLeg.Y += 20;
                            }
                            yPos = System.Convert.ToInt32(descLeg.Y + 10);
                            if (yPos < yMax)
                            {
                                yPos = yMax;
                            }
                        }
                        if (yPos > yMax)
                        {
                            // more legends than the circle
                            yMax = yPos;
                        }
                        yDimension = yMax; //- 30 'lMapHeight - 30
                        xDimension = xMax + 200;
                    }
                }
                //Loop through the values to create the Pie Chart.
                if (strFromPage == "form_page")
                {
                    //Calculate exact dimensions
                    objGraphics.Dispose();
                    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(xDimension + 25, yDimension + 30);
                    objGraphics = Graphics.FromImage(bmp);
                    objGraphics.DrawImage(objBitMap, 0, 0, lMapWidth, lMapHeight);
                    bmp.Save(Response.OutputStream, ImageFormat.Gif);
                }
                else
                {
                    objBitMap.Save(Response.OutputStream, ImageFormat.Gif);
                }
            }
            else
            {
                string strFolder = "";
                strFolder = (string) (Request.QueryString["showLabels"].ToString());

                System.Drawing.Bitmap objBitMap = new System.Drawing.Bitmap(50, 200);

                objGraphics = Graphics.FromImage(objBitMap);
                objGraphics.Clear(Color.White);
                if (strFolder.Length > 20)
                {
                    strFolder = (string) (strFolder.Substring(0, 20) + "...");
                }

                objGraphics.DrawString(strFolder, drawFont, Brushes.Black, new PointF(0, 15), SF);
                objBitMap.Save(Response.OutputStream, ImageFormat.Gif);
            }
    }