public void Execute(object parameter)
        {
            MaximoWorkOrder wo = (MaximoWorkOrder)parameter;

            MaximoServiceLibrary.AppContext.workOrderRepository.delete(wo.Id);
            MapVM.WorkOrderListVM.Update();
        }
Ejemplo n.º 2
0
        public List <MaximoDocLinks> getWorkOrderDocLinks(MaximoWorkOrder wo)
        {
            var request  = createRequest("/os/dcw_cb_wo/" + wo.workorderid + "/doclinks", false);
            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 + "]");
            }

            MaximoDocLinksRestResponse maximoDocLinksRestResponse = JsonConvert.DeserializeObject <MaximoDocLinksRestResponse>(response.Content);

            if (maximoDocLinksRestResponse.member == null)
            {
                return(new List <MaximoDocLinks>());
            }
            else
            {
                List <MaximoDocLinks> result = new List <MaximoDocLinks>();
                foreach (var maximoDocLinksWrapper in maximoDocLinksRestResponse.member)
                {
                    maximoDocLinksWrapper.describedBy.path = DownloadAttachment(maximoDocLinksWrapper.describedBy, maximoDocLinksWrapper.href);
                    result.Add(maximoDocLinksWrapper.describedBy);
                }

                return(result);
            }
        }
Ejemplo n.º 3
0
        public void showWorkOrder(MaximoWorkOrder wo)
        {
            if (!String.IsNullOrEmpty(wo.syncError))
            {
                MessageBox.Show(wo.syncError, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            MapVM.ShowWorkOrderDetail(wo);
        }
Ejemplo n.º 4
0
        public MaximoWorkOrder updateWorkOrder(MaximoWorkOrder maximoWorkOrder)
        {
            AppContext.Log.Info($"[MX] update work order : [{maximoWorkOrder.wonum}] - [{maximoWorkOrder.workorderid}]");

            var request = createRequest("/os/dcw_cb_wo/" + maximoWorkOrder.workorderid, false, Method.POST);

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

            // create an empty workorder
            MaximoWorkOrderForUpdate workOrderToBePosted = new MaximoWorkOrderForUpdate();

            workOrderToBePosted.remarkdesc    = maximoWorkOrder.remarkdesc;
            workOrderToBePosted.workorderspec = maximoWorkOrder.workorderspec;
            workOrderToBePosted.failurereport = maximoWorkOrder.failurereport;
            //workOrderToBePosted.doclinks = maximoWorkOrder.doclink;
            workOrderToBePosted.assetnum    = maximoWorkOrder.assetnum;
            workOrderToBePosted.statusdate  = maximoWorkOrder.statusdate;
            workOrderToBePosted.persongroup = maximoWorkOrder.persongroup;

            // In order to not get error from maximo side in case of failed synchronization
            if (workOrderToBePosted.workorderspec != null)
            {
                workOrderToBePosted.workorderspec.ForEach(child => child._rowstamp = null);
            }
            if (workOrderToBePosted.failurereport != null)
            {
                workOrderToBePosted.failurereport.ForEach(child => child._rowstamp = null);
            }

            request.AddJsonBody(workOrderToBePosted);

            var response = restClient.Execute(request);


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

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

            AppContext.Log.Info($"[MX] successfully updated work order : [{maximoWorkOrder.wonum}] - [{maximoWorkOrder.workorderid}]");
            MaximoWorkOrder freshWorkOrder = null;

            if (maximoWorkOrder.href != null)
            {
                freshWorkOrder = getWorkOrderByHref(maximoWorkOrder.href);
            }
            else if (maximoWorkOrder.workorderid != null && maximoWorkOrder.workorderid != 0)
            {
                freshWorkOrder = getWorkOrderByWorkorderid(maximoWorkOrder.workorderid);
            }
            return(freshWorkOrder);
        }
Ejemplo n.º 5
0
        public MaximoWorkOrder updateWorkOrderActuals(MaximoWorkOrder maximoWorkOrder)
        {
            AppContext.Log.Info($"[MX] update work order actuals : [{maximoWorkOrder.wonum}] - [{maximoWorkOrder.workorderid}]");

            var request = createRequest("/os/dcw_cb_wo/" + maximoWorkOrder.workorderid, false, Method.POST);

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

            // create an empty workorder
            MaximoWorkOrderLabtransForUpdate workOrderToBePosted = new MaximoWorkOrderLabtransForUpdate();

            workOrderToBePosted.labtrans  = maximoWorkOrder.labtrans;
            workOrderToBePosted.tooltrans = maximoWorkOrder.tooltrans;

            // In order to not get error from maximo side in case of failed synchronization
            if (workOrderToBePosted.labtrans != null)
            {
                workOrderToBePosted.labtrans.ForEach(child => child._rowstamp = null);
            }
            if (workOrderToBePosted.tooltrans != null)
            {
                workOrderToBePosted.tooltrans.ForEach(child => child._rowstamp = null);
            }

            request.JsonSerializer = new RestSharpJsonNetSerializer();
            request.AddJsonBody(workOrderToBePosted);

            var response = restClient.Execute(request);

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

                throw new Exception("update-work-order-error : " + response.StatusCode + " - [" + response.Content + "]");
            }
            AppContext.Log.Info($"[MX] successfully updated work order actuals : [{maximoWorkOrder.wonum}] - [{maximoWorkOrder.workorderid}]");

            MaximoWorkOrder freshWorkOrder = null;

            if (maximoWorkOrder.href != null)
            {
                freshWorkOrder = getWorkOrderByHref(maximoWorkOrder.href);
            }
            else if (maximoWorkOrder.workorderid != null && maximoWorkOrder.workorderid != 0)
            {
                freshWorkOrder = getWorkOrderByWorkorderid(maximoWorkOrder.workorderid);
            }
            return(freshWorkOrder);
        }
Ejemplo n.º 6
0
        public MaximoWorkOrder getWorkOrderByHref(String workOrderHref)
        {
            var request  = createRequest(workOrderHref, 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 + "]");
            }

            MaximoWorkOrder maximoWorkOrder = JsonConvert.DeserializeObject <MaximoWorkOrder>(response.Content);

            return(maximoWorkOrder);
        }
Ejemplo n.º 7
0
        public MaximoWorkOrder getWorkOrderByWorkorderid(long workorderid)
        {
            var request  = createRequest("/os/dcw_cb_wo/" + workorderid, false);
            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 + "]");
            }

            MaximoWorkOrder maximoWorkOrder = JsonConvert.DeserializeObject <MaximoWorkOrder>(response.Content);

            return(maximoWorkOrder);
        }
Ejemplo n.º 8
0
        public MaximoWorkOrder updateWorkOrderProblemCode(MaximoWorkOrder maximoWorkOrder)
        {
            AppContext.Log.Info($"[MX] update work order status : [{maximoWorkOrder.wonum}] - [{maximoWorkOrder.workorderid}]");

            var request = createRequest("/os/dcw_cb_wo/" + maximoWorkOrder.workorderid, false, Method.POST);

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

            // create an empty workorder
            MaximoWorkOrderForProblemCodeUpdate workOrderToBePosted = new MaximoWorkOrderForProblemCodeUpdate();

            workOrderToBePosted.problemcode      = maximoWorkOrder.problemcode;
            workOrderToBePosted.classstructureid = "1356";

            request.AddJsonBody(workOrderToBePosted);

            var response = restClient.Execute(request);

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

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

            AppContext.Log.Info($"[MX] successfully updated work order problemcode : [{maximoWorkOrder.wonum}] - [{maximoWorkOrder.workorderid}]");
            MaximoWorkOrder freshWorkOrder = null;

            if (maximoWorkOrder.href != null)
            {
                freshWorkOrder = getWorkOrderByHref(maximoWorkOrder.href);
            }
            else if (maximoWorkOrder.workorderid != null && maximoWorkOrder.workorderid != 0)
            {
                freshWorkOrder = getWorkOrderByWorkorderid(maximoWorkOrder.workorderid);
            }
            return(freshWorkOrder);
        }
Ejemplo n.º 9
0
        public MaximoDocLinks GetMaximoDocLinks(MaximoWorkOrder maximoWorkOrder, string doclinkHref)
        {
            char[] spearator  = { '/' };
            var    list       = doclinkHref.Split(spearator);
            var    identifier = list.Last();

            var request = createRequest("/os/dcw_cb_wo/" + maximoWorkOrder.workorderid + "/doclinks/meta/" + identifier, false);

            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 + "]");
            }

            MaximoDocLinks maximoDocLinksRestResponse = JsonConvert.DeserializeObject <MaximoDocLinks>(response.Content);

            maximoDocLinksRestResponse.path = DownloadAttachment(maximoDocLinksRestResponse, doclinkHref);

            return(maximoDocLinksRestResponse);
        }
 public void update(MaximoWorkOrder wo)
 {
     if (wo != null)
     {
         if (wo.asset != null)
         {
             Visibility = Visibility.Visible;
             panel.Children.Clear();
             foreach (var assetSpec in wo.asset.assetspecList)
             {
                 panel.Children.Add(new DetailRow(assetSpec));
             }
         }
         else
         {
             Visibility = Visibility.Collapsed;
         }
     }
     else
     {
         Visibility = Visibility.Collapsed;
     }
 }
Ejemplo n.º 11
0
        public MaximoDocLinks createAttachment(MaximoWorkOrder maximoWorkOrder, MaximoDocLinks doc)
        {
            AppContext.Log.Info($"[MX] create attachment : [{maximoWorkOrder.wonum}] - [{maximoWorkOrder.workorderid}]");

            var request = createRequest("/os/dcw_cb_wo/" + maximoWorkOrder.workorderid + "/doclinks", false, Method.POST);

            request.AddHeader("x-document-meta", "Attachments");
            request.AddHeader("slug", doc.fileName);
            request.AddHeader("x-document-description", doc.description);
            request.AddHeader("custom-encoding", "base64");

            request.AddParameter("text/plain", doc.documentdata, ParameterType.RequestBody);

            var response = restClient.Execute(request);

            if (!response.IsSuccessful)
            {
                AppContext.Log.Error($"[MX] - create attachment Error url : {response.ResponseUri.ToString()}");
                AppContext.Log.Error($"[MX] - create attachment Error request body : {request.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody)}");
                AppContext.Log.Error($"[MX] - create attachment  operation response : [{response.StatusCode}] - [{response.Content}]");

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

            AppContext.Log.Info($"[MX] successfully create attachment  : [{maximoWorkOrder.wonum}] - [{maximoWorkOrder.workorderid}]");
            string doclinkHref = null;

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

            return(GetMaximoDocLinks(maximoWorkOrder, doclinkHref));
        }
Ejemplo n.º 12
0
        public MaximoWorkOrder createWorkOrder(MaximoWorkOrder maximoWorkOrder)
        {
            AppContext.Log.Info($"[MX] create work order : [{maximoWorkOrder.Id}] - [{maximoWorkOrder.workorderid}]");

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

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


            request.AddJsonBody(maximoWorkOrder);

            var response = restClient.Execute(request);


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

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

            string workOrderHref = null;

            foreach (var responseHeader in response.Headers)
            {
                if (responseHeader.Name.Equals("Location"))
                {
                    workOrderHref = responseHeader.Value.ToString();
                }
            }
            AppContext.Log.Info($"[MX] successfully created work order : [{workOrderHref}]");

            return(getWorkOrderByHref(workOrderHref));
        }
        public void Execute(object parameter)
        {
            MaximoWorkOrder wo = (MaximoWorkOrder)parameter;

            MapVM.PanToWoAsync(wo);
        }
        public override void Execute(object parameter)
        {
            if (!MapVM.WorkOrdersIsVisible)
            {
                MapVM.WorkOrdersIsVisible = true;
            }
            var wo = new MaximoWorkOrder();

            wo.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
            MaximoWorkOrderFailureReport failureProblemCode;
            MaximoWorkOrderFailureReport failureCause;
            MaximoWorkOrderFailureReport failureRemedy;
            string crew = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser?.userPreferences?.selectedPersonGroup;

            switch ((LocalWorkOrderType)parameter)
            {
            case LocalWorkOrderType.TRUCKDUMPING:
                wo.status           = "DISPTCHD";
                wo.statusdate       = DateTime.Now;
                wo.description      = "CB Cleaning Truck Dumping";
                wo.problemcode      = "TRUCKFULL";
                wo.worktype         = "CM";
                wo.failurecode      = "CATCHBASIN";
                wo.newchildclass    = "WORKORDER";
                wo.orgid            = "DC_WASA";
                wo.woclass          = "WORKORDER";
                wo.wo1              = "CBDUMP";
                wo.receivedvia      = "F";
                wo.origproblemtype  = "SY";   // or CX
                wo.persongroup      = crew;
                wo.classstructureid = "1356";
                wo.service          = "DSS";
                wo.siteid           = "DWS_DSS";

                wo.failurereport                        = new List <MaximoWorkOrderFailureReport>();
                failureProblemCode                      = new MaximoWorkOrderFailureReport();
                failureProblemCode.failurecode          = "TRUCKFULL";
                failureProblemCode.type                 = "PROBLEM";
                failureProblemCode.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureProblemCode);
                failureCause                      = new MaximoWorkOrderFailureReport();
                failureCause.failurecode          = "FULLTRUCK";
                failureCause.type                 = "CAUSE";
                failureCause.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureCause);
                failureRemedy                      = new MaximoWorkOrderFailureReport();
                failureRemedy.failurecode          = "EMPTYTRUCK";
                failureRemedy.type                 = "REMEDY";
                failureRemedy.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureRemedy);



                break;

            case LocalWorkOrderType.NEWLYDISCOVERED:
                wo.status           = "DISPTCHD";
                wo.description      = "Newly Discovered Asset cleaned by CB Cleaning Crew";
                wo.problemcode      = "PM";
                wo.worktype         = "PM";
                wo.failurecode      = "CATCHBASIN";
                wo.newchildclass    = "WORKORDER";
                wo.orgid            = "DC_WASA";
                wo.woclass          = "WORKORDER";
                wo.wo1              = "CBPMNOIDAH";
                wo.receivedvia      = "F";
                wo.origproblemtype  = "SY";
                wo.persongroup      = crew;
                wo.classstructureid = "1356";
                wo.service          = "DSS";
                wo.siteid           = "DWS_DSS";

                wo.failurereport                        = new List <MaximoWorkOrderFailureReport>();
                failureProblemCode                      = new MaximoWorkOrderFailureReport();
                failureProblemCode.failurecode          = "PM";
                failureProblemCode.type                 = "PROBLEM";
                failureProblemCode.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureProblemCode);
                failureCause                      = new MaximoWorkOrderFailureReport();
                failureCause.failurecode          = "NEWASSET";
                failureCause.type                 = "CAUSE";
                failureCause.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureCause);
                failureRemedy                      = new MaximoWorkOrderFailureReport();
                failureRemedy.failurecode          = "COMPFOLLUP";
                failureRemedy.type                 = "REMEDY";
                failureRemedy.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureRemedy);


                break;

            case LocalWorkOrderType.EXISTING:


                wo.status           = "DISPTCHD";
                wo.description      = "CB cleaned by CB Cleaning Crew";
                wo.problemcode      = "PM";
                wo.worktype         = "PM";
                wo.failurecode      = "CATCHBASIN";
                wo.newchildclass    = "WORKORDER";
                wo.orgid            = "DC_WASA";
                wo.woclass          = "WORKORDER";
                wo.wo1              = "CBPMEXIST";
                wo.receivedvia      = "F";
                wo.origproblemtype  = "SY";
                wo.persongroup      = crew;
                wo.classstructureid = "1356";
                wo.service          = "DSS";
                wo.siteid           = "DWS_DSS";

                wo.failurereport                        = new List <MaximoWorkOrderFailureReport>();
                failureProblemCode                      = new MaximoWorkOrderFailureReport();
                failureProblemCode.failurecode          = "PM";
                failureProblemCode.type                 = "PROBLEM";
                failureProblemCode.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureProblemCode);

                wo.parent = MapVM.WorkOrderDetailVM.MaximoWorkOrder.wonum;

                break;

            case LocalWorkOrderType.NOTININVENTORY:


                wo.status           = "DISPTCHD";
                wo.description      = "New Asset cleaned by CB Cleaning Crew";
                wo.problemcode      = "PM";
                wo.worktype         = "PM";
                wo.failurecode      = "CATCHBASIN";
                wo.newchildclass    = "WORKORDER";
                wo.orgid            = "DC_WASA";
                wo.woclass          = "WORKORDER";
                wo.wo1              = "CBPMNOID";
                wo.receivedvia      = "F";
                wo.origproblemtype  = "SY";
                wo.persongroup      = crew;
                wo.classstructureid = "1356";
                wo.service          = "DSS";
                wo.siteid           = "DWS_DSS";


                wo.failurereport                        = new List <MaximoWorkOrderFailureReport>();
                failureProblemCode                      = new MaximoWorkOrderFailureReport();
                failureProblemCode.failurecode          = "PM";
                failureProblemCode.type                 = "PROBLEM";
                failureProblemCode.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureProblemCode);
                failureCause                      = new MaximoWorkOrderFailureReport();
                failureCause.failurecode          = "NEWASSET";
                failureCause.type                 = "CAUSE";
                failureCause.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureCause);
                failureRemedy                      = new MaximoWorkOrderFailureReport();
                failureRemedy.failurecode          = "COMPFOLLUP";
                failureRemedy.type                 = "REMEDY";
                failureRemedy.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureRemedy);

                wo.parent = MapVM.WorkOrderDetailVM.MaximoWorkOrder.wonum;

                break;

            case LocalWorkOrderType.INSPECTNEWLYDISCOVERED:


                wo.status           = "DISPTCHD";
                wo.description      = "Newly Discovered Asset Inspected by DSS";
                wo.problemcode      = "PM";
                wo.worktype         = "INSP";
                wo.failurecode      = "CATCHBASIN";
                wo.newchildclass    = "WORKORDER";
                wo.orgid            = "DC_WASA";
                wo.woclass          = "WORKORDER";
                wo.wo1              = "CBPMNOID";
                wo.receivedvia      = "F";
                wo.origproblemtype  = "SY";
                wo.persongroup      = crew;
                wo.classstructureid = "1356";
                wo.service          = "DSS";
                wo.siteid           = "DWS_DSS";


                wo.failurereport                        = new List <MaximoWorkOrderFailureReport>();
                failureProblemCode                      = new MaximoWorkOrderFailureReport();
                failureProblemCode.failurecode          = "PM";
                failureProblemCode.type                 = "PROBLEM";
                failureProblemCode.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureProblemCode);
                failureCause                      = new MaximoWorkOrderFailureReport();
                failureCause.failurecode          = "NEWASSET";
                failureCause.type                 = "CAUSE";
                failureCause.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureCause);
                failureRemedy                      = new MaximoWorkOrderFailureReport();
                failureRemedy.failurecode          = "COMPFOLLUP";
                failureRemedy.type                 = "REMEDY";
                failureRemedy.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                wo.failurereport.Add(failureRemedy);



                break;
            }
            wo.createdTime = DateTime.Now;
            wo             = MaximoServiceLibrary.AppContext.workOrderRepository.upsert(wo);
            MapVM.WorkOrderListVM.Update();

            var nwo = MapVM.WorkOrderListVM.WorkOrders.FirstOrDefault(_wo => _wo.Id == wo.Id);

            if (nwo == null)
            {
                MapVM.ShowWorkOrderDetail(wo);
            }
            else
            {
                MapVM.ShowWorkOrderDetail(nwo);
            }

            MapVM.WorkOrderListVM.Update();
            MapVM.WorkOrderListVM.SelectedIndex = MapVM.WorkOrderListVM.WorkOrders.Count - 1;
        }
        public bool CanExecute(object parameter)
        {
            MaximoWorkOrder wo = (MaximoWorkOrder)parameter;

            return(wo.status == "DISPTCHD" && wo.syncronizationStatus == LocalDBLibrary.model.SyncronizationStatus.CREATED);
        }
Ejemplo n.º 16
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;
        }
        public void Execute(object parameter)
        {
            if (parameter == null)
            {
                return;
            }
            if (((MaximoWorkOrder)parameter).status != "DISPTCHD")
            {
                return;
            }
            var values = MaximoServiceLibrary.AppContext.workOrderRepository.findNot("startTimerDate", null).ToList();

            if (values.Count > 0)
            {
                if (values[0].Id == ((MaximoWorkOrder)parameter).Id)
                {
                }
                else
                {
                    MessageBox.Show($"Wonum : {values[0].wonum} is still start timer");
                    var woo = WorkOrderListVM.WorkOrders.Where(w => w.Id == values[0].Id).FirstOrDefault();
                    if (woo != null)
                    {
                        WorkOrderListVM.listView.ScrollIntoView(woo);
                    }

                    return;
                }
            }
            else
            {
            }

            MaximoWorkOrder wo = ((MaximoWorkOrder)parameter);

            if (wo.startTimerDate == null)
            {
                wo.startTimerDate = DateTime.Now;
                wo.timerImageUri  = "pack://application:,,,/CatchBasin;component/Resources/Images/startWatch.png";
                MaximoServiceLibrary.AppContext.workOrderRepository.upsert(wo);
                WorkOrderListVM.Update();
            }
            else
            {
                DateTime stopTimerDate  = DateTime.Now;
                DateTime startTimerDate = Convert.ToDateTime(wo.startTimerDate);
                TimeSpan?time           = stopTimerDate - wo.startTimerDate;
                MaximoServiceLibrary.AppContext.Log.Warn($"time :{time}");

                var mxuser = MaximoServiceLibrary.AppContext.synchronizationService.mxuser;

                MaximoLabTrans labTrans       = new MaximoLabTrans();
                MaximoLabTrans secondlabTrans = new MaximoLabTrans();


                labTrans.startdateentered  = startTimerDate - startTimerDate.TimeOfDay;
                labTrans.starttimeentered  = new DateTime(1900, 1, 1) + startTimerDate.TimeOfDay;
                labTrans.finishdateentered = stopTimerDate - stopTimerDate.TimeOfDay;
                labTrans.finishtimeentered = new DateTime(1900, 1, 1) + stopTimerDate.TimeOfDay;
                labTrans.transdate         = DateTime.Now;

                if (wo.worktype == "EM" || wo.worktype == "INV" || wo.worktype == "EMERG")
                {
                    labTrans.transtype = "TRAV";
                }
                else
                {
                    labTrans.transtype = "WORK";
                }

                var _labors = MaximoServiceLibrary.AppContext.laborRepository.Find("person[*].personid", mxuser.userPreferences.setting?.leadMan).ToList();
                try
                {
                    labTrans.craft = _labors?[0].laborcraftrate?[0].craft;
                }
                catch (Exception e)
                {
                    labTrans.craft = null;
                }

                labTrans.siteid               = "DWS_DSS";
                labTrans.orgid                = "DC_WASA";
                labTrans.dcw_truckdriver      = mxuser.userPreferences.setting?.leadMan == mxuser.userPreferences.setting?.driverMan;
                labTrans.dcw_trucksecond      = false;
                labTrans.dcw_trucklead        = true;
                labTrans.dcw_trucknum         = mxuser.userPreferences.setting.vehiclenum;
                labTrans.enterdate            = DateTime.Now;
                labTrans.laborcode            = mxuser.userPreferences.setting?.leadMan;
                labTrans.enterby              = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser.personId;
                labTrans.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;



                if (((App)Application.Current).AppType == "PM")
                {
                    secondlabTrans.startdateentered  = startTimerDate - startTimerDate.TimeOfDay;
                    secondlabTrans.starttimeentered  = new DateTime(1900, 1, 1) + startTimerDate.TimeOfDay;
                    secondlabTrans.finishdateentered = stopTimerDate - stopTimerDate.TimeOfDay;
                    secondlabTrans.finishtimeentered = new DateTime(1900, 1, 1) + stopTimerDate.TimeOfDay;
                    secondlabTrans.transdate         = DateTime.Now;
                    if (wo.worktype == "EM" || wo.worktype == "INV" || wo.worktype == "EMERG")
                    {
                        secondlabTrans.transtype = "TRAV";
                    }
                    else
                    {
                        secondlabTrans.transtype = "WORK";
                    }
                    _labors = MaximoServiceLibrary.AppContext.laborRepository.Find("person[*].personid", mxuser.userPreferences.setting?.secondMan).ToList();
                    try
                    {
                        secondlabTrans.craft = _labors?[0].laborcraftrate?[0].craft;
                    }
                    catch (Exception e)
                    {
                        secondlabTrans.craft = null;
                    }
                    secondlabTrans.siteid               = "DWS_DSS";
                    secondlabTrans.orgid                = "DC_WASA";
                    secondlabTrans.dcw_truckdriver      = mxuser.userPreferences.setting?.secondMan == mxuser.userPreferences.setting?.driverMan;
                    secondlabTrans.dcw_trucksecond      = true;
                    secondlabTrans.dcw_trucklead        = false;
                    secondlabTrans.dcw_trucknum         = mxuser.userPreferences.setting.vehiclenum;
                    secondlabTrans.enterdate            = DateTime.Now;
                    secondlabTrans.laborcode            = mxuser.userPreferences.setting?.secondMan;
                    secondlabTrans.enterby              = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser.personId;
                    secondlabTrans.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;
                }


                MaximoToolTrans tool = new MaximoToolTrans();
                tool.transdate = DateTime.Now;
                tool.toolrate  = 0;
                tool.toolqty   = 1;
                if (time.HasValue)
                {
                    tool.toolhrs = time.Value.TotalHours;
                }
                tool.itemnum              = mxuser.userPreferences.setting.vehiclenum;
                tool.itemsetid            = "IDC_WASA";
                tool.enterdate            = DateTime.Now;
                tool.enterby              = MaximoServiceLibrary.AppContext.synchronizationService?.mxuser.personId;
                tool.langcode             = "EN";
                tool.syncronizationStatus = LocalDBLibrary.model.SyncronizationStatus.CREATED;



                if (WorkOrderListVM.MapVM.WorkOrderDetailIsVisible && wo?.Id == WorkOrderListVM.MapVM.WorkOrderDetailVM.MaximoWorkOrder?.Id)
                {
                    WorkOrderListVM.MapVM.WorkOrderDetailVM.LabTrans.Add(labTrans);
                    if (((App)Application.Current).AppType == "PM")
                    {
                        WorkOrderListVM.MapVM.WorkOrderDetailVM.LabTrans.Add(secondlabTrans);
                    }
                    WorkOrderListVM.MapVM.WorkOrderDetailVM.ToolTrans.Add(tool);
                    WorkOrderListVM.MapVM.WorkOrderDetailVM.MaximoWorkOrder.startTimerDate = null;
                    WorkOrderListVM.MapVM.WorkOrderDetailVM.MaximoWorkOrder.timerImageUri  = "pack://application:,,,/CatchBasin;component/Resources/Images/stopWatch.png";
                }
                else
                {
                    if (wo.labtrans == null)
                    {
                        wo.labtrans = new List <MaximoLabTrans>();
                    }
                    wo.labtrans.Add(labTrans);

                    if (((App)Application.Current).AppType == "PM")
                    {
                        wo.labtrans.Add(secondlabTrans);
                    }

                    if (wo.tooltrans == null)
                    {
                        wo.tooltrans = new List <MaximoToolTrans>();
                    }
                    wo.tooltrans.Add(tool);
                }

                wo.startTimerDate = null;
                wo.timerImageUri  = "pack://application:,,,/CatchBasin;component/Resources/Images/stopWatch.png";
                wo = MaximoServiceLibrary.AppContext.workOrderRepository.upsert(wo);
                WorkOrderListVM.Update();
                if (!WorkOrderListVM.MapVM.WorkOrderDetailIsVisible)
                {
                    WorkOrderListVM.showWorkOrder(wo);
                }
            }
        }