예제 #1
0
    private void btExpand_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        int parentId = Convert.ToInt32(ddlParentList.SelectedValue);

        Trace.Warn("btExpand_Click and parentId = " + parentId.ToString());
        if (parentId >= 0)
        {
            BuildParent(ContainerGroup.GetByKey(parentId).Childs[0].Id);
        }
        else
        {
            using (ContainerGroupList cgAll = ContainerGroup.GetAll("ContainerGroupParentId = -1"))
            {
                BuildParent(cgAll[0].Id);
            }
        }
    }
예제 #2
0
        private void UpdateDataView()
        {
            string sSql = string.Empty;

            webTab.Visible = false;
            string filter = txtFilter.Text;

            if (filter != string.Empty)
            {
                string cleanFilter = filter.Replace("'", "''").ToLower();
                cleanFilter = cleanFilter.Replace("[", "[[]");
                cleanFilter = cleanFilter.Replace("_", "[_]");
                cleanFilter = cleanFilter.Replace("%", "[%]");

                sSql += " LOWER(ContainerGroup) like '%" + cleanFilter + "%'";
            }

            using (ContainerGroupList groups = ContainerGroup.GetAll(sSql))
            {
                if (groups != null)
                {
                    if (groups.Count > 0)
                    {
                        dg.DataSource = groups;
                        Utils.InitGridSort(ref dg, false);
                        dg.DataBind();

                        dg.Visible          = true;
                        lbNoresults.Visible = false;
                    }
                    else
                    {
                        if (txtFilter.Text.Length > 0)
                        {
                            lbNoresults.Text = "No record match your search (" + txtFilter.Text + ")";
                        }

                        dg.Visible          = false;
                        lbNoresults.Visible = true;
                    }

                    panelGrid.Visible = true;
                    lbTitle.Text      = UITools.GetTranslation("Container groups list");
                }
            }
        }
예제 #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="parentId"></param>
    /// <param name="id"></param>
    /// Can move or change an container group even if it has children: Decision business review 09/05/06
    private void BuildParent(int parentId)
    {
        Trace.Warn("BuildParent(" + parentId.ToString() + ")");
        Trace.Warn("  GroupId = " + groupId.ToString());
        ViewState["nbParents"] = 0;
        lParentName.Text       = string.Empty;
        bool           bCanMove = true;
        ContainerGroup cg       = ContainerGroup.GetByKey(groupId);
        // Retrieve container based on parentId parameter
        ContainerGroup     cgComboDisplayLevel = ContainerGroup.GetByKey(parentId);
        ContainerGroupList cgChildren          = null;

        ddlParentList.Items.Clear();
        if (cgComboDisplayLevel == null)
        {
            if (cg != null)
            {
                Trace.Warn("  cgComboDisplayLevel is null [#maxDepth =" + maxDepth.ToString() + ", cg.ChildDepth=" + cg.ChildDepth.ToString() + "]");
            }
            else
            {
                Trace.Warn("  cgComboDisplayLevel is null [#maxDepth =" + maxDepth.ToString() + ", cg is null]");
            }
            ddlParentList.Items.Clear();
            ddlParentList.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Root", "-1"));
            if (cg != null)
            {
                btExpand.Visible = maxDepth > cg.ChildDepth;
            }
            else
            {
                btExpand.Visible = maxDepth > 0;
            }
        }
        else
        {
            if (cg != null)
            {
                Trace.Warn("[cg.ChildDepth=" + cg.ChildDepth.ToString() + "]");
            }
            if (cgComboDisplayLevel.Parent == null)
            {
                using (ContainerGroupList cgAll = ContainerGroup.GetAll("ContainerGroupParentId = -1 and ContainersCount=0 AND ContainerGroupId <> " + groupId.ToString()))
                {
                    cgChildren = cgAll;
                }
            }
            else
            {
                cgChildren = cgComboDisplayLevel.Parent.Childs;
            }
            // If container group has children
            if (cgChildren != null && cgChildren.Count > 0)
            {
                ddlParentList.DataSource = cgChildren;
                ddlParentList.DataBind();
                // Remove the current item from the drop down list
                ddlParentList.Items.Remove(ddlParentList.Items.FindByValue(txtGroupId.Text));
                ddlParentList.Visible = ddlParentList.Items.Count > 0;
                if (cg == null) // User is creating a new container group
                {
                    ddlParentList.SelectedIndex = 0;
                }
                else
                {
                    // Select the current parent
                    if (ddlParentList.Items.FindByValue(cg.ParentId.ToString()) != null)
                    {
                        ddlParentList.SelectedValue = cg.ParentId.ToString();
                    }
                }
                int nbChilds = cgChildren[0].Childs.Count;
                foreach (ContainerGroup cgc in cgChildren[0].Childs)
                {
                    if (cgc.Id == groupId)
                    {
                        nbChilds--;
                        break;
                    }
                }
                btExpand.Visible = nbChilds > 0;
            }
            #region maxDepth
            // If the maxDepth < 0 impossible to add child to a container group
            if (maxDepth <= 0)
            {
                panelParent.Visible = false;
            }
            else
            {
                if (cgComboDisplayLevel != null)
                {
                    string[] parents   = cgComboDisplayLevel.Path.Split('/');
                    int      nbParents = parents.Length - 1;
                    ViewState["nbParents"] = nbParents;
                    if (btExpand.Visible)
                    {
                        btExpand.Visible = nbParents < maxDepth;
                    }
                }
            }
            #endregion
            #region Build Label path
            ContainerGroup cgParent = cgComboDisplayLevel.Parent;
            while (cgParent != null)
            {
                lParentName.Text = bCanMove ? "<A HREF=javascript:__doPostBack('Path','" + cgParent.Id.ToString() + "')>" + cgParent.Name + "</A>/" + lParentName.Text : cgParent.Name + "/" + lParentName.Text;
                if (cgParent.ParentId != -1)
                {
                    cgParent = cgParent.Parent;
                }
                else
                {
                    cgParent = null;
                }
            }
            lParentName.Text = bCanMove ? "<A HREF=javascript:__doPostBack('Path','-1')>Root</A>/" + lParentName.Text : "Root/" + lParentName.Text;
            if (parentId != -1)
            {
                lParentName.Visible = true;
            }
            else
            {
                lParentName.Visible = false;
            }
            #endregion
        }
    }
예제 #4
0
파일: Export.cs 프로젝트: GitJayanth/test3
        /// <summary>
        /// Export the containers List in Excel file
        /// </summary>
        /// <param name="page"></param>
        public static void ExportContainers(Page page)
        {
            using (CollectionView cv = new CollectionView(HyperCatalog.Business.Container.GetAll()))
            {
                cv.Sort("GroupId");

                using (CollectionView cvCG = new CollectionView(ContainerGroup.GetAll()))
                {
                    using (CollectionView cvCT = new CollectionView(ContainerType.GetAll()))
                    {
                        using (CollectionView cvDT = new CollectionView(DataType.GetAll()))
                        {
                            using (CollectionView cvU = new CollectionView(User.GetAll()))
                            {
                                using (CollectionView cvLG = new CollectionView(LookupGroup.GetAll()))
                                {
                                    using (CollectionView cvIM = new CollectionView(InheritanceMethod.GetAll()))
                                    {
                                        // string contains html code to export
                                        System.Text.StringBuilder sb = new System.Text.StringBuilder(string.Empty);

                                        sb.Append("<html><body>");
                                        sb.Append("<table border='1'>");
                                        /******** Writing the User info and Current date ***********/
                                        int ColCount = 28;
                                        sb.Append("<tr style='border: none' valign='top'><td style='font-weight:bold;font-size: 14;border: none; font-family:Arial Unicode MS' colspan=" + ColCount + ">" + "Container Report" + "</td></tr>");
                                        sb.Append("<tr style='border: none' valign='top'><td style='font-weight:bold;border: none; font-size: 14; font-family:Arial Unicode MS'>Generated By: </td><td style='border: none; font-size: 14; font-family:Arial Unicode MS' colspan=" + (ColCount - 1).ToString() + ">" + SessionState.User.FullName + "</td></tr>");
                                        sb.Append("<tr style='border: none' valign='top'><td style='font-weight:bold;border: none; font-size: 14;font-family:Arial Unicode MS'>Exported On: </td><td style='border: none ;font-size: 14; font-family:Arial Unicode MS' colspan=" + (ColCount - 1).ToString() + ">" + SessionState.User.FormatUtcDate(DateTime.UtcNow, true, "MM/dd/yyyy:HH:mm:ss") + "</td></tr>");



                                        #region "Header"

                                        sb.Append("<tr style='font-size: 14; font-weight: bold;font-family:Arial Unicode MS background-color: lightgrey' wordwrap='true'>");
                                        sb.Append("<td>Id</td>");
                                        sb.Append("<td>Container group</td>");
                                        sb.Append("<td>xmlname</td>");
                                        sb.Append("<td>Name</td>");
                                        sb.Append("<td>Label</td>");
                                        sb.Append("<td>Definition</td>");
                                        sb.Append("<td>Entry rule</td>");
                                        sb.Append("<td>Sample</td>");
                                        sb.Append("<td>Data type</td>");
                                        sb.Append("<td>Container type</td>");
                                        sb.Append("<td>Lookup</td>");
                                        sb.Append("<td>Input mask</td>");
                                        sb.Append("<td>Max length</td>");
                                        sb.Append("<td>Translatable</td>");
                                        sb.Append("<td>Regionalizable</td>");
                                        sb.Append("<td>Localizable</td>");
                                        sb.Append("<td>Publishable</td>");
                                        sb.Append("<td>Readonly</td>");
                                        sb.Append("<td>Keep if obsolete</td>");
                                        sb.Append("<td>Inheritance method</td>");
                                        sb.Append("<td>Sort</td>");
                                        sb.Append("<td>Segment</td>");
                                        sb.Append("<td>ValidationMask</td>");
                                        sb.Append("<td>WWXPath</td>");
                                        sb.Append("<td>Creator</td>");
                                        sb.Append("<td>Create date</td>");
                                        sb.Append("<td>Modifier</td>");
                                        sb.Append("<td>Modifier date</td>");
                                        sb.Append("</tr>");
                                        #endregion

                                        string cellColor = "#D0D0D0", defaultCellColor = "#D0D0D0";
                                        for (int i = 0; i < cv.Count; i++)
                                        {
                                            Container curContainer = ((Container)cv[i]);
                                            sb.Append("<tr valign='top' style='font-size: 14; font-family:Arial Unicode MS;background-color: " + cellColor + ";text-color: black;'>");
                                            sb.Append("<td>" + curContainer.Id + "</td>");
                                            //********************************************************************************************
                                            //GADSC Code Change for displaying the Goup/Subgroup path of the container group in the report
                                            //Ezilla Bug N0:68758
                                            //Modified By:Kanthi.J
                                            //********************************************************************************************
                                            cvCG.ApplyFilter("Id", curContainer.GroupId, HyperCatalog.Business.CollectionView.FilterOperand.Equals);
                                            sb.Append("<td>" + ((ContainerGroup)cvCG[0]).Path + ((ContainerGroup)cvCG[0]).Name + "</td>");
                                            sb.Append("<td>" + curContainer.Tag + "</td>");
                                            sb.Append("<td>" + curContainer.Name + "</td>");
                                            sb.Append("<td>" + curContainer.Label + "</td>");
                                            sb.Append("<td>" + curContainer.Definition + "</td>");
                                            sb.Append("<td>" + curContainer.EntryRule + "</td>");
                                            sb.Append("<td>" + curContainer.Sample + "</td>");
                                            cvDT.ApplyFilter("Code", curContainer.DataTypeCode, HyperCatalog.Business.CollectionView.FilterOperand.Equals);
                                            sb.Append("<td>" + ((DataType)cvDT[0]).Name + "</td>");
                                            cvCT.ApplyFilter("Code", curContainer.ContainerTypeCode, HyperCatalog.Business.CollectionView.FilterOperand.Equals);
                                            sb.Append("<td>" + ((ContainerType)cvCT[0]).Name + "</td>");
                                            if (curContainer.LookupId == -1)
                                            {
                                                sb.Append("<td></td>");
                                            }
                                            else
                                            {
                                                cvLG.ApplyFilter("Id", curContainer.LookupId, HyperCatalog.Business.CollectionView.FilterOperand.Equals);
                                                sb.Append("<td>" + ((LookupGroup)cvLG[0]).Name + "</td>");
                                            }
                                            sb.Append("<td>" + curContainer.InputMask + "</td>");
                                            sb.Append("<td>" + curContainer.MaxLength + "</td>");
                                            sb.Append("<td>" + curContainer.Translatable + "</td>");
                                            sb.Append("<td>" + curContainer.Regionalizable + "</td>");
                                            sb.Append("<td>" + curContainer.Localizable + "</td>");
                                            sb.Append("<td>" + curContainer.Publishable + "</td>");
                                            sb.Append("<td>" + curContainer.ReadOnly + "</td>");
                                            sb.Append("<td>" + curContainer.KeepIfObsolete + "</td>");
                                            cvIM.ApplyFilter("Id", curContainer.InheritanceMethodId, HyperCatalog.Business.CollectionView.FilterOperand.Equals);
                                            sb.Append("<td>" + ((InheritanceMethod)cvIM[0]).Name + "</td>");
                                            sb.Append("<td>" + curContainer.Sort + "</td>");
                                            sb.Append("<td>" + curContainer.SegmentId + "</td>");
                                            sb.Append("<td>" + curContainer.ValidationMask + "</td>");
                                            sb.Append("<td>" + curContainer.WWXPath + "</td>");
                                            cvU.ApplyFilter("Id", curContainer.CreatorId, HyperCatalog.Business.CollectionView.FilterOperand.Equals);
                                            sb.Append("<td>" + ((User)cvU[0]).FullName + "</td>");
                                            sb.Append("<td>" + curContainer.CreateDate + "</td>");
                                            if (curContainer.ModifierId == -1)
                                            {
                                                sb.Append("<td></td>");
                                            }
                                            else
                                            {
                                                cvU.ApplyFilter("Id", curContainer.ModifierId, HyperCatalog.Business.CollectionView.FilterOperand.Equals);
                                            }
                                            sb.Append("<td>" + ((User)cvU[0]).FullName + "</td>");
                                            sb.Append("<td>" + curContainer.ModifyDate + "</td>");

                                            sb.Append("</tr>");
                                            if (cellColor == defaultCellColor)
                                            {
                                                cellColor = "white";
                                            }
                                            else
                                            {
                                                cellColor = defaultCellColor;
                                            }
                                        }

                                        sb.Append("</table>");
                                        sb.Append("</body></html>");

                                        string fileName = string.Empty;
                                        fileName += "Containers.xls";

                                        string exportContent = sb.ToString();
                                        page.Response.Clear();
                                        page.Response.ClearContent();
                                        page.Response.ClearHeaders();
                                        page.Response.Charset = string.Empty;
                                        page.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
                                        page.Response.ContentType = "application/vnd.ms-excel;";
                                        //Fix for CR 5109 - Prabhu R S
                                        page.Response.ContentEncoding = System.Text.Encoding.UTF8;
                                        page.EnableViewState          = false;
                                        page.Response.Write(exportContent);
                                        page.Response.End();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }