Ejemplo n.º 1
0
        static public Job CreateNewJob(JobClass type = JobClass.Normal, Job.SubInfo info = null)
        {
            var newjob = InternalCreateJob(type, info);

            TriggerDisplay();
            return(newjob);
        }
Ejemplo n.º 2
0
        static private Job InternalCreateJob(JobClass type, Job.SubInfo info)
        {
            var newjob = new Job();

            newjob.JobType = type;
            joblist.Add(newjob);
            jobempty = false;
            if (type == JobClass.Upload)
            {
                if (UploadInfoJob == null)
                {
                    UploadInfoJob             = CreateNewJob(JobClass.UploadInfo);
                    UploadInfoJob.DisplayName = "Upload Progress";
                    UploadInfoJob.StartTime   = DateTime.Now;
                }
                Interlocked.Increment(ref UploadAll);
                newjob.index   = Interlocked.Increment(ref UploadCur);
                info.index     = newjob.index;
                newjob.JobInfo = info;
                if (info?.type == Job.SubInfo.SubType.UploadFile)
                {
                    Interlocked.Increment(ref UploadFileAll);
                    Interlocked.Add(ref UploadTotal, info.size);
                }
                else if (info?.type == Job.SubInfo.SubType.UploadDirectory)
                {
                    Interlocked.Increment(ref UploadFolderAll);
                }
            }
            else if (type == JobClass.Download)
            {
                if (DownloadInfoJob == null)
                {
                    DownloadInfoJob             = CreateNewJob(JobClass.DownloadInfo);
                    DownloadInfoJob.DisplayName = "Download Progress";
                    DownloadInfoJob.StartTime   = DateTime.Now;
                }
                Interlocked.Increment(ref DownloadAll);
                newjob.index   = Interlocked.Increment(ref DownloadCur);
                info.index     = newjob.index;
                newjob.JobInfo = info;
                if (info?.type == Job.SubInfo.SubType.DownloadFile)
                {
                    Interlocked.Add(ref DownloadTotal, info.size);
                }
            }
            joblist_type.AddOrUpdate(type,
                                     (key) =>
            {
                var newitem = new ConcurrentBag <Job>();
                newitem.Add(newjob);
                return(newitem);
            },
                                     (key, value) =>
            {
                value.Add(newjob);
                return(value);
            });
            return(newjob);
        }
Ejemplo n.º 3
0
        static public Job CreateNewJob(JobClass type = JobClass.Normal, Job.SubInfo info = null, params Job[] depends)
        {
            var newjob = InternalCreateJob(type, info);

            foreach (var d in depends)
            {
                if (d != null)
                {
                    newjob.DependsOn.Enqueue(d);
                }
            }
            TriggerDisplay();
            return(newjob);
        }