当前位置: 首页>>代码示例>>C#>>正文


C# List.ToArray方法代码示例

本文整理汇总了C#中Service.List.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToArray方法的具体用法?C# List.ToArray怎么用?C# List.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Service.List的用法示例。


在下文中一共展示了List.ToArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetShippingRatesSync

        public ShippingRate[] GetShippingRatesSync(decimal weight, string originZipCode, string destinationZipCode)
        {
            // create object that will store results
            List<ShippingRate> rates = new List<ShippingRate>();

            // launch requests serially, waiting for each one
            using (WebResponse response = CreateFedExRequest(weight, originZipCode, destinationZipCode).GetResponse())
                rates.AddRange(GetFedExRates(response));

            using (WebResponse response = CreateUpsRequest(weight, originZipCode, destinationZipCode).GetResponse())
                rates.AddRange(GetUpsRates(response));

            using (WebResponse response = CreateUspsRequest(weight, originZipCode, destinationZipCode).GetResponse())
                rates.AddRange(GetUspsRates(response));

            return rates.ToArray();
        }
开发者ID:bgrainger,项目名称:AsyncIoDemo,代码行数:17,代码来源:ShippingRatesProvider.cs

示例2: GetShippingRatesSyncParallel

        public ShippingRate[] GetShippingRatesSyncParallel(decimal weight, string originZipCode, string destinationZipCode)
        {
            // create object that will store results
            List<ShippingRate> rates = new List<ShippingRate>();

            // launch asynchronous requests, which will complete in parallel
            WebRequest fedExRequest = CreateFedExRequest(weight, originZipCode, destinationZipCode);
            IAsyncResult fedExResult = fedExRequest.BeginGetResponse(null, null);

            WebRequest upsRequest = CreateUpsRequest(weight, originZipCode, destinationZipCode);
            IAsyncResult upsResult = upsRequest.BeginGetResponse(null, null);

            WebRequest uspsRequest = CreateUspsRequest(weight, originZipCode, destinationZipCode);
            IAsyncResult uspsResult = uspsRequest.BeginGetResponse(null, null);

            // wait for all requests; each EndGetResponse will block if the request hasn't completed

            using (WebResponse response = fedExRequest.EndGetResponse(fedExResult))
                rates.AddRange(GetFedExRates(response));

            using (WebResponse response = upsRequest.EndGetResponse(upsResult))
                rates.AddRange(GetUpsRates(response));

            using (WebResponse response = uspsRequest.EndGetResponse(uspsResult))
                rates.AddRange(GetUspsRates(response));

            return rates.ToArray();
        }
开发者ID:bgrainger,项目名称:AsyncIoDemo,代码行数:28,代码来源:ShippingRatesProvider.cs

示例3: PrepareSearchStatement

        /// <summary>
        /// Search Statement
        /// </summary>
        /// <param name="command">Telerik GridCommand</param>
        /// <param name="searchModel">RoutingMaster Search Model</param>
        /// <returns>Search Statement</returns>
        private SearchStatementModel PrepareSearchStatement(GridCommand command, ProductLineMapSearchModel searchModel)
        {
            string whereStatement = string.Empty;

            IList<object> param = new List<object>();
            HqlStatementHelper.AddEqStatement("Type", (int)com.Sconit.CodeMaster.ProductLineMapType.Van, "r", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("SAPProductLine", searchModel.SAPProductLine, HqlStatementHelper.LikeMatchMode.Start, "r", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("IsActive", searchModel.SearchIsActive, "r", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement = selectStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }
开发者ID:Novthirteen,项目名称:sih-les,代码行数:26,代码来源:VanProductLineMapController.cs

示例4: ProcessOPCServer

        /// <summary>
        /// Reading all readings from an OPC server.
        /// </summary>
        private void ProcessOPCServer(OOPCDAServer opcDaServer)
        {
            if (opcDaServer.AutomaticPollingEnabled == 0)
                return;

            XmlServer srv = null;
            try
            {
                srv = new XmlServer(opcDaServer.ObjectName);

                List<OPoint> points = TablesLogic.tPoint.LoadList(
                    TablesLogic.tPoint.OPCDAServerID == opcDaServer.ObjectID);
                if (points.Count == 0)
                    return;

                List<ReadRequestItem> readRequestItems = new List<ReadRequestItem>();
                Hashtable hash = new Hashtable();
                foreach (OPoint point in points)
                {
                    readRequestItems.Add(NewReadRequestItem(point.OPCItemName));
                    hash[point.OPCItemName] = point;
                }
                ReadRequestItemList readItemList = new ReadRequestItemList();
                readItemList.Items = readRequestItems.ToArray();

                ReplyBase reply;
                RequestOptions options = new RequestOptions();
                options.ReturnErrorText = true;
                options.ReturnItemName = true;
                ReplyItemList rslt;
                OPCError[] err;
                reply = srv.Read(options, readItemList, out rslt, out err);
                if (rslt == null)
                    throw new Exception(err[0].Text);
                else
                {
                    int count = 0;
                    foreach (ItemValue iv in rslt.Items)
                    {
                        if (iv.ResultID == null)
                        {
                            try
                            {
                                using (Connection c = new Connection())
                                {
                                    // Create the readings. 
                                    //
                                    OReading reading = TablesLogic.tReading.Create();
                                    OPoint point = hash[iv.ItemName] as OPoint;

                                    if (point != null)
                                    {
                                        reading.PointID = point.ObjectID;
                                        reading.LocationID = point.LocationID;
                                        //reading.LocationTypeParameterID = point.LocationTypeParameterID;
                                        reading.EquipmentID = point.EquipmentID;
                                        //reading.EquipmentTypeParameterID = point.EquipmentTypeParameterID;
                                        reading.DateOfReading = DateTime.Now;

                                        if (iv.Value is bool)
                                            reading.Reading = ((bool)iv.Value) ? 1 : 0;
                                        else
                                            reading.Reading = Convert.ToDecimal(iv.Value.ToString());
                                        reading.Source = ReadingSource.OPCServer;
                                        reading.CheckForBreachOfReading(point);
                                        reading.Save();
                                        count++;
                                    }
                                    c.Commit();
                                }
                            }
                            catch (Exception ex)
                            {
                                LogEvent(ex.Message + "\n\n" + ex.StackTrace, BackgroundLogMessageType.Error);
                            }
                        }
                        else
                            LogEvent("Error reading '" + iv.ItemName + "': " + iv.ResultID.Name, BackgroundLogMessageType.Error);
                    }
                    LogEvent(count + " points out of " + readItemList.Items.Length + " successfully read from server '" + opcDaServer.ObjectName + "'.");
                }
            }
            catch (Exception ex)
            {
                LogEvent(ex.Message + "\n\n" + ex.StackTrace, BackgroundLogMessageType.Error);
            }
            finally
            {
                if (srv != null)
                    srv.Dispose();
            }
            
        }
开发者ID:vinhdoan,项目名称:Angroup.demo,代码行数:96,代码来源:OPCDAService.cs

示例5: Edit

        public ActionResult Edit(SequenceGroup sequenceGroup)
        {
            ViewBag.HaveEditPrevTraceCode = CurrentUser.Permissions.Where(p => p.PermissionCode == "Url_SequenceGroup_EditPrevTraceCode").Count() > 0;
            if (ModelState.IsValid)
            {
                bool noenError = true;
                if (!ViewBag.HaveEditPrevTraceCode && !string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                {
                    SaveErrorMessage("您没有修改前个Van号的权限。");
                    noenError = false;
                }
                if (sequenceGroup.IsActive && string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                {
                    SaveErrorMessage("排序组有效的情况下,前面Van号不能为空。");
                     noenError = false;
                }
                IList<OrderSeq> orderSeqs = new List<OrderSeq>();
                if (!string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                {
                     orderSeqs = this.genericMgr.FindAll<OrderSeq>("select o from OrderSeq as o where o.ProductLine=? and o.TraceCode=?", new object[] { sequenceGroup.ProductLine, sequenceGroup.PreviousTraceCode });
                    if (orderSeqs == null || orderSeqs.Count == 0)
                    {
                        SaveErrorMessage(string.Format("生产线{0}前面Van号{1}找不到有效的数据。", sequenceGroup.ProductLine, sequenceGroup.PreviousTraceCode));
                        noenError = false;
                    }
                }
                if (!string.IsNullOrWhiteSpace(sequenceGroup.OpReference))
                {
                    try
                    {
                        sequenceGroup.OpReference.Split('|');
                    }
                    catch (Exception)
                    {
                        SaveErrorMessage(string.Format("工位{0}填写有误,正确的格式为{1}。", sequenceGroup.OpReference, Resources.SCM.SequenceGroup.SequenceGroup_OpRefRemark));
                        noenError = false;
                    }
                }
                if (noenError)
                {
                    var dbSsequenceGroup = base.genericMgr.FindById<SequenceGroup>(sequenceGroup.Code);
                    //dbSsequenceGroup.SequenceBatch = sequenceGroup.SequenceBatch;
                    //dbSsequenceGroup.OpReference = sequenceGroup.OpReference;
                    //dbSsequenceGroup.IsActive = sequenceGroup.IsActive;
                    //if (!string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                    //{
                    //    dbSsequenceGroup.PreviousTraceCode = sequenceGroup.PreviousTraceCode;
                    //    dbSsequenceGroup.PreviousOrderNo = orderSeqs.First().OrderNo;
                    //    dbSsequenceGroup.PreviousSeq = orderSeqs.First().Sequence;
                    //    dbSsequenceGroup.PreviousSubSeq = orderSeqs.First().SubSequence;
                    //}
                    //base.genericMgr.Update(dbSsequenceGroup);
                    string updateSql = "update SCM_SeqGroup set Version=Version+1,IsActive=?,SeqBatch=? ";
                    IList<object> parems = new List<object>();
                    parems.Add(sequenceGroup.IsActive);
                    parems.Add(sequenceGroup.SequenceBatch);
                    if (!string.IsNullOrWhiteSpace(sequenceGroup.OpReference))
                    {
                        updateSql += " ,OpRef=? ";
                        parems.Add(sequenceGroup.OpReference);
                    }
                    if (!string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                    {
                        updateSql += ",PrevTraceCode=?,PrevOrderNo=?,PrevSeq=?,PrevSubSeq=? ";
                        parems.Add(sequenceGroup.PreviousTraceCode);
                        parems.Add(orderSeqs.First().OrderNo);
                        parems.Add(orderSeqs.First().Sequence);
                        parems.Add(orderSeqs.First().SubSequence);
                    }
                    updateSql += "  where Code=? and Version=? ";
                    parems.Add(sequenceGroup.Code);
                    parems.Add(sequenceGroup.Version);
                    this.genericMgr.UpdateWithNativeQuery(updateSql, parems.ToArray());
                    SaveSuccessMessage(Resources.SCM.SequenceGroup.SequenceGroup_Updated);
                    return View(dbSsequenceGroup);
                }
            }

            return View(sequenceGroup);
        }
开发者ID:Novthirteen,项目名称:sih-les,代码行数:80,代码来源:SequenceGroupController.cs

示例6: PrepareSearchStatement

        /// <summary>
        /// Search Statement
        /// </summary>
        /// <param name="command">Telerik GridCommand</param>
        /// <param name="searchModel">RoutingMaster Search Model</param>
        /// <returns>Search Statement</returns>
        private SearchStatementModel PrepareSearchStatement(GridCommand command, SequenceGroupSearchModel searchModel)
        {
            string whereStatement = string.Empty;

            IList<object> param = new List<object>();

            HqlStatementHelper.AddEqStatement("ProductLine", searchModel.ProdLine, "s", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("IsActive", searchModel.IsActive, "s", ref whereStatement, param);
            HqlStatementHelper.AddLikeStatement("Code", searchModel.Code, HqlStatementHelper.LikeMatchMode.Start, "s", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);

            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectCountStatement;
            searchStatementModel.SelectStatement = selectStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }
开发者ID:Novthirteen,项目名称:sih-les,代码行数:27,代码来源:SequenceGroupController.cs

示例7: OnExecute

        public override void OnExecute()
        {
            base.OnExecute();

            DateTime now  = DateTime.Now;
            List<ONotification> notifications =
                TablesLogic.tNotification.LoadList(
                TablesLogic.tNotification.NextNotificationDateTime < now);

            foreach (ONotification notification in notifications)
            {
                try
                {
                    // Load up the object and test if the expected
                    // field is null. 
                    // 
                    OActivity activity = TablesLogic.tActivity.Load(notification.ActivityID);
                    ONotificationProcess notificationProcess = TablesLogic.tNotificationProcess.Load(notification.NotificationProcessID);
                    ONotificationMilestones milestones = notificationProcess.NotificationMilestones;

                    // 2010.06.30
                    // Kim Foong
                    // Checks if any of the objects are null, if so, we terminate the
                    // notification.
                    //
                    if (activity == null || notificationProcess == null || milestones == null)
                    {
                        using (Connection c = new Connection())
                        {
                            notification.NextNotificationDateTime = null;
                            notification.Save();
                            c.Commit();
                        }
                        continue;
                    }

                    Type type = typeof(TablesLogic).Assembly.GetType("LogicLayer." + activity.ObjectTypeName);
                    LogicLayerPersistentObject obj = PersistentObject.LoadObject(type, activity.AttachedObjectID.Value) as LogicLayerPersistentObject;
                    if (obj == null)
                    {
                        // 2010.06.30
                        // Kim Foong
                        // Terminate the notification.
                        //
                        using (Connection c = new Connection())
                        {
                            notification.NextNotificationDateTime = null;
                            notification.Save();
                            c.Commit();
                        }
                        continue;
                    }

                    int milestoneNumber = notification.NextNotificationMilestone.Value;
                    int notificationLevel = notification.NextNotificationLevel.Value;
                    string expectedField = (string)milestones.DataRow["ExpectedField" + milestoneNumber];

                    object value = DataFrameworkBinder.GetValue(obj, expectedField, false);
                    using (Connection c = new Connection())
                    {
                        if (value == null)
                        {
                            // Now since this value is null, we must send a notification.
                            //
                            // But we need to first find out the list of all the recipients 
                            // configured to receive the notification.
                            //
                            ONotificationHierarchyLevel notificationHierarchyLevel =
                                notificationProcess.NotificationHierarchy.FindNotificationHierarchyLevelByLevel(notificationLevel);

                            StringBuilder email = new StringBuilder();
                            StringBuilder cellphone = new StringBuilder();

                            // Assign users/roles to the task.
                            //
                            StringBuilder emails = new StringBuilder();
                            StringBuilder cellphones = new StringBuilder();
                            if (notificationHierarchyLevel != null)
                            {
                                List<OUser> notifyUsers = new List<OUser>();
                                List<OPosition> notifyPositions = new List<OPosition>();

                                // Here we assigned the users
                                //
                                foreach (OUser user in notificationHierarchyLevel.Users)
                                    notifyUsers.Add(user);

                                // Then we assign the positions.
                                //
                                foreach (OPosition position in notificationHierarchyLevel.Positions)
                                    notifyPositions.Add(position);

                                // Then we assign the positions through the roles.
                                //
                                List<string> roleCodes = new List<string>();
                                foreach (ORole role in notificationHierarchyLevel.Roles)
                                    roleCodes.Add(role.RoleCode);
                                List<OPosition> assignedPositions = OPosition.GetPositionsByRoleCodesAndObject(obj, roleCodes.ToArray());
                                notifyPositions.AddRange(assignedPositions);

//.........这里部分代码省略.........
开发者ID:vinhdoan,项目名称:Angroup.demo,代码行数:101,代码来源:NotificationService.cs


注:本文中的Service.List.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。