/// <summary>
        /// Takes a list of Symbol Models and a name.
        /// Creates a CompositeSymbol by merging components JPEG's
        /// and adding name. Returns null if merging jpegs failed, or
        /// if identical CompositeSymbol exists. The returned CompositeSymbol
        /// should be passed to CompositeSymbolDAL.Insert if the sybol is intended 
        /// to be saved in the database table
        /// </summary>
        /// <param name="CompositeName"></param>
        /// <param name="components"></param>
        /// <returns>BlissBase.Model.CompositeSymbol or null</returns>
        public CompositeSymbol CreateCompositeByComponents(String compositeName,
            List<Symbol> components)
        {
            List<Symbol> sortedList = components.OrderBy(s => s.symId).ToList();

            CompositeSymbol nameExists = GetExactCompositeSymbolByName(compositeName);
            if (nameExists != null)
            {
                CompositeOfDAL composites = new CompositeOfDAL();
                List<Symbol> hasComponents = composites.GetComponentsOf(nameExists);
                if (Enumerable.SequenceEqual(sortedList, hasComponents))
                    return null;
            }
            byte[] newCompJpeg = null;
            newCompJpeg = CombineJpegFromComponents(sortedList);

            CompositeSymbol newCompSymbol = null;
            if (newCompJpeg != null)
            {
                newCompSymbol = new CompositeSymbol()
                {
                    compName = compositeName,
                    compJpeg = newCompJpeg
                };
            }

            return newCompSymbol;
        }
Пример #2
0
 public List<Symbol> GetComponentsOf(CompositeSymbol innCompSymbol)
 {
     var CompositeOfDAL = new CompositeOfDAL(testing);
     return CompositeOfDAL.GetComponentsOf(innCompSymbol);
 }