public List <BeforeDelivery> GetSpecificWordGroup(int customer_Id, int manufacturer_Id, string keywords, int responsibleStaff_Id,
                                                          int helper_Id, DateTime startDate, DateTime endDate)
        {
            using (DefaultConnection db = new DefaultConnection())
            {
                int openCustomer_Id      = BusinessPartnerData.GetIdRange(db, customer_Id)[0];
                int closeCustomer_Id     = BusinessPartnerData.GetIdRange(db, customer_Id)[1];
                int openManufacturer_Id  = ManufacturerData.GetIdRange(db, manufacturer_Id)[0];
                int closeManufacturer_Id = ManufacturerData.GetIdRange(db, manufacturer_Id)[1];
                int openStaff_Id         = IdRange.Staff(db, responsibleStaff_Id)[0];
                int closeStaff_Id        = IdRange.Staff(db, responsibleStaff_Id)[1];
                int openHelper_Id        = IdRange.Helper(db, helper_Id)[0];
                int closeHelper_Id       = IdRange.Helper(db, helper_Id)[1];
                List <BeforeDelivery> beforeDeliveries = new List <BeforeDelivery>();

                if (!String.IsNullOrEmpty(keywords))
                {
                    SQLWhereString whereString = new SQLWhereString();
                    string where = whereString.SearchKeyWhere <BeforeDelivery>(db, keywords);
                    string[] keywordArray = keywords.Split(new[] { ' ', ' ' });
                    beforeDeliveries = db.Database
                                       .SqlQuery <BeforeDelivery>(where)
                                       .ToList();
                    return(beforeDeliveries
                           .Where(so => so.Customer_Id >= openCustomer_Id &&
                                  so.Customer_Id <= closeCustomer_Id &&
                                  so.Manufacturer_Id >= openManufacturer_Id &&
                                  so.Manufacturer_Id <= closeManufacturer_Id &&
                                  so.ResponsibleStaff_Id >= openStaff_Id &&
                                  so.ResponsibleStaff_Id <= closeStaff_Id &&
                                  so.Helper_Id >= openHelper_Id &&
                                  so.Helper_Id <= closeHelper_Id &&
                                  so.SalesOrderDate >= startDate &&
                                  so.SalesOrderDate <= endDate)
                           .ToList());
                }
                else
                {
                    return(db.BeforeDeliveries
                           .Where(so => so.Customer_Id >= openCustomer_Id &&
                                  so.Customer_Id <= closeCustomer_Id &&
                                  so.Manufacturer_Id >= openManufacturer_Id &&
                                  so.Manufacturer_Id <= closeManufacturer_Id &&
                                  so.ResponsibleStaff_Id >= openStaff_Id &&
                                  so.ResponsibleStaff_Id <= closeStaff_Id &&
                                  so.Helper_Id >= openHelper_Id &&
                                  so.Helper_Id <= closeHelper_Id &&
                                  so.SalesOrderDate >= startDate &&
                                  so.SalesOrderDate <= endDate)
                           .ToList());
                }
            }
        }
Exemple #2
0
 public override IdRange NextIdBatch(int size)
 {
     lock (this)
     {
         IdRange range = IdQueue.nextIdBatch(size);
         if (range.TotalSize() == 0)
         {
             AskForNextRangeFromMaster();
             range = IdQueue.nextIdBatch(size);
         }
         return(range);
     }
 }
Exemple #3
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }
            IdRange idRange = ( IdRange )o;

            return(_rangeStart == idRange._rangeStart && _rangeLength == idRange._rangeLength && Arrays.Equals(_defragIds, idRange._defragIds));
        }
Exemple #4
0
        private IdRange RespectingHighId(IdRange idRange)
        {
            int  adjustment         = 0;
            long originalRangeStart = idRange.RangeStart;

            if (_highId > originalRangeStart)
            {
                adjustment = ( int )(_highId - originalRangeStart);
            }
            long rangeStart  = max(this._highId, originalRangeStart);
            int  rangeLength = idRange.RangeLength - adjustment;

            if (rangeLength <= 0)
            {
                throw new System.InvalidOperationException("IdAllocation state is probably corrupted or out of sync with the cluster. " + "Local highId is " + _highId + " and allocation range is " + idRange);
            }
            return(new IdRange(idRange.DefragIds, rangeStart, rangeLength));
        }
Exemple #5
0
        internal virtual IdAllocation AcquireIds(IdType idType)
        {
            while (true)
            {
                long firstUnallocated = _idAllocationStateMachine.firstUnallocated(idType);
                ReplicatedIdAllocationRequest idAllocationRequest = new ReplicatedIdAllocationRequest(_me, idType, firstUnallocated, _allocationSizes[idType]);

                if (ReplicateIdAllocationRequest(idType, idAllocationRequest))
                {
                    IdRange idRange = new IdRange(EMPTY_LONG_ARRAY, firstUnallocated, _allocationSizes[idType]);
                    return(new IdAllocation(idRange, -1, 0));
                }
                else
                {
                    _log.info("Retrying ID generation due to conflict. Request was: " + idAllocationRequest);
                }
            }
        }
Exemple #6
0
 public override IdRange NextIdBatch(int size)
 {
     lock (this)
     {
         IdRange idBatch = GetReusableIdBatch(size);
         if (idBatch.TotalSize() > 0)
         {
             return(idBatch);
         }
         IdRange range = _idQueue.nextIdBatch(size);
         if (range.TotalSize() == 0)
         {
             AcquireNextIdBatch();
             range  = _idQueue.nextIdBatch(size);
             HighId = range.HighId;
         }
         return(range);
     }
 }
Exemple #7
0
        protected override void EndProcessing()
        {
            var idRanges = IdRange.Invoke(Path, ObjectType).Select(o => o.BaseObject).Cast <ObjectIdRange>();
            var reserved = Reserved.Invoke(Path, ObjectType).Select(o => o.BaseObject).Cast <ObjectIdInfo>();
            var inUse    = InUse.Invoke(Path, ObjectType, Recurse).Select(o => o.BaseObject).Cast <ObjectIdInfo>();

            if (MyInvocation.BoundParameters.ContainsKey(nameof(ObjectType)))
            {
                idRanges = idRanges.Where(r => ObjectType.Contains(r.ObjectType));
                reserved = reserved.Where(r => ObjectType.Contains(r.ObjectType));
                inUse    = inUse.Where(o => ObjectType.Contains(o.ObjectType));
            }

            switch (Summary.IsPresent)
            {
            case true: WriteSummary(idRanges, reserved, inUse); break;

            case false: WriteDetails(idRanges, reserved, inUse); break;
            }
        }
Exemple #8
0
        public IdRange_I IssueRange(IdContext_I context, int size)
        {
            lock (context.SyncRoot)
            {
                var lastIdentifierIssued = context.AvailableRange.LastIssuedId;

                var start = lastIdentifierIssued + 1;

                var stop = start - 1 + size;

                var range = new IdRange()
                {
                    EndInclusive   = stop,
                    StartInclusive = start
                };

                context.AvailableRange.LastIssuedId = range.EndInclusive;

                return(range);
            }
        }
 /// <summary>
 /// Returns the appropriate parameterized SQL criteria
 /// </summary>
 /// <returns>A parameterized SQL criteria</returns>
 /// <remarks>
 /// For Example, Range is 12-15,20.
 /// Method should return:
 /// ***
 /// ((OrderNumber &gt;= @r1b AND OrderNumber &lt;= @r1e)
 /// OR OrderNumber = @o20)
 /// ***
 /// Where r1b = range 1 begin, r1e = range 1 end, o20 = order 20
 /// </remarks>
 public string GetSqlString(string joinWord)
 {
     if (_IdRanges != null && _IdRanges.Count > 0)
     {
         StringBuilder sql = new StringBuilder();
         if (!string.IsNullOrEmpty(joinWord))
         {
             sql.Append(" " + joinWord + " ");
         }
         for (int i = 0; i < _IdRanges.Count; i++)
         {
             IdRange range = _IdRanges[i];
             if (i > 0)
             {
                 sql.Append(" OR ");
             }
             sql.Append(range.GetSqlString(_UniqueId, _FieldName, i));
         }
         return(sql.ToString());
     }
     return(string.Empty);
 }
Exemple #10
0
        private void RegisterAllocateIds()
        {
            TargetCaller <Master, IdAllocation> allocateIdTarget = (master, context, input, target) =>
            {
                IdType idType = IdType.values()[input.readByte()];
                return(master.allocateIds(context, idType));
            };
            ObjectSerializer <IdAllocation> allocateIdSerializer = (idAllocation, result) =>
            {
                IdRange idRange = idAllocation.IdRange;
                result.writeInt(idRange.DefragIds.length);
                foreach (long id in idRange.DefragIds)
                {
                    result.writeLong(id);
                }
                result.writeLong(idRange.RangeStart);
                result.writeInt(idRange.RangeLength);
                result.writeLong(idAllocation.HighestIdInUse);
                result.writeLong(idAllocation.DefragCount);
            };

            Register(HaRequestTypes_Type.AllocateIds, allocateIdTarget, allocateIdSerializer);
        }
Exemple #11
0
 public IdGenerator(Func <IdRange, IdRange> nextBatchFunc)
 {
     _nextBatchFunc = nextBatchFunc;
     _currentRange  = null;
 }
Exemple #12
0
        /// <summary>
        /// 使用游程编码压缩进行存储
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            //编号,范围长度,... 16311,6;8,20;
            List <int> temp      = new List <int>();
            IdRange    firstPart = new IdRange(0, 0, true);

            //融合并排序
            //temp.AddRange(viewedIds);
            foreach (IdRange idr in viewedIds)
            {
                if (!idr.isFirst)
                {
                    temp.AddRange(idr.ToList());
                }
                else
                {
                    firstPart = idr;
                }
            }
            temp.AddRange(viewingIds);
            temp.Sort();

            //string firstPartStr = firstPart.Start + "," + firstPart.Range + ";";

            //压缩
            if (temp.Count > 1)
            {
                //超过该数量时向第一部分合并
                const int MAX_ID     = 1000;
                int       startIndex = 0;
                if (temp.Count > MAX_ID)
                {
                    //大于上限时归并至第一部分
                    firstPart.Range = temp[temp.Count - MAX_ID - 1];
                    startIndex      = temp.Count - MAX_ID;
                }

                StringBuilder sb = new StringBuilder();
                //int last = temp[0], range = 0, lastTrim = 0;
                int last = temp[startIndex], range = 0, lastTrim = firstPart.Range;
                //for (int i = 1; i < temp.Count; i++)
                for (int i = startIndex + 1; i < temp.Count; i++)
                {
                    if (i < temp.Count - 1)
                    {
                        //跳过重复的
                        if (temp[i] == temp[i + 1])
                        {
                            continue;
                        }
                    }

                    if (temp[i] == last + range + 1)
                    {
                        range++;
                        //continue;
                    }
                    else if (temp[i] != last)
                    {
                        //遇到不连续点且非重复
                        sb.Append((last - lastTrim) + "," + range + ";");
                        lastTrim = last + range;
                        last     = temp[i];
                        range    = 0;
                    }
                }

                return(firstPart.Start + "," + firstPart.Range + ";" + sb.ToString() + (last - lastTrim) + "," + range);
            }
            else if (temp.Count == 1)
            {
                return(firstPart.Start + "," + firstPart.Range + ";" + (temp[0] - firstPart.Range) + ",0");
            }
            else
            {
                return(firstPart.Start + "," + firstPart.Range);
            }
        }
Exemple #13
0
        /// <summary>
        /// 使用游程编码压缩进行存储
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            //编号,范围长度,... 16311,6;8,20;
            List<int> temp = new List<int>();
            IdRange firstPart = new IdRange(0, 0, true);
            //融合并排序
            //temp.AddRange(viewedIds);
            foreach (IdRange idr in viewedIds)
            {
                if (!idr.isFirst)
                    temp.AddRange(idr.ToList());
                else firstPart = idr;
            }
            temp.AddRange(viewingIds);
            temp.Sort();

            //string firstPartStr = firstPart.Start + "," + firstPart.Range + ";";

            //压缩
            if (temp.Count > 1)
            {
                //超过该数量时向第一部分合并
                const int MAX_ID = 1000;
                int startIndex = 0;
                if (temp.Count > MAX_ID)
                {
                    //大于上限时归并至第一部分
                    firstPart.Range = temp[temp.Count - MAX_ID - 1];
                    startIndex = temp.Count - MAX_ID;
                }

                StringBuilder sb = new StringBuilder();
                //int last = temp[0], range = 0, lastTrim = 0;
                int last = temp[startIndex], range = 0, lastTrim = firstPart.Range;
                //for (int i = 1; i < temp.Count; i++)
                for (int i = startIndex + 1; i < temp.Count; i++)
                {
                    if (i < temp.Count - 1)
                    {
                        //跳过重复的
                        if (temp[i] == temp[i + 1])
                            continue;
                    }

                    if (temp[i] == last + range + 1)
                    {
                        range++;
                        //continue;
                    }
                    else if (temp[i] != last)
                    {
                        //遇到不连续点且非重复
                        sb.Append((last - lastTrim) + "," + range + ";");
                        lastTrim = last + range;
                        last = temp[i];
                        range = 0;
                    }
                }

                return firstPart.Start + "," + firstPart.Range + ";" + sb.ToString() + (last - lastTrim) + "," + range;
            }
            else if (temp.Count == 1)
            {
                return firstPart.Start + "," + firstPart.Range + ";" + (temp[0] - firstPart.Range) + ",0";
            }
            else return firstPart.Start + "," + firstPart.Range;
        }
Exemple #14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void dumpFile(System.Func<java.io.File, org.neo4j.kernel.impl.store.StoreFactory> createStoreFactory, String fileName) throws Exception
        private static void DumpFile(System.Func <File, StoreFactory> createStoreFactory, string fileName)
        {
            File file = new File(fileName);

            IdRange[] ids = null;               // null means all possible ids

            if (file.File)
            {
                /* If file exists, even with : in its path, then accept it straight off. */
            }
            else if (!file.Directory && file.Name.IndexOf(':') != -1)
            {
                /* Now we know that it is not a directory either, and that the last component
                 * of the path contains a colon, thus it is very likely an attempt to use the
                 * id-specifying syntax. */

                int idStart = fileName.LastIndexOf(':');

                string[] idStrings = fileName.Substring(idStart + 1).Split(",", true);
                ids = new IdRange[idStrings.Length];
                for (int i = 0; i < ids.Length; i++)
                {
                    ids[i] = IdRange.Parse(idStrings[i]);
                }
                file = new File(fileName.Substring(0, idStart));

                if (!file.File)
                {
                    throw new System.ArgumentException("No such file: " + fileName);
                }
            }
            DatabaseFile databaseFile = DatabaseFile.fileOf(file.Name).orElseThrow(IllegalArgumentExceptionSupplier(fileName));
            StoreType    storeType    = StoreType.typeOf(databaseFile).orElseThrow(IllegalArgumentExceptionSupplier(fileName));

            using (NeoStores neoStores = createStoreFactory(file).openNeoStores(storeType))
            {
                switch (storeType.innerEnumValue)
                {
                case StoreType.InnerEnum.META_DATA:
                    DumpMetaDataStore(neoStores);
                    break;

                case StoreType.InnerEnum.NODE:
                    DumpNodeStore(neoStores, ids);
                    break;

                case StoreType.InnerEnum.RELATIONSHIP:
                    DumpRelationshipStore(neoStores, ids);
                    break;

                case StoreType.InnerEnum.PROPERTY:
                    DumpPropertyStore(neoStores, ids);
                    break;

                case StoreType.InnerEnum.SCHEMA:
                    DumpSchemaStore(neoStores, ids);
                    break;

                case StoreType.InnerEnum.PROPERTY_KEY_TOKEN:
                    DumpPropertyKeys(neoStores, ids);
                    break;

                case StoreType.InnerEnum.LABEL_TOKEN:
                    DumpLabels(neoStores, ids);
                    break;

                case StoreType.InnerEnum.RELATIONSHIP_TYPE_TOKEN:
                    DumpRelationshipTypes(neoStores, ids);
                    break;

                case StoreType.InnerEnum.RELATIONSHIP_GROUP:
                    DumpRelationshipGroups(neoStores, ids);
                    break;

                default:
                    throw new System.ArgumentException("Unsupported store type: " + storeType);
                }
            }
        }
Exemple #15
0
 public IdGenerator(Func<IdRange, IdRange> nextBatchFunc)
 {
     _nextBatchFunc = nextBatchFunc;
     _currentRange = null;
 }