public void MigrateAllX12EnvelopeOverrides(Server.X12ProtocolSettings serverX12ProtocolSettings, Services.X12ProtocolSettings cloudX12ProtocolSettings)
 {
     foreach (Server.X12EnvelopeOverrides serverEnvOverrides in serverX12ProtocolSettings.EnvelopeSettings.GetOverrides())
     {
         this.MigrateX12EnvelopOverridese(serverEnvOverrides, cloudX12ProtocolSettings);
     }
 }
 internal void MigrateAllX12ValidationOverrides(Server.X12ProtocolSettings serverX12ProtocolSettings, Services.X12ProtocolSettings cloudX12ProtocolSettings)
 {
     foreach (var serverValidationOverrides in serverX12ProtocolSettings.ValidationSettings.GetOverrides())
     {
         this.MigrateX12ValidationOverrides(serverValidationOverrides, cloudX12ProtocolSettings);
     }
 }
        private Services.X12ProtocolSettings CreateX12ProtocolSettings(Server.X12ProtocolSettings serverProtocolSettings)
        {
            Services.X12ProtocolSettings cloudProtocolSettings = new Services.X12ProtocolSettings();
            cloudProtocolSettings.AcknowledgementControlNumberLowerBound = serverProtocolSettings.AcknowledgementSettings.AcknowledgementControlNumberLowerBound;
            cloudProtocolSettings.AcknowledgementControlNumberPrefix     = serverProtocolSettings.AcknowledgementSettings.AcknowledgementControlNumberPrefix;
            cloudProtocolSettings.AcknowledgementControlNumberRollover   = serverProtocolSettings.AcknowledgementSettings.AcknowledgementControlNumberRollover;
            cloudProtocolSettings.AcknowledgementControlNumberSuffix     = serverProtocolSettings.AcknowledgementSettings.AcknowledgementControlNumberSuffix;
            cloudProtocolSettings.AcknowledgementControlNumberUpperBound = serverProtocolSettings.AcknowledgementSettings.AcknowledgementControlNumberUpperBound;

            cloudProtocolSettings.AllowLeadingAndTrailingSpacesAndZeroes = serverProtocolSettings.ValidationSettings.AllowLeadingAndTrailingSpacesAndZeroes;
            cloudProtocolSettings.AuthorizationQualifier = serverProtocolSettings.SecuritySettings.AuthorizationQualifier;
            cloudProtocolSettings.AuthorizationValue     = serverProtocolSettings.SecuritySettings.AuthorizationValue;
            cloudProtocolSettings.SecurityQualifier      = serverProtocolSettings.SecuritySettings.SecurityQualifier;
            if (serverProtocolSettings.SecuritySettings.PasswordValue != null)
            {
                cloudProtocolSettings.SecurityValue = serverProtocolSettings.SecuritySettings.PasswordValue;
            }

            cloudProtocolSettings.BatchFunctionalAck = serverProtocolSettings.AcknowledgementSettings.BatchFunctionalAcknowledgements;
            cloudProtocolSettings.BatchTechnicalAck  = serverProtocolSettings.AcknowledgementSettings.BatchTechnicalAcknowledgements;

            cloudProtocolSettings.CharacterSet = (short)serverProtocolSettings.FramingSettings.CharacterSet;
            cloudProtocolSettings.CheckDuplicateGroupControlNumber          = serverProtocolSettings.ValidationSettings.CheckDuplicateGroupControlNumber;
            cloudProtocolSettings.CheckDuplicateInterchangeControlNumber    = serverProtocolSettings.ValidationSettings.CheckDuplicateInterchangeControlNumber;
            cloudProtocolSettings.CheckDuplicateTransactionSetControlNumber = serverProtocolSettings.ValidationSettings.CheckDuplicateTransactionSetControlNumber;
            cloudProtocolSettings.ComponentSeparator    = serverProtocolSettings.FramingSettings.ComponentSeparator;
            cloudProtocolSettings.ControlStandardsId    = serverProtocolSettings.EnvelopeSettings.ControlStandardsId;
            cloudProtocolSettings.ControlVersionNumber  = serverProtocolSettings.EnvelopeSettings.ControlVersionNumber;
            cloudProtocolSettings.ConvertImpliedDecimal = serverProtocolSettings.ProcessingSettings.ConvertImpliedDecimal;
            cloudProtocolSettings.CreateEmptyXmlTagsForTrailingSeparators = serverProtocolSettings.ProcessingSettings.CreateEmptyXmlTagsForTrailingSeparators;
            cloudProtocolSettings.DataElementSeparator              = serverProtocolSettings.FramingSettings.DataElementSeparator;
            cloudProtocolSettings.EnableDefaultGroupHeaders         = serverProtocolSettings.EnvelopeSettings.EnableDefaultGroupHeaders;
            cloudProtocolSettings.FunctionalGroupId                 = serverProtocolSettings.EnvelopeSettings.FunctionalGroupId;
            cloudProtocolSettings.GenerateLoopForValidMessagesInAck = serverProtocolSettings.AcknowledgementSettings.NeedLoopForValidMessages;
            cloudProtocolSettings.GroupControlNumberLowerBound      = serverProtocolSettings.EnvelopeSettings.GroupControlNumberLowerBound;
            cloudProtocolSettings.GroupControlNumberRollover        = serverProtocolSettings.EnvelopeSettings.GroupControlNumberRollover;
            cloudProtocolSettings.GroupControlNumberUpperBound      = serverProtocolSettings.EnvelopeSettings.GroupControlNumberUpperBound;

            cloudProtocolSettings.GroupHeaderVersion = serverProtocolSettings.EnvelopeSettings.GroupHeaderVersion;

            cloudProtocolSettings.InterchangeControlNumberLowerBound = serverProtocolSettings.EnvelopeSettings.InterchangeControlNumberLowerBound;
            cloudProtocolSettings.InterchangeControlNumberRollover   = serverProtocolSettings.EnvelopeSettings.InterchangeControlNumberRollover;
            cloudProtocolSettings.InterchangeControlNumberUpperBound = serverProtocolSettings.EnvelopeSettings.InterchangeControlNumberUpperBound;

            cloudProtocolSettings.MaskSecurityInfo           = serverProtocolSettings.ProcessingSettings.MaskSecurityInfo;
            cloudProtocolSettings.MessageFilterType          = (short)serverProtocolSettings.MessageFilter.MessageFilterType;
            cloudProtocolSettings.NeedFunctionalAck          = serverProtocolSettings.AcknowledgementSettings.NeedFunctionalAcknowledgement;
            cloudProtocolSettings.NeedTechnicalAck           = serverProtocolSettings.AcknowledgementSettings.NeedTechnicalAcknowledgement;
            cloudProtocolSettings.PreserveInterchange        = serverProtocolSettings.ProcessingSettings.PreserveInterchange;
            cloudProtocolSettings.ProtocolName               = serverProtocolSettings.ProtocolName;
            cloudProtocolSettings.ReceiverApplicationId      = serverProtocolSettings.EnvelopeSettings.ReceiverApplicationId;
            cloudProtocolSettings.ReplaceChar                = serverProtocolSettings.FramingSettings.ReplaceChar;
            cloudProtocolSettings.ReplaceSeparatorsInPayload = serverProtocolSettings.FramingSettings.ReplaceSeparatorsInPayload;

            cloudProtocolSettings.SecurityQualifier = serverProtocolSettings.SecuritySettings.SecurityQualifier;

            cloudProtocolSettings.SegmentTerminator       = serverProtocolSettings.FramingSettings.SegmentTerminator;
            cloudProtocolSettings.SegmentTerminatorSuffix = (short)serverProtocolSettings.FramingSettings.SegmentTerminatorSuffix;
            cloudProtocolSettings.SenderApplicationId     = serverProtocolSettings.EnvelopeSettings.SenderApplicationId;
            cloudProtocolSettings.Name = serverProtocolSettings.SettingsName;

            cloudProtocolSettings.SuspendInterchangeOnError = serverProtocolSettings.ProcessingSettings.SuspendInterchangeOnError;
            cloudProtocolSettings.TrailingSeparatorPolicy   = (short)serverProtocolSettings.ValidationSettings.TrailingSeparatorPolicy;

            cloudProtocolSettings.TSControlNumberLowerBound     = serverProtocolSettings.EnvelopeSettings.TransactionSetControlNumberLowerBound;
            cloudProtocolSettings.TSControlNumberPrefix         = serverProtocolSettings.EnvelopeSettings.TransactionSetControlNumberPrefix;
            cloudProtocolSettings.TSControlNumberRollover       = serverProtocolSettings.EnvelopeSettings.TransactionSetControlNumberRollover;
            cloudProtocolSettings.TSControlNumberSuffix         = serverProtocolSettings.EnvelopeSettings.TransactionSetControlNumberSuffix;
            cloudProtocolSettings.TSControlNumberUpperBound     = serverProtocolSettings.EnvelopeSettings.TransactionSetControlNumberUpperBound;
            cloudProtocolSettings.UsageIndicator                = (short)serverProtocolSettings.EnvelopeSettings.UsageIndicator;
            cloudProtocolSettings.UseControlStandardsIdAsRepSep = serverProtocolSettings.EnvelopeSettings.UseControlStandardsIdAsRepetitionCharacter;
            cloudProtocolSettings.UseDotAsDecimalSeparator      = serverProtocolSettings.ProcessingSettings.UseDotAsDecimalSeparator;
            cloudProtocolSettings.ValidateCharacterSet          = serverProtocolSettings.ValidationSettings.ValidateCharacterSet;
            cloudProtocolSettings.ValidateEDITypes              = serverProtocolSettings.ValidationSettings.ValidateEDITypes;
            cloudProtocolSettings.ValidateExtended              = serverProtocolSettings.ValidationSettings.ValidateXSDTypes;

            cloudProtocolSettings.NeedFunctionalAck = serverProtocolSettings.AcknowledgementSettings.NeedFunctionalAcknowledgement;
            if (cloudProtocolSettings.NeedFunctionalAck == true)
            {
                cloudProtocolSettings.FunctionalAckVersion = "00401";
            }
            else
            {
                cloudProtocolSettings.FunctionalAckVersion = null;
            }

            cloudProtocolSettings.FunctionalAckVersion     = null;
            cloudProtocolSettings.NeedTechnicalAck         = serverProtocolSettings.AcknowledgementSettings.NeedTechnicalAcknowledgement;
            cloudProtocolSettings.ImplementationAckVersion = null;
            cloudProtocolSettings.NeedImplementationAck    = false;
            cloudProtocolSettings.BatchImplementationAck   = false;

            return(cloudProtocolSettings);
        }
        public void CreateobX12ContextFiles(string partnerName, AgreementMigrationItemViewModel agreementItem, Server.X12ProtocolSettings protocolSettingsBA, string targetSchemaId, string obFlowId, string transformId, string documentKey, string txnType)
        {
            obFlowPartnerContext obCtxt = new obFlowPartnerContext();

            obCtxt.id          = CreateNewGuid();
            obCtxt.recordType  = AppConstants.obFlowPartnerContext;
            obCtxt.description = agreementItem.Protocol + " " + txnType + " Message from " + partnerName;
            obCtxt.schemaId    = targetSchemaId;
            obCtxt.transformId = transformId;
            obCtxt.docKey      = new obFlowPartnerDockey()
            {
                obFlowContextId        = obFlowId,
                partnerDetailsId       = outboundPartnerDetails,
                partnerIdentifierValue = txnType
            };
            obCtxt.documentKey              = documentKey;
            obCtxt.documentType             = AppConstants.DefaultDocumentType;
            obCtxt.preTransformProcessing   = new JArray();
            obCtxt.postTransformProcessing  = new JArray();
            obCtxt.schemaValidationRequired = true;
            obCtxt.ediOverrideDelimiters    = new Edioverridedelimiters()
            {
                dataElementSeparator    = protocolSettingsBA.FramingSettings.DataElementSeparator,
                componentSeparator      = protocolSettingsBA.FramingSettings.ComponentSeparator,
                replacementCharacter    = protocolSettingsBA.FramingSettings.ReplaceChar,
                segmentTerminator       = protocolSettingsBA.FramingSettings.SegmentTerminator,
                segmentTerminatorSuffix = protocolSettingsBA.FramingSettings.SegmentTerminatorSuffix.ToString()
            };
            string fileName = string.Format(Resources.MetaDataContextPath, partnerName);

            fileName = fileName + partnerName + "_obFlowPartnerContext_" + txnType + ".json";
            if (!File.Exists(fileName))
            {
                File.Create(fileName).Close();
                System.IO.File.WriteAllText(fileName, JObject.Parse(JsonConvert.SerializeObject(obCtxt).ToString()).ToString());
            }
            else
            {
                File.Delete(fileName);
                File.Create(fileName).Close();
                System.IO.File.WriteAllText(fileName, JObject.Parse(JsonConvert.SerializeObject(obCtxt).ToString()).ToString());
            }
        }