Exemple #1
0
        private void UpdateDataView()
        {
            string sSql = string.Empty;

            string filter = txtFilter.Text;

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

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

            using (ContainerTypeList containerTypes = ContainerType.GetAll(sSql))
            {
                if (containerTypes != null)
                {
                    if (containerTypes.Count > 0)
                    {
                        dg.DataSource = containerTypes;
                        Utils.InitGridSort(ref dg);
                        dg.DataBind();

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

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

                    panelGrid.Visible = true;
                    lbTitle.Text      = "Container types list";
                }
            }
        }
    private ContainerTypeList GetPossibleContainerTypes()
    {
        // result list of container type
        ContainerTypeList resultList = new ContainerTypeList();

        // Get all container types
        using (ContainerTypeList containerTypes = ContainerType.GetAll())
        {
            // Get all exclusion rules for this input form type (input form type code is not empty)
            string sqlFilter = "InputFormTypeCode = '" + inputFormTypeCode + "'";
            using (InputFormTypeExclusionRuleList iftExclusionRules = InputFormTypeExclusionRule.GetAll(sqlFilter))
            {
                // Delete container type already used
                if (containerTypes != null)
                {
                    foreach (ContainerType ct in containerTypes)
                    {
                        bool isFound = false;

                        if (iftExclusionRules != null)
                        {
                            foreach (InputFormTypeExclusionRule er in iftExclusionRules)
                            {
                                isFound = isFound || (er.ContainerTypeCode == ct.Code);
                            }
                        }

                        if (!isFound)
                        {
                            resultList.Add(ct);
                        }
                    }
                }
            }
        }
        return(resultList);
    }
Exemple #3
0
        /// <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();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }