Пример #1
0
        public void CreatePositionIm(int businessUnitId, int orderId, int orderPositionId, OrderPositionData opd, DbTransaction dbTran)
        {
            Action <int, int, DbTransaction> setOrderIm = (orderId, orderImTypeId, dbTran) =>
            {
                var orderIm = _orderImProcessor.GetOrderIm(orderId, orderImTypeId);

                if (orderIm == null)
                {
                    _orderImProcessor.CreateOrderIm(orderId, orderImTypeId, null, dbTran);
                }
            };

            if (opd.StringData != null)
            {
                var positionIm = _positionImFactory.Create(orderId, orderPositionId, positionImTypeId: 1);
                _repository.SetPositionIm(positionIm, newTaskFile: false, newMaketFile: false, isActual: true, dbTran);

                _stringProcessor.CreateFullString(businessUnitId, opd.ClientId, orderPositionId, opd.StringData, dbTran);

                setOrderIm(orderId, 1, dbTran);
            }

            if (opd.ModuleData != null)
            {
                var positionIm = _positionImFactory.Create(orderId, orderPositionId, positionImTypeId: 2);
                positionIm = _repository.SetPositionIm(positionIm, newTaskFile: true, newMaketFile: false, isActual: true, dbTran);

                _moduleProcessor.CreateModule(opd.ClientId, businessUnitId, orderPositionId, dbTran);

                var bytes        = Base64ToBytesConverter.Convert(opd.ModuleData.Base64String);
                var taskFileDate = (DateTime)positionIm.TaskFileDate;

                _moduleMaketProcessor.CreateSampleImage(orderPositionId, bytes, "ImgTask", taskFileDate);
                _moduleMaketProcessor.CreateModuleGraphics(orderPositionId, bytes, opd.ModuleData.Name);

                setOrderIm(orderId, 2, dbTran);
            }
        }