Example #1
0
        public JournalsImportResult ImportJournals(IList<Journal> journals, JournalsImportMode journalsImportMode)
        {
            var distinctJournals = journals.Distinct(new JournalIssnEqualityComparer()).ToList();

            var countries = this.ImportCountries(distinctJournals);
            var languages = this.ImportLanguages(distinctJournals);
            var subjects = this.ImportSubjects(distinctJournals);
            var publishers = this.ImportPublishers(distinctJournals);

            Logger.Info("Retrieving existing journals from database...");
            var allJournals = this.journalRepository.All;

            var currentJournalIssns = this.journalRepository.AllIssns.ToList();

            var newJournals = distinctJournals.Where(j => !currentJournalIssns.Contains(j.ISSN, StringComparer.InvariantCultureIgnoreCase)).ToList();

            Logger.Info("Found {0} new journals", newJournals.Count);

            var existingJournals = distinctJournals.Where(j => currentJournalIssns.Contains(j.ISSN, StringComparer.InvariantCultureIgnoreCase)).ToList();

            Logger.Info("Found {0} existing journals", existingJournals.Count);

            if (ShouldInsertJournals(journalsImportMode))
            {
                this.InsertJournals(newJournals, countries, publishers, languages, subjects);
            }

            if (ShouldUpdateJournals(journalsImportMode))
            {
                this.UpdateJournals(existingJournals, countries, publishers, languages, subjects, allJournals);
            }

            return new JournalsImportResult { NumberOfImportedJournals = distinctJournals.Count, NumberOfNewJournals = newJournals.Count };
        }
 private void AvailablePackagesServiceRunFinished(IList<Package> packages)
 {
     this.Invoke(() =>
         {
             IList<Package> distinct = packages.Distinct().ToList();
             _bindingsource.DataSource = distinct;
         });
 }
        public SignatureHelpItems(
            IList<SignatureHelpItem> items,
            TextSpan applicableSpan,
            int argumentIndex,
            int argumentCount,
            string argumentName,
            int? selectedItem = null)
        {
            Contract.ThrowIfNull(items);
            Contract.ThrowIfTrue(items.IsEmpty());
            Contract.ThrowIfTrue(selectedItem.HasValue && selectedItem.Value >= items.Count);

            if (argumentIndex < 0)
            {
                throw new ArgumentException($"{nameof(argumentIndex)} < 0. {argumentIndex} < 0", nameof(argumentIndex));
            }

            if (argumentCount < argumentIndex)
            {
                throw new ArgumentException($"{nameof(argumentCount)} < {nameof(argumentIndex)}. {argumentCount} < {argumentIndex}", nameof(argumentIndex));
            }

            // Adjust the `selectedItem` index if duplicates are able to be removed.
            var distinctItems = items.Distinct().ToList();
            if (selectedItem.HasValue && items.Count != distinctItems.Count)
            {
                // `selectedItem` index has already been determined to be valid, it now needs to be adjusted to point
                // to the equivalent item in the reduced list to account for duplicates being removed
                // E.g.,
                //   items = {A, A, B, B, C, D}
                //   selectedItem = 4 (index for item C)
                // ergo
                //   distinctItems = {A, B, C, D}
                //   actualItem = C
                //   selectedItem = 2 (index for item C)
                var actualItem = items[selectedItem.Value];
                selectedItem = distinctItems.IndexOf(actualItem);
                Debug.Assert(selectedItem.Value >= 0, "actual item was not part of the final list");
            }

            this.Items = distinctItems;
            this.ApplicableSpan = applicableSpan;
            this.ArgumentIndex = argumentIndex;
            this.ArgumentCount = argumentCount;
            this.SelectedItemIndex = selectedItem;
            this.ArgumentName = argumentName;
        }
Example #4
0
		protected ServiceProxyBase( object unavailableImpl, Type typeInterface, IList<MethodInfo> mRefs, IList<EventInfo> eRefs )
		{
            Debug.Assert( mRefs.All( r => r != null ) && mRefs.Distinct().SequenceEqual( mRefs ) );
            _typeInterface = typeInterface;
            _status = RunningStatus.Disabled;
            RawImpl = _unavailableImpl = unavailableImpl;
            _mRefs = new MEntry[mRefs.Count];
            for( int i = 0; i < mRefs.Count; i++ )
            {
                _mRefs[i].Method = mRefs[i];
            }
            _eRefs = new EEntry[eRefs.Count];
            for( int i = 0; i < eRefs.Count; i++ )
            {
                _eRefs[i].Event = eRefs[i];
            }
        }
        /// <summary>
        /// Implements gift wrapping algorithm.
        /// </summary>
        /// <param name="points">Set of points.</param>
        /// <returns>Polygon representing convex hull.</returns>
        public static Polygon ConvexHull(IList<Vector> points)
        {
            Debug.Assert(points != null);
            Debug.Assert(points.Count >= 3);

            // Leave only distinct points
            points = new List<Vector>(points.Distinct());

            // Find first point
            Vector hullStart = points[0];
            for (int i = 1; i < points.Count; ++i)
            {
                Vector point = points[i];
                if (point.X < hullStart.X || (point.X == hullStart.X && point.Y < hullStart.Y))
                    hullStart = point;
            }

            Vector currentHullPoint = hullStart;
            Polygon result = new Polygon();
            bool[] usedPoints = new bool[points.Count];
            do
            {
                result.vertices.Add(currentHullPoint);
                
                int nextHullPointIndex = 0;
                for (int i = 1; i < points.Count; ++i)
                {
                    if (usedPoints[nextHullPointIndex] ||
                        points[nextHullPointIndex] == currentHullPoint ||
                        Vector.CrossProduct(points[i] - currentHullPoint, points[nextHullPointIndex] - currentHullPoint) < 0)
                    {
                        nextHullPointIndex = i;
                    }
                }
                
                currentHullPoint = points[nextHullPointIndex];
                usedPoints[nextHullPointIndex] = true;
            } while (currentHullPoint != hullStart);

            return result;
        }
 /// <summary>
 /// Replaces all required attendees in an event
 /// </summary>
 public void ReplaceRequiredAttendees(IList<CalendarEventAttendee> attendees)
 {
     _requiredAttendees = attendees.Distinct().ToList();
     IsDirty = true;
 }
 /// <summary>
 /// Replaces all optional attendees in an event
 /// </summary>
 public void ReplaceOptionalAttendees(IList<CalendarEventAttendee> attendees)
 {
     _optionalAttendees = attendees.Distinct().ToList();
     IsDirty = true;
 }
Example #8
0
 private double CalculateDistinct(IList<double> values)
 {
     double result = 0.0;
     values = values.OrderBy(m => m).ToList();
     result = values.Distinct().Count() - 1 ;
     return result;
 }
Example #9
0
        private static string GetNumberType(IList<int> list)
        {
            int digits = 0;
            if (list.Count == 2)
            {
                digits = list.Distinct().Count();
                return (digits == 2) ? "Z2" : "B2";
            }

            digits = list.Distinct().Count();
            if (digits == 3) return "Z36";
            return (digits == 2) ? "Z33" : "B3";
        }
Example #10
0
        public FlowMaster GetReverseFlow(FlowMaster flow, IList<string> itemCodeList)
        {
            FlowMaster reverseFlow = new FlowMaster();
            Mapper.Map(flow, reverseFlow);
            reverseFlow.PartyFrom = flow.PartyTo;
            reverseFlow.PartyTo = flow.PartyFrom;
            reverseFlow.IsCheckPartyFromAuthority = flow.IsCheckPartyToAuthority;
            reverseFlow.IsCheckPartyToAuthority = flow.IsCheckPartyFromAuthority;
            reverseFlow.ShipFrom = flow.ShipTo;
            reverseFlow.ShipTo = flow.ShipFrom;
            reverseFlow.LocationFrom = flow.LocationTo;
            reverseFlow.LocationTo = flow.LocationFrom;
            reverseFlow.IsShipScanHu = flow.IsReceiveScanHu;
            reverseFlow.IsReceiveScanHu = flow.IsShipScanHu;
            reverseFlow.IsShipFifo = flow.IsReceiveFifo;
            reverseFlow.IsReceiveFifo = flow.IsShipFifo;
            reverseFlow.IsShipExceed = flow.IsReceiveExceed;
            reverseFlow.IsReceiveExceed = flow.IsShipExceed;
            //reverseFlow.IsShipFulfillUC = flow.IsReceiveFulfillUC;
            //reverseFlow.IsReceiveFulfillUC = flow.IsShipFulfillUC;
            reverseFlow.IsInspect = flow.IsRejectInspect;
            reverseFlow.IsRejectInspect = flow.IsInspect;
            reverseFlow.IsCreatePickList = false;
            reverseFlow.IsShipByOrder = true;
            //以后有什么字段再加

            #region 路线明细
            if (flow.FlowDetails == null || flow.FlowDetails.Count == 0)
            {
                string hql = "from FlowDetail where Flow = ?";
                IList<object> parm = new List<object>();
                parm.Add(flow.Code);
                if (itemCodeList != null && itemCodeList.Count() > 0)
                {
                    string whereHql = string.Empty;
                    foreach (string itemCode in itemCodeList.Distinct())
                    {
                        if (whereHql == string.Empty)
                        {
                            whereHql = " and Item in (?";
                        }
                        else
                        {
                            whereHql += ",?";
                        }
                        parm.Add(itemCode);
                    }
                    whereHql += ")";
                    hql += whereHql;
                }
                hql += " order by Sequence";

                flow.FlowDetails = this.genericMgr.FindAll<FlowDetail>(hql, parm.ToArray());
            }

            if (flow.FlowDetails != null && flow.FlowDetails.Count > 0)
            {
                IList<FlowDetail> reverseFlowDetailList = new List<FlowDetail>();
                foreach (FlowDetail flowDetail in flow.FlowDetails)
                {
                    FlowDetail reverseFlowDetail = new FlowDetail();
                    Mapper.Map(flowDetail, reverseFlowDetail);
                    reverseFlowDetail.LocationFrom = flowDetail.LocationTo;
                    reverseFlowDetail.LocationTo = flowDetail.LocationFrom;
                    reverseFlowDetail.IsRejectInspect = flowDetail.IsInspect;
                    reverseFlowDetail.IsInspect = flowDetail.IsRejectInspect;
                    //PartyFrom?
                    reverseFlowDetailList.Add(reverseFlowDetail);
                }
                reverseFlow.FlowDetails = reverseFlowDetailList;
            }
            #endregion

            return reverseFlow;
        }
Example #11
0
        private IList<FlowDetail> TryLoadFlowDetails(FlowMaster flowMaster, IList<string> itemCodeList)
        {
            if (!string.IsNullOrWhiteSpace(flowMaster.Code))
            {
                if (flowMaster.FlowDetails == null)
                {
                    string hql = "from FlowDetail where Flow = ?";
                    IList<object> parm = new List<object>();
                    parm.Add(flowMaster.Code);

                    if (itemCodeList != null && itemCodeList.Count > 0 && itemCodeList.Count < 2000)
                    {
                        string whereHql = string.Empty;
                        foreach (string itemCode in itemCodeList.Distinct())
                        {
                            if (whereHql == string.Empty)
                            {
                                whereHql = " and Item in (?";
                            }
                            else
                            {
                                whereHql += ",?";
                            }
                            parm.Add(itemCode);
                        }
                        whereHql += ")";
                        hql += whereHql;
                    }

                    hql += " order by Sequence";

                    flowMaster.FlowDetails = this.genericMgr.FindAll<FlowDetail>(hql, parm.ToArray());
                    if (itemCodeList != null && itemCodeList.Count >= 2000)
                    {
                        flowMaster.FlowDetails = flowMaster.FlowDetails.Where(f => itemCodeList.Contains(f.Item)).ToList();
                    }
                }

                return flowMaster.FlowDetails;
            }
            else
            {
                return null;
            }
        }
Example #12
0
        public IList<string> GetFilteredLinksToVisit(IList<string> linksToFilter, IList<string> visitedLinks, bool onlyRootLinks = true)
        {
            foreach (string visitedLink in visitedLinks) {
                linksToFilter.Remove(visitedLink);
            }

            //var rootUriWithoutHttpPrefix = rootUri.Replace("http://www", "");
            //rootUriWithoutHttpPrefix = rootUriWithoutHttpPrefix.Replace("https://www", "");

            IList<string> listToRemove = new List<string>();
            foreach (string link in linksToFilter) {
                if (onlyRootLinks) {
                    if (!link.Contains("devart.com")) {
                        listToRemove.Add(link);
                    }
                }

                foreach (string ignoreMask in LinkTypesToIgnoreForVisit) {
                    if (!listToRemove.Contains(link) &&
                        link.EndsWith(ignoreMask)) {
                        listToRemove.Add(link);
                    }
                }
            }

            foreach (string s in listToRemove) {
                linksToFilter.Remove(s);
            }

            return linksToFilter.Distinct().ToList();
        }
Example #13
0
		public WhenAllContinuation (TaskCompletionSource<object> owner, IList<Task> tasks)
		{
			this.owner = owner;
            
            tasks = tasks.Distinct().ToList();
			counter = tasks.Count;
			
            foreach (var t in tasks)
                t.ContinueWith(this);
		}
Example #14
0
        public IList<FlowDetail> GetFlowDetails(IList<Int32> flowDetailIdList)
        {
            if (flowDetailIdList != null && flowDetailIdList.Count > 0)
            {
                IList<FlowDetail> flowDetailList = new List<FlowDetail>();

                string hql = string.Empty;
                IList<object> parm = new List<object>();

                foreach (int flowDetailId in flowDetailIdList.Distinct())
                {
                    if (hql == string.Empty)
                    {
                        hql = "from FlowDetail where Id in (?";
                    }
                    else
                    {
                        hql += ", ?";
                    }
                    parm.Add(flowDetailId);

                    if (parm.Count() >= 2000)
                    {
                        hql += ")";
                        ((List<FlowDetail>)flowDetailList).AddRange(this.genericMgr.FindAll<FlowDetail>(hql, parm.ToArray()));
                        hql = string.Empty;
                        parm = new List<object>();
                    }
                }

                hql += ")";
                if (parm.Count() > 0)
                {
                    ((List<FlowDetail>)flowDetailList).AddRange(this.genericMgr.FindAll<FlowDetail>(hql, parm.ToArray()));
                }

                return flowDetailList;
            }

            return null;
        }
Example #15
0
		public async Task<bool> EditPostAsync(string postid, string title, string description, IList<string> categories, bool publish)
		{
			XmlRPC.Array array = new XmlRPC.Array((categories == null) ? 0 : categories.Count);
			if (categories != null)
			{
				List<string> list = categories.Distinct<string>().ToList<string>();
				list.Sort();
				List<Value> ss = new List<Value>();
				(
					from c in list
					select new StringValue(c)).ToList<StringValue>().ForEach(delegate(StringValue i)
				{
					ss.Add(i);
				});
				array.AddRange(ss);
			}
			Service service = new Service(this.BlogConnectionInfo.MetaWeblogURL);
			Struct @struct = new Struct();
			@struct["title"] = new StringValue(title);
			@struct["description"] = new StringValue(description);
			@struct["categories"] = array;
			MethodCall methodCall = new MethodCall("metaWeblog.editPost");
			methodCall.Parameters.Add(postid);
			methodCall.Parameters.Add(this.BlogConnectionInfo.Username);
			methodCall.Parameters.Add(this.BlogConnectionInfo.Password);
			methodCall.Parameters.Add(@struct);
			methodCall.Parameters.Add(publish);
			service.Cookies = this.BlogConnectionInfo.Cookies;
			MethodResponse methodResponse = await service.ExecuteAsync(methodCall);
			Value value = methodResponse.Parameters[0];
			BooleanValue booleanValue = (BooleanValue)value;
			return booleanValue.Boolean;
		}
Example #16
0
        private List<PlantPower> getPlantPowerList(IList<Meter> meterList)
        {
            var plantPowerList = new List<PlantPower>();

               Logger.Debug(String.Format("MeterList has {0} distinct elements", meterList.Count));

               List<DateTime> dateList = new List<DateTime>();
               dateList=meterList.Distinct().Select(x=>x.startDate).Distinct().ToList();
               dateList=dateList.Concat(meterList.Distinct().Select(x=>x.endDate).Distinct()).ToList();
               Logger.Debug(String.Format("DateList has {0} distinct elements", dateList.Count));

               for (int i=0; i<dateList.Count-1;i++)
               {
               PlantPower plantPower = new PlantPower();
               var totalPower = 0.0;
               foreach (var meter in meterList.OrderBy(x => x.startDate))
               {
                   //Logger.Debug(String.Format("startDate:{0}, EndDate{1}", dateList[i], dateList[i + 1]));
                   if (meter.startDate <= dateList[i] && meter.endDate >= dateList[i+1])
                   {
                       plantPower.IdPlant = meter.IdPlant;
                       plantPower.startDate = dateList[i];
                       plantPower.endDate = dateList[i + 1];
                       totalPower += meter.Power * 1000;
                   }
               }
               plantPower.Power = Math.Round(totalPower, 5);
               Logger.Debug(String.Format("IdPlant: {0},Startdate: {1}, EndDate: {2}, Power: {3}", plantPower.IdPlant, plantPower.startDate,plantPower.endDate,plantPower.Power));
               plantPowerList.Add(plantPower);
               }

               return plantPowerList;
        }
Example #17
0
        /// <summary>
        /// Calcola i saldi per persona e unità immobiliare
        /// Utilizzato dalla funzione subentri
        /// </summary>
        /// <param name="idEsercizio">Identificativo dell'esercizio</param>
        /// <param name="idPersone">Lista degli indeitificativi delle persone di cui occorre calcolare il saldo, nel caso di subentro sarà costituita dall'identificativo della persona entrante e della persona uscente</param>
        /// <param name="unitaImmobiliari">Lista delle unità immobiliari per le quali occorre calcolare il saldo</param>
        /// <param name="calcoloPerSubentro">Se true il calcolo viene eseguito per confermare un subentro</param>
        /// <returns>Lista dei saldi</returns>
        public decimal GetSaldoByPersonaUnitaImmobiliari(int idEsercizio, IList<int> idPersone, IList<int> unitaImmobiliari, bool calcoloPerSubentro)
        {
            var esercizio = _daoFactory.GetEsercizioDao().GetById(idEsercizio, false);

            const string hql = "FROM SaldoSoggetto SALD WHERE SALD.Esercizio = :esercizio AND SALD.Soggetto.Persona.ID = :persona AND SALD.Soggetto.UnitaImmobiliare IN (:unita)";
            var saldi = new List<SaldoSoggetto>();
            foreach (var idPersona in idPersone.Distinct())
                saldi.AddRange(_daoFactory.GetSaldoSoggettoDao().GetByQuery(hql, new QueryParam("persona", idPersona), new QueryParam("unita", unitaImmobiliari), new QueryParam("esercizio", esercizio)).ToList());

            decimal importoSaldo = 0;

            // Se presenti uso saldi in tabella ........
            if (saldi.Count > 0)
                importoSaldo = saldi.Sum(saldo => saldo.Importo.GetValueOrDefault());
            // .... altrimenti devo calcolarli in base all'esercizio precedente
            else if (esercizio.Gestione == GestioneEsercizioEnum.Ordinario && esercizio.GetEsercizioPrecedente() != null)
            {
                var items = _bilancioService.GetDataSourceRipartizioneBilancioConsuntivo(esercizio.GetEsercizioPrecedente().ID, null, null, null, null, null, null, false, false, TipoAccorpamentoRateEnum.Nessuno, false, calcoloPerSubentro, false, false, null);
                var spese = (from item in items
                            where item.OrdineConto == 9993 || item.OrdineConto == 9994
                            select item).ToList();

                importoSaldo = 0;
                foreach (var idUnitaImmobiliare in unitaImmobiliari)
                {
                    var unita = _daoFactory.GetUnitaImmobiliareDao().GetById(idUnitaImmobiliare, false);
                    importoSaldo += unita.Soggetti.Where(soggetto => idPersone.Contains(soggetto.Persona.ID)).Sum(soggetto => GetImportoSaldoPrecedenteDaConsuntivo(soggetto.ID, spese));
                }
            }

            return importoSaldo;
        }
		private FileSystemOptions(Type nodeCacheType, IList<Type> nodeServiceProviderTypes, IList<Type> nodeResolutionFilterTypes, IList<Type> nodeOperationFilterTypes, IList<Type> accessPermissionVerifierTypes, NameValueCollection variables)
		{
			this.NodeCacheType = nodeCacheType;
			this.Variables = new FileSystemVariablesCollection(variables);
			this.NodeTransformationFilterTypes = new ReadOnlyCollection<Type>(new List<Type>());
			this.AccessPermissionVerifierTypes = new ReadOnlyCollection<Type>(accessPermissionVerifierTypes.Distinct().ToList());
			this.NodeServiceProviderTypes = new ReadOnlyCollection<Type>(nodeServiceProviderTypes.Distinct().ToList());
			this.NodeResolutionFilterTypes = new ReadOnlyCollection<Type>(nodeResolutionFilterTypes.Distinct().ToList());
			this.NodeOperationFilterTypes = new ReadOnlyCollection<Type>(nodeOperationFilterTypes.Distinct().ToList());
		}
Example #19
0
        public void DeleteTransportOrderDetail(string orderNo, IList<string> ipNoList)
        {
            if (string.IsNullOrWhiteSpace(orderNo))
            {
                throw new TechnicalException("运输单号不能为空。");
            }

            if (ipNoList == null || ipNoList.Count() == 0)
            {
                throw new TechnicalException("ASN号不能为空。");
            }

            TransportOrderMaster transportOrderMaster = this.genericMgr.FindAll<TransportOrderMaster>("from TransportOrderMaster where OrderNo = ?", orderNo).SingleOrDefault();
            if (transportOrderMaster == null)
            {
                throw new BusinessException("运输单号{0}不存在。", orderNo);
            }

            if (transportOrderMaster.Status == TransportStatus.Close)
            {
                throw new BusinessException("运输单号{0}已经关闭,不能删除ASN。", orderNo);
            }

            if (transportOrderMaster.Status == TransportStatus.Cancel)
            {
                throw new BusinessException("运输单号{0}已经取消,不能删除ASN。", orderNo);
            }

            if (ipNoList != null)
            {
                ipNoList = ipNoList.Distinct().ToArray();
            }

            StringBuilder selectTransportOrderDetailHql = null;
            StringBuilder selectIpMasterHql = null;
            IList<object> parms = new List<object>();
            foreach (string ipNo in ipNoList)
            {
                if (selectTransportOrderDetailHql == null)
                {
                    selectTransportOrderDetailHql = new StringBuilder("from TransportOrderDetail where OrderNo = ? and IpNo in (?");
                    selectIpMasterHql = new StringBuilder("from IpMaster where IpNo in (?");
                    parms.Add(orderNo);
                }
                else
                {
                    selectTransportOrderDetailHql.Append(",?");
                    selectIpMasterHql.Append(",?");
                }

                parms.Add(ipNo);
            }
            selectTransportOrderDetailHql.Append(")");
            selectIpMasterHql.Append(")");

            IList<TransportOrderDetail> transportOrderDetailList = genericMgr.FindAll<TransportOrderDetail>(selectTransportOrderDetailHql.ToString(), parms.ToArray());
            parms.RemoveAt(0);
            IList<IpMaster> ipMasterList = genericMgr.FindAll<IpMaster>(selectIpMasterHql.ToString(), parms.ToArray());

            foreach (string ipNo in ipNoList)
            {
                IpMaster ipMaster = ipMasterList.Where(i => i.IpNo == ipNo).SingleOrDefault();

                if (ipMaster == null)
                {
                    throw new BusinessException("ASN号{0}不存在。", ipNo);
                }

                if (transportOrderDetailList.Where(d => d.IpNo == ipNo).Count() == 0)
                {
                    throw new BusinessException("ASN{0}不在运输单{1}中,不能删除。", new object[] { ipNo, orderNo });
                }

                if (ipMaster.Status == IpStatus.InProcess || ipMaster.Status == IpStatus.Close)
                {
                    throw new BusinessException("ASN号{0}已经收货不能删除。", ipNo);
                }
            }

            foreach (TransportOrderDetail transportOrderDetail in transportOrderDetailList)
            {
                genericMgr.Delete(transportOrderDetail);
            }
        }
 /// <summary>
 /// Filters the assets
 /// </summary>
 /// <param name="Assets">Assets to filter</param>
 /// <returns>The filtered assets</returns>
 public IList<IAsset> Filter(IList<IAsset> Assets)
 {
     if (Assets == null || Assets.Count == 0)
         return new List<IAsset>();
     return Assets.Distinct().ToList();
 }
Example #21
0
        /// <summary>
        /// Копирование определенич блока из внешнего чертежа
        /// </summary>
        /// <param name="blNames">Имена блоков</param>
        /// <param name="fileDrawing">Полный путь к чертежу из которого копируется блок</param>
        /// <param name="destDb">База чертежа в который копируетсяя блок</param>
        /// <exception cref="Exception">Если нет блока в файле fileDrawing.</exception>
        /// <returns>Список пар значений имени блока и idBtr</returns>        
        public static Dictionary<string, ObjectId> CopyBlockFromExternalDrawing(IList<string> blNames, string fileDrawing, Database destDb,
                                                DuplicateRecordCloning mode = DuplicateRecordCloning.Ignore)
        {
            var resVal = new Dictionary<string, ObjectId>();
            var uniqBlNames = blNames.Distinct(StringComparer.OrdinalIgnoreCase);

            using (var extDb = new Database(false, true))
            {
                extDb.ReadDwgFile(fileDrawing, System.IO.FileShare.ReadWrite, true, "");
                extDb.CloseInput(true);

                var valToCopy = new Dictionary<ObjectId, string>();

                using (var bt = (BlockTable)extDb.BlockTableId.Open(OpenMode.ForRead))
                {
                    foreach (var blName in uniqBlNames)
                    {
                        ObjectId id;
                        if (bt.Has(blName))
                        {
                            id = bt[blName];
                            valToCopy.Add(id, blName);
                        }
                    }
                }
                // Копир
                if (valToCopy.Count > 0)
                {
                    // Получаем текущую базу чертежа
                    using (IdMapping map = new IdMapping())
                    {
                        using (var ids = new ObjectIdCollection(valToCopy.Keys.ToArray()))
                        {
                            destDb.WblockCloneObjects(ids, destDb.BlockTableId, map, mode, false);
                            foreach (var item in valToCopy)
                            {
                                resVal.Add(item.Value, map[item.Key].Value);
                            }
                        }
                    }
                }
            }

            // Если задан режим переопределения - то перерисовка геометрии динамических блоков
            if (mode == DuplicateRecordCloning.Replace)
            {
                using (var t = destDb.TransactionManager.StartTransaction())
                {
                    var bt = destDb.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable;
                    foreach (var item in resVal)
                    {
                        if (item.Value.IsValidEx())
                        {
                            var btr = item.Value.GetObject(OpenMode.ForRead) as BlockTableRecord;
                            if (btr.IsDynamicBlock)
                            {
                                try
                                {
                                    btr.UpgradeOpen();
                                    btr.UpdateAnonymousBlocks();
                                }
                                catch { }
                            }
                        }
                    }
                    t.Commit();
                }
            }

            return resVal;
        }
        protected virtual IList<StudentWithMetrics> GradeLevelOrder(IList<StudentWithMetrics> query,
                                                             string sortDirection)
        {
            query = query.Distinct().ToList();

            query = sortDirection == "desc"
                ? query.OrderByDescending(entity => entity.GradeLevel)
                    .ThenByDescending(entity => entity.Name).ToList()
                : query.OrderBy(entity => entity.GradeLevel)
                    .ThenBy(entity => entity.Name).ToList();

            return query;
        }
Example #23
0
        public IList<Item> GetItems(IList<string> itemCodeList)
        {
            if (itemCodeList != null && itemCodeList.Count > 0)
            {
                IList<Item> itemList = new List<Item>();

                string hql = string.Empty;
                IList<object> parm = new List<object>();

                foreach (string itemCode in itemCodeList.Distinct())
                {
                    if (hql == string.Empty)
                    {
                        hql = "from Item where Code in (?";
                    }
                    else
                    {
                        hql += ", ?";
                    }
                    parm.Add(itemCode);

                    if (parm.Count() >= 2000)
                    {
                        hql += ")";
                        ((List<Item>)itemList).AddRange(this.genericMgr.FindAll<Item>(hql, parm.ToArray()));
                        hql = string.Empty;
                        parm = new List<object>();
                    }
                }

                hql += ")";
                if (parm.Count() > 0)
                {
                    ((List<Item>)itemList).AddRange(this.genericMgr.FindAll<Item>(hql, parm.ToArray()));
                }

                return itemList;
            }

            return null;
        }
Example #24
0
 private static int DistinctSides(IList<decimal> sides)
 {
     return sides.Distinct ().Count ();
 }
        public void CreateDynamicCalendar(IList<ProjectCalendarVO> listProjectCalendar)
        {
            if (listProjectCalendar.Count > 0)
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("<table class='ProjectCalendar' cellspacing='0' cellpadding='0'> <thead>");
                builder.Append("<tr>");
                for (int i = 0; i < _view.CalendarDateRange.Count; i++)
                {
                    if (_view.CalendarDateRange.Count - 1 == i)
                        builder.Append("<th> <div>");
                    else
                        builder.Append("<th class='BorderRight'> <div>");
                    builder.Append(_view.CalendarDateRange[i].ToString("ddd MM/dd/yy"));
                    builder.Append("</div></th>");
                }
                builder.Append("</tr> </thead><tbody>");
                List<ProjectCalendarVO> divisionList = listProjectCalendar.Distinct(new Globals.ProjectCalendar.ProjectCalendarComparer()).ToList();
                for (int i = 0; i < divisionList.Count; i++)
                {
                    builder.Append("<tr>");

                    for (int j = 0; j < _view.CalendarDateRange.Count; j++)
                    {

                        builder.Append("<td class='Division'>");
                        if (j == 0)
                            builder.Append(divisionList[i].DivisionName);
                        else
                            builder.Append("&nbsp;");
                        builder.Append("</td>");
                    }

                    builder.Append("</tr>");

                    for (int j = 0; j < divisionList[i].JobCalendarList.Count; j++)
                    {
                        bool writtenName = false;

                        builder.Append("<tr>");
                        for (int k = 0; k < _view.CalendarDateRange.Count; k++)
                        {
                            JobCalendarVO jobCalendar = listProjectCalendar.FirstOrDefault(e => e.DivisionID == divisionList[i].DivisionID && e.CalendarDate == _view.CalendarDateRange[k]).JobCalendarList.FirstOrDefault(job => job.JobID == divisionList[i].JobCalendarList[j].JobID);
                            if (jobCalendar.PaintDate)
                            {
                                builder.Append("<td class='PaintJob'");
                            }
                            else
                                builder.Append("<td");

                            if (jobCalendar.PaintDate)
                            {
                                builder.AppendFormat(" onmouseenter=\"javascript: ShowToolTip(document.getElementById('ProjectToolTip{0}'));\"", jobCalendar.JobID);
                                builder.AppendFormat(" onmouseleave=\"javascript: document.getElementById('ProjectToolTip{0}').style.display = 'none';\" ", jobCalendar.JobID);
                            }

                            builder.AppendFormat(">");

                            if (!writtenName && jobCalendar.PaintDate)
                            {
                                writtenName = true;
                                builder.Append("<a href=\"" + string.Format("javascript: var newWindow = window.open('/JobRecord.aspx?JobId={0}', '', 'width=800, height=600, scrollbars=1, resizable=yes');", jobCalendar.JobID) + "\"><div>&nbsp;<div style='position:absolute;'>" + jobCalendar.Job + " - " + jobCalendar.CustomerName + "</div></div></a>");

                                builder.Append(string.Format(@"<DIV style='background-color:white; display:none; position:fixed; width:250; z-index: 999;' id='ProjectToolTip{0}'>
                                    <DIV class='divUpperFields'>
                                        <DIV class='label'><SPAN>Job #:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{1}</SPAN></DIV>
                                        <DIV class='label'><SPAN>Company Name:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{2}</SPAN></DIV>
                                    </DIV>
                                    <DIV class='divUpperFields'>
                                        <DIV class='label'><SPAN>Division:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{3}</SPAN></DIV>
                                        <DIV class='label'><SPAN>City:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{4}</SPAN></DIV>
                                        <DIV class='label'><SPAN>State:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{5}</SPAN></DIV>
                                        <DIV class='label'><SPAN>Job Satus:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{6}</SPAN></DIV>
                                        <DIV class='label'><SPAN>Job Action:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{7}</SPAN></DIV>
                                    </DIV>
                                </DIV>", jobCalendar.JobID, jobCalendar.Job, jobCalendar.CustomerName, jobCalendar.DivisionName, jobCalendar.CityName, jobCalendar.StateName, jobCalendar.StatusName, jobCalendar.ActionName));
                            }
                            else
                                builder.Append("&nbsp;");

                            builder.Append("</td>");
                        }
                        builder.Append("</tr>");
                        for (int k = 0; k < divisionList[i].JobCalendarList[j].ResourceList.Count; k++)
                        {
                            bool writtenNameResource = false;
                            bool estimatedWorkStart = true;

                            builder.Append("<tr>");
                            for (int l = 0; l < _view.CalendarDateRange.Count; l++)
                            {
                                ResourceVO resourceNextDay = null;
                                ResourceVO resource = listProjectCalendar.FirstOrDefault
                                                                (e =>
                                                                    e.DivisionID == divisionList[i].DivisionID &&
                                                                    e.CalendarDate == _view.CalendarDateRange[l]
                                                                ).JobCalendarList.FirstOrDefault
                                                                                (job =>
                                                                                    job.JobID == divisionList[i].JobCalendarList[j].JobID
                                                                                 ).ResourceList.FirstOrDefault
                                                                                                (r =>
                                                                                                       (r.EquipmentID == divisionList[i].JobCalendarList[j].ResourceList[k].EquipmentID &&
                                                                                                       divisionList[i].JobCalendarList[j].ResourceList[k].EquipmentID.HasValue) ||
                                                                                                       (r.EmployeeID == divisionList[i].JobCalendarList[j].ResourceList[k].EmployeeID &&
                                                                                                       divisionList[i].JobCalendarList[j].ResourceList[k].EmployeeID.HasValue) ||
                                                                                                       (r.EquipmentTypeID == divisionList[i].JobCalendarList[j].ResourceList[k].EquipmentTypeID &&
                                                                                                       divisionList[i].JobCalendarList[j].ResourceList[k].EquipmentTypeID.HasValue)

                                                                                                       );

                                string sClass = string.Empty;

                                if (resource.Worked)
                                    sClass = "ResourceWorked";

                                if (resource.EstimatedWork)
                                {
                                    if (_view.CalendarDateRange.Count != l + 1)
                                    {
                                        resourceNextDay = listProjectCalendar.FirstOrDefault
                                                                        (e =>
                                                                            e.DivisionID == divisionList[i].DivisionID &&
                                                                            e.CalendarDate == _view.CalendarDateRange[l + 1]
                                                                        ).JobCalendarList.FirstOrDefault
                                                                                        (job =>
                                                                                            job.JobID == divisionList[i].JobCalendarList[j].JobID
                                                                                         ).ResourceList.FirstOrDefault
                                                                                                        (r =>
                                                                                                               ((r.EmployeeID == divisionList[i].JobCalendarList[j].ResourceList[k].EmployeeID &&
                                                                                                               divisionList[i].JobCalendarList[j].ResourceList[k].EmployeeID.HasValue) ||
                                                                                                               (r.EquipmentID == divisionList[i].JobCalendarList[j].ResourceList[k].EquipmentID &&
                                                                                                               divisionList[i].JobCalendarList[j].ResourceList[k].EquipmentID.HasValue)) &&
                                                                                                               r.EstimatedWork
                                                                                                        );
                                    }

                                    if (estimatedWorkStart)
                                    {
                                        sClass += " ResourceEstimatedStart";
                                        estimatedWorkStart = false;
                                    }
                                    else if (resource.EstimatedWork && !estimatedWorkStart && null != resourceNextDay)
                                        sClass += " ResourceEstimated";

                                    if (resource.EstimatedWork && !estimatedWorkStart && null == resourceNextDay)
                                    {
                                        sClass += " ResourceEstimatedEnd";
                                        estimatedWorkStart = true;
                                    }
                                }

                                if (resource.Reserved)
                                    sClass += " Reserved";

                                Globals.ProjectCalendar.ResourceType rType = (Globals.ProjectCalendar.ResourceType)resource.ResourceColor;

                                switch (rType)
                                {
                                    case Globals.ProjectCalendar.ResourceType.ReservedEmployee:
                                        if(resource.EmployeeID.HasValue)
                                            sClass += " Resource Employee";
                                        break;
                                    case Globals.ProjectCalendar.ResourceType.ReservedEquipment:
                                        if(resource.EquipmentTypeID.HasValue)
                                            sClass += " Resource Equipment";
                                        break;
                                    case Globals.ProjectCalendar.ResourceType.AddEmployee:
                                        if(resource.EmployeeID.HasValue)
                                            sClass += " Resource AddEmployee";
                                        break;
                                    case Globals.ProjectCalendar.ResourceType.AddEquipment:
                                        if(resource.EquipmentID.HasValue)
                                            sClass += " Resource AddEquipment";
                                        break;
                                    default:
                                        break;
                                }

                                builder.Append("<td");
                                if (resource.EmployeeID.HasValue)
                                {
                                    builder.AppendFormat(" onmouseenter=\"javascript: ShowToolTip(document.getElementById('ProjectToolTipResource{0}'));\"", resource.EmployeeID.Value);
                                    builder.AppendFormat(" onmouseleave=\"javascript: document.getElementById('ProjectToolTipResource{0}').style.display = 'none';\" ", resource.EmployeeID.Value);
                                }
                                else if (resource.EquipmentID.HasValue)
                                {
                                    builder.AppendFormat(" onmouseenter=\"javascript: ShowToolTip(document.getElementById('ProjectToolTipResource{0}'));\"", resource.EquipmentID.Value);
                                    builder.AppendFormat(" onmouseleave=\"javascript: document.getElementById('ProjectToolTipResource{0}').style.display = 'none';\" ", resource.EquipmentID.Value);
                                }
                                else if (resource.EquipmentTypeID.HasValue)
                                {
                                    builder.AppendFormat(" onmouseenter=\"javascript: ShowToolTip(document.getElementById('ProjectToolTipResource{0}'));\"", resource.EquipmentTypeID.Value);
                                    builder.AppendFormat(" onmouseleave=\"javascript: document.getElementById('ProjectToolTipResource{0}').style.display = 'none';\" ", resource.EquipmentTypeID.Value);
                                }
                                if (!string.IsNullOrEmpty(sClass))
                                {
                                    builder.Append(" class='" + sClass.Trim() + "'><div>&nbsp;<div style='position:absolute;'>");

                                }
                                else
                                {
                                    builder.Append(">");
                                }

                                if (!writtenNameResource && (resource.Worked || resource.EstimatedWork || resource.Reserved))
                                {
                                    writtenNameResource = true;
                                    if (resource.EmployeeID.HasValue)
                                        builder.Append(resource.EmployeeName);
                                    else if (resource.EquipmentID.HasValue)
                                        builder.Append(resource.EquipmentName);
                                    else if (resource.EquipmentTypeID.HasValue)
                                        builder.Append(resource.EquipmentTypeName);
                                }
                                else
                                    builder.Append("&nbsp;");

                                builder.Append("</div></div>");

                                if (resource.EmployeeID.HasValue)
                                {
                                    builder.Append(string.Format(@"<DIV style='background-color:white; display:none; position:fixed; width:250; z-index: 999;' id='ProjectToolTipResource{0}'>
                                    <DIV class='divUpperFields'>
                                        <DIV class='label'><SPAN>Resource:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{1}</SPAN></DIV>
                                        </DIV>
                                    </DIV>", resource.EmployeeID.Value, resource.EmployeeName));
                                }
                                else if (resource.EquipmentID.HasValue)
                                {
                                    builder.Append(string.Format(@"<DIV style='background-color:white; display:none; position:fixed; width:250; z-index: 999;' id='ProjectToolTipResource{0}'>
                                    <DIV class='divUpperFields'>
                                        <DIV class='label'><SPAN>Resource:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{1}</SPAN></DIV>
                                        </DIV>
                                    </DIV>", resource.EquipmentID.Value, resource.EquipmentName));
                                }
                                else if (resource.EquipmentTypeID.HasValue)
                                {
                                    builder.Append(string.Format(@"<DIV style='background-color:white; display:none; position:fixed; width:250; z-index: 999;' id='ProjectToolTipResource{0}'>
                                    <DIV class='divUpperFields'>
                                        <DIV class='label'><SPAN>Resource:</SPAN></DIV>
                                        <DIV class='text'><SPAN>{1}</SPAN></DIV>
                                        </DIV>
                                    </DIV>", resource.EquipmentTypeID.Value, resource.EquipmentTypeName));
                                }

                                builder.Append("</td>");
                            }
                            builder.Append("</tr>");
                        }
                    }

                }

                builder.Append("</tbody> </table>");
                _view.CalendarSource = builder.ToString();
            }
        }
Example #26
0
        public string CreateTransportOrder(TransportOrderMaster transportOrderMaster, IDictionary<int, string> shipAddressDic, IList<string> ipNoList)
        {
            #region 是否生成运输单号校验
            if (!string.IsNullOrWhiteSpace(transportOrderMaster.OrderNo))
            {
                throw new TechnicalException("已经生成运输单号。");
            }
            #endregion

            #region 必输字段校验
            if (string.IsNullOrWhiteSpace(transportOrderMaster.Flow))
            {
                throw new BusinessException("运输路线代码不能为空");
            }

            if (string.IsNullOrWhiteSpace(transportOrderMaster.Vehicle))
            {
                throw new BusinessException("运输工具不能为空。");
            }

            if (string.IsNullOrWhiteSpace(transportOrderMaster.Carrier))
            {
                throw new BusinessException("承运商不能为空。");
            }
            #endregion

            #region 字段合法性校验
            TransportFlowMaster transportFlowMaster = this.genericMgr.FindAll<TransportFlowMaster>("from TransportFlowMaster where Code = ?", transportOrderMaster.Flow).SingleOrDefault();
            if (transportFlowMaster == null)
            {
                throw new BusinessException("运输路线{0}不存在。", transportOrderMaster.Flow);
            }
            else
            {
                transportOrderMaster.FlowDescription = transportFlowMaster.Description;
                transportOrderMaster.MinLoadRate = transportFlowMaster.MinLoadRate;
                transportOrderMaster.IsAutoRelease = transportFlowMaster.IsAutoRelease;
                //transportOrderMaster.IsAutoStart = transportFlowMaster.IsAutoStart;
                transportOrderMaster.MultiSitePick = transportFlowMaster.MultiSitePick;
            }

            //IList<TransportFlowRoute> transportFlowRouteList = this.genericMgr.FindAll<TransportFlowRoute>("from TransportFlowRoute where Flow = ? order by Sequence", transportOrderMaster.Flow);
            //if (transportFlowRouteList == null || transportFlowRouteList.Count < 2)
            //{
            //    throw new BusinessException("运输路线{0}没有维护足够的运输站点。", transportOrderMaster.Flow);
            //}
            //else
            //{
            //    transportOrderMaster.ShipFrom = transportFlowRouteList.First().ShipAddress;
            //    transportOrderMaster.ShipFromAddress = transportFlowRouteList.First().ShipAddressDescription;
            //    transportOrderMaster.ShipTo = transportFlowRouteList.Last().ShipAddress;
            //    transportOrderMaster.ShipToAddress = transportFlowRouteList.Last().ShipAddressDescription;
            //}

            //Carrier carrier = genericMgr.FindAll<Carrier>("from Carrier where Code = ?", transportOrderMaster.Carrier).FirstOrDefault();

            //if (carrier == null)
            //{
            //    throw new BusinessException("承运商代码{0}不存在。", transportOrderMaster.Carrier);
            //}
            //else
            //{
            //    transportOrderMaster.CarrierName = carrier.Name;
            //}

            TransportFlowCarrier transportFlowCarrier = genericMgr.FindAll<TransportFlowCarrier>("from TransportFlowCarrier where Flow = ? and Carrier = ? and TransportMode = ?",
                new object[] { transportFlowMaster.Code, transportOrderMaster.Carrier, transportOrderMaster.TransportMode }).FirstOrDefault();

            if (transportFlowCarrier != null)
            {
                transportFlowCarrier.PriceList = transportFlowCarrier.PriceList;
                transportFlowCarrier.BillAddress = transportFlowCarrier.BillAddress;
            }

            //if (!string.IsNullOrWhiteSpace(transportOrderMaster.Vehicle))
            //{
            //    Vehicle vehicle = genericMgr.FindAll<Vehicle>("from Vehicle where Code = ?", transportOrderMaster.Vehicle).FirstOrDefault();

            //    if (vehicle == null)
            //    {
            //        throw new BusinessException("运输工具{0}不存在。", transportOrderMaster.Vehicle);
            //    }

            //    if (vehicle.Carrier != carrier.Code)
            //    {
            //        throw new BusinessException("运输工具{0}不属于承运商{1}。", transportOrderMaster.Vehicle, transportOrderMaster.Carrier);
            //    }

            //    Tonnage tonnage = genericMgr.FindAll<Tonnage>("from Tonnage where Code = ?", vehicle.Tonnage).FirstOrDefault();

            //    if (tonnage == null)
            //    {
            //        throw new BusinessException("运输工具{0}的吨位代码{1}不存在。", vehicle.Code, transportOrderMaster.Tonnage);
            //    }

            //    transportOrderMaster.Tonnage = tonnage.Code;
            //    transportOrderMaster.LoadVolume = tonnage.LoadVolume;
            //    transportOrderMaster.LoadWeight = tonnage.LoadWeight;
            //    transportOrderMaster.DrivingNo = vehicle.DrivingNo;

            //    if (string.IsNullOrWhiteSpace(transportOrderMaster.Driver) && !string.IsNullOrWhiteSpace(vehicle.Driver))
            //    {
            //        Driver driver = genericMgr.FindAll<Driver>("from Driver where Code = ?", vehicle.Driver).FirstOrDefault();
            //        if (driver != null)
            //        {
            //            transportOrderMaster.Driver = driver.Code;
            //            transportOrderMaster.DriverMobilePhone = driver.MobilePhone;
            //            transportOrderMaster.LicenseNo = driver.LicenseNo;
            //        }
            //    }
            //}

            //if (!string.IsNullOrWhiteSpace(transportOrderMaster.Driver))
            //{
            //    Driver driver = genericMgr.FindAll<Driver>("from Driver where Code = ?", transportOrderMaster.Driver).FirstOrDefault();

            //    if (driver == null)
            //    {
            //        throw new BusinessException("驾驶员{0}不存在。", transportOrderMaster.Driver);
            //    }

            //    transportOrderMaster.Driver = driver.Code;
            //    transportOrderMaster.DriverMobilePhone = driver.MobilePhone;
            //    transportOrderMaster.LicenseNo = driver.LicenseNo;
            //}
            #endregion

            #region 准备运单
            string orderNo = numberControlMgr.GetTransportOrderNo(transportOrderMaster);
            transportOrderMaster.OrderNo = orderNo;
            if (ipNoList != null)
            {
                ipNoList = ipNoList.Distinct().ToArray();
            }

            IList<TransportOrderRoute> transportOrderRouteList = PrepareTransportOrderRoute(orderNo, transportOrderMaster.TransportMode, shipAddressDic);

            IList<TransportOrderDetail> transportOrderDetailList = PrepareTransportOrderDetail(orderNo, transportOrderMaster.TransportMode, transportOrderMaster.MultiSitePick, ipNoList, transportOrderRouteList);

            if (transportOrderRouteList == null || transportOrderRouteList.Count < 2)
            {
                throw new BusinessException("运输站点不能小于2个。");
            }
            else
            {
                transportOrderMaster.ShipFrom = transportOrderRouteList.First().ShipAddress;
                transportOrderMaster.ShipFromAddress = transportOrderRouteList.First().ShipAddressDescription;
                transportOrderMaster.ShipTo = transportOrderRouteList.Last().ShipAddress;
                transportOrderMaster.ShipToAddress = transportOrderRouteList.Last().ShipAddressDescription;
            }
            #endregion

            #region 创建运单
            this.genericMgr.Create(transportOrderMaster);
            foreach (TransportOrderRoute transportOrderRoute in transportOrderRouteList)
            {
                this.genericMgr.Create(transportOrderRoute);
            }
            transportOrderMaster.TransportOrderRouteList = transportOrderRouteList;

            foreach (TransportOrderDetail transportOrderDetail in transportOrderDetailList)
            {
                TransportOrderRoute transportOrderRouteFrom = transportOrderRouteList.Where(r => r.ShipAddress == transportOrderDetail.ShipFrom).OrderBy(r => r.Sequence).First();
                transportOrderDetail.OrderRouteFrom = transportOrderRouteFrom.Id;
                transportOrderDetail.OrderRouteTo = transportOrderRouteList.Where(r => r.ShipAddress == transportOrderDetail.ShipTo && r.Sequence > transportOrderRouteFrom.Sequence).OrderBy(r => r.Sequence).First().Id;
                this.genericMgr.Create(transportOrderDetail);
            }
            transportOrderMaster.TransportOrderDetailList = transportOrderDetailList;
            #endregion

            if (transportOrderMaster.IsAutoRelease)
            {
                ReleaseTransportOrderMaster(transportOrderMaster);
            }

            return orderNo;
        }
 private void PackagesServiceRunFinished(IList<Package> packages)
 {
     if (this.InvokeRequired)
     {
         Invoke(new PackageSServiceHandler(PackagesServiceRunFinished), new object[] { packages });
     }
     else
     {
         var distinctpackages = packages.Distinct().ToList();
         PackageList.DataSource = distinctpackages;
         PackageList.DisplayMember = "Name";
         if(distinctpackages.Count > 0) PackageList.SelectedIndex = 0;
         ClearStatus();
         lblStatus.Text = "Number of installed packages: " + packages.Count;
         SelectPackage();
     }
 }
Example #28
0
        /// <summary>Get multiple Series at once. Download progress is provided trough DownloadProgressNotification event</summary>
        /// <param name="series">List of Series ID's to download meta data for.</param>
        /// <param name="parallelDownloads">Number of Parallel downloads</param>
        /// <returns>Enumerable collection of Series</returns>
        public static IEnumerable<Series> GetMulti(IList<int> series, int parallelDownloads)
        {
            ServicePointManager.DefaultConnectionLimit = parallelDownloads <= 5 ? 5 : parallelDownloads;

            Logging.ConfigureLogging("FANART.TV-API", "fanart.tv-api.log.txt", Configuration.LogLevel);

            if (parallelDownloads <= 0)
            {
                parallelDownloads = 10;
            }

            Logger.Info("Downloading {0} series metadata. Parallelism: {1}", series.Count, parallelDownloads);

            lock (DownloadedXmlLock)
            {
                foreach (var seriesId in series)
                {
                    if (!DownloadedXml.ContainsKey(seriesId))
                    {
                        DownloadedXml.Add(seriesId, null);
                    }
                }
            }

            var downloadThreadPool = new SmartThreadPool(10000, parallelDownloads);
            downloadThreadPool.Start();

            foreach (var seriesId in series.Distinct())
            {
                downloadThreadPool.QueueWorkItem(new Amib.Threading.Func<int, bool, Series>(Get), seriesId, true);
            }

            downloadThreadPool.WaitForIdle();
            lock (DownloadedXmlLock)
            {
                var returnValue = DownloadedXml.Where(s => series.Contains(s.Key)).ToDictionary(e => e.Key, e => e.Value).Select(s => s.Value);
                
                var elementsToRemove = DownloadedXml.Keys.Where(series.Contains).ToList();
                foreach (var elementToRemove in elementsToRemove)
                {
                    DownloadedXml.Remove(elementToRemove);
                }

                return returnValue;
            }
        }
 private bool AddBlankRowToRecordset(IDataListItem dlItem, IList<IScalar> columns, int indexToInsertAt, int indexNum)
 {
     bool itemsAdded = false;
     if(dlItem.IsRecordset)
     {
         IList<IScalar> recsetCols = columns.Distinct(Scalar.Comparer).ToList();
         string colName = null;
         foreach(var col in recsetCols)
         {
             if(string.IsNullOrEmpty(colName) || !colName.Equals(col.Name))
             {
                 WorkflowInputs.Insert(indexToInsertAt + 1, new DataListItem
                 {
                     DisplayValue = string.Concat(dlItem.Recordset, "(", indexNum, ").", col.Name),
                     Value = string.Empty,
                     IsRecordset = dlItem.IsRecordset,
                     Recordset = dlItem.Recordset,
                     Field = col.Name,
                     Description = col.Description,
                     RecordsetIndex = indexNum.ToString(CultureInfo.InvariantCulture)
                 });
                 indexToInsertAt++;
             }
             colName = col.Name;
             itemsAdded = true;
             
         }
     }
     return itemsAdded;
 }
        /// <summary>
        /// 添加敏感词
        /// </summary>
        /// <param name="words">敏感词集合</param>
        /// <param name="typeId">敏感词类型Id</param>
        public void BatchCreate(IList<string> words, int? typeId)
        {
            if (words == null)
            {
                return;
            }

            words = words.Distinct().ToList();

            List<SensitiveWord> sensitiveWords = new List<SensitiveWord>();
            foreach (string word in words)
            {
                SensitiveWord sensitiveWord = SensitiveWord.New();
                if (word.Contains("="))
                {
                    string[] parts = word.Split('=');

                    if (parts.Count() == 2)
                    {
                        sensitiveWord.Word = parts[0];
                        sensitiveWord.Replacement = parts[1];
                    }
                }
                else
                {
                    sensitiveWord.Word = word;
                    sensitiveWord.Replacement = "*";
                }

                if (typeId.HasValue)
                {
                    sensitiveWord.TypeId = typeId.Value;
                }

                sensitiveWords.Add(sensitiveWord);

            }

            EventBus<SensitiveWord>.Instance().OnBatchBefore(sensitiveWords, new CommonEventArgs(EventOperationType.Instance().Create()));
            sensitiveWordRepository.BatchInsert(sensitiveWords);
            EventBus<SensitiveWord>.Instance().OnBatchAfter(sensitiveWords, new CommonEventArgs(EventOperationType.Instance().Create()));
        }