Beispiel #1
0
        private async Task DeleteAsync(InspectionDetail row)
        {
            try
            {
                UserDialogs.Instance.ShowLoading("Deleting...");
                InspectionHeadersRequestDTO inspectionTbsRequestDTO = new InspectionHeadersRequestDTO()
                {
                    Id = row.Id,

                    //IsActive = false
                };
                var result = await webServiceManager.DeleteInspectionDetailsById(inspectionTbsRequestDTO).ConfigureAwait(true);

                if (result.IsSuccess)
                {
                    //write here logic for the after deleting row.
                }
            }
            catch
            {
                UserDialogs.Instance.HideLoading();
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }
Beispiel #2
0
        private void btnInspecDetail_Click(object sender, EventArgs e)
        {
            InspectionDetail insD = new InspectionDetail();

            insD.Show();
            this.Hide();
        }
Beispiel #3
0
        public InspectionDetail InsertInspectionDetail(InspectionDetail inspectionDetail)
        {
            var inserted = iTIDataEntities.InspectionDetails.Add(inspectionDetail);

            iTIDataEntities.SaveChanges();
            return(inserted);
        }
Beispiel #4
0
        public ActionResult Delete(int id = 0)
        {
            InspectionDetail inspectionDetail = new InspectionDetail();

            if (id > 0)
            {
                inspectionRepository.DelectInspectionDetail(id);
            }
            return(RedirectToAction("Index"));
        }
Beispiel #5
0
        public Guid CreateInspectionDetail(IOrganizationService service, InspectionDetail inspectionDetail)
        {
            var newInspection = new Entity("blu_inspectiondetail")
            {
                ["blu_name"]            = inspectionDetail.Name,
                ["blu_inspectionid"]    = new EntityReference("blu_inspection", inspectionDetail.InspectionId),
                ["blu_productid"]       = new EntityReference("product", inspectionDetail.ProductId),
                ["blu_appointmentid"]   = new EntityReference("appointment", inspectionDetail.AppointmentId),
                ["blu_orderid"]         = new EntityReference("salesorder", inspectionDetail.OrderId),
                ["ownerid"]             = new EntityReference("systemuser", inspectionDetail.OwnerId),
                ["blu_productcategory"] = inspectionDetail.ProductCategory
            };

            return(service.Create(newInspection));
        }
        public void SaveCoordinator(InspectionDetail detail, string currentUser)
        {
            var siteManager       = this.container.GetInstance <SiteManager>();
            var inspectionManager = this.container.GetInstance <InspectionManager>();

            var site = siteManager.GetById(detail.SiteId);

            if (site != null)
            {
                if (site.Description != detail.SiteDescription)
                {
                    site.OverridenDescription = detail.SiteDescription;
                    site.UpdatedBy            = currentUser;
                    site.UpdatedDate          = DateTime.Now;

                    siteManager.Save(site);
                }
            }

            var inspection = inspectionManager.GetById(detail.InspectionId);

            if (inspection != null)
            {
                var hasChanges = false;
                if (inspection.CommendablePractices != detail.CommendablePractices)
                {
                    inspection.OverridenPractices = detail.CommendablePractices;
                    hasChanges = true;
                }

                if (inspection.OverallImpressions != detail.OverallImpressions)
                {
                    inspection.OverridenImpressions = detail.OverallImpressions;
                    hasChanges = true;
                }

                if (hasChanges)
                {
                    inspection.UpdatedBy   = currentUser;
                    inspection.UpdatedDate = DateTime.Now;

                    inspectionManager.Save(inspection);
                }
            }
        }
        public ServiceResponse SaveCoordinatorAsync(InspectionDetail inspectionItem)
        {
            DateTime startTime = DateTime.Now;

            try
            {
                var inspectionFacade = this.Container.GetInstance <InspectionFacade>();

                base.LogMessage("SaveAsync", DateTime.Now - startTime);

                inspectionFacade.SaveCoordinator(inspectionItem, Email);

                return(new ServiceResponse());
            }
            catch (Exception ex)
            {
                return(base.HandleException(ex));
            }
        }
Beispiel #8
0
        public ActionResult Create(int id = 0)
        {
            InspectionDetail inspectionDetail = new InspectionDetail();

            if (id > 0)
            {
                inspectionDetail = inspectionRepository.GetInspectionDetailById(id);
            }
            InspectionModel inspectionModel = new InspectionModel
            {
                ID            = inspectionDetail.ID,
                DateOfInsp    = inspectionDetail.DateOfInsp,
                PurposeOfInsp = inspectionDetail.PurposeOfInsp,
                InspectorName = inspectionDetail.InspectorName,
                InspectorDesg = inspectionDetail.InspectorDesg,
                InspectorAdrs = inspectionDetail.InspectorAdrs,
                Report        = inspectionDetail.Report
            };

            return(View(inspectionModel));
        }
Beispiel #9
0
 public ActionResult Create(InspectionModel inspectionModel)
 {
     try
     {
         InspectionDetail inspectionDetail = new InspectionDetail
         {
             ID            = inspectionModel.ID,
             DateOfInsp    = inspectionModel.DateOfInsp,
             PurposeOfInsp = inspectionModel.PurposeOfInsp,
             InspectorName = inspectionModel.InspectorName,
             InspectorDesg = inspectionModel.InspectorDesg,
             InspectorAdrs = inspectionModel.InspectorAdrs,
             Report        = inspectionModel.Report
         };
         if (ModelState.IsValid)
         {
             if (inspectionDetail.ID > 0)
             {
                 inspectionRepository.UpdateInspectionDetail(inspectionDetail);
             }
             else
             {
                 inspectionRepository.InsertInspectionDetail(inspectionDetail);
             }
         }
         else
         {
             return(View(inspectionModel));
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(View(inspectionModel));
     }
 }
Beispiel #10
0
 public InspectionDetail UpdateInspectionDetail(InspectionDetail inspectionDetail)
 {
     iTIDataEntities.Entry(inspectionDetail).State = EntityState.Modified;
     iTIDataEntities.SaveChanges();
     return(inspectionDetail);
 }
Beispiel #11
0
        public void Execute(IServiceProvider serviceProvider)
        {
            var trace   = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            var service = factory.CreateOrganizationService(context.UserId);
            var payment = ((Entity)context.InputParameters["Target"]);

            if (!payment.Attributes.Contains("blu_orderid"))
            {
                return;
            }

            var orderEr = (EntityReference)payment.Attributes["blu_orderid"];

            var columns    = new[] { "opportunityid" };
            var conditions = new[] { new ConditionExpression("salesorderid", ConditionOperator.Equal, orderEr.Id) };
            var order      = Qe.QueryRecord(service, "salesorder", columns, conditions);

            if (order == null || order.Attributes == null || !order.Attributes.Contains("opportunityid"))
            {
                return;
            }
            var opportunityEr = (EntityReference)order.Attributes["opportunityid"];

            columns    = new[] { "blu_regardingpropertyid" };
            conditions = new[] { new ConditionExpression("opportunityid", ConditionOperator.Equal, opportunityEr.Id) };
            var opportunity = Qe.QueryRecord(service, "opportunity", columns, conditions);

            if (opportunity == null || opportunity.Attributes == null || !opportunity.Attributes.Contains("blu_regardingpropertyid"))
            {
                return;
            }
            var propertyEr = (EntityReference)opportunity.Attributes["blu_regardingpropertyid"];

            columns    = new[] { "productid" };
            conditions = new[] { new ConditionExpression("opportunityid", ConditionOperator.Equal, opportunityEr.Id) };

            var opportunityProducts = Qe.QueryMultipleRecords(service, "opportunityproduct", columns, conditions);

            if (opportunityProducts == null || opportunityProducts.Count == 0)
            {
                return;
            }
            var opportunityProduct = opportunityProducts[0];

            var productEr = (EntityReference)opportunityProduct.Attributes["productid"];

            columns    = new[] { "scheduledstart", "scheduledend", "ownerid" };
            conditions = new[] { new ConditionExpression("regardingobjectid", ConditionOperator.Equal, order.Id) };
            var appointments = Qe.QueryMultipleRecords(service, "appointment", columns, conditions);

            foreach (var appointment in appointments)
            {
                var inspectionDetail = new InspectionDetail()
                {
                    Name          = "InspectionDetail | " + productEr.Name + " | " + propertyEr.Name,
                    InspectionId  = propertyEr.Id,
                    AppointmentId = appointment.Id,
                    OrderId       = order.Id,
                    OwnerId       = ((EntityReference)appointment["ownerid"]).Id,
                    ProductId     = productEr.Id
                };

                CreateInspectionDetail(service, inspectionDetail);
            }
        }
Beispiel #12
0
        public Boolean SaveInspectionDetails(InspectionDetail item)
        {
            ////////////////////////////////////
            // Update TRACK_INSPECTION_DETAIL
            DAL.TRACK_INSPECTION_DETAIL recordInspectDetail = new DAL.TRACK_INSPECTION_DETAIL();
            var cmpntd = new Component(_context, longNullableToint(item.EqunitAuto));
            var component = _context.GENERAL_EQ_UNIT.Where(m => m.equnit_auto == item.EqunitAuto).FirstOrDefault();
            if (component == null)
                return false;

            // FK ID
            recordInspectDetail.inspection_auto = _InspectionAuto;

            // FK ID
            recordInspectDetail.track_unit_auto = item.EqunitAuto;

            // tool_auto ???
            recordInspectDetail.tool_auto = -1;

            // reading ????
            recordInspectDetail.reading = 0;

            // worn percentage ????
            recordInspectDetail.worn_percentage = 0;

            // eval_code ????
            recordInspectDetail.eval_code = "U";

            // ReadingEnteredByEval
            recordInspectDetail.ReadingEnteredByEval = false;

            // hours_on_surface
            recordInspectDetail.hours_on_surface = cmpntd.GetComponentLifeMiddleOfNewAction(DateTime.Now);

            // Side
            recordInspectDetail.Side = component.side ?? 0;

            // UCSystemId
            recordInspectDetail.UCSystemId = component.module_ucsub_auto;

            // INSERT
            _TRACK_INSPECTION_DETAIL.Add(recordInspectDetail);
            _context.SaveChanges();

            /////////////////////////////////////////////////////////
            // MEASUREMENT_POINT_RECORD, MEASUREPOINT_RECORD_IMAGES
            foreach (var measurementPoint in item.MeasurementPoints)
            {
                ///////////////////////////////
                // MEASUREMENT_POINT_RECORD
                int newMeasurePointId = 0;
                int firstMeasurePointId = 0;
                int countReading = 0;
                foreach (var reading in measurementPoint.Measures)
                {
                    newMeasurePointId = SaveInspectionReading(
                        recordInspectDetail.inspection_detail_auto,
                        measurementPoint.MeasurementPointId,
                        measurementPoint.ToolCode,
                        measurementPoint.Notes,
                        reading,
                        countReading);

                    if (countReading == 0)
                        firstMeasurePointId = newMeasurePointId;
                    countReading++;
                }

                ////////////////////////////////////////////////////////////
                // MEASUREPOINT_RECORD_IMAGES
                foreach (var image in measurementPoint.Images)
                {
                    SaveInspectionImg(
                        firstMeasurePointId,
                        image);
                }
            }
            _context.SaveChanges();

            ///////////////////////////
            // Update component worn
            WornPercentage componentWorn = GetComponentWorn(_InspectionAuto, item.EqunitAuto);
            if (componentWorn != null && componentWorn.wornPercentage != 0 && !componentWorn.evalCode.Equals('U'))
            {
                // tool_auto
                recordInspectDetail.tool_auto = componentWorn.tool_auto;

                // reading
                recordInspectDetail.reading = componentWorn.reading;

                // worn percentage
                recordInspectDetail.worn_percentage = componentWorn.wornPercentage;

                // eval_code
                recordInspectDetail.eval_code = componentWorn.evalCode.ToString();

                // Update
                //_TRACK_INSPECTION_DETAIL   .Upda.Add(recordInspectDetail);
                _context.SaveChanges();
            }

            return true;
        }