コード例 #1
0
        public void SetFilter(string strName,
                              FilterDocument filter)
        {
            if (IgnoreCase == true)
            {
                strName = strName.ToLower();
            }
            FilterList filterlist = null;

            this._lock.AcquireWriterLock(_nLockTimeout);
            try
            {
                filterlist = (FilterList)_table[strName];

                if (filterlist == null)
                {
                    filterlist           = new FilterList();
                    filterlist.Container = this;
                    _table[strName]      = filterlist;
                }
                Debug.Assert(filterlist != null, "");
            }
            finally
            {
                this._lock.ReleaseWriterLock();
            }

            filterlist.SetFilter(filter);
        }
コード例 #2
0
        public void ReturnFilter(FilterDocument filter)
        {
            this.m_lock.AcquireReaderLock(m_nLockTimeout);
            try
            {
                for (int i = 0; i < list.Count; i++)
                {
                    FilterHolder item = this.list[i];

                    if (item.FilterDocument == filter)
                    {
                        int nValue = Interlocked.Decrement(ref item.UsedCount);
                        if (nValue < 0)
                        {
                            throw new Exception("还回后UsedCount小于0, 错误");
                        }
                        return;
                    }
                }
            }
            finally
            {
                this.m_lock.ReleaseReaderLock();
            }

            throw new Exception("还回的对象在数组中没有找到");
        }
コード例 #3
0
        public int Max = 100;            // 每个List中对象数上限。100

        public FilterDocument GetFilter(string strName)
        {
            if (IgnoreCase == true)
            {
                strName = strName.ToLower();
            }

            FilterList filterlist = null;

            this._lock.AcquireWriterLock(_nLockTimeout);
            try
            {
                // 查看一个名字是否有对应的 FilterList 对象了
                filterlist = (FilterList)_table[strName];

                // 如果还没有,则创建一个新对象
                if (filterlist == null)
                {
                    filterlist           = new FilterList();
                    filterlist.Container = this;
                    _table[strName]      = filterlist;
                }
            }
            finally
            {
                this._lock.ReleaseWriterLock();
            }

            // 从 FilterList 对象中获取一个 FilterDocument 对象。
            // 注: FilterList 对象用于管理多个 FilterDocument 对象,其中被征用的暂时就不能被使用了,需要创建新对象
            FilterDocument filter = filterlist.GetFilter();

            return(filter);
        }
コード例 #4
0
        /// <summary>
        /// 归还或者加入一个 FilterDocument 对象。
        /// 如果对象在 list 中已经存在,则归还它;如果在 list 中不存在,则新添加它进入 list,此时它是尚未被征用状态。
        /// 对 list 中最大对象数是进行了控制的
        /// </summary>
        /// <param name="filter"></param>
        /// <returns>true: 成功; false: 没能加入 list,因为超过数量极限 Max 了</returns>
        public bool SetFilter(FilterDocument filter)
        {
            // string strMessage = "";

            this._lock.AcquireReaderLock(_nLockTimeout);
            try
            {
                foreach (FilterHolder item in _list)
                {
                    if (item.FilterDocument == filter)
                    {
                        int nValue = Interlocked.Decrement(ref item.UsedCount);
                        if (nValue < 0)
                        {
                            throw new Exception("还回后UsedCount小于0, 错误");
                        }

                        return(true);
                    }
                }
            }
            finally
            {
                this._lock.ReleaseReaderLock();
            }

            return(NewFilter(filter));
        }
コード例 #5
0
        // 加入一个 FilterDocument 对象。
        // 如果 list 中的对象数量超过了 Max 上限,则不会加入
        // return:
        //      true    已经加入
        //      false   未加入
        public bool NewFilter(FilterDocument filter)
        {
            this._lock.AcquireWriterLock(_nLockTimeout);
            try
            {
                if (this._list.Count >= this._container.Max)
                {
                    return(false);
                }

                FilterHolder item = new FilterHolder();
                item.FilterDocument = filter;
                this._list.Add(item);
                return(true);
            }
            finally
            {
                this._lock.ReleaseWriterLock();
            }
        }
コード例 #6
0
 void Parse(FilterDocument filter)
 {
 }
コード例 #7
0
    // 维护260对照关系
    void Manage260()
    {
        string strError = "";
        string strISBN  = "";
        int    nRet     = 0;

        strISBN = this.DetailForm.MarcEditor.Record.Fields.GetFirstSubfield("020", "a").Trim();

        string strPublisherNumber = "";

        if (String.IsNullOrEmpty(strISBN) == false)
        {
            // 切割出 出版社 代码部分
            nRet = this.DetailForm.MainForm.GetPublisherNumber(strISBN,
                                                               out strPublisherNumber,
                                                               out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }
        }

        if (String.IsNullOrEmpty(strPublisherNumber) == true)
        {
            strPublisherNumber = "978-0-?";
        }

        strPublisherNumber = InputDlg.GetInput(
            this.DetailForm,
            "维护260对照表 -- 第1步",
            "请输入ISBN中出版社号码部分:",
            strPublisherNumber,
            this.DetailForm.MainForm.DefaultFont);
        if (strPublisherNumber == null)
        {
            return;     // 放弃整个操作
        }
        string strValue = "";

        nRet = this.DetailForm.GetPublisherInfo(strPublisherNumber,
                                                out strValue,
                                                out strError);
        if (nRet == -1)
        {
            goto ERROR1;
        }

        if (nRet == 0 || strValue == "")
        {
            // 获得现有的260字段 $a$b
            Field field_260 = this.DetailForm.MarcEditor.Record.Fields.GetOneField("260", 0);
            if (field_260 != null)
            {
                Subfield subfield_a = field_260.Subfields["a"];
                Subfield subfield_b = field_260.Subfields["b"];
                if (subfield_a != null && subfield_b != null &&
                    string.IsNullOrEmpty(subfield_a.Value) == false &&
                    string.IsNullOrEmpty(subfield_b.Value) == false)
                {
                    strValue = FilterDocument.TrimEndChar(subfield_a.Value.Trim()).Trim()
                               + ":"
                               + FilterDocument.TrimEndChar(subfield_b.Value.Trim()).Trim();
                }
            }

            if (string.IsNullOrEmpty(strValue) == true)
            {
                strValue = "出版地:出版社名";
            }
        }

        // 创建新条目
        strValue = InputDlg.GetInput(
            this.DetailForm,
            "维护260对照表 -- 第2步",
            "请输入ISBN出版社号码 '" + strPublisherNumber + "' 对应的 MARC21 260$a$c参数(格式 出版地:出版社名):",
            strValue,
            this.DetailForm.MainForm.DefaultFont);
        if (strValue == null)
        {
            return;     // 放弃整个操作
        }
        if (strValue == "")
        {
            goto DOSAVE;
        }

        // MessageBox.Show(this.DetailForm, strValue);

        // 把全角冒号替换为半角的形态
        strValue = strValue.Replace(":", ":");

        string strName = "";
        string strCity = "";

        nRet = strValue.IndexOf(":");
        if (nRet == -1)
        {
            strError = "输入的内容中缺少冒号";
            goto ERROR1;
            // strName = strValue;
        }
        else
        {
            strCity = strValue.Substring(0, nRet);
            strName = strValue.Substring(nRet + 1);
        }

        strValue = strCity + ":" + strName;

DOSAVE:
        nRet = this.DetailForm.SetPublisherInfo(strPublisherNumber,
                                                strValue,
                                                out strError);
        if (nRet == -1)
        {
            goto ERROR1;
        }
        return;

ERROR1:
        MessageBox.Show(this.DetailForm, strError);
    }
コード例 #8
0
        public IHttpActionResult GellAll(FilterDocument filter)
        {
            var result = handler.GetAll(filter);

            return(Ok(result));
        }
コード例 #9
0
        public Response <List <DocumentDisplayModel> > GetAll(FilterDocument filter)
        {
            try
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    var list = unitOfWork.GetRepository <Document>().GetMany(u => u.IsDelete == false && !u.DocumentType);
                    if (filter.DepartmentId != null)
                    {
                        var _listDirs = unitOfWork.GetRepository <Directory>().GetMany(d => d.DepartmentId == filter.DepartmentId).Select(d => d.DirectoryId).ToList();
                        if (filter.DirectoryId != null)
                        {
                            list = list.Where(d => d.DirectoryId == filter.DirectoryId);
                        }
                        else
                        {
                            list = list.Where(d => _listDirs.Contains(d.DirectoryId));
                        }
                    }
                    if (filter.CategoryId != null)
                    {
                        list = list.Where(d => IsInCate(Convert.ToInt32(filter.CategoryId), d.FileCates));
                    }

                    if (filter.StartDate != null)
                    {
                        list = list.Where(d => d.CreatedOnDate >= filter.StartDate.Value);
                    }
                    if (filter.EndDate != null)
                    {
                        list = list.Where(d => d.CreatedOnDate <= filter.EndDate.Value);
                    }
                    if (filter.UserId != null)
                    {
                        list = list.Where(d => d.CreatedByUserId == filter.UserId);
                    }

                    if (filter.Name.Length > 0)
                    {
                        list = list.Where(d => d.Name.Trim().ToLower().Contains(filter.Name.Trim().ToLower()));
                    }
                    var result = list.Join(unitOfWork.GetRepository <User>().GetAll(),
                                           d => d.CreatedByUserId,
                                           u => u.UserId,
                                           (d, u) => new DocumentDisplayModel
                    {
                        CreatedByUserId      = d.CreatedByUserId,
                        CreatedOnDate        = d.CreatedOnDate,
                        DocumentId           = d.DocumentId,
                        FileCates            = d.FileCates,
                        FileUrl              = d.FileUrl,
                        LastModifiedByUserId = d.LastModifiedByUserId,
                        LastModifiedOnDate   = d.LastModifiedOnDate,
                        Name = d.Name,
                        CreatedByUserName = u.UserName
                    })
                                 .OrderByDescending(u => u.DocumentId)
                                 .ToList();
                    return(new Response <List <DocumentDisplayModel> >(1, "", result));
                }
            }
            catch (Exception ex)
            {
                return(new Response <List <DocumentDisplayModel> >(-1, ex.ToString(), null));
            }
        }