Ejemplo n.º 1
0
        //Set the region by timezone on the nomad
        private void SetRegion()
        {
            try
            {
                //Get the regions based on the Windows settings 
                Hashtable regions = Utilities.GenerateRegionList();

                if (null != regions)
                {
                    try
                    {
                        string r = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString();
                        properties["region"] = regions[r].ToString();
                    }
                    catch
                    {
                        RegionSelection objRegion = new RegionSelection(rsess.Reader, (Reader.Region[])rsess.Reader.ParamGet("/reader/region/supportedRegions"));
                        objRegion.ShowDialog();
                        properties = Utilities.GetProperties();
                    }
                }
                //If the saved region is empty or saved region is conflicted with timezone selection
                if ((savedRegion == "") || (savedRegion != properties["region"]))
                {
                    //Set the region based on the productGroupID 
                    UInt16 productGroupID = (UInt16)rsess.Reader.ParamGet("/reader/version/productGroupID");
                    if (productGroupID == 2)//NA
                    {

                        UInt16 productid = (UInt16)rsess.Reader.ParamGet("/reader/version/productID");
                        switch (productid)
                        {
                            case USB_READER: break;
                            case NA_ANTENNA:
                                //Antenna NA (product id 2)
                                List<Reader.Region> regionsSuuportedbyAntennaNA = new List<Reader.Region>();
                                regionsSuuportedbyAntennaNA.Add(Reader.Region.NA);
                                regionsSuuportedbyAntennaNA.Add(Reader.Region.AU);
                                regionsSuuportedbyAntennaNA.Add(Reader.Region.PRC);
                                
                                if (!regionsSuuportedbyAntennaNA.Contains((Reader.Region)Enum.Parse(typeof(Reader.Region), properties["region"].ToString(), true)))
                                {
                                    RegionSelection objRegion = new RegionSelection(rsess.Reader, regionsSuuportedbyAntennaNA.ToArray());
                                    objRegion.ShowDialog();
                                    properties = Utilities.GetProperties();
                                }
                                //If user not selected the region in region selection screen
                                if (properties["region"] == "")
                                {                                 
                                    properties["region"] = ((savedRegion == "")?"na":savedRegion);
                                }
                                break;
                            case EU_ANTENNA:
                                //Antenna EU(product id 3)
                                List<Reader.Region> regionsSuuportedbyAntennaEU = new List<Reader.Region>();
                                regionsSuuportedbyAntennaEU.Add(Reader.Region.EU3);
                                regionsSuuportedbyAntennaEU.Add(Reader.Region.IN);
                                regionsSuuportedbyAntennaEU.Add(Reader.Region.NZ);

                                if (!regionsSuuportedbyAntennaEU.Contains((Reader.Region)Enum.Parse(typeof(Reader.Region), properties["region"].ToString(), true)))
                                {
                                    RegionSelection objRegion = new RegionSelection(rsess.Reader, regionsSuuportedbyAntennaEU.ToArray());
                                    objRegion.ShowDialog();
                                    properties = Utilities.GetProperties();
                                }
                                //If user not selected the region in region selection screen
                                if (properties["region"] == "")
                                {
                                    properties["region"] = ((savedRegion == "") ? "eu3" : savedRegion);
                                }
                                break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("In SetRegion(): " + ex.ToString());
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 2
0
        //Set the region by timezone on the nomad
        private void SetRegion()
        {
            try
            {
                //Get the regions based on the Windows settings
                Hashtable regions = Utilities.GenerateRegionList();

                if (null != regions)
                {
                    try
                    {
                        string r = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString();
                        properties["region"] = regions[r].ToString();
                    }
                    catch
                    {
                        RegionSelection objRegion = new RegionSelection(rsess.Reader, (Reader.Region[])rsess.Reader.ParamGet("/reader/region/supportedRegions"));
                        objRegion.ShowDialog();
                        properties = Utilities.GetProperties();
                    }
                }
                //If the saved region is empty or saved region is conflicted with timezone selection
                if ((savedRegion == "") || (savedRegion != properties["region"]))
                {
                    //Set the region based on the productGroupID
                    UInt16 productGroupID = (UInt16)rsess.Reader.ParamGet("/reader/version/productGroupID");
                    if (productGroupID == 2)//NA
                    {
                        UInt16 productid = (UInt16)rsess.Reader.ParamGet("/reader/version/productID");
                        switch (productid)
                        {
                        case USB_READER: break;

                        case NA_ANTENNA:
                            //Antenna NA (product id 2)
                            List <Reader.Region> regionsSuuportedbyAntennaNA = new List <Reader.Region>();
                            regionsSuuportedbyAntennaNA.Add(Reader.Region.NA);
                            regionsSuuportedbyAntennaNA.Add(Reader.Region.AU);
                            regionsSuuportedbyAntennaNA.Add(Reader.Region.PRC);

                            if (!regionsSuuportedbyAntennaNA.Contains((Reader.Region)Enum.Parse(typeof(Reader.Region), properties["region"].ToString(), true)))
                            {
                                RegionSelection objRegion = new RegionSelection(rsess.Reader, regionsSuuportedbyAntennaNA.ToArray());
                                objRegion.ShowDialog();
                                properties = Utilities.GetProperties();
                            }
                            //If user not selected the region in region selection screen
                            if (properties["region"] == "")
                            {
                                properties["region"] = ((savedRegion == "")?"na":savedRegion);
                            }
                            break;

                        case EU_ANTENNA:
                            //Antenna EU(product id 3)
                            List <Reader.Region> regionsSuuportedbyAntennaEU = new List <Reader.Region>();
                            regionsSuuportedbyAntennaEU.Add(Reader.Region.EU3);
                            regionsSuuportedbyAntennaEU.Add(Reader.Region.IN);
                            regionsSuuportedbyAntennaEU.Add(Reader.Region.NZ);

                            if (!regionsSuuportedbyAntennaEU.Contains((Reader.Region)Enum.Parse(typeof(Reader.Region), properties["region"].ToString(), true)))
                            {
                                RegionSelection objRegion = new RegionSelection(rsess.Reader, regionsSuuportedbyAntennaEU.ToArray());
                                objRegion.ShowDialog();
                                properties = Utilities.GetProperties();
                            }
                            //If user not selected the region in region selection screen
                            if (properties["region"] == "")
                            {
                                properties["region"] = ((savedRegion == "") ? "eu3" : savedRegion);
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("In SetRegion(): " + ex.ToString());
                MessageBox.Show(ex.Message);
            }
        }