public LICSRequestArticle[] GetRequestArticles() { LICSRequestArticle[] articles = new LICSRequestArticle[] { }; try { IPluginSettings plugingSettings = _pluginSettings.AllAvailablePluginSettings().FirstOrDefault(pl => pl.CheckArticles); if (plugingSettings == null) { //_logger.Log("There was not adjusted any article setting"); return(articles); } foreach (var plugin in CustomerDataPlugins) { if (((string)plugin.Metadata[CurrentServiceInformation.NameForPluginMetadata]).Equals(Enum.GetName(typeof(CustomDataSourceTypes), plugingSettings.PluginType))) { articles = plugin.Value.GetRequestArticles(plugingSettings); break; } } } catch (Exception ex) { // _logger.Log(ex); } return(articles); }
public static LICSRequest ConvertToLICSRequest(this OutputPayLoad navisionOutputPayload) { LICSRequest licsRequest = new LICSRequest(); List <LICSRequestArticle> listLicsRequestArticles = new List <LICSRequestArticle>(); List <LICSRequestOrderPosition> orderPositions = new List <LICSRequestOrderPosition>(); LICSRequestOrder requestOrder = new LICSRequestOrder(); requestOrder.ShipmentDate = DateTime.ParseExact(navisionOutputPayload.OrderHeader.Date, "dd.MM.yy", System.Globalization.CultureInfo.InvariantCulture); requestOrder.OrderNo = navisionOutputPayload.OrderHeader.OrderNumber; requestOrder.CustomerNo = Convert.ToString(navisionOutputPayload.OrderHeader.CustomerNumber); requestOrder.DistributionCenter = navisionOutputPayload.OrderHeader.WarehouseOrder; LICSRequestOrderRecipient orderRecipient = new LICSRequestOrderRecipient(); orderRecipient.Name = navisionOutputPayload.OrderHeader.CustomerName; // orderRecipient.AdditionalName = (string)navisionOutputPayload.OrderHeader.CustomerName2; RESOLVE THIS PROBLEM orderRecipient.Street = navisionOutputPayload.OrderHeader.CustomerStreet; orderRecipient.ZIPCode = Convert.ToString(navisionOutputPayload.OrderHeader.CustomerZIP); orderRecipient.City = navisionOutputPayload.OrderHeader.CustomerTown; foreach (OutputPayLoadOutputPosition outputPosition in navisionOutputPayload.Positions) { LICSRequestOrderPosition orderPosition = new LICSRequestOrderPosition(); orderPosition.ArticleGroup = outputPosition.VPECode; orderPosition.PositionNo = (int)outputPosition.ArticleRowNumber; orderPosition.ArticleNo = outputPosition.ArticleNumber; orderPosition.TargetQuantity = Convert.ToDouble(outputPosition.VPECount); LICSRequestArticle requestArticle = new LICSRequestArticle(); requestArticle.ArticleNo = outputPosition.ArticleNumber; requestArticle.ArticleDescription = outputPosition.Description; requestArticle.ArticleDescription2 = outputPosition.Description2; requestArticle.ArticleGroup = outputPosition.VPECode; requestArticle.ArticleGroupFactor = outputPosition.BaseUnitQuantity; orderPositions.Add(orderPosition); listLicsRequestArticles.Add(requestArticle); } requestOrder.Positions = orderPositions.ToArray(); requestOrder.Recipient = orderRecipient; licsRequest.ArticleImport = listLicsRequestArticles.ToArray(); licsRequest.OrderImport = new LICSRequestOrder[] { requestOrder }; return(licsRequest); }
private void CheckDeliveries() { try { if (UpdateTimeWatcher.TimeToCheck(Ix4RequestProps.Deliveries)) { if (_cachedArticles == null) { _loger.Log("There is no cheched articles for filling deliveries"); CheckArticles(); if (_cachedArticles == null) { _loger.Log("WE CANNOT GET DELIVERIES WITHOUT ARTICLES"); return; } } int currentClientID = _customerInfo.ClientID; LICSRequest request = new LICSRequest(); request.ClientId = currentClientID; LICSRequestDelivery[] deliveries = _dataCompositor.GetRequestDeliveries(); List <LICSRequestArticle> articlesByDelliveries = new List <LICSRequestArticle>(); _loger.Log(deliveries, "deliveries"); if (deliveries.Length == 0) { _loger.Log("There is no deliveries"); return; } foreach (LICSRequestDelivery delivery in deliveries) { bool deliveryHasErrors = false; articlesByDelliveries = new List <LICSRequestArticle>(); delivery.ClientNo = currentClientID; request.DeliveryImport = new LICSRequestDelivery[] { delivery }; foreach (var position in delivery.Positions) { LICSRequestArticle findArticle = GetArticleByNumber(position.ArticleNo); if (findArticle == null) { _loger.Log("Cannot find article with no: " + position.ArticleNo); _loger.Log("Delivery with wrong article position: " + delivery); deliveryHasErrors = true; } else { articlesByDelliveries.Add(findArticle); } } if (deliveryHasErrors) { _loger.Log("Delivery " + delivery + "WAS NOT SEND"); continue; } else { request.ArticleImport = articlesByDelliveries.ToArray(); _loger.Log("Delivery before sending: "); foreach (LICSRequestDelivery item in request.DeliveryImport) { _loger.Log(item.SerializeObjectToString <LICSRequestDelivery>()); } var res = SendLicsRequestToIx4(request, "deliveryFile.xml"); _loger.Log("Delivery result: " + res); } } UpdateTimeWatcher.SetLastUpdateTimeProperty(Ix4RequestProps.Deliveries); } } catch (Exception ex) { _loger.Log(ex); } }
private LICSRequestArticle[] LoadArticles(IDataReader reader) { DataTable table = new DataTable(); List <LICSRequestArticle> articles = new List <LICSRequestArticle>(); table.Load(reader); foreach (DataRow row in table.AsEnumerable()) { try { LICSRequestArticle articleItem = new LICSRequestArticle(); // articleItem.GetType().GetProperty(propertyName).SetValue.GetValue((car, null); // var r = table.AsEnumerable(); foreach (DataColumn column in row.Table.Columns) { var res = row[column.ColumnName]; PropertyInfo propertyInfo = articleItem.GetType().GetProperty(column.ColumnName); if (row[column.ColumnName].GetType().Equals(DBNull.Value.GetType())) { propertyInfo.SetValue(articleItem, Convert.ChangeType(GetDefaultValue(propertyInfo.PropertyType), propertyInfo.PropertyType), null); } else { propertyInfo.SetValue(articleItem, Convert.ChangeType(row[column.ColumnName].ToString().Trim(), propertyInfo.PropertyType), null); } } articles.Add(articleItem); //double currentArticleGroupFactor = 0; //double currentWeight = 0; //int identityNo = 0; //if (!string.IsNullOrEmpty(Convert.ToString(row["ArticleGroupFactor"]))) //{ // currentArticleGroupFactor = double.Parse(Convert.ToString(row["ArticleGroupFactor"]), CultureInfo.InvariantCulture); //} //if (!string.IsNullOrEmpty(Convert.ToString(row["Weight"]))) //{ // currentWeight = double.Parse(Convert.ToString(row["Weight"]), CultureInfo.InvariantCulture); //} //if (!string.IsNullOrEmpty(Convert.ToString(row["IdentityNo"]))) //{ // identityNo = Int32.Parse(Convert.ToString(row["IdentityNo"]), CultureInfo.InvariantCulture); //} //articles.Add(new LICSRequestArticle //{ // ArticleNo = (row["ArticleNo"] ?? string.Empty).ToString().Trim(), // ArticleNo2 = (row["ArticleNo2"] ?? string.Empty).ToString().Trim(), // ArticleDescription = (row["ArticleDescription"] ?? string.Empty).ToString().Trim(), // ArticleDescription2 = (row["ArticleDescription2"] ?? string.Empty).ToString().Trim(), // // IdentityNo = identityNo, // QuantityUnit = (row["QuantityUnit"] ?? string.Empty).ToString().Trim(), // // EAN = (row["EAN"] ?? string.Empty).ToString(), // // ProductCode = (row["ProductCode"] ?? string.Empty).ToString(), // // ArticleGroup = (row["ArticleGroup"] ?? string.Empty).ToString(), // // ArticleGroupFactor = currentArticleGroupFactor, // // Weight = currentWeight //}); } catch (Exception ex) { _loger.Log("Exception while reflect DataColumn values using Reflection"); _loger.Log(ex); } } return(articles.Where(i => !string.IsNullOrEmpty(i.ArticleNo)).ToArray()); }