Example #1
0
        /// <summary>
        /// The Set.
        /// </summary>
        /// <param name="SqlConnectString">The SqlConnectString<see cref="string"/>.</param>
        /// <param name="cards">The cards<see cref="IFigures"/>.</param>
        /// <param name="Renew">The Renew<see cref="bool"/>.</param>
        /// <returns>The <see cref="IDeck{IDeck{IFigure}}"/>.</returns>
        public IDeck <IDeck <IFigure> > Set(string SqlConnectString, IFigures cards, bool Renew)
        {
            try
            {
                if (sqaf == null)
                {
                    sqaf = new Sqlbase(SqlConnectString);
                }
                try
                {
                    bool buildmap = true;
                    if (cards.Count > 0)
                    {
                        BulkPrepareType prepareType = BulkPrepareType.Drop;

                        if (Renew)
                        {
                            prepareType = BulkPrepareType.Trunc;
                        }

                        var ds = sqaf.Update(cards, true, buildmap, true, null, prepareType);
                        if (ds != null)
                        {
                            IFigures im = (IFigures)Summon.New(cards.GetType());
                            im.Rubrics    = cards.Rubrics;
                            im.FigureType = cards.FigureType;
                            im.FigureSize = cards.FigureSize;
                            im.Add(ds["Failed"].AsValues());
                            return(sqaf.Insert(im, true, false, prepareType));
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    return(null);
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }