/// <summary> /// Fill $colVM with @cor and @coa. /// $colVM is the combination of @cor and @coa /// </summary> /// <param name="colVM"></param> /// <param name="cor"></param> /// <param name="coa"></param> /// interface method public CardOrderListViewModel fillListViewModel(List <CardOrderRequest> cor, List <CardOrderAnswer> coa) { // create CardOrderListViewModel CardOrderListViewModel p_colVM = new CardOrderListViewModel(); // fill CardOrderListViewModel foreach (var request in cor) { // create CardOrderViewModel CardOrderViewModel cardOrderVM = new CardOrderViewModel(); var validStatusDate = ""; var receivedStatusDate = ""; var declinedStatusDate = ""; var sentStatusDate = ""; var successfullyCanceledStatusDate = ""; var unsuccessfullyCanceledStatusDate = ""; var pomRowColor = ""; var message = ""; fillCardOrderStatusesDate(out message, out validStatusDate, out receivedStatusDate, out declinedStatusDate, out sentStatusDate, out successfullyCanceledStatusDate, out unsuccessfullyCanceledStatusDate, out pomRowColor, coa, request); cardOrderVM = createAndReturnNewCardOrderViewModel(request.CardTypeId, request.Content, request.CreationDateTime, request.ID, message, request.PartnerId, request.PartnerRequestId, request.RequestID, request.CardCount, request.CarrierTypeId, request.EnvelopeTypeId, request.PlasticTypeId, request.AttachementId, request.PackageAttachementId, request.RequestStatus, request.LastUpdate, request.SlaDeadLine, request.StatusFinal, request.ValidTo, request.IsProcessing, validStatusDate, receivedStatusDate , declinedStatusDate, sentStatusDate, successfullyCanceledStatusDate, unsuccessfullyCanceledStatusDate, pomRowColor, request.OrderType, request.DeliveryListId); // add CardOrderViewModel into CardOrderListViewModel p_colVM.colVm.Add(cardOrderVM); } return(p_colVM); }
/// <summary> /// Metoda sluzi ako logika pre automatizovane nastavenie card order-ov, konkretne ich [isProcessing] stlpec na TRUE /// ak je tento stlpec nastaveny na TRUE => objednavka sa realne fyzicky spracovava /// </summary> public void freshCardOrdersWidget() { var receivedCardOrders = getCardOrdersByRequestStatus(1); var todaySentOrders = getCardOrdersByRequestStatus(2).Where(x => x.LastUpdate >= DateTime.Today) /*.Select(x=>x)*/; var joinOrders = receivedCardOrders; joinOrders.AddRange(todaySentOrders); // ALL received + TODAY sent foreach (var item in joinOrders) { if (item.RequestStatus == 1) // RECEIVED ORDER { CardOrderViewModel covm = new CardOrderViewModel(); //if (item.IsProcessing == false) //{ // var pom = orderIsProcessing(item); // if (pom) // { // var pomTableName = "[dbo].[____REQ002]"; // string queryString = String.Format("UPDATE FROM {0} SET is_processing = true WHERE id = {1}", pomTableName, item.ID); // string connectionString = "Server=192.168.20.102;Database=dev;User Id=xskok;Password=emo7veR3;"; // using (SqlConnection connection = new SqlConnection(connectionString)) // { // SqlCommand command = new SqlCommand(queryString, connection); // command.Parameters.AddWithValue("@pomRequestId", item.ID); // connection.Open(); // command.ExecuteNonQuery(); // } var validStatusDate = ""; var receivedStatusDate = ""; var declinedStatusDate = ""; var sentStatusDate = ""; var successfullyCanceledStatusDate = ""; var unsuccessfullyCanceledStatusDate = ""; // unnecessary var pomRowColor = ""; var message = ""; m_cardOrderEngine.fillCardOrderStatusesDate(out message, out validStatusDate, out receivedStatusDate, out declinedStatusDate, out sentStatusDate, out successfullyCanceledStatusDate, out unsuccessfullyCanceledStatusDate, out pomRowColor, m_cardOrderEngine.getCardnetDAL().getCardOrderAnswers(), item); covm = m_cardOrderEngine.createAndReturnNewCardOrderViewModel(item.CardTypeId, item.Content, item.CreationDateTime, item.ID, message, item.PartnerId, item.PartnerRequestId, item.RequestID, item.CardCount, item.CarrierTypeId, item.EnvelopeTypeId, item.PlasticTypeId, item.AttachementId, item.PackageAttachementId, item.RequestStatus, item.LastUpdate, item.SlaDeadLine, item.StatusFinal, item.ValidTo, item.IsProcessing, validStatusDate, receivedStatusDate , declinedStatusDate, sentStatusDate, successfullyCanceledStatusDate, unsuccessfullyCanceledStatusDate, pomRowColor, item.OrderType, item.DeliveryListId); this.m_tablesViewModel.colVm.Add(covm); // } //} //else //{ // var validStatusDate = ""; // var receivedStatusDate = ""; // var declinedStatusDate = ""; // var sentStatusDate = ""; // var canceledStatusDate = ""; // var pomRowColor = ""; // var message = ""; // m_cardOrderEngine.fillCardOrderStatusesDate(out message, out validStatusDate, out receivedStatusDate, out declinedStatusDate, out sentStatusDate, out canceledStatusDate, out pomRowColor, m_cardOrderEngine.getCardnetDAL().getCardOrderAnswers(), item); // covm = m_cardOrderEngine.createAndReturnNewCardOrderViewModel(item.CardTypeId, item.Content, item.CreationDateTime, item.ID, message, item.PartnerId, item.PartnerRequestId, item.RequestID, // item.CardCount, item.CarrierTypeId, item.EnvelopeTypeId, item.PlasticTypeId, item.AttachementId, item.PackageAttachementId, item.RequestStatus, item.LastUpdate, item.SlaDeadLine, item.StatusFinal, item.ValidTo, item.IsProcessing, validStatusDate, receivedStatusDate // , declinedStatusDate, sentStatusDate, canceledStatusDate, pomRowColor); // this.m_tablesViewModel.colVm.Add(covm); //} } else // request_status == 2 // SENT ORDER { CardOrderViewModel covm_todaysent = new CardOrderViewModel(); var validStatusDate = ""; var receivedStatusDate = ""; var declinedStatusDate = ""; var sentStatusDate = ""; var successfullyCanceledStatusDate = ""; var unsuccessfullyCanceledStatusDate = ""; var pomRowColor = ""; var message = ""; m_cardOrderEngine.fillCardOrderStatusesDate(out message, out validStatusDate, out receivedStatusDate, out declinedStatusDate, out sentStatusDate, out successfullyCanceledStatusDate, out unsuccessfullyCanceledStatusDate, out pomRowColor, m_cardOrderEngine.getCardnetDAL().getCardOrderAnswers(), item); covm_todaysent = m_cardOrderEngine.createAndReturnNewCardOrderViewModel(item.CardTypeId, item.Content, item.CreationDateTime, item.ID, message, item.PartnerId, item.PartnerRequestId, item.RequestID, item.CardCount, item.CarrierTypeId, item.EnvelopeTypeId, item.PlasticTypeId, item.AttachementId, item.PackageAttachementId, item.RequestStatus, item.LastUpdate, item.SlaDeadLine, item.StatusFinal, item.ValidTo, item.IsProcessing, validStatusDate, receivedStatusDate , declinedStatusDate, sentStatusDate, successfullyCanceledStatusDate, unsuccessfullyCanceledStatusDate, pomRowColor, item.OrderType, item.DeliveryListId); this.m_tablesViewModel.colVm_todaySent.Add(covm_todaysent); } } }
public CardOrderViewModel createAndReturnNewCardOrderViewModel(short?cardTypeId, string content, DateTime?creationDateTime, long id, string message, int?partnerId, string partnerRequestId, long?requestId, int?cardCount, string carrierTypeId1, string envelopeTypeId, string plasticTypeId, string attachementId, string packageAttachementId, int?requestStatus, DateTime?lastUpdate, string slaDeadLine, bool?statusFinal, string validTo, bool?isProcessing, string validStatusDate, string receivedStatusDate, string declinedStatusDate, string sentStatusDate, string successfullyCanceledStatusDate, string unsuccessfullyCanceledStatusDate, string rowColor, string orderType, string deliveryListId) { CardOrderViewModel covm = new CardOrderViewModel(); covm.CardTypeId = cardTypeId; var pomCardType = rwEngine.getRewardoDAL().getCardProductsFromRW().Where(ct => ct.CardProductID == cardTypeId).Select(ct => ct.CardProductName).FirstOrDefault(); covm.CardTypeName = pomCardType == null ? "DOESN'T EXIST (" + cardTypeId.ToString() + ")" : pomCardType; covm.Content = content; covm.CreationDateTime = creationDateTime; covm.ID = id; var pom1 = (from item1 in m_cardnetDAL.getCardOrderAnswers() where item1.PartnerId == partnerId && item1.RequestId == requestId select item1.Message).LastOrDefault(); covm.Message = pom1 == null ? "" : pom1.ToString(); covm.PartnerId = partnerId; covm.PartnerName = m_cardnetDAL.getPartners().Where(p => p.ID == partnerId).Select(p => p.OrganizationName).First(); // TODO covm.PartnerRequestId = partnerRequestId; covm.RequestID = requestId; covm.CardCount = cardCount; covm.CarrierTypeId = carrierTypeId1 == null ? "NULL" : m_cardnetDAL.getConstantPartner().Where(c => c.PartnerId == partnerId && c.ConstantName == "CarrierTypeId" && c.ConstantValue == carrierTypeId1).Select(c => c.ConstantDescription).First(); // TODO covm.EnvelopeTypeId = envelopeTypeId == null ? "NULL" : m_cardnetDAL.getConstantPartner().Where(c => c.PartnerId == partnerId && c.ConstantName == "EnvelopeTypeId" && c.ConstantValue == envelopeTypeId).Select(c => c.ConstantDescription).First(); // TODO; covm.PlasticTypeId = plasticTypeId == null ? "NULL" : m_cardnetDAL.getConstantPartner().Where(c => c.PartnerId == partnerId && c.ConstantName == "PlasticTypeId" && c.ConstantValue == plasticTypeId).Select(c => c.ConstantDescription).First(); // TODO; covm.AttachementId = attachementId == null ? "NULL" : m_cardnetDAL.getConstantPartner().Where(c => c.PartnerId == partnerId && c.ConstantName == "AttachementId" && c.ConstantValue == attachementId).Select(c => c.ConstantDescription).First(); // TODO; covm.PackageAttachementId = packageAttachementId == null ? "NULL" : m_cardnetDAL.getConstantPartner().Where(c => c.PartnerId == partnerId && c.ConstantName == "PackageAttachementId" && c.ConstantValue == packageAttachementId).Select(c => c.ConstantDescription).First(); // TODO; covm.CarrierTypeIdConstantValue = carrierTypeId1; covm.EnvelopeTypeIdConstantValue = envelopeTypeId; covm.PlasticTypeIdConstantValue = plasticTypeId; covm.AttachementIdConstantValue = attachementId; covm.PackageAttachementIdConstantValue = packageAttachementId; covm.DeliveryListIdConstantValue = deliveryListId; covm.OrderType = orderType.Substring(0, 3) == "CAN" ? partnerRequestId : "normal"; covm.RequestStatus = requestStatus; covm.RequestStatusName = requestStatus == null ? "INSERTED" : m_cardnetDAL.getConstantUniversals().Where(c => c.ConstantName == "card_order_state" && c.ConstantValue == requestStatus).Select(c => c.ConstantDescription).First(); // TODO covm.LastUpdate = lastUpdate; covm.SlaDeadLine = slaDeadLine; covm.StatusFinal = statusFinal; covm.ValidTo = validTo; covm.isProcessing = true; covm.TriggerOnLoad = false; covm.TriggerOnLoadMessage = ""; var pomValidStatusDate = (from answer in m_cardnetDAL.getCardOrderAnswers() where answer.PartnerId == partnerId && answer.RequestId == requestId && answer.RequestStatus == 4 select answer.ChangeDateTime).FirstOrDefault(); covm.ValidStatusDate = pomValidStatusDate == null ? "todo" : pomValidStatusDate.ToString(); var pomReceivedStatusDate = (from answer in m_cardnetDAL.getCardOrderAnswers() where answer.PartnerId == partnerId && answer.RequestId == requestId && answer.RequestStatus == 1 select answer.ChangeDateTime).FirstOrDefault(); covm.ReceivedStatusDate = pomReceivedStatusDate == null ? "todo" : pomReceivedStatusDate.ToString(); var pomDeclinedStatusDate = (from answer in m_cardnetDAL.getCardOrderAnswers() where answer.PartnerId == partnerId && answer.RequestId == requestId && answer.RequestStatus == 3 select answer.ChangeDateTime).FirstOrDefault(); covm.DeclinedStatusDate = pomDeclinedStatusDate == null ? "todo" : pomDeclinedStatusDate.ToString(); var pomSendStatusDate = (from answer in m_cardnetDAL.getCardOrderAnswers() where answer.PartnerId == partnerId && answer.RequestId == requestId && answer.RequestStatus == 2 select answer.ChangeDateTime).FirstOrDefault(); covm.SentStatusDate = pomSendStatusDate == null ? "todo" : pomSendStatusDate.ToString(); // TODO cancel var pomsuccessfullyCanceledStatusDate = (from answer in m_cardnetDAL.getCardOrderAnswers() where answer.PartnerId == partnerId && answer.RequestId == requestId && answer.RequestStatus == 5 select answer.ChangeDateTime).FirstOrDefault(); covm.CanceledStatusDate = pomsuccessfullyCanceledStatusDate == null ? "todo" : pomsuccessfullyCanceledStatusDate.ToString(); var pomunsuccessfullyCanceledStatusDate = (from answer in m_cardnetDAL.getCardOrderAnswers() where answer.PartnerId == partnerId && answer.RequestId == requestId && answer.RequestStatus == 6 select answer.ChangeDateTime).FirstOrDefault(); covm.CancelDeclinedStatusDate = pomunsuccessfullyCanceledStatusDate == null ? "todo" : pomunsuccessfullyCanceledStatusDate.ToString(); covm.RowColor = rowColor; if (orderType.Substring(0, 3) != "CAN" && covm.RequestStatusName == "CANCEL RECEIVED") { covm.RequestStatusName = "CANCELED"; } covm.DeliveryListId = deliveryListId == null ? "NULL" : m_cardnetDAL.getConstantPartner().Where(c => c.PartnerId == partnerId && c.ConstantName == "DeliveryListId" && c.ConstantValue == deliveryListId).Select(c => c.ConstantDescription).First(); covm.CardOrderDetailsPhotoGallery.AddPhotoNameToList(carrierTypeId1); covm.CardOrderDetailsPhotoGallery.AddPhotoNameToList(envelopeTypeId); covm.CardOrderDetailsPhotoGallery.AddPhotoNameToList(attachementId); covm.CardOrderDetailsPhotoGallery.AddPhotoNameToList(packageAttachementId); covm.CardOrderDetailsPhotoGallery.AddPhotoNameToList(deliveryListId); covm.CardOrderDetailsPhotoGallery.AddPhotoNameToList(plasticTypeId); return(covm); }