Example #1
0
        private void OnDownloadTaskCompletedHandler(object sender, TaskCompletedEventArgs args)
        {
            HttpFileDownloadTask task = sender as HttpFileDownloadTask;
            FeedEnclosure        enc  = task.UserState as FeedEnclosure;

            if (enc != null)
            {
                if (args.Error != null || task.Status == TaskStatus.Failed)
                {
                    enc.DownloadStatus = FeedDownloadStatus.DownloadFailed;
                }
                else if (!args.Cancelled)
                {
                    if (task.Status == TaskStatus.Succeeded)
                    {
                        try {
                            enc.SetFileImpl(
                                task.RemoteUri.ToString(),
                                Path.GetDirectoryName(task.LocalPath),
                                task.MimeType,
                                Path.GetFileName(task.LocalPath)
                                );
                        } catch (Exception e) {
                            Log.Error(e);
                            enc.LastDownloadError = FeedDownloadError.DownloadFailed;
                            enc.DownloadStatus    = FeedDownloadStatus.DownloadFailed;
                            enc.Save();
                        }
                    }
                }
            }
        }
Example #2
0
        public void Save()
        {
            bool is_new = DbId < 1;

            Provider.Save(this);
            if (enclosure != null)
            {
                enclosure.Item = this;
                enclosure.Save(false);
            }

            if (is_new)
            {
                Manager.OnItemAdded(this);
            }
            else
            {
                Manager.OnItemChanged(this);
            }
        }