Esempio n. 1
0
        public void UpdatePath(string newPath)
        {
            if (!File.Exists(newPath))
            {
                throw new ArgumentException("newPath must be valid path");
            }

            AlbumManager mgr = GetManager(false);

            if (mgr != null)
            {
                // Just pull new info from the manager
                _albumPath = mgr.FullName;
                Text       = mgr.ShortName;
            }
            else
            {
                // use given path to update node
                _albumPath = newPath;
                Text       = Path.GetFileNameWithoutExtension(newPath);
            }
        }
Esempio n. 2
0
 public bool RenameAlbum(string newName)
 {
     try
     {
         AlbumManager mgr = GetManager(false);
         if (mgr == null)
         {
             _albumPath = AlbumManager.RenameAlbum(AlbumPath, newName);
         }
         else
         {
             mgr.RenameAlbum(newName);
             _albumPath = mgr.FullName;
         }
         return(true);
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Unable to rename album. An album with that name already exists.");
         return(false);
     }
 }
Esempio n. 3
0
        private bool SaveAndCloseAlbum()
        {
            DialogResult result = AlbumController.AskForSave(Manager);

            if (result == DialogResult.Yes)
            {
                SaveAlbum();
            }
            else if (result == DialogResult.Cancel)
            {
                return(false); // do not close
            }
            // Close the album and return true
            if (Manager.Album != null)
            {
                Manager.Album.Dispose();
            }

            Manager = new AlbumManager();
            SetTitleBar();
            return(true);
        }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.Get("SK") != null)
        {
            string searchKey = Request.QueryString.Get("SK");

            if (searchKey.Length > 3)
            {
                NewsAndEventManager      newsAndEventsManager = new NewsAndEventManager();
                List <NewsAndEventsItem> news    = newsAndEventsManager.SearchNewsHeadlines(searchKey);
                List <NewsAndEventsItem> events  = newsAndEventsManager.SearchEventsHeadlines(searchKey);
                List <NewsLetter>        letters = newsAndEventsManager.SearchNewsLetters(searchKey);

                AlbumManager albumManager = new AlbumManager();
                List <Album> albums       = albumManager.SearchAlbums(searchKey);

                if (news.Count == 0 && events.Count == 0 && letters.Count == 0 && albums.Count == 0)
                {
                    Session["error"] = "No Match Found";
                }
                else
                {
                    Session["news"]        = news;
                    Session["events"]      = events;
                    Session["newsLetters"] = letters;
                    Session["albums"]      = albums;
                    Session["error"]       = null;
                }
            }
            else
            {
                Session["error"] = "You must include at least one positive keyword with 3 characters or more.";
            }
        }
        else
        {
            Response.Redirect(Request.ApplicationPath + "/Default.aspx");
        }
    }
        /// <summary>
        /// Deserializer method that reads the data.bin file in root (if exists) and retrieve its data.
        /// </summary>
        /// <param name="errorMessage"></param>
        /// <returns>instance of retrieved ablum manager</returns>
        public static AlbumManager Deserialize(out string errorMessage)
        {
            FileStream fileStream = null;

            errorMessage = null;
            AlbumManager albumManager = new AlbumManager();

            try
            {
                if (File.Exists(DefaultTargetFile))
                {
                    fileStream = new FileStream(DefaultTargetFile, FileMode.Open);
                    BinaryFormatter b = new BinaryFormatter();
                    if (new FileInfo(DefaultTargetFile).Length > 0)
                    {
                        try
                        {
                            albumManager = (AlbumManager)b.Deserialize(fileStream);
                        }
                        catch (System.Text.DecoderFallbackException e)
                        {
                            errorMessage = "Error in decoding the saved data. File is corrupt. \n" + e.Message;
                        }
                    }
                }
            }
            catch (SerializationException e)
            {
                errorMessage = "Error loading saved data .\n" + e.Message;
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
            return(albumManager);
        }
Esempio n. 6
0
        /// <summary>
        /// Method to update a <see cref="AlbumEntity"/> asynchronous.
        /// </summary>
        /// <param name="entity">An <see cref="AlbumEntity"/> to update.</param>
        /// <param name="autoDate">Auto initialize dates.</param>
        /// <returns>The updated <see cref="AlbumEntity"/>.</returns>
        public async Task <AlbumEntity> UpdateAsync(AlbumEntity entity, bool autoDate = true)
        {
            if (entity == null)
            {
                return(null);
            }

            using (Db.Context)
            {
                // Try to attach entity to the database context.
                try { Db.Context.Attach(entity); }
                catch (Exception e)
                {
                    InvalidOperationException i = new InvalidOperationException($"Error on database Context Attach {entity?.GetType()}", e);
                    log.Error(i.Output());
                    throw;
                }

                // Update entity.
                return(await AlbumManager.UpdateAsync(entity, autoDate));
            }
        }
Esempio n. 7
0
        public ActionResult Edit(ManageAlbumViewModel model, System.Web.HttpPostedFileBase file)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (file != null && file.ContentLength > 0)
            {
                var fileName = System.IO.Path.Combine(Request.MapPath("~/Content/Album/"), System.IO.Path.GetFileName(file.FileName));
                file.SaveAs(fileName);
                model.Cover = System.IO.Path.GetFileName(file.FileName);

                string oldCover = _db.tbl_Album.SingleOrDefault(a => a.album_Id == model.Id).album_Cover;
                if (model.Cover != oldCover && oldCover != "Album_1.jpg")
                {
                    ImageManager.Delete(Server.MapPath("~/Content/Album/" + oldCover));
                }
            }
            AlbumManager.Edit(model);
            ModelState.AddModelError("", "修改成功");
            return(RedirectToAction("Edit", new { id = model.Id }));
        }
Esempio n. 8
0
        private void lvAlbumList_ItemActivate(object sender, EventArgs e)
        {
            // ListViewItem is visible and selected
            ListViewItem item = lvAlbumList.SelectedItems[0];
            TreeNode     node = null;

            if (ShowingAlbums)
            {
                string       albumPath;
                AlbumManager mgr = item.Tag as AlbumManager;
                if (mgr == null)
                {
                    albumPath = item.Tag as string;
                }
                else
                {
                    albumPath = mgr.FullName;
                }

                if (albumPath != null)
                {
                    node = atvAlbumTree.FindAlbumNode(albumPath);
                }
            }
            else
            {
                Photo photo = item.Tag as Photo;
                if (photo != null)
                {
                    node = atvAlbumTree.FindPhotoNode(photo);
                }
            }

            if (node != null)
            {
                atvAlbumTree.SelectedNode = node;
            }
        }
Esempio n. 9
0
        private void RenameAlbum(ListViewItem item, string newName)
        {
            try
            {
                string oldPath = null;
                string newPath = null;

                if (item.Tag is AlbumManager)
                {
                    AlbumManager mgr = (AlbumManager)item.Tag;
                    oldPath = mgr.FullName;
                    mgr.RenameAlbum(newName);
                    newPath = mgr.FullName;
                }
                else if (item.Tag is string)
                {
                    // Presume tag is album path
                    oldPath  = (string)item.Tag;
                    newPath  = AlbumManager.RenameAlbum(oldPath, newName);
                    item.Tag = newPath;
                }

                if (oldPath != null)
                {
                    // Update the album node
                    AlbumNode aNode = atvAlbumTree.FindAlbumNode(oldPath);
                    if (aNode != null)
                    {
                        aNode.UpdatePath(newPath);
                    }
                }
            }
            catch (ArgumentException aex)
            {
                MessageBox.Show("Unable to rename album. ["
                                + aex.Message + "]");
            }
        }
Esempio n. 10
0
        private void ListPhotoData(AlbumNode albumNode)
        {
            spbxPhoto.Visible   = false;
            lvAlbumList.Visible = true;
            ShowingAlbums       = false;

            lvAlbumList.Columns.Add("Caption", 120);
            lvAlbumList.Columns.Add("Photographer", 100);
            lvAlbumList.Columns.Add("Taken", 80, HorizontalAlignment.Center);
            lvAlbumList.Columns.Add("File Name", 200);

            AlbumManager mgr = albumNode.GetManager(true);

            if (mgr != null)
            {
                foreach (Photograph p in mgr.Album)
                {
                    ListViewItem item = new ListViewItem(p.Caption, "Photp");
                    AssignSubItems(item, p);
                    lvAlbumList.Items.Add(item);
                }
            }
        }
 public static DialogResult AskForSave(AlbumManager manager)
 {
     if (manager.Album.HasChanged)
     {
         string msg;
         if (manager.FullName == null)
         {
             msg = "Do you wish to save your changes?";
         }
         else
         {
             msg = "Do you wish to save your changes to " +
                   manager.ShortName + "?";
         }
         // Ask user if they wish to save file
         DialogResult result = MessageBox.Show(
             msg, "Save changes?",
             MessageBoxButtons.YesNoCancel,
             MessageBoxIcon.Question);
         return(result);
     }
     return(DialogResult.No);
 }
        private void AssignSubItems(ListViewItem item, string path, AlbumManager mgr)
        {
            item.SubItems.Clear();
            item.Text = Path.GetFileNameWithoutExtension(path);

            ListViewItem.ListViewSubItem subItem;
            if (mgr == null)
            {
                item.Tag = path;
                item.SubItems.Add("");
                subItem = item.SubItems.Add("?");
            }
            else
            {
                PhotoAlbum album = mgr.Album;
                int        count = album.Count;

                item.Tag = mgr;
                item.SubItems.Add(album.Title);
                subItem     = item.SubItems.Add(count.ToString());
                subItem.Tag = count;
            }
        }
Esempio n. 13
0
        private void DisplayTreeNodeProperties()
        {
            TreeNode node = atvAlbumTree.SelectedNode;

            if (node is AlbumNode)
            {
                AlbumNode    aNode = (AlbumNode)node;
                AlbumManager mgr   = aNode.GetManager(true);
                if (mgr != null)
                {
                    DisplayAlbumProperties(mgr);
                }
            }
            else if (node is PhotoNode)
            {
                PhotoNode pNode = (PhotoNode)node;
                DisplayPhotoProperties(pNode.Photograph);
            }

            // Preserve and display any changes
            atvAlbumTree.SaveAlbumChanges();
            atvAlbumTree.RefreshNode();
        }
Esempio n. 14
0
        private void OpenAlbum(string path)
        {
            string password = null;

            if (path != null && path.Length > 0 &&
                AlbumController.CheckAlbumPassword(path, ref password))
            {
                if (CloseAlbum())
                {
                    return; // cancel open
                }
                try
                {
                    Manager = new AlbumManager(path, password);
                }
                catch (AlbumStorageException)
                {
                    Manager = null;
                }
            }
            UpdateTabs();
            EnablePhotoButtons();
        }
        private void ListAlbumData(AlbumDirectoryNode dirNode)
        {
            // Show albums in list view
            spbxPhoto.Visible   = false;
            lvAlbumList.Visible = true;
            ShowingAlbums       = true;

            //Presume list cleared, so recreate columns
            lvAlbumList.Columns.Add("Name", 80);
            lvAlbumList.Columns.Add("Title", 120);
            lvAlbumList.Columns.Add("Size", 40, HorizontalAlignment.Center);

            // Add them albums for given node
            foreach (AlbumNode aNode in dirNode.AlbumNodes)
            {
                string       text = Path.GetFileNameWithoutExtension(aNode.AlbumPath);
                ListViewItem item = lvAlbumList.Items.Add(text);

                AlbumManager mgr = aNode.GetManager(false);
                item.ImageKey = aNode.ImageKey;
                AssignSubItems(item, aNode.AlbumPath, mgr);
            }
        }
        /// <summary>
        /// Serializer Method that takes an instance of album manager and serialize its content to a file from SaveFileDialog
        /// </summary>
        /// <param name="albumManager"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool Serialize(AlbumManager albumManager, string filePath)
        {
            FileStream fileStream = null;

            try
            {
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                fileStream = new FileStream(filePath, FileMode.Create);
                binaryFormatter.Serialize(fileStream, albumManager);
            }
            catch
            {
                return(false);
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
            return(true);
        }
Esempio n. 17
0
        private bool CloseAlbum()
        {
            if (Manager != null)
            {
                DialogResult result = AlbumController.AskForSave(Manager);
                switch (result)
                {
                case DialogResult.None:
                    break;

                case DialogResult.OK:
                    break;

                case DialogResult.Cancel:
                    return(true);

                case DialogResult.Abort:
                    break;

                case DialogResult.Retry:
                    break;

                case DialogResult.Ignore:
                    break;

                case DialogResult.Yes:
                    Manager.Save();
                    break;

                case DialogResult.No:
                    break;
                }
                Manager.Album.Dispose();
                Manager = null;
            }
            return(false);
        }
Esempio n. 18
0
 public AlbumManager GetManager(bool interactive)
 {
     if (_manager == null)
     {
         string path = AlbumPath;
         string pwd  = null;
         try
         {
             if (AlbumStorage.IsEncrypted(path))
             {
                 DialogResult result = DialogResult.None;
                 if (interactive)
                 {
                     result = MessageBox.Show("The album " + path + "is encrypted. " + "Do you wish to open this album?", "Encrypted Album", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                 }
                 if (result != DialogResult.Yes || !AlbumController.CheckAlbumPassword(path, ref pwd))
                 {
                     return(null);
                 }
             }
             _manager              = new AlbumManager(path, pwd);
             this.ImageKey         = "Album";
             this.SelectedImageKey = "AlbumSelect";
         }
         catch (AlbumStorageException ex)
         {
             if (interactive)
             {
                 MessageBox.Show("The album could not be opened [" + ex.Message + "]");
             }
             this.ImageKey         = "AlbumError";
             this.SelectedImageKey = "AlbumError";
             _manager = null;
         }
     }
     return(_manager);
 }
    private IEnumerator Start()
    {
        yield return(new WaitForEndOfFrame());

        mAlbumManager = new AlbumManager();
        DOTween.Init();
        iTween.Init(base.gameObject);
        mKeyController = new KeyControl();
        mStateManager  = new StateManager <State>(State.None);
        mUIAlbumSelectGate.SetOnSelectedShipAlbumListener(OnSelectedShipAlbumListener);
        mUIAlbumSelectGate.SetOnSelectedSlotItemAlbumListener(OnSelectedSlotItemAlbumListener);
        mUIAlbumSelectGate.SetOnSelectedBackListener(OnSelectedBackListener);
        mUIAlbumSelectGate.SetActive(isActive: false);
        mUserInterfaceShipAlbumManager.SetOnBackListener(OnBackShipAlbumListener);
        mUserInterfaceShipAlbumManager.SetOnChangeStateListener(OnChangeStateUserInterfaceShipAlbumManager);
        mUserInterfaceShipAlbumManager.SetActive(isActive: false);
        mUserInterfaceSlotItemAlbumManager.SetOnChangeStateListener(OnChangeStateUserInterfaceSlotItemAlbumManager);
        mUserInterfaceSlotItemAlbumManager.SetOnBackListener(OnBackSlotItemAlbumListener);
        mUserInterfaceSlotItemAlbumManager.SetActive(isActive: false);
        yield return(new WaitForEndOfFrame());

        local.utils.Utils.GetSlotitemType3Name(0);
        yield return(new WaitForEndOfFrame());

        mStateManager.OnPush   = OnPushState;
        mStateManager.OnPop    = OnPopState;
        mStateManager.OnResume = OnResumeState;
        if (SingletonMonoBehaviour <UIPortFrame> .exist())
        {
            SingletonMonoBehaviour <UIPortFrame> .Instance.gameObject.SetActive(false);
        }
        yield return(new WaitForEndOfFrame());

        SingletonMonoBehaviour <PortObjectManager> .Instance.PortTransition.EndTransition(null);

        mStateManager.PushState(State.AlbumSelectGate);
    }
Esempio n. 20
0
 public AlbumNode(string name, string albumPath) : base(name)
 {
     if (albumPath == null)
     {
         throw new ArgumentNullException("albumPath");
     }
     if (!File.Exists(albumPath))
     {
         throw new ArgumentException("albumPath is not valid path");
     }
     _manager   = null;
     _albumPath = Path.GetFullPath(albumPath);
     this.Nodes.Add("child");
     if (AlbumStorage.IsEncrypted(albumPath))
     {
         this.ImageKey         = "AlbumLock";
         this.SelectedImageKey = "AlbumLock";
     }
     else
     {
         this.ImageKey         = "Album";
         this.SelectedImageKey = "AlbumSelect";
     }
 }
Esempio n. 21
0
        private void mnuFileOpen_Click(object sender, EventArgs e)
        {
            // Allow user to select a new album
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Title  = "Open Album";
            dlg.Filter = "Album files (*.abm)|*.abm|"
                         + "All files (*.*)|*.*";
            dlg.InitialDirectory = AlbumManager.DefaultPath;
            dlg.RestoreDirectory = true;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string path = dlg.FileName;
                // TODO: save any existing album.
                // Close any existing album
                if (!SaveAndCloseAlbum())
                {
                    return; // Close canceled
                }
                try
                {
                    // Open the new album
                    Manager = new AlbumManager(path);
                }
                catch (AlbumStorageException aex)
                {
                    string msg = String.Format("Unableto open album file {0}\n({1})", path, aex.Message);
                    MessageBox.Show(msg, "Unable to Open");
                    Manager = new AlbumManager();
                }
                // TODO: handle invalid album file
                Manager = new AlbumManager(dlg.FileName);
                DisplayAlbum();
            }
            dlg.Dispose();
        }
Esempio n. 22
0
        private bool SaveAndCloseAlbum()
        {
            if (Manager.Album.HasChanged)
            {
                // Offer to save the current album
                string msg;
                if (String.IsNullOrEmpty(Manager.Fullname))
                {
                    msg = "Do you wish to save your changes?";
                }
                else
                {
                    msg = String.Format("Do you wish to save changes to \n{0}?", Manager.Fullname);
                }

                DialogResult result = MessageBox.Show(this, msg, "Save Changes?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    SaveAlbum();
                }
                else if (result == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            // Close the album and return true
            if (Manager.Album != null)
            {
                Manager.Album.Dispose();
            }

            Manager = new AlbumManager();
            SetTitleBar();
            return(true);
        }
Esempio n. 23
0
 public Form1(string path, string pwd)
     : this()
 {// Caller must deal with any exception
     Manager = new AlbumManager(path, pwd);
 }
Esempio n. 24
0
 public MainPage()
 {
     this.InitializeComponent();
     Albums = AlbumManager.GetAlbums();
 }
Esempio n. 25
0
 public EditorForm()
 {
     InitializeComponent();
     Manager = new AlbumManager();
 }
Esempio n. 26
0
        private IResponseMessageBase GetResponseMessage(KeywordInfo keywordInfo, string keyword)
        {
            try
            {
                if (keywordInfo != null && !keywordInfo.IsDisabled)
                {
                    if (keywordInfo.KeywordType == EKeywordType.Text)
                    {
                        DataProviderWX.CountDAO.AddCount(publishmentSystemInfo.PublishmentSystemId, ECountType.RequestText);

                        var responseMessage = CreateResponseMessage <ResponseMessageText>();
                        responseMessage.Content = keywordInfo.Reply;
                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.News)
                    {
                        DataProviderWX.CountDAO.AddCount(publishmentSystemInfo.PublishmentSystemId, ECountType.RequestNews);

                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();

                        foreach (var resourceInfo in DataProviderWX.KeywordResourceDAO.GetResourceInfoList(keywordInfo.KeywordID))
                        {
                            var imageUrl = PageUtils.AddProtocolToUrl(PageUtility.ParseNavigationUrl(publishmentSystemInfo, resourceInfo.ImageUrl));

                            var pageUrl = string.Empty;
                            if (resourceInfo.ResourceType == EResourceType.Site)
                            {
                                if (resourceInfo.ChannelID > 0 && resourceInfo.ContentID > 0)
                                {
                                    pageUrl = PageUtilityWX.GetContentUrl(publishmentSystemInfo, resourceInfo.ChannelID, resourceInfo.ContentID, false);
                                }
                                else if (resourceInfo.ChannelID > 0)
                                {
                                    pageUrl = PageUtilityWX.GetChannelUrl(publishmentSystemInfo, resourceInfo.ChannelID);
                                }
                                else
                                {
                                    pageUrl = PageUtilityWX.GetChannelUrl(publishmentSystemInfo, publishmentSystemInfo.PublishmentSystemId);
                                }
                            }
                            else if (resourceInfo.ResourceType == EResourceType.Content)
                            {
                                pageUrl = PageUtilityWX.GetWeiXinFileUrl(publishmentSystemInfo, resourceInfo.KeywordID, resourceInfo.ResourceID);
                            }
                            else if (resourceInfo.ResourceType == EResourceType.Url)
                            {
                                pageUrl = resourceInfo.NavigationUrl;
                            }

                            responseMessage.Articles.Add(new Article()
                            {
                                Title       = resourceInfo.Title,
                                Description = MPUtils.GetSummary(resourceInfo.Summary, resourceInfo.Content),
                                PicUrl      = imageUrl,
                                Url         = pageUrl
                            });
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Coupon)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = CouponManager.Trigger(keywordInfo, keyword, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Vote)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = VoteManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Message)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = MessageManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Appointment)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = AppointmentManager.Trigger(keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Conference)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = ConferenceManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Map)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = MapManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.View360)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = View360Manager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Album)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = AlbumManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Scratch)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.Scratch, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.BigWheel)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.BigWheel, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.GoldEgg)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.GoldEgg, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Flap)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.Flap, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.YaoYao)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = LotteryManager.Trigger(keywordInfo, ELotteryType.YaoYao, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Search)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = SearchManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Store)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = StoreManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Collect)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = CollectManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                    else if (keywordInfo.KeywordType == EKeywordType.Card)
                    {
                        var responseMessage = CreateResponseMessage <ResponseMessageNews>();
                        var articleList     = CardManager.Trigger(publishmentSystemInfo, keywordInfo, RequestMessage.FromUserName);
                        if (articleList.Count > 0)
                        {
                            foreach (var article in articleList)
                            {
                                responseMessage.Articles.Add(article);
                            }
                        }

                        return(responseMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtils.AddLog(string.Empty, "Gexia Error", ex.StackTrace);
            }

            return(null);
        }
Esempio n. 27
0
        public async Task GetPhotoAlbumsCallsApiClient()
        {
            AlbumManager sut = CreateSystemUnderTest();

            await sut.GetPhotoAlbumsAsync(default);
Esempio n. 28
0
 private void NewAlbum()
 {
     // TODO: clean up,  save  existing album
     Manager = new AlbumManager();
     DisplayAlbum();
 }
 public MainForm(string path, string pwd) : this()
 {
     Manager = new AlbumManager(path, pwd);
 }
Esempio n. 30
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Dispose managed
            }

            // Dispose unmanaged
            if (!IsInvalid)
            {
                try
                {
                    _mainThreadNotification.Set();

                    lock (_eventQueueLock)
                    {
                        Monitor.Pulse(_eventQueueLock);
                    }

                    if (_callbacks != null)
                    {
                        _callbacks.Dispose();
                        _callbacks = null;
                    }

                    PlaylistTrackManager.RemoveAll(this);
                    TrackManager.DisposeAll(this);

                    LinkManager.RemoveAll(this);
                    UserManager.RemoveAll(this);

                    PlaylistContainerManager.RemoveAll(this);
                    PlaylistManager.RemoveAll(this);
                    ContainerPlaylistManager.RemoveAll(this);
                    ArtistManager.RemoveAll();
                    AlbumManager.RemoveAll();

                    SessionManager.Remove(Handle);

                    lock (Spotify.Mutex)
                    {
                        Error error = Error.OK;

                        if (ConnectionState == ConnectionState.LoggedIn)
                        {
                            error = Spotify.sp_session_logout(Handle);
                            Debug.WriteLineIf(error != Error.OK, error.GetMessage());
                        }

                        error = Spotify.sp_session_release(Handle);
                        Debug.WriteLineIf(error != Error.OK, error.GetMessage());
                        Handle = IntPtr.Zero;
                    }
                }
                catch
                {
                    // Ignore
                }
                finally
                {
                    Debug.WriteLine("Session disposed");
                }
            }

            base.Dispose(disposing);
        }