예제 #1
0
 private void _timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (_datus.Count != 0)
     {
         IDataOpItem d = _datus.Dequeue();
         d.Action(_datacenter);
     }
 }
예제 #2
0
        private void _dc_Began(IDataOpItem item, long length)
        {
            string dir = (new FileInfo(item.Target)).DirectoryName;

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            Began?.Invoke(item, length);
        }
예제 #3
0
        private void _dc_Ended(IDataOpItem item)
        {
            if (item is DownloadDataItem)
            {
                DownloadDataItem ddi = item as DownloadDataItem;
                if (ddi.Success)
                {
                    if (_excludedItems.Contains(Kits.GetFilename(ddi.Target)))
                    {
                        return;
                    }
                    _downedCount++;
                    //unpackage
                    string target = ddi.Target.Replace(@"\" + _temp, "");

                    string dir = (new FileInfo(target)).DirectoryName;
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    try
                    {
                        int l = ResourcePackage.Unpackage(ddi.Target, target);
                        Notified?.Invoke(CVRDownloadResult.Finished, new FinishedItem {
                            Name = target, Length = l
                        });
                    }
                    catch
                    {
                        Notified?.Invoke(CVRDownloadResult.UnpackageHappened, target);
                    }

                    if (_requestedCount == _downedCount)
                    {
                        string targetemp = Path.Combine(Target, _temp);
                        if (Directory.Exists(targetemp))
                        {
                            Kits.DeleteDirectory(targetemp);
                        }

                        Notified?.Invoke(CVRDownloadResult.Completed, _downedCount);
                    }
                }
                else
                {
                    Notified?.Invoke(CVRDownloadResult.DownloadHappened, ddi.Source);
                }
            }
        }
예제 #4
0
        private void _dc_Ended(IDataOpItem item)
        {
            Ended?.Invoke(item);

            if (++_curIndex >= _curNum)
            {
                if (++_pageNo < _pageCount)
                {
                    _to.Select(_sqlString, _pageSize, _pageNo);
                }
                else
                {
                    Completed?.Invoke();
                }
            }
        }
예제 #5
0
        private void _dc_Ended(IDataOpItem item)
        {
            if (item is DownloadDataItem)
            {
                DownloadDataItem ddi = item as DownloadDataItem;
                if (ddi.Success)
                {
                    string crc = FileMD5.Create(ddi.Target);
                    if (crc == ddi.Crc)
                    {
                        string localPathfile = _dc.GetLocalPathfile(ddi.Source);

                        try
                        {
                            if (LocalFile)
                            {
                                ResourcePackage.Unpackage(ddi.Target, localPathfile);
                                Notified?.Invoke(CVResRequestResult.RequestFileSucceed, localPathfile);
                            }
                            else
                            {
                                byte[] buff = ResourcePackage.Unpackage(File.ReadAllBytes(ddi.Target));
                                Notified?.Invoke(CVResRequestResult.RequestDataSucceed, buff);
                            }
                        }
                        catch (NullReferenceException)
                        {
                            Notified?.Invoke(CVResRequestResult.UnpackageFailed, localPathfile);
                        }
                        catch (IOException)
                        {
                            Notified?.Invoke(CVResRequestResult.WriteFailed, localPathfile);
                        }
                    }
                    else
                    {
                        Notified?.Invoke(CVResRequestResult.CrcFailded, ddi.Message);
                    }
                }
                else
                {
                    Notified?.Invoke(CVResRequestResult.DownloadFailed, ddi.Message);
                }
            }
        }
예제 #6
0
        private void _dc_Ended(IDataOpItem item)
        {
            if (item is UploadDataItem)
            {
                UploadDataItem udi = item as UploadDataItem;

                if (udi.Success)
                {
                    string source = udi.Tag as string;
                    string crc    = FileMD5.Create(udi.Source);
                    string name   = Kits.GetFilename(source);

                    string pathname = _dc.GetPathfileByRemotePathfile(udi.Target);

                    ResourceOp rop = OpFactory <ResourceOp> .Create(_ic);

                    rop.Add(pathname, name, udi.Group, 0, udi.Version, Kits.GetLastWriteTime(source), udi.Remark, "cvraddresource", crc);
                }
                else
                {
                    Notified?.Invoke(CVReSubmitResult.UploadFailed, udi.Message);
                }
            }
        }
예제 #7
0
 private void _dc_Stepped(IDataOpItem item, long segment)
 {
     Stepped?.Invoke(item, segment);
 }
예제 #8
0
 /// <summary>
 /// 执行操作
 /// </summary>
 /// <param name="di"></param>
 /// <param name="replied">默认不回执</param>
 public void Execute(IDataOpItem di, bool replied = false)
 {
     di.Replied = replied;
     di.Action(this);
 }
예제 #9
0
 /// <summary>
 /// 增加任务队列内容
 /// </summary>
 /// <param name="di"></param>
 /// <param name="replied">默认回执</param>
 public void Add(IDataOpItem di, bool replied = true)
 {
     di.Replied = replied;
     _dataOpQue?.Add(di);
 }
예제 #10
0
 public void Add(IDataOpItem d)
 {
     _datus.Enqueue(d);
 }