Exemplo n.º 1
0
        public void Cancel()
        {
            if (isDirty)
            {
                MessageBoxResult messageBoxResult = MessageBox.Show("Asset was modified. Save Changes?", "Asset :" + Asset.assetnum, MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    Save();
                }
                else if (messageBoxResult == MessageBoxResult.No)
                {
                    WorkOrderDetailVM.HideAssetDetail();
                }
            }
            else
            {
                WorkOrderDetailVM.HideAssetDetail();
            }
        }
Exemplo n.º 2
0
        public async void Save()
        {
            Asset.eq3 = LocationDetail;

            for (int i = 0; i < Asset.assetspec.Count; i++)
            {
                switch (Asset.assetspec[i].assetattrid)
                {
                case "CB_SUBT":
                    if (Asset.assetspec[i].alnvalue != Type)
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = Type;
                    break;

                case "TOPMATRL":
                    if (Asset.assetspec[i].alnvalue != TopMaterial)
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = TopMaterial;
                    break;

                case "TOPTHICK":
                    if (Asset.assetspec[i].numvalue != TopThickness)
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].numvalue = TopThickness;
                    break;

                case "GRATETY":
                    if (Asset.assetspec[i].alnvalue != GrateType)
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = GrateType;
                    break;

                case "NUMCHAMB":
                    if (Asset.assetspec[i].numvalue != NumberOfChambers)
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].numvalue = NumberOfChambers;
                    break;

                case "NUMTHROAT":
                    if (Asset.assetspec[i].numvalue != NumberOfThroats)
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].numvalue = NumberOfThroats;
                    break;

                case "OWNER":
                    if (Asset.assetspec[i].alnvalue != Owner)
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = Owner;
                    break;

                case "CLN_RESP":
                    if (Asset.assetspec[i].alnvalue != CleaningResponsibility)
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = CleaningResponsibility;
                    break;

                case "WQ":
                    if (Asset.assetspec[i].alnvalue != (WaterQuality == true ? "Y" : "N"))
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = WaterQuality == true ? "Y" : "N";
                    break;

                case "INMS4":
                    if (Asset.assetspec[i].alnvalue != (InMS4 == true ? "Y" : "N"))
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = InMS4 == true ? "Y" : "N";
                    break;

                case "ISCORNRCB":
                    if (Asset.assetspec[i].alnvalue != (CornerCB == true ? "Y" : "N"))
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = CornerCB == true ? "Y" : "N";
                    break;

                case "BIOFLTR":
                    if (Asset.assetspec[i].alnvalue != (Biofilter == true ? "Y" : "N"))
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = Biofilter == true ? "Y" : "N";
                    break;

                case "FLORESTY":
                    if (Asset.assetspec[i].alnvalue != FlowRestrictorType)
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = FlowRestrictorType;
                    break;

                case "HASSUMP":
                    if (Asset.assetspec[i].alnvalue != (Sump == true ? "Y" : "N"))
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = Sump == true ? "Y" : "N";
                    break;

                case "HASWATERSEAL":
                    if (Asset.assetspec[i].alnvalue != (WaterSeal == true ? "Y" : "N"))
                    {
                        Asset.assetspec[i].syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
                    }
                    Asset.assetspec[i].alnvalue = WaterSeal == true ? "Y" : "N";
                    break;
                }
            }

            Asset.changedate = DateTime.Now;
            Asset.changeby   = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser.personId;
            // asset maybe choosed or created on map!

            if (!String.IsNullOrEmpty(Asset.assetnum))
            {
                Asset.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.MODIFIED;
            }
            else
            {
                Asset.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
            }
            WorkOrder.asset = Asset;

            if (Asset.assettag.First() == 'N' && WorkOrder.asset.syncronizationStatus == LocalDBLibrary.model.SyncronizationStatus.CREATED)
            {
                var             layer           = workOrderDetailVM.MapVM.assetLayer;
                QueryParameters queryParameters = new QueryParameters();
                queryParameters.WhereClause = $"ASSETTAG = '{Asset.assettag}'";

                var result = await layer.FeatureTable.QueryFeaturesAsync(queryParameters);

                var feature = result.FirstOrDefault();
                if (feature != null)
                {
                    switch (Type)
                    {
                    case "UNKNOWN":
                        feature.SetAttributeValue("SUBTYPE", 0);
                        break;

                    case "SINGLE":

                        feature.SetAttributeValue("SUBTYPE", 1);
                        break;

                    case "DOUBLE":

                        feature.SetAttributeValue("SUBTYPE", 2);
                        break;

                    case "TRIPLE":

                        feature.SetAttributeValue("SUBTYPE", 3);
                        break;

                    case "GRATE":

                        feature.SetAttributeValue("SUBTYPE", 4);
                        break;

                    case "QUADRUPLE":

                        feature.SetAttributeValue("SUBTYPE", 5);
                        break;

                    case "ELONGATE":

                        feature.SetAttributeValue("SUBTYPE", 6);
                        break;

                    case "DOUBLE GRATE":

                        feature.SetAttributeValue("SUBTYPE", 7);
                        break;

                    case "FIELD DRAIN":

                        feature.SetAttributeValue("SUBTYPE", 8);
                        break;

                    case "TRENCH DRAIN":

                        feature.SetAttributeValue("SUBTYPE", 9);
                        break;

                    default:
                        feature.SetAttributeValue("SUBTYPE", 0);
                        break;
                    }
                    feature.SetAttributeValue("ASSETTAG", Asset.assettag);

                    feature.SetAttributeValue("TOPMATRL", TopMaterial);
                    feature.SetAttributeValue("TOPTHICK", (int)TopThickness);
                    feature.SetAttributeValue("GRATETY", GrateType);
                    feature.SetAttributeValue("NUMCHAMB", (int?)NumberOfChambers);
                    feature.SetAttributeValue("NUMTHROAT", (int?)NumberOfThroats);
                    feature.SetAttributeValue("LOCATIONDETAIL", LocationDetail);
                    feature.SetAttributeValue("OWNER", Owner);
                    feature.SetAttributeValue("CLNRESP", CleaningResponsibility);
                    feature.SetAttributeValue("ISWQI", (WaterQuality == true ? "Y" : "N"));
                    feature.SetAttributeValue("INMS4", (InMS4 == true ? "Y" : "N"));
                    feature.SetAttributeValue("ISCORNRCB", (CornerCB == true ? "Y" : "N"));
                    feature.SetAttributeValue("BIOFLTR", (Biofilter == true ? "Y" : "N"));
                    feature.SetAttributeValue("FLORESTY", FlowRestrictorType);
                    feature.SetAttributeValue("HASSUMP", (Sump == true ? "Y" : "N"));
                    feature.SetAttributeValue("HASWATERSEAL", (WaterSeal == true ? "Y" : "N"));
                    await layer.FeatureTable.UpdateFeatureAsync(feature);

                    feature.Refresh();
                }
                else
                {
                    await addModified(Asset);
                }
            }
            else
            {
                await addModified(Asset);
            }

            workOrderDetailVM.MaximoWorkOrder.asset = Asset;
            if (WorkOrder.Id > 0)
            {
                MaximoServiceLibrary.AppContext.workOrderRepository.update(WorkOrder);
            }
            isDirty = false;
            WorkOrderDetailVM.HideAssetDetail();
        }