コード例 #1
0
        public void Refresh(int estRevID)
        {
            //Drawing Items
            DrawingRequisitionItems = _db.Sales_Dispatching_DrawingRequisition_EstimationItem.Where(x => x.RequisitionID == RequisitionID).ToList();
            if (DrawingRequisitionItems.Any())
            {
                foreach (var drwItem in DrawingRequisitionItems)
                {
                    drwItem.ItemName = EstItemCommon.GetFullItemName(drwItem.EST_Item);
                }
            }

            IsThereActiveItems = DrawingRequisitionItems.Where(x => x.IsIncludedWhenPrint).ToList().Any();

            var estItems = _db.EST_Item.Where(x => x.EstRevID == estRevID &&
                                              x.ItemPurposeID == (short)NEstItemPurpose.ForEstimation &&
                                              !x.Sales_Dispatching_DrawingRequisition_EstimationItem.Any()
                                              ).ToList();

            AvailableEstItems = new List <MyLongKeyValueBool>();
            if (!estItems.Any( ))
            {
                return;
            }

            foreach (var estItem in estItems)
            {
                var sli = new MyLongKeyValueBool
                {
                    Key       = estItem.EstItemID,
                    Value1    = EstItemCommon.GetFullItemName(estItem),
                    Value2    = estItem.Description,
                    IsChecked = true,
                };
                AvailableEstItems.Add(sli);
            }
        }
コード例 #2
0
        private void GetAllDrawingItems(string sfProjectID, int drawingRequisitionID, int estRevID, string sfDrawingID, enterprise.QueryResult result)
        {
            try
            {
                //create service client to call API endpoint
                using (enterprise.SoapClient queryClient = new enterprise.SoapClient("Soap", apiAddr))
                {
                    if (result == null || (result != null && result.size == 0))
                    {
                        return;
                    }

                    //cast query results
                    IEnumerable <enterprise.Item__c> itemList = result.records.Cast <enterprise.Item__c>();

                    //show results
                    var           results = new List <MyLongKeyValueBool>();
                    List <string> items   = new List <string>();
                    foreach (var il in itemList)
                    {
                        items.Add(il.Id);
                        int itemIDTemp = CommonMethods.GetMISID(TableName.Sales_Dispatching_DrawingRequisition_EstimationItem, il.Id, sfDrawingID, salesForceProjectID);
                        if (itemIDTemp == 0)
                        {
                            /* get item ID from EST_ITEM table */
                            int itemID = CommonMethods.GetEstimationItemID(estRevID, il.Item_Name__c);
                            if (itemID != 0)
                            {
                                var r = new MyLongKeyValueBool();
                                r.Key       = itemID;
                                r.IsChecked = true;
                                r.Value1    = il.Id;
                                results.Add(r);
                            }
                        }
                        else
                        {
                            UpdateDrawingItem(itemIDTemp, il.Quantity__c, il.Item_Description__c);
                        }
                    }

                    if (results.Any())
                    {
                        var vm = new DrawingRequisitionItemVm();
                        vm.RequisitionID     = drawingRequisitionID;
                        vm.AvailableEstItems = results;
                        vm.CreateRequisitionItems();
                        foreach (var ret in results)
                        {
                            if (Convert.ToInt16(ret.Value2) > 0)
                            {
                                CommonMethods.InsertToMISSalesForceMapping(TableName.Sales_Dispatching_DrawingRequisition_EstimationItem, ret.Value1, ret.Value2, sfDrawingID, salesForceProjectID);
                            }
                        }
                    }

                    // delete old data
                    DeleteAllDeletedDrawingItems(items.ToArray(), sfDrawingID);

                    LogMethods.Log.Debug("GetAllDrawingItems:Debug:" + "Done");
                }
            }
            catch (Exception e)
            {
                LogMethods.Log.Error("GetAllDrawingItems:Error:" + e.Message);
            }
        }