Esempio n. 1
0
        /// <summary>
        /// Applies all PNG filters to the given scanline and returns the filtered scanline that is deemed
        /// to be most compressible, using lowest total variation as proxy for compressibility.
        /// </summary>
        /// <returns>The <see cref="T:byte[]"/></returns>
        private IManagedByteBuffer GetOptimalFilteredScanline()
        {
            // Palette images don't compress well with adaptive filtering.
            if (this.pngColorType == PngColorType.Palette || this.bitDepth < 8)
            {
                NoneFilter.Encode(this.rawScanline.GetSpan(), this.result.GetSpan());
                return(this.result);
            }

            Span <byte> scanSpan = this.rawScanline.GetSpan();
            Span <byte> prevSpan = this.previousScanline.GetSpan();

            // This order, while different to the enumerated order is more likely to produce a smaller sum
            // early on which shaves a couple of milliseconds off the processing time.
            UpFilter.Encode(scanSpan, prevSpan, this.up.GetSpan(), out int currentSum);

            // TODO: PERF.. We should be breaking out of the encoding for each line as soon as we hit the sum.
            // That way the above comment would actually be true. It used to be anyway...
            // If we could use SIMD for none branching filters we could really speed it up.
            int lowestSum = currentSum;
            IManagedByteBuffer actualResult = this.up;

            PaethFilter.Encode(scanSpan, prevSpan, this.paeth.GetSpan(), this.bytesPerPixel, out currentSum);

            if (currentSum < lowestSum)
            {
                lowestSum    = currentSum;
                actualResult = this.paeth;
            }

            SubFilter.Encode(scanSpan, this.sub.GetSpan(), this.bytesPerPixel, out currentSum);

            if (currentSum < lowestSum)
            {
                lowestSum    = currentSum;
                actualResult = this.sub;
            }

            AverageFilter.Encode(scanSpan, prevSpan, this.average.GetSpan(), this.bytesPerPixel, out currentSum);

            if (currentSum < lowestSum)
            {
                actualResult = this.average;
            }

            return(actualResult);
        }
Esempio n. 2
0
        /// <summary>
        /// Encodes the pixel data line by line.
        /// Each scanline is encoded in the most optimal manner to improve compression.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="rowSpan">The row span.</param>
        /// <param name="row">The row.</param>
        /// <returns>The <see cref="IManagedByteBuffer"/></returns>
        private IManagedByteBuffer EncodePixelRow <TPixel>(ReadOnlySpan <TPixel> rowSpan, int row)
            where TPixel : struct, IPixel <TPixel>
        {
            switch (this.pngColorType)
            {
            case PngColorType.Palette:
                // TODO: Use Span copy!
                Buffer.BlockCopy(this.palettePixelData, row * this.rawScanline.Length(), this.rawScanline.Array, 0, this.rawScanline.Length());
                break;

            case PngColorType.Grayscale:
            case PngColorType.GrayscaleWithAlpha:
                this.CollectGrayscaleBytes(rowSpan);
                break;

            default:
                this.CollectTPixelBytes(rowSpan);
                break;
            }

            switch (this.pngFilterMethod)
            {
            case PngFilterMethod.None:
                NoneFilter.Encode(this.rawScanline.Span, this.result.Span);
                return(this.result);

            case PngFilterMethod.Sub:
                SubFilter.Encode(this.rawScanline.Span, this.sub.Span, this.bytesPerPixel, out int _);
                return(this.sub);

            case PngFilterMethod.Up:
                UpFilter.Encode(this.rawScanline.Span, this.previousScanline.Span, this.up.Span, out int _);
                return(this.up);

            case PngFilterMethod.Average:
                AverageFilter.Encode(this.rawScanline.Span, this.previousScanline.Span, this.average.Span, this.bytesPerPixel, out int _);
                return(this.average);

            case PngFilterMethod.Paeth:
                PaethFilter.Encode(this.rawScanline.Span, this.previousScanline.Span, this.paeth.Span, this.bytesPerPixel, out int _);
                return(this.paeth);

            default:
                return(this.GetOptimalFilteredScanline());
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Applies all PNG filters to the given scanline and returns the filtered scanline that is deemed
        /// to be most compressible, using lowest total variation as proxy for compressibility.
        /// </summary>
        /// <returns>The <see cref="T:byte[]"/></returns>
        private IManagedByteBuffer GetOptimalFilteredScanline()
        {
            // Palette images don't compress well with adaptive filtering.
            if (this.pngColorType == PngColorType.Palette || this.bitDepth < 8)
            {
                NoneFilter.Encode(this.rawScanline.GetSpan(), this.result.GetSpan());
                return(this.result);
            }

            Span <byte> scanSpan = this.rawScanline.GetSpan();
            Span <byte> prevSpan = this.previousScanline.GetSpan();

            // This order, while different to the enumerated order is more likely to produce a smaller sum
            // early on which shaves a couple of milliseconds off the processing time.
            UpFilter.Encode(scanSpan, prevSpan, this.up.GetSpan(), out int currentSum);

            int lowestSum = currentSum;
            IManagedByteBuffer actualResult = this.up;

            PaethFilter.Encode(scanSpan, prevSpan, this.paeth.GetSpan(), this.bytesPerPixel, out currentSum);

            if (currentSum < lowestSum)
            {
                lowestSum    = currentSum;
                actualResult = this.paeth;
            }

            SubFilter.Encode(scanSpan, this.sub.GetSpan(), this.bytesPerPixel, out currentSum);

            if (currentSum < lowestSum)
            {
                lowestSum    = currentSum;
                actualResult = this.sub;
            }

            AverageFilter.Encode(scanSpan, prevSpan, this.average.GetSpan(), this.bytesPerPixel, out currentSum);

            if (currentSum < lowestSum)
            {
                actualResult = this.average;
            }

            return(actualResult);
        }
Esempio n. 4
0
        private void DecodePixelData(byte[][] pixelData)
        {
//            data = new Color[_width * _height];
            _colors = new Color[width * height];
            pixels  = new int[width * height];

            var previousScanline = new byte[bytesPerScanline];

            for (var y = 0; y < height; ++y)
            {
                var    scanline = pixelData[y];
                byte[] defilteredScanline;
                switch (scanline[0])
                {
                case 0:
                    defilteredScanline = NoneFilter.Decode(scanline);
                    break;

                case 1:
                    defilteredScanline = SubFilter.Decode(scanline, bytesPerPixel);
                    break;

                case 2:
                    defilteredScanline = UpFilter.Decode(scanline, previousScanline);
                    break;

                case 3:
                    defilteredScanline = AverageFilter.Decode(scanline, previousScanline, bytesPerPixel);
                    break;

                case 4:
                    defilteredScanline = PaethFilter.Decode(scanline, previousScanline, bytesPerPixel);
                    break;

                default:
                    throw new Exception("Unknown filter type.");
                }

                previousScanline = defilteredScanline;
                ProcessDefilteredScanline(defilteredScanline, y);
            }
        }
Esempio n. 5
0
    public FilterGenerator(int quadrantSize, LocalTerrain localTerrain)
    {
        globalFilterMountainC = new GlobalCoordinates(100);
        globalFilterAverageC = new GlobalCoordinates(100);
        globalFilterMedianC = new GlobalCoordinates(100);
        globalFilterSpikeC = new GlobalCoordinates(100);
        globalFilterGaussianC = new GlobalCoordinates(100);
        globalFilterMinThresholdC = new GlobalCoordinates(100);
        globalFilterMaxThresholdC = new GlobalCoordinates(100);

        lt = localTerrain;
        localCoordinates = lt.localTerrainC;

        mf = new MountainFilter(this);
        af = new AverageFilter(this);
        mdf = new MedianFilter(this);
        sf = new SpikeFilter(this);
        gf = new GaussianFilter(this);
        tf = new ThresholdFilter(this);
    }
Esempio n. 6
0
        /// <summary>
        /// Decodes the raw interlaced pixel data row by row
        /// <see href="https://github.com/juehv/DentalImageViewer/blob/8a1a4424b15d6cc453b5de3f273daf3ff5e3a90d/DentalImageViewer/lib/jiu-0.14.3/net/sourceforge/jiu/codecs/PNGCodec.java"/>
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="compressedStream">The compressed pixel data stream.</param>
        /// <param name="image">The current image.</param>
        private void DecodeInterlacedPixelData <TPixel>(Stream compressedStream, ImageFrame <TPixel> image)
            where TPixel : struct, IPixel <TPixel>
        {
            while (true)
            {
                int numColumns = this.ComputeColumnsAdam7(this.pass);

                if (numColumns == 0)
                {
                    this.pass++;

                    // This pass contains no data; skip to next pass
                    continue;
                }

                int bytesPerInterlaceScanline = this.CalculateScanlineLength(numColumns) + 1;

                while (this.currentRow < this.header.Height)
                {
                    int bytesRead = compressedStream.Read(this.scanline.Array, this.currentRowBytesRead, bytesPerInterlaceScanline - this.currentRowBytesRead);
                    this.currentRowBytesRead += bytesRead;
                    if (this.currentRowBytesRead < bytesPerInterlaceScanline)
                    {
                        return;
                    }

                    this.currentRowBytesRead = 0;

                    Span <byte> scanSpan   = this.scanline.Slice(0, bytesPerInterlaceScanline);
                    Span <byte> prevSpan   = this.previousScanline.Slice(0, bytesPerInterlaceScanline);
                    var         filterType = (FilterType)scanSpan[0];

                    switch (filterType)
                    {
                    case FilterType.None:
                        break;

                    case FilterType.Sub:

                        SubFilter.Decode(scanSpan, this.bytesPerPixel);
                        break;

                    case FilterType.Up:

                        UpFilter.Decode(scanSpan, prevSpan);
                        break;

                    case FilterType.Average:

                        AverageFilter.Decode(scanSpan, prevSpan, this.bytesPerPixel);
                        break;

                    case FilterType.Paeth:

                        PaethFilter.Decode(scanSpan, prevSpan, this.bytesPerPixel);
                        break;

                    default:
                        throw new ImageFormatException("Unknown filter type.");
                    }

                    Span <TPixel> rowSpan = image.GetPixelRowSpan(this.currentRow);
                    this.ProcessInterlacedDefilteredScanline(this.scanline.Array, rowSpan, Adam7FirstColumn[this.pass], Adam7ColumnIncrement[this.pass]);

                    Swap(ref this.scanline, ref this.previousScanline);

                    this.currentRow += Adam7RowIncrement[this.pass];
                }

                this.pass++;
                this.previousScanline.Clear();

                if (this.pass < 7)
                {
                    this.currentRow = Adam7FirstRow[this.pass];
                }
                else
                {
                    this.pass = 0;
                    break;
                }
            }
        }
Esempio n. 7
0
        public dynamic AgentRankingExport(AverageFilter filters, string userName)
        {
            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString))
            {
                string p = Path.Combine(HostingEnvironment.MapPath(@"~\export\"));
                if (!Directory.Exists(p))
                {
                    Directory.CreateDirectory(p);
                }

                Filter f = new Filter()
                {
                    filters = filters.filters, range = filters.range
                };
                SqlCommand sqlComm = new SqlCommand();

                if (filters.filters.missedItems != null && filters.filters.missedItems.Count != 0)
                {
                    sqlComm = DashboardHelpers.GetFiltersParameters(f, "[getAgentRankingJson_v3_ExportForMissedPoints]", userName, filters.comparison);
                }
                else
                {
                    sqlComm = DashboardHelpers.GetFiltersParameters(f, "[getAgentRankingJson_v2]", userName, filters.comparison);
                }


                sqlComm.Connection = sqlCon;
                var aRankingResponseData = new AgentRankingResponseData();



                List <AgentMissedPoint> agentRankingInfolst = new List <AgentMissedPoint>();
                List <Agent>            agentRankinglst     = new List <Agent>();
                try
                {
                    sqlCon.Open();
                    SqlDataReader reader = sqlComm.ExecuteReader();
                    try
                    {
                        while (reader.Read())
                        {
                            agentRankingInfolst.Add(new AgentMissedPoint
                            {
                                agentId           = reader.GetValue(reader.GetOrdinal("agent")).ToString(),
                                questionShortName = reader.GetValue(reader.GetOrdinal("q_short_name")).ToString(),
                                missedCalls       = int.Parse(reader.GetValue(reader.GetOrdinal("missed")).ToString()),
                                totalCalls        = int.Parse(reader.GetValue(reader.GetOrdinal("total")).ToString()),
                                isComposite       = int.Parse(reader.GetValue(reader.GetOrdinal("hasTemplate")).ToString()) == 1,
                                isLinked          = int.Parse(reader.GetValue(reader.GetOrdinal("isLinked")).ToString()) == 1,
                                questionType      = reader.GetValue(reader.GetOrdinal("questionType")).ToString(),
                                questionId        = reader.IsDBNull(reader.GetOrdinal("question_id")) ? (int?)null : int.Parse(reader.GetValue(reader.GetOrdinal("question_id")).ToString())
                            });
                        }
                    }
                    catch (Exception ex) { throw ex; }



                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            try
                            {
                                var temp_ranking = new Agent()
                                {
                                    id                   = reader.GetValue(reader.GetOrdinal("agentID")).ToString(),
                                    name                 = reader.GetValue(reader.GetOrdinal("AgentName")).ToString(),
                                    groupNames           = new List <string>(),
                                    averageScore         = reader.IsDBNull(reader.GetOrdinal("averageScore"))? 0:decimal.Parse(reader.GetValue(reader.GetOrdinal("averageScore")).ToString()),
                                    previousAverageScore = reader.IsDBNull(reader.GetOrdinal("previousAverageScore")) ? 0 : decimal.Parse(reader.GetValue(reader.GetOrdinal("previousAverageScore")).ToString()),
                                    totalCalls           = reader.IsDBNull(reader.GetOrdinal("totalCalls")) ? 0 : int.Parse(reader.GetValue(reader.GetOrdinal("totalCalls")).ToString()),
                                    totalBadCalls        = reader.IsDBNull(reader.GetOrdinal("totalBadCalls")) ? (int?)null : (int?)reader.GetValue(reader.GetOrdinal("totalBadCalls")),
                                    earliestCallDate     = reader.IsDBNull(reader.GetOrdinal("earlier")) ? (DateTime?)null : (DateTime?)reader.GetDateTime(reader.GetOrdinal("earlier")),
                                    // DateTime.Parse(reader.GetValue(reader.GetOrdinal("earlier")).ToString()),
                                };
                                temp_ranking.top3MissedPoints = (from val in agentRankingInfolst where val.agentId.Trim().Equals(temp_ranking.id.Trim()) select val).ToList();
                                agentRankinglst.Add(temp_ranking);
                            }
                            catch (Exception ex) { throw ex; }
                        }
                    }
                    List <UserGroupInfo> ugi = new List <UserGroupInfo>();
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            try
                            {
                                ugi.Add(new UserGroupInfo()
                                {
                                    groupname = reader.GetValue(reader.GetOrdinal("user_group")).ToString(),
                                    username  = reader.GetValue(reader.GetOrdinal("Agent")).ToString()
                                });
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }
                    }

                    foreach (var a in agentRankinglst)
                    {
                        a.groupNames = (from val in ugi where a.name.Equals(val.username) select val.groupname).ToList();
                    }
                    //
                    #region Export
                    //EXPORT Realization
                    aRankingResponseData.agents = agentRankinglst;

                    var                       propNames          = new List <PropertieName>();
                    PropertieName             name               = new PropertieName();
                    List <ExportAgentRanking> exportAgentRanking = new List <ExportAgentRanking>();
                    List <ExportAgentRankingTopMissedPoints> exportAgentRankingTopMissedPoints = new List <ExportAgentRankingTopMissedPoints>();
                    if (f.filters.missedItems != null && f.filters.missedItems.Count == 1)
                    {
                        propNames.Add(new PropertieName {
                            propName = "Agent Name", propValue = "name", propPosition = 1
                        });
                        propNames.Add(new PropertieName {
                            propName = "Missed Item", propValue = "questionName", propPosition = 2
                        });
                        propNames.Add(new PropertieName {
                            propName = "Call Count", propValue = "callCount", propPosition = 3
                        });
                        propNames.Add(new PropertieName {
                            propName = "Missed Calls", propValue = "missedCalls", propPosition = 4
                        });
                        propNames.Add(new PropertieName {
                            propName = "Missed Percent", propValue = "missedPercent", propPosition = 5
                        });
                        //List<int> missed = new List<int>();
                        //int z = 0;
                        foreach (var item in aRankingResponseData.agents)
                        {
                            item.questionName = new List <string>();
                            foreach (var i in item.top3MissedPoints)
                            {
                                if (Convert.ToInt32(filters.filters.missedItems[0]) == i.questionId)
                                {
                                    //missed.Add(i.missedCalls);
                                    item.missedCalls = i.missedCalls;
                                    item.totalCalls  = i.totalCalls;
                                    item.questionName.Add(i.questionShortName);
                                }
                            }
                            //z++;
                        }
                        foreach (var item in aRankingResponseData.agents)
                        {
                            exportAgentRankingTopMissedPoints.Add(new ExportAgentRankingTopMissedPoints
                            {
                                name          = item.name,
                                questionName  = item.questionName[0],
                                callCount     = item.totalCalls,
                                missedCalls   = item.missedCalls,
                                missedPercent = Math.Round((double)(item.missedCalls * 100) / item.totalCalls) + "%" //-100 - ((item.averageScore * 100) / item.previousAverageScore)
                            });
                        }
                        ExportHelper.Export(propNames, exportAgentRankingTopMissedPoints, "AgentRanking " + DateTime.Now.ToString("MM-dd-yyyy") + DateTime.Now.Millisecond.ToString() + ".xlsx", "AgentRanking", userName);
                    }
                    else
                    {
                        propNames.Add(new PropertieName {
                            propName = "Agent Name", propValue = "name", propPosition = 1
                        });
                        propNames.Add(new PropertieName {
                            propName = "Start Date", propValue = "startDate", propPosition = 2
                        });
                        propNames.Add(new PropertieName {
                            propName = "Score", propValue = "score", propPosition = 3
                        });
                        propNames.Add(new PropertieName {
                            propName = "Group Name", propValue = "groupName", propPosition = 4
                        });
                        propNames.Add(new PropertieName {
                            propName = "Delta", propValue = "delta", propPosition = 5
                        });
                        propNames.Add(new PropertieName {
                            propName = "Total Calls", propValue = "totalCalls", propPosition = 6
                        });
                        propNames.Add(new PropertieName {
                            propName = "Top Missed Points", propValue = "top3Agents", propPosition = 7
                        });


                        foreach (var item in aRankingResponseData.agents)
                        {
                            List <string> topAgents = new List <string>();
                            foreach (var i in item.top3MissedPoints)
                            {
                                if (item.id == i.agentId)
                                {
                                    topAgents.Add((new StringBuilder().Append(i.questionShortName + ", missed " + i.missedCalls + " of " + i.totalCalls + ";").ToString()));
                                }
                            }
                            exportAgentRanking.Add(new ExportAgentRanking
                            {
                                name       = item.name,
                                startDate  = item.earliestCallDate,
                                score      = item.averageScore,
                                groupName  = ExportCodeHelper.GetCSVFromList(item.groupNames),
                                delta      = ((item.averageScore - item.previousAverageScore) % 100) + "%",
                                totalCalls = item.totalCalls,
                                top3Agents = ExportCodeHelper.GetCSVFromList(topAgents)//GetCSVFromList(topAgents) as string
                            });
                        }

                        ExportHelper.Export(propNames, exportAgentRanking, "AgentRanking " + DateTime.Now.ToString("MM-dd-yyyy") + DateTime.Now.Millisecond.ToString() + ".xlsx", "AgentRanking", userName);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                #endregion
                return("success");
            }
        }
Esempio n. 8
0
        public dynamic ExportTopQaMissedItems(AverageFilter filters, string userName)
        {
            Filter f = new Filter()
            {
                filters = filters.filters, range = filters.range
            };

            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString))
            {
                if (filters.filters.badCallsOnly == false)
                {
                    SqlCommand sqlComm = DashboardHelpers.GetFiltersParameters(f, "[getTopqaMissedItemsJson_v2]", userName, filters.comparison);

                    sqlComm.Connection = sqlCon;

                    PageFiltersData pageFiltersData = new PageFiltersData();
                    sqlCon.Open();

                    TopMissedItemsResponseData topMissed = new TopMissedItemsResponseData()
                    {
                        missedItems = new List <MissedItem>()
                    };
                    try
                    {
                        SqlDataReader reader = sqlComm.ExecuteReader();
                        while (reader.Read())
                        {
                            try
                            {
                                topMissed.missedItems.Add(new MissedItem()
                                {
                                    questionId          = int.Parse(reader.GetValue(reader.GetOrdinal("questionId")).ToString()),
                                    questionShortName   = (reader.GetValue(reader.GetOrdinal("questionShortName")).ToString()),
                                    scorecardName       = (reader.GetValue(reader.GetOrdinal("scorecardName")).ToString()),
                                    totalCalls          = int.Parse(reader.GetValue(reader.GetOrdinal("totalCalls")).ToString()),
                                    missedCalls         = int.Parse(reader.GetValue(reader.GetOrdinal("missedCalls")).ToString()),
                                    questionSectionName = reader.GetValue(reader.GetOrdinal("sectionName")).ToString(),
                                    isComposite         = bool.Parse(reader.GetValue(reader.GetOrdinal("hasTemplate")).ToString()),
                                    isLinked            = bool.Parse(reader.GetValue(reader.GetOrdinal("isLinked")).ToString()),
                                    questionType        = reader.GetValue(reader.GetOrdinal("questionType")).ToString(),
                                    comparedMissedCalls = int.Parse(reader.GetValue(reader.GetOrdinal("comparedMissedCalls")).ToString()),
                                    comparedTotalCalls  = int.Parse(reader.GetValue(reader.GetOrdinal("comparedTotalCalls")).ToString()),
                                });
                            }
                            catch (Exception ex) { }
                        }
                        reader.NextResult();
                        List <MissedItemAgentInfo> lst = new List <MissedItemAgentInfo>();
                        while (reader.Read())
                        {
                            try
                            {
                                lst.Add(new MissedItemAgentInfo()
                                {
                                    questionId  = int.Parse(reader.GetValue(reader.GetOrdinal("questionId")).ToString()),
                                    name        = reader.GetValue(reader.GetOrdinal("reviewer")).ToString(),
                                    totalCalls  = int.Parse(reader.GetValue(reader.GetOrdinal("total_calls")).ToString()),
                                    missedCalls = int.Parse(reader.GetValue(reader.GetOrdinal("number_missed")).ToString()),
                                });
                            }
                            catch (Exception ex) { }
                        }
                        foreach (var item in topMissed.missedItems)
                        {
                            item.top3Agents = new List <MissedItemAgentInfo>();
                            item.top3Agents.AddRange((from v in lst where v.questionId == item.questionId select v).ToList());
                        }

                        //return topMissed;
                        List <TopMissedItemsExportModel> topMissedItemsExportModel = new List <TopMissedItemsExportModel>();
                        var propNames = new List <PropertieName>
                        {
                            new PropertieName {
                                propName = "Missed Point", propValue = "questionShortName", propPosition = 1
                            },
                            new PropertieName {
                                propName = "Section", propValue = "questionSectionName", propPosition = 2
                            },
                            new PropertieName {
                                propName = "Scorecard", propValue = "scorecardName", propPosition = 3
                            },
                            new PropertieName {
                                propName = "Number missed", propValue = "missedCalls", propPosition = 4
                            },
                            new PropertieName {
                                propName = "Total calls", propValue = "totalCalls", propPosition = 5
                            },
                            new PropertieName {
                                propName = "Occurrence", propValue = "occurrence", propPosition = 6
                            },
                            new PropertieName {
                                propName = "Delta", propValue = "delta", propPosition = 7
                            },
                            new PropertieName {
                                propName = "Top 3 agents", propValue = "top3Agents", propPosition = 8
                            }
                        };
                        foreach (var item in topMissed.missedItems)
                        {
                            List <string> topAgents = new List <string>();

                            foreach (var i in item.top3Agents)
                            {
                                if (item.questionId == i.questionId)
                                {
                                    topAgents.Add((new StringBuilder().Append(i.name + i.missedCalls + "/" + i.totalCalls + ";").ToString()));
                                }
                            }
                            if (item.comparedTotalCalls == 0)
                            {
                                topMissedItemsExportModel.Add(new TopMissedItemsExportModel
                                {
                                    questionShortName   = item.questionShortName,
                                    questionSectionName = item.questionSectionName,
                                    scorecardName       = item.scorecardName,
                                    missedCalls         = item.missedCalls,
                                    totalCalls          = item.totalCalls,
                                    occurrence          = (float)Math.Round((float)((float)item.missedCalls / (float)item.totalCalls) * 100),
                                    delta      = (float)Math.Round((float)((float)item.missedCalls / (float)item.totalCalls) * 100), //(item.comparedMissedCalls / item.comparedTotalCalls),
                                    top3Agents = ExportCodeHelper.GetCSVFromList(topAgents)
                                });
                            }
                            else
                            {
                                topMissedItemsExportModel.Add(new TopMissedItemsExportModel
                                {
                                    questionShortName   = item.questionShortName,
                                    questionSectionName = item.questionSectionName,
                                    scorecardName       = item.scorecardName,
                                    missedCalls         = item.missedCalls,
                                    totalCalls          = item.totalCalls,
                                    occurrence          = (float)Math.Round(((float)item.missedCalls / (float)item.totalCalls) * 100),
                                    delta      = (float)Math.Round(((float)((float)item.missedCalls / (float)item.totalCalls) * 100) - ((float)((float)item.comparedMissedCalls / (float)item.comparedTotalCalls) * 100)),//(item.missedCalls / item.totalCalls) * 100,
                                    top3Agents = ExportCodeHelper.GetCSVFromList(topAgents)
                                });
                            }
                        }
                        ExportHelper.Export(propNames, topMissedItemsExportModel, "TopQaMissed" + DateTime.Now.ToString("MM-dd-yyyy") + DateTime.Now.Second.ToString() + ".xlsx", "TopQaMissedPoints", userName);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                return("success");
            }
        }