Пример #1
0
        private string getTemplateFileName(FileTransferConfiguration template)
        {
            string fileName = GetConfigurationSetting("SiteFolder", "");

            fileName += "\\App_Data\\DataTransferTemplates\\" + template.ConfigurationTemplate;

            return(fileName);
        }
        public FileTransferConfigurationModel FindDataTransferConfigurationModel(int id, bool bCreateIfNotFound = false)
        {
            var item = db.FindFileTransferConfiguration(id);

            if (item == null && bCreateIfNotFound)
            {
                item = new FileTransferConfiguration();
            }
            return(MapToModel(item));
        }
        public Error InsertOrUpdateDataTransferConfiguration(FileTransferConfigurationModel config, UserModel user, string lockGuid = "")
        {
            var error = validateModel(config);

            if (!error.IsError)
            {
                // Check that the lock is still current
                if (!db.IsLockStillValid(typeof(FileTransferConfiguration).ToString(), config.Id, lockGuid))
                {
                    error.SetError(EvolutionResources.errRecordChangedByAnotherUser, "TransferName");
                }
                else
                {
                    FileTransferConfiguration temp = null;
                    if (config.Id != 0)
                    {
                        temp = db.FindFileTransferConfiguration(config.Id);
                    }
                    else
                    {
                        temp = db.FindFileTransferConfiguration(config.TransferName);
                    }
                    if (temp == null)
                    {
                        temp = new FileTransferConfiguration();
                    }

                    mapToEntity(config, temp);

                    if (temp.CreatedById == 0)
                    {
                        temp.CreatedById = user.Id;
                        temp.CreatedDate = DateTimeOffset.Now;
                    }

                    temp.Location         = db.FindLocation(temp.LocationId ?? 0);
                    temp.FreightForwarder = db.FindFreightForwarder(temp.FreightForwarderId ?? 0);
                    if (temp.ConfigurationTemplate == "0")
                    {
                        temp.ConfigurationTemplate = "";
                    }

                    db.InsertOrUpdateFileTransferConfiguration(temp);
                    config.Id = temp.Id;
                }
            }
            return(error);
        }
        public FileTransferConfigurationModel MapToModel(FileTransferConfiguration config)
        {
            if (config == null)
            {
                return(null);
            }
            else
            {
                var newItem = Mapper.Map <FileTransferConfiguration, FileTransferConfigurationModel>(config);

                //newItem.DataTransferFolder = GetConfigurationSetting("DataTransferFolder", "");

                if (config.User != null)
                {
                    newItem.CreatedByText = config.User.Name;
                }

                newItem.TransferTypeText = ((FileTransferType)config.TransferType).ToString();
                newItem.DataTypeText     = (config.LOVItem_DataType == null ? "" : config.LOVItem_DataType.ItemText);
                newItem.ProtocolText     = ((FTPProtocol)config.Protocol).ToString();

                return(newItem);
            }
        }
 private void mapToEntity(FileTransferConfigurationModel model, FileTransferConfiguration entity)
 {
     Mapper.Map <FileTransferConfigurationModel, FileTransferConfiguration>(model, entity);
 }