/// <summary>
        /// The UpdateRead.
        /// </summary>
        /// <param name="toUpdateCards">The toUpdateCards<see cref="IFigures"/>.</param>
        /// <returns>The <see cref="IDeck{IDeck{IFigure}}"/>.</returns>
        public IDeck <IDeck <IFigure> > UpdateRead(IFigures toUpdateCards)
        {
            IFigures        deck         = toUpdateCards;
            IDeck <IFigure> updatedList  = new Album <IFigure>();
            IDeck <IFigure> toInsertList = new Album <IFigure>();

            int i = 0;

            do
            {
                int columnsCount = deck.Rubrics != null ? deck.Rubrics.Count : 0;

                if (i == 0 && columnsCount == 0)
                {
                    IFigures tab = DeckFromSchema(dr.GetSchemaTable(), deck.Rubrics.KeyRubrics, true);
                    deck         = tab;
                    columnsCount = deck.Rubrics.Count;
                }
                object[] itemArray = new object[columnsCount];
                int[]    keyOrder  = deck.Rubrics.KeyRubrics.Ordinals;
                while (dr.Read())
                {
                    if ((columnsCount - 1) != (int)(dr.FieldCount / 2))
                    {
                        IFigures tab = DeckFromSchema(dr.GetSchemaTable(), deck.Rubrics.KeyRubrics, true);
                        deck         = tab;
                        columnsCount = deck.Rubrics.Count;
                        itemArray    = new object[columnsCount];
                        keyOrder     = deck.Rubrics.KeyRubrics.AsValues().Select(k => k.FieldId).ToArray();
                    }

                    dr.GetValues(itemArray);

                    IFigure row = deck.NewFigure();

                    row.ValueArray = itemArray.Select((a, y) => itemArray[y] = (a == DBNull.Value) ? a.GetType().Default() : a).ToArray();

                    //row.SerialCode = new Ussn(keyOrder.Select(ko => itemArray[ko]).ToArray());

                    updatedList.Add(row);
                }

                foreach (IFigure ir in toUpdateCards)
                {
                    if (!updatedList.ContainsKey(ir))
                    {
                        toInsertList.Add(ir);
                    }
                }
            } while (dr.NextResult());

            IDeck <IDeck <IFigure> > iSet = new Album <IDeck <IFigure> >();

            iSet.Add("Failed", toInsertList);

            iSet.Add("Updated", updatedList);

            return(iSet);
        }
        /// <summary>
        /// The DeleteRead.
        /// </summary>
        /// <param name="toDeleteCards">The toDeleteCards<see cref="IFigures"/>.</param>
        /// <returns>The <see cref="IDeck{IDeck{IFigure}}"/>.</returns>
        public IDeck <IDeck <IFigure> > DeleteRead(IFigures toDeleteCards)
        {
            IFigures        deck        = toDeleteCards;
            IDeck <IFigure> deletedList = new Album <IFigure>();
            IDeck <IFigure> brokenList  = new Album <IFigure>();

            int i = 0;

            do
            {
                int columnsCount = deck.Rubrics.Count;

                if (i == 0 && deck.Rubrics.Count == 0)
                {
                    IFigures tab = DeckFromSchema(dr.GetSchemaTable(), deck.Rubrics.KeyRubrics);
                    deck         = tab;
                    columnsCount = deck.Rubrics.Count;
                }
                object[] itemArray  = new object[columnsCount];
                int[]    keyIndexes = deck.Rubrics.KeyRubrics.Ordinals;
                while (dr.Read())
                {
                    if ((columnsCount - 1) != dr.FieldCount)
                    {
                        IFigures tab = DeckFromSchema(dr.GetSchemaTable(), deck.Rubrics.KeyRubrics);
                        deck         = tab;
                        columnsCount = deck.Rubrics.Count;
                        itemArray    = new object[columnsCount];
                        keyIndexes   = deck.Rubrics.KeyRubrics.Ordinals;
                    }

                    dr.GetValues(itemArray);

                    IFigure row = deck.NewFigure();

                    row.ValueArray = itemArray.Select((a, y) => itemArray[y] = (a == DBNull.Value) ? a.GetType().Default() : a).ToArray();

                    //row.SerialCode = new Ussn(keyIndexes.Select(ko => itemArray[ko]).ToArray());

                    deletedList.Add(row);
                }

                foreach (IFigure ir in toDeleteCards)
                {
                    if (!deletedList.ContainsKey(ir))
                    {
                        brokenList.Add(ir);
                    }
                }
            } while (dr.NextResult());

            IDeck <IDeck <IFigure> > iSet = new Album <IDeck <IFigure> >();

            iSet.Add("Failed", brokenList);

            iSet.Add("Deleted", deletedList);

            return(iSet);
        }
        public Album <Album <IFigure> > InsertRead(IMultemic toInsertCards)
        {
            IMultemic       deck         = toInsertCards;
            Album <IFigure> insertedList = new Album <IFigure>();
            Album <IFigure> brokenList   = new Album <IFigure>();

            int i = 0;

            do
            {
                int columnsCount = deck.Rubrics.Count;

                if (i == 0 && deck.Rubrics.Count == 0)
                {
                    InstantMultemic tab = DeckFromSchema(dr.GetSchemaTable(), deck.Rubrics.KeyRubrics);
                    deck         = tab.Collection;
                    columnsCount = deck.Rubrics.Count;
                }
                object[] itemArray = new object[columnsCount];
                int[]    keyOrder  = deck.Rubrics.KeyRubrics.AsValues().Select(k => k.FigureFieldId).ToArray();
                while (dr.Read())
                {
                    if ((columnsCount - 1) != dr.FieldCount)
                    {
                        InstantMultemic tab = DeckFromSchema(dr.GetSchemaTable(), deck.Rubrics.KeyRubrics);
                        deck         = tab.Collection;
                        columnsCount = deck.Rubrics.Count;
                        itemArray    = new object[columnsCount];
                        keyOrder     = deck.Rubrics.KeyRubrics.AsValues().Select(k => k.FigureFieldId).ToArray();
                    }

                    dr.GetValues(itemArray);

                    IFigure row = deck.NewFigure();

                    row.ValueArray = itemArray.Select((a, y) => itemArray[y] = (a == DBNull.Value) ? a.GetType().GetDefault() : a).ToArray();

                    row.SystemSerialCode = new Ussn(keyOrder.Select(ko => itemArray[ko]).ToArray());

                    insertedList.Add(row);
                }

                foreach (IFigure ir in toInsertCards)
                {
                    if (!insertedList.ContainsKey(ir))
                    {
                        brokenList.Add(ir);
                    }
                }
            } while (dr.NextResult());

            Album <Album <IFigure> > iSet = new Album <Album <IFigure> >();

            iSet.Add("Failed", brokenList);

            iSet.Add("Inserted", insertedList);

            return(iSet);
        }
Beispiel #4
0
        private void UISubmit_Click(object sender, EventArgs e)
        {
            if (TryGetSelectedId(out ServerIdentity id))
            {
                SelectedID  = id;
                music       = TagLib.File.Create(FilesPath[0]);
                AlbumToSend = new Album(music.Tag.Album);

                foreach (var p in FilesPath)
                {
                    music = TagLib.File.Create(p);
                    var tmpFile     = TagLib.File.Create(p);
                    var MusicUpload = new Music(tmpFile.Tag.Title, new Author(tmpFile.Tag.Performers[0]), new Album(AlbumToSend.Name), System.IO.File.ReadAllBytes(p))
                    {
                        Format = Path.GetExtension(p),
                        Genre  = music.Tag.Genres
                    };
                    AlbumToSend.Add(MusicUpload);
                }

                IsUploadValid = true;

                Close();
            }
        }
        public int album_capnhat(short ID, string TenAlbum, string MoTa)
        {
            if (ID == 0)
            {
                Album a = new Album();
                a.TenAlbum = TenAlbum;
                a.MoTa     = MoTa;
                a.NgayTao  = DateTime.Now.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

                int i = a.Add();
                if (i > 0)
                {
                    var path = Path.Combine(Server.MapPath("~/images/upload/album/"), i.ToString());
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    return(i);
                }
                return(0);
            }
            else
            {
                Album a = new Album().FindByID(ID);
                return(a.Update());
            }
        }
Beispiel #6
0
    private static void AddDirectory(Device device, Album album, string dir)
    {
        foreach (string file in Directory.GetFiles(dir))
        {
            try {
                Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(file);

                Photo photo = device.PhotoDatabase.CreatePhoto();

                AddThumbnails(device, photo, pixbuf);
                pixbuf.Dispose();

                photo.FullSizeFileName = file;
                album.Add(photo);
            } catch (GLib.GException e) {
            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }

        foreach (string child in Directory.GetDirectories(dir))
        {
            AddDirectory(device, album, child);
        }
    }
        public void Add_ThreePositiveValues_OneAtZeroIndex()            // Using three list objects because a fourth generates a new array, erasing current array objects
        {
            // Arrange
            Album <int> album1   = new Album <int>();
            int         value1   = 1;
            int         value2   = 2;
            int         value3   = 3;
            int         expected = 1;
            int         actual;             //	Result of test

            // Act
            album1.Add(value1);
            album1.Add(value2);
            album1.Add(value3);
            actual = album1[0];               // Retrieves value at initial array position and returns as int

            // Assert
            Assert.AreEqual(expected, actual);                // Tests if equal, throws exception if they are not
        }
Beispiel #8
0
 public virtual ActionResult Edit(long?id, Album a)
 {
     if (id.HasValue)
     {
         a.Id = id.Value;
         Album.Update(a);
         return(RedirectToAction("Index"));
     }
     Album.Add(a, WebUser.UserId);
     return(RedirectToAction("Index"));
 }
        public void Add_FourPositiveValues_IncreaseCapacity()
        {
            // Arrange
            Album <int> album1   = new Album <int>();
            int         value1   = 1;
            int         value2   = 2;
            int         value3   = 3;
            int         value4   = 4;
            int         expected = 8;       // Should have 8 array positions in list at end of test
            int         actual;             //	Result of test

            // Act
            album1.Add(value1);
            album1.Add(value2);
            album1.Add(value3);
            album1.Add(value4);
            actual = album1.capacity;               // Retrieves number of available array positions and returns as int

            // Assert
            Assert.AreEqual(expected, actual);                // Tests if equal, throws exception if they are not
        }
        public void Add_FourPositiveValues_CountOfFour()
        {
            // Arrange
            Album <int> album1   = new Album <int>();
            int         value1   = 1;
            int         value2   = 2;
            int         value3   = 3;
            int         value4   = 4;
            int         expected = 4;       // Should have 4 items in list at end of test
            int         actual;             //	Result of test

            // Act
            album1.Add(value1);
            album1.Add(value2);
            album1.Add(value3);
            album1.Add(value4);
            actual = album1.count;                // Retrieves number of items in list and returns as int

            // Assert
            Assert.AreEqual(expected, actual);                // Tests if equal, throws exception if they are not
        }
        public void Add_AddFiveStrings_ExemptionThrown()
        {
            // Arrange
            Album <string> album1 = new Album <string>();
            string         value1 = "A";
            string         value2 = "B";
            string         value3 = "C";
            string         value4 = "D";
            string         value5 = "E";
            string         thrown;          //	Result of test

            // Act
            album1.Add(value1);
            album1.Add(value2);
            album1.Add(value3);
            album1.Add(value4);
            album1.Add(value5);
            var exception = Assert.ThrowsException <ArgumentOutOfRangeException>(() => thrown = album1[-1]);             // Retrieves value at array position outside of count and throws out of range exception

            // Assert
            Assert.AreEqual("Specified argument was out of the range of valid values. (Parameter '-1 is out of Album Range.')", exception.Message);               // Tests if equal, throws exception if they are not
        }
        public void Add_AddFiveStrings_IndexZeroHasStringAAfterArrayConcat()
        {
            // Arrange
            Album <string> album1   = new Album <string>();
            string         value1   = "A";
            string         value2   = "B";
            string         value3   = "C";
            string         value4   = "D";
            string         value5   = "E";
            string         expected = value5;
            string         actual;                //	Result of test

            // Act
            album1.Add(value1);
            album1.Add(value2);
            album1.Add(value3);
            album1.Add(value4);
            album1.Add(value5);
            actual = album1[4];               // Retrieves value at fifth array position after concat new empty array and returns as string

            // Assert
            Assert.AreEqual(expected, actual);                // Tests if equal, throws exception if they are not
        }
Beispiel #13
0
        public static bool AddElement(UploadMusic tmp)
        {
            if (!Indexation.IsElementExisting(tmp.MusicPart.Musics.First().Author))
            {
                AddAuthor(tmp);
            }

            if (Indexation.IsElementExisting(tmp.MusicPart))
            {
                if (IsElementExisting(tmp.MusicPart.Musics.First()))
                {
                    return(false);
                }
                else
                {
                    if (AddMusic(tmp))
                    {
                        return(true);
                    }
                }
            }
            else
            {
                string path      = AddAlbum(tmp);
                var    music     = tmp.MusicPart.Musics.First();
                string MusicPath = Path.Combine(path, music.Title + music.Format);
                System.IO.File.WriteAllBytes(MusicPath, tmp.MusicPart.Musics.First().FileBinary);
                MusicsInfo.SaveMusicInfo(tmp.MusicPart.Musics.First());
                foreach (var a in ServerMusics)
                {
                    if (a.MID == music.Author.MID)
                    {
                        music.FileBinary = null;
                        music.ServerPath = MusicPath;
                        music.Author     = a;

                        Album tmpAl = new Album(a, tmp.MusicPart.Name, path);
                        music.Album = tmpAl;
                        tmpAl.Add(music);
                        a.Albums.Add(tmpAl);
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #14
0
        public ResultsViewModel(string title, ISearchResult result)
        {
            Title         = title;
            SearchResults = new List <Album>();
            foreach (var album in result.AlbumList)
            {
                var albumEntry = new Album();
                albumEntry.Header.Title = album.Title;
                foreach (var track in album.TrackList)
                {
                    albumEntry.Add(new Track()
                    {
                        Title            = track.Title,
                        Artist           = track.Artist,
                        TrackNr          = track.TrackNr,
                        AlbumCoverSource = album.AlbumCoverSource
                    });

                    albumEntry.Header.Artists.Add(track.Artist);
                }

                SearchResults.Add(albumEntry);
            }
        }
        public void SelectionEvt(object sender, SelectionChangedEventArgs ev)
        {
            List <object> oldSel = new List <object>(ev.PreviousSelection);
            List <object> newSel = new List <object>(ev.CurrentSelection);

            foreach (object item in oldSel)
            {
                if (item != null && item is Gallery)
                {
                    Gallery galItem = (Gallery)item;
                    if (!(newSel.Contains(item)))
                    {
                        galItem.Selected = false;
                        // Tizen.Log.Debug("Unselected: {0}", galItem.ViewLabel);
                    }
                }
                else if (item is Album selAlbum)
                {
                    if (!(newSel.Contains(selAlbum)))
                    {
                        selAlbum.Selected = false;
                        // Tizen.Log.Debug("Unselected Group: {0}", selAlbum.Title);
                        if (selAlbum == insertDeleteGroup)
                        {
                            albumSource.RemoveAt(2);
                        }
                    }
                }
            }
            foreach (object item in newSel)
            {
                if (item != null && item is Gallery)
                {
                    Gallery galItem = (Gallery)item;
                    if (!(oldSel.Contains(item)))
                    {
                        galItem.Selected = true;
                        // Tizen.Log.Debug("Selected: {0}", galItem.ViewLabel);

                        if (galItem == insertMenu)
                        {
                            // Insert new item to index 3.
                            Random rand = new Random();
                            int    idx  = rand.Next(1000);
                            albumSource[2].Insert(3, new Gallery(idx, "Inserted Item"));
                        }
                        else if (galItem == deleteMenu)
                        {
                            // Remove item in index 3.
                            albumSource[2].RemoveAt(0);
                        }
                        else if (galItem == moveMenu)
                        {
                            // Move last indexed item to index 3.
                            albumSource[2].Move(albumSource[2].Count - 1, 0);
                        }
                    }
                }
                else if (item is Album selAlbum)
                {
                    if (!(oldSel.Contains(selAlbum)))
                    {
                        selAlbum.Selected = true;
                        // Tizen.Log.Debug("Selected Group: {0}", selAlbum.Title);
                        if (selAlbum == insertDeleteGroup)
                        {
                            Random rand        = new Random();
                            int    groupIdx    = rand.Next(1000);
                            Album  insertAlbum = new Album(groupIdx, "Inserted group", new DateTime(1999, 12, 31));
                            int    idx         = rand.Next(1000);
                            insertAlbum.Add(new Gallery(idx, "Inserted Item 1"));
                            idx = rand.Next(1000);
                            insertAlbum.Add(new Gallery(idx, "Inserted Item 2"));
                            idx = rand.Next(1000);
                            insertAlbum.Add(new Gallery(idx, "Inserted Item 3"));
                            albumSource.Insert(2, insertAlbum);
                        }
                        else if (selAlbum == moveGroup)
                        {
                            albumSource.Move(albumSource.Count - 1, 2);
                        }
                    }
                }
            }
            if (colView.Header != null && colView.Header is DefaultTitleItem)
            {
                DefaultTitleItem title = (DefaultTitleItem)colView.Header;
                title.Text = "Grid Sample Count[" + albumSource.Count + "] Selected[" + newSel.Count + "]";
            }
        }
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            albumSource = new AlbumViewModel();
            // Add test menu options.
            moveGroup.Add(moveMenu);
            albumSource.Insert(0, moveGroup);
            insertDeleteGroup.Add(insertMenu);
            insertDeleteGroup.Add(deleteMenu);
            albumSource.Insert(0, insertDeleteGroup);

            selMode = ItemSelectionMode.Multiple;
            DefaultTitleItem myTitle = new DefaultTitleItem();

            myTitle.Text = "Grid Sample Count[" + albumSource.Count + "]";
            //Set Width Specification as MatchParent to fit the Item width with parent View.
            myTitle.WidthSpecification = LayoutParamPolicies.MatchParent;

            colView = new CollectionView()
            {
                ItemsSource   = albumSource,
                ItemsLayouter = new GridLayouter(),
                ItemTemplate  = new DataTemplate(() =>
                {
                    DefaultGridItem item     = new DefaultGridItem();
                    item.WidthSpecification  = 180;
                    item.HeightSpecification = 240;
                    //Decorate Label
                    item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
                    item.Label.HorizontalAlignment = HorizontalAlignment.Center;
                    //Decorate Image
                    item.Image.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");
                    item.Image.WidthSpecification  = 170;
                    item.Image.HeightSpecification = 170;
                    //Decorate Badge checkbox.
                    //[NOTE] This is sample of CheckBox usage in CollectionView.
                    // Checkbox change their selection by IsSelectedProperty bindings with
                    // SelectionChanged event with Mulitple ItemSelectionMode of CollectionView.
                    item.Badge = new CheckBox();
                    //FIXME : SetBinding in RadioButton crashed as Sensitive Property is disposed.
                    //item.Badge.SetBinding(CheckBox.IsSelectedProperty, "Selected");
                    item.Badge.WidthSpecification  = 30;
                    item.Badge.HeightSpecification = 30;

                    return(item);
                }),
                GroupHeaderTemplate = new DataTemplate(() =>
                {
                    DefaultTitleItem group = new DefaultTitleItem();
                    //Set Width Specification as MatchParent to fit the Item width with parent View.
                    group.WidthSpecification = LayoutParamPolicies.MatchParent;

                    group.Label.SetBinding(TextLabel.TextProperty, "Date");
                    group.Label.HorizontalAlignment = HorizontalAlignment.Begin;

                    return(group);
                }),
                Header              = myTitle,
                IsGrouped           = true,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                SelectionMode       = selMode
            };
            colView.SelectionChanged += SelectionEvt;

            window.Add(colView);
        }
Beispiel #17
0
        /// <summary>
        /// The BatchInsert.
        /// </summary>
        /// <param name="table">The table<see cref="IFigures"/>.</param>
        /// <param name="buildMapping">The buildMapping<see cref="bool"/>.</param>
        /// <param name="batchSize">The batchSize<see cref="int"/>.</param>
        /// <returns>The <see cref="IDeck{IDeck{IFigure}}"/>.</returns>
        public IDeck <IDeck <IFigure> > BatchInsert(IFigures table, bool buildMapping, int batchSize = 1000)
        {
            try
            {
                IFigures                 tab   = table;
                IList <FieldMapping>     nMaps = new List <FieldMapping>();
                SqlAdapter               afad  = new SqlAdapter(_cn);
                StringBuilder            sb    = new StringBuilder();
                IDeck <IDeck <IFigure> > nSet  = new Album <IDeck <IFigure> >();
                sb.AppendLine(@"  /* ----  SQL BANK START CMD ------ */  ");
                int count = 0;
                foreach (IFigure ir in tab)
                {
                    foreach (FieldMapping nMap in nMaps)
                    {
                        MemberRubric[] ic = tab.Rubrics.AsValues().Where(c => nMap.ColumnOrdinal.Contains(c.FieldId)).ToArray();
                        MemberRubric[] ik = tab.Rubrics.AsValues().Where(c => nMap.KeyOrdinal.Contains(c.FieldId)).ToArray();

                        string qry = BatchInsertQuery(ir, nMap.DbTableName, ic, ik).ToString();
                        sb.Append(qry);
                        count++;
                    }
                    if (count >= batchSize)
                    {
                        sb.AppendLine(@"  /* ----  DATA BATCH END CMD ------ */  ");
                        var bIFigures = afad.ExecuteInsert(sb.ToString(), tab);
                        if (nSet.Count == 0)
                        {
                            nSet = bIFigures;
                        }
                        else
                        {
                            foreach (Album <IFigure> its in bIFigures.AsValues())
                            {
                                if (nSet.Contains(its))
                                {
                                    nSet[its].Put(its.AsValues());
                                }
                                else
                                {
                                    nSet.Add(its);
                                }
                            }
                        }
                        sb.Clear();
                        sb.AppendLine(@"  /* ----  SQL BANK START CMD ------ */  ");
                        count = 0;
                    }
                }
                sb.AppendLine(@"  /* ----  DATA BANK END CMD ------ */  ");

                var rIFigures = afad.ExecuteInsert(sb.ToString(), tab);

                if (nSet.Count == 0)
                {
                    nSet = rIFigures;
                }
                else
                {
                    foreach (IDeck <IFigure> its in rIFigures.AsValues())
                    {
                        if (nSet.Contains(its))
                        {
                            nSet[its].Put(its.AsValues());
                        }
                        else
                        {
                            nSet.Add(its);
                        }
                    }
                }

                return(nSet);
            }
            catch (SqlException ex)
            {
                _cn.Close();
                throw new SqlInsertException(ex.ToString());
            }
        }
Beispiel #18
0
        /// <summary>
        /// The BulkInsert.
        /// </summary>
        /// <param name="table">The table<see cref="IFigures"/>.</param>
        /// <param name="keysFromDeckis">The keysFromDeckis<see cref="bool"/>.</param>
        /// <param name="buildMapping">The buildMapping<see cref="bool"/>.</param>
        /// <param name="updateKeys">The updateKeys<see cref="bool"/>.</param>
        /// <param name="updateExcept">The updateExcept<see cref="string[]"/>.</param>
        /// <param name="tempType">The tempType<see cref="BulkPrepareType"/>.</param>
        /// <returns>The <see cref="IDeck{IDeck{IFigure}}"/>.</returns>
        public IDeck <IDeck <IFigure> > BulkInsert(IFigures table, bool keysFromDeckis = false, bool buildMapping = false, bool updateKeys = false, string[] updateExcept = null, BulkPrepareType tempType = BulkPrepareType.Trunc)
        {
            try
            {
                IFigures tab = table;
                if (tab.Any())
                {
                    IList <FieldMapping> nMaps = new List <FieldMapping>();
                    if (buildMapping)
                    {
                        SqlMapper imapper = new SqlMapper(tab, keysFromDeckis);
                    }
                    nMaps = tab.Rubrics.Mappings;
                    string     dbName = _cn.Database;
                    SqlAdapter afad   = new SqlAdapter(_cn);
                    afad.DataBulk(tab, tab.FigureType.Name, tempType, BulkDbType.TempDB);
                    _cn.ChangeDatabase(dbName);
                    IDeck <IDeck <IFigure> > nSet = new Album <IDeck <IFigure> >();

                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine(@"  /* ----  SQL BANK START CMD ------ */  ");
                    foreach (FieldMapping nMap in nMaps)
                    {
                        sb.AppendLine(@"  /* ----  TABLE BULK START CMD ------ */  ");

                        MemberRubric[] ic = tab.Rubrics.AsValues().Where(c => nMap.ColumnOrdinal.Contains(c.FieldId)).ToArray();
                        MemberRubric[] ik = tab.Rubrics.AsValues().Where(c => nMap.KeyOrdinal.Contains(c.FieldId)).ToArray();

                        if (updateExcept != null)
                        {
                            ic = ic.Where(c => !updateExcept.Contains(c.RubricName)).ToArray();
                            ik = ik.Where(c => !updateExcept.Contains(c.RubricName)).ToArray();
                        }

                        string qry = BulkInsertQuery(dbName, tab.FigureType.Name, nMap.DbTableName, ic, ik, updateKeys).ToString();
                        sb.Append(qry);
                        sb.AppendLine(@"  /* ----  TABLE BULK END CMD ------ */  ");
                    }
                    sb.AppendLine(@"  /* ----  SQL BANK END CMD ------ */  ");

                    IDeck <IDeck <IFigure> > bIFigures = afad.ExecuteInsert(sb.ToString(), tab, true);


                    if (nSet.Count == 0)
                    {
                        nSet = bIFigures;
                    }
                    else
                    {
                        foreach (IDeck <IFigure> its in bIFigures.AsValues())
                        {
                            if (nSet.Contains(its))
                            {
                                nSet[its].Put(its.AsValues());
                            }
                            else
                            {
                                nSet.Add(its);
                            }
                        }
                    }
                    sb.Clear();

                    return(nSet);
                }
                else
                {
                    return(null);
                }
            }
            catch (SqlException ex)
            {
                _cn.Close();
                throw new SqlInsertException(ex.ToString());
            }
        }
        public Album <Album <IFigure> > BatchUpdate(IMultemic table, bool keysFromDeck = false, bool buildMapping = false, bool updateKeys = false, string[] updateExcept = null, int batchSize = 250)
        {
            try
            {
                IMultemic            tab   = table;
                IList <FieldMapping> nMaps = new List <FieldMapping>();
                SqlAdapter           afad  = new SqlAdapter(_cn);
                StringBuilder        sb    = new StringBuilder();
                var nSet = new Album <Album <IFigure> >();
                sb.AppendLine(@"  /* ----  SQL BANK START CMD ------ */  ");
                int count = 0;
                foreach (IFigure ir in table)
                {
                    if (ir.GetType().DeclaringType != tab.FigureType)
                    {
                        if (buildMapping)
                        {
                            SqlMapper imapper = new SqlMapper(tab, keysFromDeck);
                        }
                        nMaps = tab.Rubrics.Mappings;
                    }

                    foreach (FieldMapping nMap in nMaps)
                    {
                        IDeck <int>    co = nMap.ColumnOrdinal;
                        IDeck <int>    ko = nMap.KeyOrdinal;
                        MemberRubric[] ic = tab.Rubrics.AsValues().Where(c => nMap.ColumnOrdinal.Contains(c.FigureFieldId)).ToArray();
                        MemberRubric[] ik = tab.Rubrics.AsValues().Where(c => nMap.KeyOrdinal.Contains(c.FigureFieldId)).ToArray();
                        if (updateExcept != null)
                        {
                            ic = ic.Where(c => !updateExcept.Contains(c.RubricName)).ToArray();
                            ik = ik.Where(c => !updateExcept.Contains(c.RubricName)).ToArray();
                        }

                        string qry = BatchUpdateQuery(ir, nMap.DbTableName, ic, ik, updateKeys).ToString();
                        sb.Append(qry);
                        count++;
                    }
                    if (count >= batchSize)
                    {
                        sb.AppendLine(@"  /* ----  DATA BATCH END CMD ------ */  ");
                        Album <Album <IFigure> > bIMultemic = afad.ExecuteUpdate(sb.ToString(), tab);
                        if (nSet.Count == 0)
                        {
                            nSet = bIMultemic;
                        }
                        else
                        {
                            foreach (Album <IFigure> its in bIMultemic.AsValues())
                            {
                                if (nSet.Contains(its))
                                {
                                    nSet[its].Put(its.AsValues());
                                }
                                else
                                {
                                    nSet.Add(its);
                                }
                            }
                        }
                        sb.Clear();
                        sb.AppendLine(@"  /* ----  SQL BANK START CMD ------ */  ");
                        count = 0;
                    }
                }
                sb.AppendLine(@"  /* ----  DATA BANK END CMD ------ */  ");

                Album <Album <IFigure> > rIMultemic = afad.ExecuteUpdate(sb.ToString(), tab, true);

                if (nSet.Count == 0)
                {
                    nSet = rIMultemic;
                }
                else
                {
                    foreach (Album <IFigure> its in rIMultemic.AsValues())
                    {
                        if (nSet.Contains(its))
                        {
                            nSet[its].Put(its.AsValues());
                        }
                        else
                        {
                            nSet.Add(its);
                        }
                    }
                }

                return(nSet);
            }
            catch (SqlException ex)
            {
                _cn.Close();
                throw new SqlUpdateException(ex.ToString());
            }
        }
Beispiel #20
0
        /// <summary>
        /// The BulkDelete.
        /// </summary>
        /// <param name="table">The table<see cref="IFigures"/>.</param>
        /// <param name="keysFromDeckis">The keysFromDeckis<see cref="bool"/>.</param>
        /// <param name="buildMapping">The buildMapping<see cref="bool"/>.</param>
        /// <param name="tempType">The tempType<see cref="BulkPrepareType"/>.</param>
        /// <returns>The <see cref="IDeck{IDeck{IFigure}}"/>.</returns>
        public IDeck <IDeck <IFigure> > BulkDelete(IFigures table, bool keysFromDeckis = false, bool buildMapping = false, BulkPrepareType tempType = BulkPrepareType.Trunc)
        {
            try
            {
                IFigures tab = table;
                if (tab.Any())
                {
                    IList <FieldMapping> nMaps = new List <FieldMapping>();
                    if (buildMapping)
                    {
                        SqlMapper imapper = new SqlMapper(tab, keysFromDeckis);
                    }
                    nMaps = tab.Rubrics.Mappings;
                    string     dbName  = _cn.Database;
                    SqlAdapter adapter = new SqlAdapter(_cn);
                    adapter.DataBulk(tab, tab.FigureType.Name, tempType, BulkDbType.TempDB);
                    _cn.ChangeDatabase(dbName);
                    IDeck <IDeck <IFigure> > nSet = new Album <IDeck <IFigure> >();

                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine(@"  /* ----  SQL BANK START CMD ------ */  ");
                    foreach (FieldMapping nMap in nMaps)
                    {
                        sb.AppendLine(@"  /* ----  TABLE BULK START CMD ------ */  ");

                        string qry = BulkDeleteQuery(dbName, tab.FigureType.Name, nMap.DbTableName).ToString();
                        sb.Append(qry);

                        sb.AppendLine(@"  /* ----  TABLE BULK END CMD ------ */  ");
                    }
                    sb.AppendLine(@"  /* ----  SQL BANK END CMD ------ */  ");

                    IDeck <IDeck <IFigure> > bIFigures = adapter.ExecuteDelete(sb.ToString(), tab, true);


                    if (nSet.Count == 0)
                    {
                        nSet = bIFigures;
                    }
                    else
                    {
                        foreach (IDeck <IFigure> its in bIFigures.AsValues())
                        {
                            if (nSet.Contains(its))
                            {
                                nSet[its].Put(its.AsValues());
                            }
                            else
                            {
                                nSet.Add(its);
                            }
                        }
                    }
                    sb.Clear();

                    return(nSet);
                }
                else
                {
                    return(null);
                }
            }
            catch (SqlException ex)
            {
                _cn.Close();
                throw new SqlDeleteException(ex.ToString());
            }
        }
        private void Upload()
        {
            account.Gallery.Progress          = new ProgressItem();
            account.Gallery.Progress.Changed += HandleProgressChanged;

            System.Console.WriteLine("Starting upload");

            FilterSet filters = new FilterSet();

            if (account.Version == GalleryVersion.Version1)
            {
                filters.Add(new WhiteListFilter(new string [] { ".jpg", ".jpeg", ".png", ".gif" }));
            }
            if (scale)
            {
                filters.Add(new ResizeFilter((uint)size));
            }
            else if (rotate)
            {
                filters.Add(new OrientationFilter());
            }


            while (photo_index < items.Length)
            {
                IBrowsableItem item = items [photo_index];

                System.Console.WriteLine("uploading {0}", photo_index);

                progress_dialog.Message  = System.String.Format(Catalog.GetString("Uploading picture \"{0}\""), item.Name);
                progress_dialog.Fraction = photo_index / (double)items.Length;
                photo_index++;

                progress_dialog.ProgressText = System.String.Format(Catalog.GetString("{0} of {1}"), photo_index, items.Length);


                FilterRequest req = new FilterRequest(item.DefaultVersionUri);

                filters.Convert(req);
                try {
                    int id = album.Add(item, req.Current.LocalPath);

                    if (item != null && item is Photo && Core.Database != null && id != 0)
                    {
                        Core.Database.Exports.Create((item as Photo).Id, (item as Photo).DefaultVersionId,
                                                     ExportStore.Gallery2ExportType,
                                                     String.Format("{0}:{1}", album.Gallery.Uri.ToString(), id.ToString()));
                    }
                } catch (System.Exception e) {
                    progress_dialog.Message      = String.Format(Catalog.GetString("Error uploading picture \"{0}\" to Gallery: {1}"), item.Name, e.Message);
                    progress_dialog.ProgressText = Catalog.GetString("Error");
                    Console.WriteLine(e);

                    if (progress_dialog.PerformRetrySkip())
                    {
                        photo_index--;
                    }
                }
            }

            progress_dialog.Message      = Catalog.GetString("Done Sending Photos");
            progress_dialog.Fraction     = 1.0;
            progress_dialog.ProgressText = Catalog.GetString("Upload Complete");
            progress_dialog.ButtonLabel  = Gtk.Stock.Ok;

            if (browser)
            {
                GnomeUtil.UrlShow(album.GetUrl());
            }
        }
 void CheckCorrecAns()
 {
     album.Add(idPieceAlbum.IdPiece);
     PlayerPrefs.SetString("Album Piece" + idPieceAlbum.IdPiece, "true");
     idPieceAlbum.gameObject.SetActive(false);
 }
Beispiel #23
0
        public void Activate()
        {
            Window window = NUIApplication.GetDefaultWindow();

            albumSource = new AlbumViewModel();
            // Add test menu options.
            moveGroup.Add(moveMenu);
            albumSource.Insert(0, moveGroup);
            insertDeleteGroup.Add(insertMenu);
            insertDeleteGroup.Add(deleteMenu);
            albumSource.Insert(0, insertDeleteGroup);

            selMode = ItemSelectionMode.Single;
            DefaultTitleItem myTitle = new DefaultTitleItem();

            //To Bind the Count property changes, need to create custom property for count.
            myTitle.Text = "Linear Sample Group[" + albumSource.Count + "]";
            //Set Width Specification as MatchParent to fit the Item width with parent View.
            myTitle.WidthSpecification = LayoutParamPolicies.MatchParent;

            colView = new CollectionView()
            {
                ItemsSource   = albumSource,
                ItemsLayouter = new LinearLayouter(),
                ItemTemplate  = new DataTemplate(() =>
                {
                    DefaultLinearItem item = new DefaultLinearItem();
                    //Set Width Specification as MatchParent to fit the Item width with parent View.
                    item.WidthSpecification = LayoutParamPolicies.MatchParent;
                    //Decorate Label
                    item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
                    item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
                    //Decorate Icon
                    item.Icon.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");
                    item.Icon.WidthSpecification  = 80;
                    item.Icon.HeightSpecification = 80;
                    //Decorate Extra RadioButton.
                    //[NOTE] This is sample of RadioButton usage in CollectionView.
                    // RadioButton change their selection by IsSelectedProperty bindings with
                    // SelectionChanged event with Single ItemSelectionMode of CollectionView.
                    // be aware of there are no RadioButtonGroup.
                    item.Extra = new RadioButton();
                    //FIXME : SetBinding in RadioButton crashed as Sensitive Property is disposed.
                    //item.Extra.SetBinding(RadioButton.IsSelectedProperty, "Selected");
                    item.Extra.WidthSpecification  = 80;
                    item.Extra.HeightSpecification = 80;

                    return(item);
                }),
                GroupHeaderTemplate = new DataTemplate(() =>
                {
                    DefaultTitleItem group = new DefaultTitleItem();
                    //Set Width Specification as MatchParent to fit the Item width with parent View.
                    group.WidthSpecification = LayoutParamPolicies.MatchParent;

                    group.Label.SetBinding(TextLabel.TextProperty, "Date");
                    group.Label.HorizontalAlignment = HorizontalAlignment.Begin;

                    return(group);
                }),
                Header              = myTitle,
                IsGrouped           = true,
                ScrollingDirection  = ScrollableBase.Direction.Vertical,
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                SelectionMode       = selMode
            };
            colView.SelectionChanged += SelectionEvt;

            window.Add(colView);
        }
Beispiel #24
0
        public void SelectionEvt(object sender, SelectionChangedEventArgs ev)
        {
            //Tizen.Log.Debug("NUI", "LSH :: SelectionEvt called");

            //SingleSelection Only have 1 or nil object in the list.
            foreach (object item in ev.PreviousSelection)
            {
                if (item == null)
                {
                    break;
                }
                if (item is Gallery unselItem)
                {
                    unselItem.Selected = false;
                    selectedItem       = null;
                    //Tizen.Log.Debug("NUI", "LSH :: Unselected: {0}", unselItem.ViewLabel);
                }
                else if (item is Album selAlbum)
                {
                    selectedItem      = selAlbum.Title;
                    selAlbum.Selected = false;
                    if (selAlbum == insertDeleteGroup)
                    {
                        albumSource.RemoveAt(2);
                    }
                }
            }
            foreach (object item in ev.CurrentSelection)
            {
                if (item == null)
                {
                    break;
                }
                if (item is Gallery selItem)
                {
                    selItem.Selected = true;
                    selectedItem     = selItem.Name;
                    //Tizen.Log.Debug("NUI", "LSH :: Selected: {0}", selItem.ViewLabel);

                    // Check test menu options.
                    if (selItem == insertMenu)
                    {
                        // Insert new item to index 3.
                        Random rand = new Random();
                        int    idx  = rand.Next(1000);
                        albumSource[2].Insert(0, new Gallery(idx, "Inserted Item"));
                    }
                    else if (selItem == deleteMenu)
                    {
                        // Remove item in index 3.
                        albumSource[2].RemoveAt(0);
                    }
                    else if (selItem == moveMenu)
                    {
                        // Move last indexed item to index 3.
                        albumSource[2].Move(albumSource[2].Count - 1, 0);
                    }
                }
                else if (item is Album selAlbum)
                {
                    selectedItem      = selAlbum.Title;
                    selAlbum.Selected = true;
                    if (selAlbum == insertDeleteGroup)
                    {
                        Random rand        = new Random();
                        int    groupIdx    = rand.Next(1000);
                        Album  insertAlbum = new Album(groupIdx, "Inserted group", new DateTime(1999, 12, 31));
                        int    idx         = rand.Next(1000);
                        insertAlbum.Add(new Gallery(idx, "Inserted Item 1"));
                        idx = rand.Next(1000);
                        insertAlbum.Add(new Gallery(idx, "Inserted Item 2"));
                        idx = rand.Next(1000);
                        insertAlbum.Add(new Gallery(idx, "Inserted Item 3"));
                        albumSource.Insert(2, insertAlbum);
                    }
                    else if (selAlbum == moveGroup)
                    {
                        albumSource.Move(albumSource.Count - 1, 2);
                    }
                }
            }
            if (colView.Header != null && colView.Header is DefaultTitleItem)
            {
                DefaultTitleItem title = (DefaultTitleItem)colView.Header;
                title.Text = "Linear Sample Count[" + albumSource.Count + (selectedItem != null ? "] Selected [" + selectedItem + "]" : "]");
            }
        }