Ejemplo n.º 1
0
        public MaximoAsset getAssetByAssetnum(String assetnum)
        {
            if (String.IsNullOrEmpty(assetnum))
            {
                return(null);
            }
            var request = createRequest("/os/dcw_cbasset", false);

            request.AddParameter("oslc.where", $"assetnum=\"{assetnum}\"");
            request.AddParameter("oslc.select", "*");
            request.AddParameter("oslc.pageSize", "1");

            var response = restClient.Execute(request);

            if (!response.IsSuccessful)
            {
                throw new Exception("getAssetByAssetnum-service-error : " + response.StatusCode + " - [" + response.Content + "]");
            }

            MaximoAssetRestResponse maximoAssetRestResponse = JsonConvert.DeserializeObject <MaximoAssetRestResponse>(response.Content);

            if (maximoAssetRestResponse.member.Count == 0)
            {
                return(null);
            }

            MaximoAsset maximoAsset = maximoAssetRestResponse.member[0];

            return(maximoAsset);
        }
Ejemplo n.º 2
0
        public MaximoAsset createAsset(MaximoAsset maximoAsset)
        {
            AppContext.Log.Info($"[MX] create asset : [{maximoAsset.assettag}] - [{maximoAsset.Id}]");

            var request = createRequest("/os/dcw_cbasset", false, Method.POST);

            request.AddHeader("x-method-override", "POST");

            MaximoAssetForCreation maximoAssetForCreation = new MaximoAssetForCreation();

            maximoAssetForCreation.assettag         = maximoAsset.assettag;
            maximoAssetForCreation.eq3              = maximoAsset.eq3;
            maximoAssetForCreation.classstructureid = maximoAsset.classstructureid;
            maximoAssetForCreation.siteid           = maximoAsset.siteid;

            maximoAssetForCreation.status            = maximoAsset.status;
            maximoAssetForCreation.description       = maximoAsset.description;
            maximoAssetForCreation.failurecode       = maximoAsset.failurecode;
            maximoAssetForCreation.orgid             = maximoAsset.orgid;
            maximoAssetForCreation.plussfeatureclass = maximoAsset.plussfeatureclass;
            maximoAssetForCreation.plussisgis        = maximoAsset.plussisgis;


            if (maximoAssetForCreation.siteid == null)
            {
                maximoAssetForCreation.siteid = "DWS_DSS";
            }

            request.AddJsonBody(maximoAssetForCreation);

            var response = restClient.Execute(request);

            if (!response.IsSuccessful)
            {
                AppContext.Log.Error($"[MX] - create asset Error url : {response.ResponseUri.ToString()}");
                AppContext.Log.Error($"[MX] - create asset Error request body : {request.JsonSerializer.Serialize(maximoAssetForCreation)}");
                AppContext.Log.Error($"[MX] - create asset operation response : [{response.StatusCode}] - [{response.Content}]");

                throw new Exception("create-asset-error : " + response.StatusCode + " - [" + response.Content + "]");
            }

            string assetHref = null;

            foreach (var responseHeader in response.Headers)
            {
                if (responseHeader.Name.Equals("Location"))
                {
                    assetHref = responseHeader.Value.ToString();
                }
            }

            AppContext.Log.Info($"[MX] successfully created asset : [{assetHref}]");

            return(getAssetByHref(assetHref));
        }
Ejemplo n.º 3
0
        public MaximoAsset getAssetByHref(String assetHref)
        {
            var request  = createRequest(assetHref, true);
            var response = restClient.Execute(request);

            if (!response.IsSuccessful)
            {
                AppContext.Log.Warn("rest-service-error : " + response.StatusCode + " - [" + response.Content + "]");
                throw new Exception("rest-service-error : " + response.StatusCode + " - [" + response.Content + "]");
            }

            MaximoAsset maximoAsset = JsonConvert.DeserializeObject <MaximoAsset>(response.Content);

            return(maximoAsset);
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            Task task = new Task(() =>
            {
                Console.WriteLine($" async rnning in thread: {Thread.CurrentThread.ManagedThreadId}");
            });

            task.Start();

            Console.WriteLine($" sync rnning in thread: {Thread.CurrentThread.ManagedThreadId}");


            IEnumerable <MaximoWorkOrder> maximoWorkOrdersFromDb = AppContext.workOrderRepository.findAll();

            Console.WriteLine($"fetched : {maximoWorkOrdersFromDb.ToList().Count} workorders from db");


            MaximoService maximoService = AppContext.maximoService;
            bool          loginResponse = AppContext.maximoService.login("erdem", "password");

            Console.WriteLine($"authenticated : {loginResponse}");

            MaximoUser        maximoUser        = maximoService.whoami();
            MaximoPersonGroup maximoPersonGroup = maximoService.getPersonGroup(maximoUser.personId);

            List <MaximoWorkOrder> maximoWorkOrders = AppContext.maximoService.getWorkOrders(maximoPersonGroup.persongroup);

            Console.WriteLine($"fetched : {maximoWorkOrders.Count} workorders from Maximo");

            foreach (var maximoWorkOrder in maximoWorkOrders)
            {
                MaximoAsset maximoAsset = maximoService.getAssetByAssetnum(maximoWorkOrder.assetnum);
                maximoWorkOrder.asset = maximoAsset;

                List <MaximoDocLinks> workOrderDocLists = maximoService.getWorkOrderDocLinks(maximoWorkOrder);
                maximoWorkOrder.doclink = workOrderDocLists;
                Console.WriteLine($"fetched {workOrderDocLists.Count} doclinks");
            }
        }
Ejemplo n.º 5
0
        public void Clear()
        {
            Asset                  = null;
            AssetTag               = null;
            LocationDetail         = null;
            Type                   = null;
            TopMaterial            = null;
            TopThickness           = null;
            GrateType              = null;
            NumberOfChambers       = null;
            NumberOfThroats        = null;
            Owner                  = null;
            CleaningResponsibility = null;
            WaterQuality           = null;
            InMS4                  = null;
            CornerCB               = null;
            Biofilter              = null;
            FlowRestrictorType     = null;
            Sump                   = null;
            WaterSeal              = null;

            isDirty = false;
        }
Ejemplo n.º 6
0
        public MaximoAsset updateAsset(MaximoAsset maximoAsset)
        {
            AppContext.Log.Info($"[MX] update asset : [{maximoAsset.assetnum}] - [{maximoAsset.href}]");

            var request = createRequest(maximoAsset.href, true, Method.POST);

            request.AddHeader("x-method-override", "PATCH");

            request.AddJsonBody(maximoAsset);

            var response = restClient.Execute(request);

            if (!response.IsSuccessful)
            {
                AppContext.Log.Error($"[MX] - update asset Error url : {response.ResponseUri.ToString()}");
                AppContext.Log.Error($"[MX] - update asset Error request body : {request.JsonSerializer.Serialize(maximoAsset)}");
                AppContext.Log.Error($"[MX] - update asset operation response : [{response.StatusCode}] - [{response.Content}]");

                throw new Exception("update-asset-error : " + response.StatusCode + " - [" + response.Content + "]");
            }

            AppContext.Log.Info($"[MX] successfully updated asset : [{maximoAsset.assetnum}] - [{maximoAsset.href}]");
            return(getAssetByHref(maximoAsset.href));
        }
Ejemplo n.º 7
0
        public async Task addModified(MaximoAsset Asset)
        {
            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 == null ? 0.0 : TopThickness));
                feature.SetAttributeValue("GRATETY", GrateType);
                feature.SetAttributeValue("NUMCHAMB", (int?)NumberOfChambers == null ? 0 : NumberOfChambers);
                feature.SetAttributeValue("NUMTHROAT", (int?)NumberOfThroats == null ? 0 : 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
            {
                var cbLayer = (FeatureLayer)workOrderDetailVM.MapVM.AssetsLayer.Layers.FirstOrDefault(_layer => _layer.Name == "Catch Basin - Cleaned by DC Water");

                QueryParameters cbQueryParameters = new QueryParameters();
                cbQueryParameters.WhereClause = $"ASSETTAG = '{Asset.assettag}'";

                var cbResult = await cbLayer.FeatureTable.QueryFeaturesAsync(cbQueryParameters);

                var cbFeature = cbResult.FirstOrDefault();

                if (cbFeature != null)
                {
                    feature = layer.FeatureTable.CreateFeature();

                    var mp = (MapPoint)cbFeature.Geometry;
                    feature.Geometry = new MapPoint(mp.X, mp.Y, mp.SpatialReference);


                    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 == null ? 0.0 : TopThickness));
                    feature.SetAttributeValue("GRATETY", GrateType);
                    feature.SetAttributeValue("NUMCHAMB", (int?)NumberOfChambers == null ? 0 : NumberOfChambers);
                    feature.SetAttributeValue("NUMTHROAT", (int?)NumberOfThroats == null ? 0 : 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"));
                    feature.SetAttributeValue("CHANGEBY", MaximoServiceLibrary.AppContext.synchronizationService.mxuser.userName);
                    await layer.FeatureTable.AddFeatureAsync(feature);

                    feature.Refresh();
                }
            }
        }
Ejemplo n.º 8
0
        public void Update(MaximoWorkOrder wo)
        {
            WorkOrder = wo;
            Asset     = wo.asset;

            if (wo.syncronizationStatus == LocalDBLibrary.model.SyncronizationStatus.CREATED)
            {
                IsCreated = true;
            }
            else
            {
                IsCreated = false;
            }

            AssetTag       = Asset.assettag;
            LocationDetail = Asset.eq3;

            foreach (MaximoAssetSpec assetSpec in Asset.assetspec)
            {
                switch (assetSpec.assetattrid)
                {
                case "CB_SUBT":
                    Type = assetSpec.alnvalue;
                    break;

                case "TOPMATRL":
                    TopMaterial = assetSpec.alnvalue;
                    break;

                case "TOPTHICK":
                    TopThickness = assetSpec.numvalue;
                    break;

                case "GRATETY":
                    GrateType = assetSpec.alnvalue;
                    break;

                case "NUMCHAMB":
                    NumberOfChambers = Convert.ToInt32(assetSpec.numvalue);
                    break;

                case "NUMTHROAT":
                    NumberOfThroats = Convert.ToInt32(assetSpec.numvalue);
                    break;

                case "OWNER":
                    Owner = assetSpec.alnvalue;
                    break;

                case "CLN_RESP":
                    CleaningResponsibility = assetSpec.alnvalue;
                    break;

                case "WQ":
                    WaterQuality = assetSpec.alnvalue == "Y";;
                    break;

                case "INMS4":
                    InMS4 = assetSpec.alnvalue == "Y";;
                    break;

                case "ISCORNRCB":
                    CornerCB = assetSpec.alnvalue == "Y";;
                    break;

                case "BIOFLTR":
                    Biofilter = assetSpec.alnvalue == "Y";;
                    break;

                case "FLORESTY":
                    FlowRestrictorType = assetSpec.alnvalue;
                    break;

                case "HASSUMP":
                    Sump = assetSpec.alnvalue == "Y";;
                    break;

                case "HASWATERSEAL":
                    WaterSeal = assetSpec.alnvalue == "Y";;
                    break;
                }
            }

            isDirty = false;
        }