Пример #1
0
 /// <summary>
 /// Read Header Xml file based in database NId,
 /// Create HeaderDeatails class object and assign property based on xml file values,
 /// Searialize object to json string using JavaScriptSerializer and return 
 /// </summary>
 /// <param name="requestParam">Containg information to retreve xml file</param>
 /// <returns>string containing header information</returns>
 public string GetHeaderDetail(string requestParam)
 {
     HeaderDetailsTemplate ObjHeaderDetail;
     bool IsDIDatabase = false;
     string DbNid = string.Empty;
     string[] Params;
     string RetVal = string.Empty;
     System.Web.Script.Serialization.JavaScriptSerializer jSearializer = null;
     try
     {
         ObjHeaderDetail = new HeaderDetailsTemplate();
         Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
         DbNid = Params[0];
         IsDIDatabase = Convert.ToBoolean(Params[1]);
         // Check if to getheader for Di Adaptations or UNSD
         if (IsDIDatabase)
         {
             ObjHeaderDetail = GetDIHeaderStructure(DbNid);
         }
         else
         {
             ObjHeaderDetail = GetUNSDHeaderStructure(DbNid);
         }
         // Initlize javascript seailizer
         jSearializer = new System.Web.Script.Serialization.JavaScriptSerializer();
         // Searilize Header deatail and return
         RetVal = jSearializer.Serialize(ObjHeaderDetail);
     }
     catch (Exception Ex)
     {
         RetVal = string.Empty;
         Global.CreateExceptionString(Ex, null);
     }
     return RetVal;
 }
Пример #2
0
    /// <summary>
    /// Generate and save header.xml file based passed input parameters 
    /// </summary>
    /// <param name="requestParam">input parameters for generating header Xml file</param>
    /// <returns>True if header file created successfuly, else return false</returns>
    public bool SaveHeaderDetails(string requestParam)
    {
        Boolean RetVal = false;
        string[] Params;
        string DbNid = string.Empty;
        bool IsDIDatabase = false;
        HeaderDetailsTemplate ObjHeaderDet;
        try
        {
            Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
            DbNid = Params[0];
            ObjHeaderDet = new HeaderDetailsTemplate();
            ObjHeaderDet.LanguageCode = Params[1];
            IsDIDatabase = Convert.ToBoolean(Params[2]);
            ObjHeaderDet.HeaderId = Params[3];
            ObjHeaderDet.HeaderDsdName = Params[4];
            ObjHeaderDet.SenderId = Params[5];
            ObjHeaderDet.RecieverId = Params[6];
            ObjHeaderDet.SenderName = Params[7];
            ObjHeaderDet.SenderContactName = Params[8];
            ObjHeaderDet.SenderDepartment = Params[9];
            ObjHeaderDet.SenderRole = Params[10];
            ObjHeaderDet.SenderFax = Params[11];
            ObjHeaderDet.SenderTelephone = Params[12];
            ObjHeaderDet.SenderEmail = Params[13];
            ObjHeaderDet.RecieverName = Params[14];
            ObjHeaderDet.RecieverContactName = Params[15];
            ObjHeaderDet.RecieverDepartment = Params[16];
            ObjHeaderDet.RecieverRole = Params[17];
            ObjHeaderDet.RecieverFax = Params[18];
            ObjHeaderDet.RecieverTelephone = Params[19];
            ObjHeaderDet.RecieverEmail = Params[20];
            ObjHeaderDet.Prepared = Params[22];

            // Check if to save header for di adaptation--2.1
            if (IsDIDatabase)
            {
                // Create StructureType object of  SDMXObjectModel--2.1
                SDMXObjectModel.Message.StructureType ObjStructure = new StructureType();
                // Set header field of structure object, by calling method
                ObjStructure.Header = GetDiMessageHeaderStructure(ObjHeaderDet);
                ObjStructure.Footer = null;
                // Call method to save header xml
                RetVal = SaveDIHeaderStructure(DbNid, ObjStructure);

            }
            else// if to save header for unsd--2.0
            {
                // create StructureType object of  SDMXApi_2_0
                SDMXApi_2_0.Message.StructureType ObjSdxmStructure = new SDMXApi_2_0.Message.StructureType();
                // set header field of structure object
                ObjSdxmStructure.Header = GetSdmxMessageHeaderStructure(ObjHeaderDet);
                ObjSdxmStructure.Concepts = null;
                ObjSdxmStructure.KeyFamilies = null;
                ObjSdxmStructure.CodeLists = null;
                ObjSdxmStructure.MetadataStructureDefinitions = null;
                ObjSdxmStructure.OrganisationSchemes = null;
                ObjSdxmStructure.HierarchicalCodelists = null;
                ObjSdxmStructure.Metadataflows = null;
                ObjSdxmStructure.Processes = null;
                ObjSdxmStructure.ReportingTaxonomies = null;
                ObjSdxmStructure.StructureSets = null;
                ObjSdxmStructure.CategorySchemes = null;
                ObjSdxmStructure.Dataflows = null;
                // Call method to save header xml
                RetVal = SaveUNSDHeaderStructure(DbNid, ObjSdxmStructure);
            }
        }
        catch (Exception Ex)
        {
            Global.CreateExceptionString(Ex, null);
            RetVal = false;
        }
        return RetVal;
    }
Пример #3
0
    /// <summary>
    /// Sets header details to sdmx structure header object and return object
    /// </summary>
    /// <param name="ObjHeaderDet">Class containg fields for header detail</param>
    /// <returns>Structure header object with fields initlized</returns>
    private SDMXApi_2_0.Message.HeaderType GetSdmxMessageHeaderStructure(HeaderDetailsTemplate ObjHeaderDet)
    {
        SDMXApi_2_0.Message.HeaderType ObjHeader = null;
        SDMXApi_2_0.Message.PartyType SenderParty;
        SDMXApi_2_0.Message.PartyType RecieverParty;
        SDMXApi_2_0.Message.ContactType SenderContact;
        SDMXApi_2_0.Message.ContactType ReceiverContact;
        string LanguageCode = string.Empty;
        try
        {
            SenderParty = new SDMXApi_2_0.Message.PartyType();
            RecieverParty = new SDMXApi_2_0.Message.PartyType();
            SenderParty.Contact = new List<SDMXApi_2_0.Message.ContactType>();
            RecieverParty.Contact = new List<SDMXApi_2_0.Message.ContactType>();
            LanguageCode = ObjHeaderDet.LanguageCode;

            #region "--Set sender fields value--"
            // Set sender Id
            SenderParty.id = ObjHeaderDet.SenderId;
            // Set sender name
            SenderParty.Name = SetHeaderFilds(LanguageCode, ObjHeaderDet.SenderName);
            // Set sender contact Name
            SenderContact = new SDMXApi_2_0.Message.ContactType();
            SenderContact.Name = SetHeaderFilds(LanguageCode, ObjHeaderDet.SenderContactName);
            // Set reciever contact role
            SenderContact.Role = SetHeaderFilds(LanguageCode, ObjHeaderDet.SenderRole);
            // Set sender contact department
            SenderContact.Department = SetHeaderFilds(LanguageCode, ObjHeaderDet.SenderDepartment);

            // Set value of sender item fileds, telephone,emailid and fax
            SenderContact.Items = new string[] { ObjHeaderDet.SenderTelephone, ObjHeaderDet.SenderEmail, ObjHeaderDet.SenderFax };
            SenderContact.ItemsElementName = new SDMXApi_2_0.Message.ContactChoiceType[] { SDMXApi_2_0.Message.ContactChoiceType.Telephone, SDMXApi_2_0.Message.ContactChoiceType.Email, SDMXApi_2_0.Message.ContactChoiceType.Fax };

            SenderParty.Contact.Add(SenderContact);
            #endregion

            #region "--set Reciever fields value--"
            // Set Reciever Id
            RecieverParty.id = ObjHeaderDet.RecieverId;
            // Set reciever name
            RecieverParty.Name = SetHeaderFilds(LanguageCode, ObjHeaderDet.RecieverName);
            ReceiverContact = new SDMXApi_2_0.Message.ContactType();
            // Set reciever contact name
            ReceiverContact.Name = SetHeaderFilds(LanguageCode, ObjHeaderDet.RecieverContactName);
            // Set reciever contact role
            ReceiverContact.Role = SetHeaderFilds(LanguageCode, ObjHeaderDet.RecieverRole);
            // Set reciever contact department
            ReceiverContact.Department = SetHeaderFilds(LanguageCode, ObjHeaderDet.RecieverDepartment);
            // Set value of sender item fileds, telephone,emailid and fax
            ReceiverContact.Items = new string[] { ObjHeaderDet.RecieverTelephone, ObjHeaderDet.RecieverEmail, ObjHeaderDet.RecieverFax };
            ReceiverContact.ItemsElementName = new SDMXApi_2_0.Message.ContactChoiceType[] { SDMXApi_2_0.Message.ContactChoiceType.Telephone, SDMXApi_2_0.Message.ContactChoiceType.Email, SDMXApi_2_0.Message.ContactChoiceType.Fax };

            RecieverParty.Contact.Add(ReceiverContact);
            #endregion

            //Init line header object
            ObjHeader = new SDMXApi_2_0.Message.HeaderType();
            // Add SenderParty object to headers sender property
            ObjHeader.Sender.Add(SenderParty);
            // Add RecieverParty object to headers reciever property
            ObjHeader.Receiver.Add(RecieverParty);
            // Set id of header
            ObjHeader.ID = ObjHeaderDet.HeaderId;
            ObjHeader.Name = SetHeaderFilds(LanguageCode, ObjHeaderDet.HeaderDsdName);
            ObjHeader.Prepared = ObjHeaderDet.Prepared;
        }
        catch (Exception Ex)
        {
            throw Ex;
        }

        return ObjHeader;
    }
Пример #4
0
    /// <summary>
    /// Reads UNSD header file and return object
    /// </summary>
    /// <param name="dbNId">Nid Of unsd Database</param>
    /// <returns>Object containing header</returns>
    private HeaderDetailsTemplate GetUNSDHeaderStructure(string dbNId)
    {
        HeaderDetailsTemplate RetVal = null;
        string AssociatedDbNId, SourceHeaderFileNameWPath;
        SDMXApi_2_0.Message.StructureType ObjStructure;
        AssociatedDbNId = string.Empty;
        SourceHeaderFileNameWPath = string.Empty;
        RetVal = new HeaderDetailsTemplate();
        SDMXApi_2_0.Message.ContactType SenderContact;
        SDMXApi_2_0.Message.ContactType RecieverContact;
        try
        {
            SourceHeaderFileNameWPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.Data + dbNId + "\\" + Constants.FolderName.SDMX.sdmx + HeaderFileName);
            if (File.Exists(SourceHeaderFileNameWPath))
            {
                ObjStructure = (SDMXApi_2_0.Message.StructureType)SDMXApi_2_0.Deserializer.LoadFromFile(typeof(SDMXApi_2_0.Message.StructureType), SourceHeaderFileNameWPath);

                RetVal.HeaderId = ObjStructure.Header.ID;
                RetVal.Prepared = !string.IsNullOrEmpty(ObjStructure.Header.Prepared.ToString()) ? ObjStructure.Header.Prepared.ToString() : string.Empty;
                RetVal.HeaderDsdName = !string.IsNullOrEmpty(ObjStructure.Header.Name[0].Value.ToString()) ? ObjStructure.Header.Name[0].Value.ToString() : string.Empty;
                RetVal.SenderId = !string.IsNullOrEmpty(ObjStructure.Header.Sender[0].id.ToString()) ? ObjStructure.Header.Sender[0].id.ToString() : string.Empty;
                RetVal.SenderName = !string.IsNullOrEmpty(ObjStructure.Header.Sender[0].Name[0].Value.ToString()) ? ObjStructure.Header.Sender[0].Name[0].Value.ToString() : string.Empty;
                RetVal.LanguageCode = !string.IsNullOrEmpty(ObjStructure.Header.Sender[0].Name[0].lang.ToString()) ? ObjStructure.Header.Sender[0].Name[0].lang.ToString() : string.Empty;
                SenderContact = ObjStructure.Header.Sender[0].Contact[0];

                RetVal.SenderDepartment = !string.IsNullOrEmpty(SenderContact.Department[0].Value.ToString()) ? SenderContact.Department[0].Value.ToString() : string.Empty;
                RetVal.SenderRole = !string.IsNullOrEmpty(SenderContact.Role[0].Value.ToString()) ? SenderContact.Role[0].Value.ToString() : string.Empty;
                RetVal.SenderContactName = !string.IsNullOrEmpty(SenderContact.Name[0].Value.ToString()) ? SenderContact.Name[0].Value.ToString() : string.Empty;
                if (SenderContact.Items.Length > 2)
                {
                    RetVal.SenderTelephone = !string.IsNullOrEmpty(SenderContact.Items[0].ToString()) ? SenderContact.Items[0].ToString() : string.Empty;
                    RetVal.SenderFax = !string.IsNullOrEmpty(SenderContact.Items[1].ToString()) ? SenderContact.Items[1].ToString() : string.Empty;
                    RetVal.SenderEmail = !string.IsNullOrEmpty(SenderContact.Items[2].ToString()) ? SenderContact.Items[2].ToString() : string.Empty;
                }
                else if(SenderContact.Items.Length >1)
                {
                    RetVal.SenderTelephone = !string.IsNullOrEmpty(SenderContact.Items[0].ToString()) ? SenderContact.Items[0].ToString() : string.Empty;
                    RetVal.SenderEmail = !string.IsNullOrEmpty(SenderContact.Items[2].ToString()) ? SenderContact.Items[2].ToString() : string.Empty;
                }
                else
                {
                    RetVal.SenderTelephone = !string.IsNullOrEmpty(SenderContact.Items[0].ToString()) ? SenderContact.Items[0].ToString() : string.Empty;
                }
                RecieverContact = ObjStructure.Header.Receiver[0].Contact[0];

                RetVal.RecieverId = !string.IsNullOrEmpty(ObjStructure.Header.Receiver[0].id.ToString()) ? ObjStructure.Header.Receiver[0].id.ToString() : string.Empty;
                RetVal.RecieverName = !string.IsNullOrEmpty(ObjStructure.Header.Receiver[0].Name[0].Value) ? ObjStructure.Header.Receiver[0].Name[0].Value.ToString() : string.Empty;
                RetVal.RecieverDepartment = !string.IsNullOrEmpty(RecieverContact.Department[0].Value) ? RecieverContact.Department[0].Value.ToString() : string.Empty;
                RetVal.RecieverRole = !string.IsNullOrEmpty(RecieverContact.Role[0].Value) ? RecieverContact.Role[0].Value.ToString() : string.Empty;
                RetVal.RecieverContactName = !string.IsNullOrEmpty(RecieverContact.Name[0].Value) ? RecieverContact.Name[0].Value.ToString() : string.Empty;
                if (RecieverContact.Items.Length > 2)
                {
                    RetVal.RecieverTelephone = !string.IsNullOrEmpty(RecieverContact.Items[0].ToString()) ? RecieverContact.Items[0].ToString() : string.Empty;
                    RetVal.RecieverEmail = !string.IsNullOrEmpty(RecieverContact.Items[1].ToString()) ? RecieverContact.Items[1].ToString() : string.Empty;
                    RetVal.RecieverFax = !string.IsNullOrEmpty(RecieverContact.Items[2].ToString()) ? RecieverContact.Items[2].ToString() : string.Empty;
                }
                else if (RecieverContact.Items.Length >1)
                {
                    RetVal.RecieverTelephone = !string.IsNullOrEmpty(RecieverContact.Items[0].ToString()) ? RecieverContact.Items[0].ToString() : string.Empty;
                    RetVal.RecieverEmail = !string.IsNullOrEmpty(RecieverContact.Items[1].ToString()) ? RecieverContact.Items[1].ToString() : string.Empty;
                }
                else
                {
                    RetVal.RecieverTelephone = !string.IsNullOrEmpty(RecieverContact.Items[0].ToString()) ? RecieverContact.Items[0].ToString() : string.Empty;
                }
            }
        }
        catch (Exception Ex)
        {
            Global.CreateExceptionString(Ex, null);
            RetVal = null;
            throw Ex;
        }
        return RetVal;
    }
Пример #5
0
    /// <summary>
    /// Sets header details to di structure header object and return object
    /// </summary>
    /// <param name="ObjHeaderDet">Class containg fields for header detail</param>
    /// <returns>Structure header object with fields initlized</returns>
    private SDMXObjectModel.Message.StructureHeaderType GetDiMessageHeaderStructure(HeaderDetailsTemplate ObjHeaderDet)
    {
        SDMXObjectModel.Message.StructureHeaderType ObjStructureHeader = null;
        SenderType Sender;
        PartyType Receiver;
        Sender = new SenderType(ObjHeaderDet.SenderId, ObjHeaderDet.SenderName, ObjHeaderDet.LanguageCode, new SDMXObjectModel.Message.ContactType(ObjHeaderDet.SenderContactName, ObjHeaderDet.SenderDepartment, ObjHeaderDet.SenderRole, ObjHeaderDet.LanguageCode));
        Sender.Contact[0].Items = new string[] { ObjHeaderDet.SenderTelephone, ObjHeaderDet.SenderEmail, ObjHeaderDet.SenderFax };
        Sender.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

        Receiver = new PartyType(ObjHeaderDet.RecieverId, ObjHeaderDet.RecieverName, ObjHeaderDet.LanguageCode, new SDMXObjectModel.Message.ContactType(ObjHeaderDet.RecieverContactName, ObjHeaderDet.RecieverDepartment, ObjHeaderDet.RecieverRole, ObjHeaderDet.LanguageCode));
        Receiver.Contact[0].Items = new string[] { ObjHeaderDet.RecieverTelephone, ObjHeaderDet.RecieverEmail, ObjHeaderDet.RecieverFax };
        Receiver.Contact[0].ItemsElementName = new SDMXObjectModel.Message.ContactChoiceType[] { SDMXObjectModel.Message.ContactChoiceType.Telephone, SDMXObjectModel.Message.ContactChoiceType.Email, SDMXObjectModel.Message.ContactChoiceType.Fax };

        ObjStructureHeader = new StructureHeaderType(ObjHeaderDet.HeaderId, true, DateTime.Now, Sender, Receiver);
        return ObjStructureHeader;
    }