/// <inheritdoc />
        public async Task <FtpResponseLine> GetNextLineAsync(object?token, CancellationToken cancellationToken)
        {
            StatusStore?statusStore;

            if (token is null)
            {
                if (_buildStatus == FtpResponseListStatus.Finished)
                {
                    statusStore = new StatusStore
                    {
                        Enumerator = _result.GetEnumerator(),
                    };
                }
                else
                {
                    statusStore = new StatusStore()
                    {
                        Status = await CreateInitialStatusAsync(cancellationToken).ConfigureAwait(false),
                    };

                    _result.Clear();
                    _buildStatus = FtpResponseListStatus.StartLine;
                }
            }
            else
            {
                statusStore = (StatusStore)token;
            }

            string?resultLine;

            if (statusStore.Enumerator is null)
            {
                switch (_buildStatus)
                {
                case FtpResponseListStatus.StartLine:
                    resultLine   = $"{Code}-{StartMessage.TrimEnd()}";
                    _buildStatus = FtpResponseListStatus.Between;
                    break;

                case FtpResponseListStatus.Between:
                    Debug.Assert(statusStore.Status != null, "statusStore.Status != null");
                    resultLine = await GetNextLineAsync(statusStore.Status !, cancellationToken)
                                 .ConfigureAwait(false);

                    if (resultLine is null)
                    {
                        resultLine   = $"{Code} {EndMessage.TrimEnd()}";
                        _buildStatus = FtpResponseListStatus.Finished;
                    }
                    else
                    {
                        resultLine = " " + resultLine;
                    }

                    break;

                case FtpResponseListStatus.Finished:
                    resultLine  = null;
                    statusStore = null;
                    break;

                default:
                    throw new InvalidOperationException();
                }

                if (!(resultLine is null))
                {
                    _result.Add(resultLine);
                }
            }
            else
            {
                if (statusStore.Enumerator.MoveNext())
                {
                    resultLine = " " + statusStore.Enumerator.Current;
                }
                else
                {
                    statusStore.Enumerator.Dispose();
                    statusStore.IsFinished = true;
                    statusStore            = null;
                    resultLine             = null;
                }
            }

            return(new FtpResponseLine(
                       resultLine,
                       statusStore));
        }
Example #2
0
    private void SearchLoad()//查询窗口初始化
    {
        //初始化日期
        df_begin.SelectedDate = System.DateTime.Today;
        df_end.SelectedDate   = System.DateTime.Today;
        //df_begin.SelectedDate = System.DateTime.Today;//.AddDays(-1);
        //df_end.SelectedDate = System.DateTime.Today;
        #region 初始化职务
        var pos = from p in dc.Position
                  from per in dc.Person
                  where p.Posid == per.Posid && per.Maindeptid == SessionBox.GetUserSession().DeptNumber
                  select new
        {
            p.Posid,
            p.Posname
        };
        Store3.DataSource = pos;
        Store3.DataBind();
        #endregion

        #region 初始化部门
        //var dep = from d in dc.Department
        //          where d.Fatherid == SessionBox.GetUserSession().DeptNumber
        //          select new
        //          {
        //              d.Deptname,
        //              Deptid = d.Deptnumber
        //          };
        //DeptStore.DataSource = dep;
        //DeptStore.DataBind();

        var dep = from d in dc.Department
                  from p in dc.Person
                  where d.Deptnumber == p.Areadeptid && p.Maindeptid == SessionBox.GetUserSession().DeptNumber
                  select new
        {
            d.Deptname,
            Deptid = d.Deptnumber
        };
        DeptStore.DataSource = dep;
        DeptStore.DataBind();

        #endregion

        #region 初始化单位
        if (SessionBox.GetUserSession().rolelevel.Trim().IndexOf("1") > -1)
        {
            var dept = from d in dc.Department
                       where d.Deptnumber.Substring(4) == "00000" && d.Deptname.EndsWith("矿")
                       select new
            {
                d.Deptname,
                Deptid = d.Deptnumber
            };
            UnitStore.DataSource = dept;
            UnitStore.DataBind();
            cbbUnit.Disabled = false;

            cbb_position.Disabled = true;
            cbb_person.Disabled   = true;
            cbb_part.Disabled     = true;
            cbb_status.Disabled   = true;
        }
        else
        {
            var dept = from d in dc.Department
                       where d.Deptnumber == SessionBox.GetUserSession().DeptNumber
                       select new
            {
                d.Deptname,
                Deptid = d.Deptnumber
            };
            UnitStore.DataSource = dept;
            UnitStore.DataBind();
            cbbUnit.SelectedItem.Value = SessionBox.GetUserSession().DeptNumber;
            cbbUnit.Disabled           = true;
        }
        #endregion

        //#region 初始化级别
        //var lavel = from l in dc.Yinhuanlevel
        //            select new
        //                {
        //                    l.YHLevelID,
        //                    l.YHLevel
        //                };
        //LevelStore.DataSource = lavel;
        //LevelStore.DataBind();
        //#endregion

        #region 初始化类型
        int zyID = int.Parse(PublicMethod.ReadXmlReturnNode("ZY", this));

        var type = from t in dc.CsBaseinfoset
                   where t.Fid == zyID
                   select new
        {
            YHTypeID = t.Infoid,
            YHType   = t.Infoname
        };
        TypeStore.DataSource = type;
        TypeStore.DataBind();
        #endregion

        #region 初始化状态
        StatusStore.DataBind();
        #endregion
    }