本文整理匯總了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();
}
示例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();
}
示例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;
}
示例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();
}
}
示例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);
}
示例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;
}
示例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);
//.........這裏部分代碼省略.........