Exemplo n.º 1
0
        public bool HandleUploadedFile(int bookingId, ENums.UploadXMLType uploadXMLType, ArrayList recordList)
        {
            switch (uploadXMLType)
            {
            case ENums.UploadXMLType.Tourist:
                return(UploadTourist(bookingId, uploadXMLType, recordList));

            default:
                break;
            }
            return(false);
        }
Exemplo n.º 2
0
        private bool UploadTourist(int bookingId, ENums.UploadXMLType uploadXMLType, ArrayList recordList)
        {
            ITouristUploader touristUploader = null;

            touristUploader = new TouristUploader();

            try
            {
                XmlDocument xmlMappingDoc = XMLHelper.LoadXML(uploadXMLType);
                //string xPath = @"//table";
                return(touristUploader.processUplodedFile(bookingId, recordList, xmlMappingDoc));
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Exemplo n.º 3
0
        internal static XmlDocument LoadXML(ENums.UploadXMLType uploadXMLType)
        {
            string xmlFileName = string.Empty;

            switch (uploadXMLType)
            {
            case ENums.UploadXMLType.Tourist:
                xmlFileName = XMLConstants.TOURISTMAPPER;
                break;

            case ENums.UploadXMLType.ApplicationRights:
                xmlFileName = XMLConstants.APPLICATIONRIGHTS;
                break;

            default:
                break;
            }

            if (!String.IsNullOrEmpty(xmlFileName))
            {
                XmlDocument xmlDoc = new XmlDocument();
                try
                {
                    string dataDirectory = AppDomain.CurrentDomain.BaseDirectory;
                    //dataDirectory = dataDirectory.Replace("ResortManager\\", "");
                    dataDirectory = dataDirectory + XMLConstants.baseDirectory + xmlFileName;
                    xmlDoc.Load(dataDirectory);
                    return(xmlDoc);
                }
                catch (Exception exp)
                {
                    throw exp;
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        public bool HandleUploadedFile(int BookingId, ENums.UploadXMLType uploadXMLType, ArrayList RecordList)
        {
            UploadHelper uploadHelper = new UploadHelper();

            return(uploadHelper.HandleUploadedFile(BookingId, uploadXMLType, RecordList));
        }
Exemplo n.º 5
0
 public static XmlDocument LoadXML(ENums.UploadXMLType uploadXMLType)
 {
     return(XMLHandler.LoadXML(uploadXMLType));
 }
Exemplo n.º 6
0
    protected void Submit1_ServerClick1(object sender, EventArgs e)
    {
        string msg = string.Empty;

        #region Validating Input
        if ((fileUploader.PostedFile != null) && (fileUploader.PostedFile.ContentLength > 0))
        {
            string fn = System.IO.Path.GetFileName(fileUploader.PostedFile.FileName);
            if (!fn.ToUpper().StartsWith("FH_TOURISTDETAILS") || !fn.EndsWith(".csv"))
            {
                msg = "You can only select FH_TOURISTDETAILS_XXXXXXX.CSV to upload.";
                System.IO.StringWriter sw = new System.IO.StringWriter();
                sw.Write(msg);
                HtmlTextWriter tw = new HtmlTextWriter(sw);
                //Response.Write(msg);
                base.DisplayAlert(msg);
                return;
            }
        }
        #endregion

        try
        {
            #region Loading the Excel/CSV File
            ArrayList RecordList = new ArrayList();
            using (System.IO.StreamReader sr = new System.IO.StreamReader(fileUploader.PostedFile.InputStream))
            {
                while (sr.Peek() >= 0)
                {
                    string tempString = sr.ReadLine();
                    //recordCollection = tempString.Split(';');
                    RecordList.Add(tempString);
                }
                sr.Close();
            }
            #endregion

            #region Upload File To the Database

            ENums.UploadXMLType uploadXMLType = (ENums.UploadXMLType)Enum.Parse(typeof(ENums.UploadXMLType), uploadType);
            XmlDocument         xmlMappingDoc = XMLHelper.LoadXML(uploadXMLType);
            //XmlDocument xd = new XmlDocument();
            ////xd.LoadXml(uploadXMLType);
            //UploadServices uploadServices = new UploadServices();
            //Response.Write("abc");
            //bool uploaded = uploadServices.HandleUploadedFile(BookingId, uploadXMLType, RecordList);
            bool uploaded = tourisst.processUplodedFile(BookingId, RecordList, xmlMappingDoc);

            #endregion

            #region Validating Response
            if (uploaded)
            {
                msg = "File uploaded and processed successfully.";
                base.DisplayAlert(msg);
                Response.Redirect("~\\ClientUI\\ViewTourists.aspx?bid=" + BookingId.ToString());
            }
            else
            {
                msg = "File is not processed successfully. Please try again.";
                base.DisplayAlert(msg);
            }
            msg = "The file has been uploaded.";
            base.DisplayAlert(msg);
            #endregion
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
            msg = "File is not uploaded successfully, please try again, or contact your system administrator.";
            base.DisplayAlert(msg);
            GF.LogError("uploader.Submit", ex.Message);
            System.IO.StringWriter sw = new System.IO.StringWriter();
            sw.Write(msg);
            HtmlTextWriter tw = new HtmlTextWriter(sw);

            tw.Write(msg + " " + ex.Message);
            tw.Write(ex.StackTrace);

            //Note: Exception.Message returns detailed message that describes the current exception.
            //For security reasons, we do not recommend you return Exception.Message to end users in
            //production environments. It would be better just to put a generic error message.
        }
    }