예제 #1
0
        /// <summary>
        /// 儲存程式編輯
        /// </summary>
        /// <param name="macroName">程式編輯名稱</param>
        /// <param name="macroGuid">程式編輯 ID</param>
        /// <param name="shapeModelFilepath">程式編輯模型檔案路徑</param>
        /// <param name="note">程式編輯描述</param>
        /// <param name="trainingImage">程式編輯訓練影像二元檔</param>
        /// <param name="exportUnit">輸出單位</param>
        /// <param name="matchingParamData">模型參數二元檔</param>
        /// <param name="measureBinaryData">測量資料二元檔</param>
        /// <param name="measureAssistantParamData">測量參數二元檔</param>
        /// <param name="upperLight">上光源</param>
        /// <param name="bottomLight">下光源</param>
        /// <param name="findedShapeViewModel">Matching 模型資訊</param>
        /// <param name="loginUser">登入者</param>
        /// <param name="trainingImageFilepath">程式編輯訓練影像實體路徑</param>
        /// <param name="snapshot">程式編輯縮圖二元檔</param>
        /// <param name="objectXLength">物件大小 X</param>
        /// <param name="objectYLength">物件大小 Y</param>
        /// <param name="technicalDrawingModel">工程圖資訊</param>
        /// <returns></returns>
        public static bool SaveMacroPlan(string macroName, string macroGuid, string shapeModelFilepath, string note, Binary trainingImage
            , string exportUnit, Binary matchingParamData, Binary measureBinaryData, Binary measureAssistantParamData
            , LightChannel upperLight, LightChannel bottomLight
            , ShapeViewModel findedShapeViewModel, string loginUser
            , string trainingImageFilepath
            , Binary snapshot
            , double objectXLength, double objectYLength
            , XDocument technicalDrawingModel)
        {
            bool success = true;
            try
            {
                MacroPlan plan = _dc.MacroPlan.SingleOrDefault(p => p.MacroGuid == macroGuid);
                var isUpdate = (plan != null);
                if (!isUpdate)
                {
                    plan = new MacroPlan() { CreateBy = loginUser, CreateOn = DateTime.Now, MacroGuid = macroGuid };
                }
                plan.MacroName = macroName;
                plan.ShapeModelFilepath = shapeModelFilepath;
                plan.Note = note;
                plan.TrainingImage = trainingImage;
                plan.TrainingImageFilepath = trainingImageFilepath;
                plan.ExportUnit = exportUnit;
                plan.MatchingParamBinaryData = matchingParamData;
                plan.MeasureBinaryData = measureBinaryData;
                plan.UpperLightSwitch = (upperLight.OnOff == LightControl.LightSwitch.On);
                plan.UpperLightValue = upperLight.Intensity.ToString("d3");
                plan.BottomLightSiwtch = (bottomLight.OnOff == LightControl.LightSwitch.On);
                plan.BottomLigthValue = bottomLight.Intensity.ToString("d3");
                plan.ModifiedOn = DateTime.Now;
                plan.ModifiedBy = loginUser;
                plan.MeasureAssistantBinaryData = measureAssistantParamData;
                plan.ModelRow = findedShapeViewModel.Row;
                plan.ModelCol = findedShapeViewModel.Col;
                plan.ModelAngle = findedShapeViewModel.Angle;
                plan.IsDeleted = false;
                plan.Snapshot = snapshot;
                plan.ObjectXLength = objectXLength;
                plan.ObjectYLength = objectYLength;
                plan.TechnicalDrawingModel = XElement.Load(technicalDrawingModel.CreateReader());

                if (!isUpdate)
                {
                    _dc.MacroPlan.InsertOnSubmit(plan);
                }
                _dc.SubmitChanges();
            }
            catch (Exception ex)
            {
                success = false;
                Hanbo.Log.LogManager.Error(ex.Message);
            }
            return success;
        }
예제 #2
0
 public static bool SaveMacroPlan(string macroName, string macroGuid, string shapeModelFilepath, string note, Binary trainingImage, string exportUnit, Binary matchingParamData, Binary measureBinaryData, Binary measureAssistantParamData, LightChannel upperLight, LightChannel bottomLight, ShapeViewModel shapeView, string loginUser
     , string trainingImageFilepath
     , double objectXLength, double objectYLength)
 {
     return SaveMacroPlan(macroName, macroGuid, shapeModelFilepath, note, trainingImage, exportUnit, matchingParamData, measureBinaryData, measureAssistantParamData, upperLight, bottomLight, shapeView, loginUser
         , trainingImageFilepath, null
         , objectXLength, objectYLength, null);
 }