コード例 #1
0
ファイル: WSREMobileManager.cs プロジェクト: hari81/BLL
        public Boolean SaveWSREComponentRecords(
            DAL.WSREComponentRecord record,
            WSREComponentRecordModel item)
        {
            // Comment
            record.Comment = item.Comment;

            // ComponentId
            record.ComponentId = item.ComponentId;

            // Measurement
            record.Measurement = item.Measurement;

            // MeasurementToolId
            TrackTool tool = new TrackTool();
            int       Id   = tool.GetIdByToolCode(item.MeasurementToolId);

            record.MeasurementToolId = Id;

            // WornPercentage
            var component = new BLL.Core.Domain.Component(new UndercarriageContext(), Convert.ToInt32(record.ComponentId));

            record.WornPercentage = component.CalcWornPercentage(record.Measurement.ConvertMMToInch(), record.MeasurementToolId, InspectionImpact.High);
            char charEval = record.WornPercentage.toEvalChar();

            _overallEval = GetOverallEval(charEval, _overallEval);

            // INSERT
            _WSREComponentRecords.Add(record);
            _context.SaveChanges();
            _arrComponentRecordId.Add(record.Id);

            //////////////////////////////////
            // WSREComponentImages table
            foreach (var image in item.Images)
            {
                // ComponentrecordId
                DAL.WSREComponentImage imgRecord = new DAL.WSREComponentImage();
                imgRecord.ComponentRecordId = record.Id;

                // Data
                byte[] imageData = GetUploadImageData(image.Data);
                imgRecord.Data = imageData;

                // Title
                imgRecord.Title = image.ImageTitle;

                // Comment
                imgRecord.Comment = image.ImageComment;

                // IncludeInReport
                imgRecord.IncludeInReport = true;

                // Deleted
                imgRecord.Deleted = false;

                // INSERT
                _WSREComponentImages.Add(imgRecord);
            }

            ///////////////////////////////////////////////
            // WSREComponentRecordRecommendations table
            foreach (var recommend in item.RecommendationId)
            {
                DAL.WSREComponentRecordRecommendation recommendRecord = new DAL.WSREComponentRecordRecommendation();
                recommendRecord.ComponentRecordId = record.Id;
                recommendRecord.RecommendationId  = recommend;

                // INSERT
                _WSREComponentRecordRecommendations.Add(recommendRecord);
            }

            return(true);
        }
コード例 #2
0
ファイル: WSREMobileManager.cs プロジェクト: hari81/BLL
        public Boolean SaveWSREInfo(WRESSyncModel equip)
        {
            try
            {
                BLL.Core.Domain.TTDevUser user = new BLL.Core.Domain.TTDevUser(new DAL.SharedContext(), 0);

                ////////////////////
                //// WSREs table
                //DAL.WSRE WSREsRecord = new DAL.WSRE();
                //WSREsRecord.Date = DateTime.Now;
                //WSREsRecord.SystemId = equip.SystemId;
                //WSREsRecord.JobsiteId = equip.JobsiteId;
                //WSREsRecord.InspectorId = user.GetUserAutoById(equip.InspectorId);
                //WSREsRecord.JobNumber = equip.JobNumber;
                //WSREsRecord.OldTagNumber = equip.OldTagNumber;
                //WSREsRecord.OverallComment = equip.OverallComment;
                //WSREsRecord.OverallRecommendation = equip.OverallRecommendation;
                //WSREsRecord.StatusId = 1;
                //WSREsRecord.CustomerReference = equip.CustomerReference;
                //WSREsRecord.SystemLife = new BLL.Core.Domain.UCSystem(new DAL.UndercarriageContext(), (int)WSREsRecord.SystemId).GetSystemLife(DateTime.Now);
                //_WSREs.Add(WSREsRecord);

                //// COMMIT
                //_context.SaveChanges();
                //_WSREId = WSREsRecord.Id;

                _WSREId = equip.serverInspectionId;

                /////////////////////////////
                // WSREInitialImages table
                foreach (var item in equip.InitialImages)
                {
                    DAL.WSREInitialImage record = new DAL.WSREInitialImage();
                    record.WSREId = _WSREId;
                    SaveWSREInitialImages(record, item);
                }

                //////////////////////////////////
                // WSREComponentRecords table
                foreach (var item in equip.ComponentRecords)
                {
                    DAL.WSREComponentRecord record = new DAL.WSREComponentRecord();
                    record.WSREId = _WSREId;
                    SaveWSREComponentRecords(record, item);
                }

                //////////////////////////////////
                // WSRECrackTest table
                DAL.WSRECrackTest recordCrack = new DAL.WSRECrackTest();
                recordCrack.WSREId = _WSREId;
                SaveWSRECrackTestsRecords(recordCrack, equip);

                //////////////////////////////
                // DipTests tables
                foreach (var item in equip.DipTestRecords)
                {
                    DAL.WSREDipTest recordDipTest = new DAL.WSREDipTest();
                    recordDipTest.WSREId = _WSREId;
                    SaveWSREDipTestsRecords(recordDipTest, item);
                }

                // COMMIT
                _context.SaveChanges();

                /////////////////////////
                // Update "OverallEval"
                UpdateOverallEval();
            }
            catch (Exception e)
            {
                // Sync failed, roll back
                RollbackWSREInfo();
                return(false);
            }

            return(true);
        }