ERROR WHEN CULTURE IS SET TO ar-SA

Last post 01-18-2011, 3:47 AM by hassan. 9 replies.
Sort Posts: Previous Next
  •  01-11-2011, 3:49 AM 65668

    ERROR WHEN CULTURE IS SET TO ar-SA

    The following error occurs iof you set the Culture to ar-SA. It might be that it is not recognising the date as the date in this culture is around 1429:
     
     exception:The DateTime represented by the string is not supported in calendar System.Globalization.UmAlQuraCalendar
  •  01-11-2011, 8:32 AM 65675 in reply to 65668

    Re: ERROR WHEN CULTURE IS SET TO ar-SA

    Dear hassan,
     
    How did you set the culture to "ar-SA", can you post your code here?
     
    Thank you for askfing
  •  01-11-2011, 2:39 PM 65679 in reply to 65675

    Re: ERROR WHEN CULTURE IS SET TO ar-SA

    we set the culture based o the users country (from their IP) in the following way
     
    This code is palced by overriding the Controllers's (in MVC)  OnActionExecuting(ActionExecutingContext filterContext)
     
    so the whole thing is
     

    protected override void OnActionExecuting(ActionExecutingContext filterContext)

    {

    base.OnActionExecuting(filterContext);

    System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(Session["Culture"].ToString());

    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Session["Culture"].ToString());

     

    }

  •  01-11-2011, 5:03 PM 65680 in reply to 65679

    Re: ERROR WHEN CULTURE IS SET TO ar-SA

    Dear hassan,
     
    exception:The DateTime represented by the string is not supported in calendar System.Globalization.UmAlQuraCalendar
     
    Please check the value of the string, it is an invalid value, it should be the reason that leads to your issue.
    The UmAlQuraCalendar class supports only dates from 04/30/1900 00.00.00 (Gregorian date) through 05/13/2029 23:59:59 (Gregorian date).
     
    Thank you for asking
  •  01-11-2011, 5:43 PM 65681 in reply to 65680

    Re: ERROR WHEN CULTURE IS SET TO ar-SA

    Eric,
    we are not doing any Date manipulations or passing any string to anything for the string to be incorrect. All we are doing is setting the culture as stated above and then just do a simple file upload with the uploader. The line that breaks the code is:
    CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);
    If you test this, you should get the same issue. Please advise!
    Many Thanks
  •  01-13-2011, 8:57 PM 65717 in reply to 65681

    Re: ERROR WHEN CULTURE IS SET TO ar-SA

    Any news on this issue. Please check this for yourself and you will see that it is the uploader that is causing the problem.
  •  01-14-2011, 9:15 AM 65725 in reply to 65717

    Re: ERROR WHEN CULTURE IS SET TO ar-SA

    Dear hassan,
     
    Please extract your code to one runnable example which can reproduce this issue,  you can post it here or send it to eric@cutesoft.net , I will run it on my end and check this issue.
     
    Thank you for asking
  •  01-14-2011, 6:52 PM 65729 in reply to 65725

    Re: ERROR WHEN CULTURE IS SET TO ar-SA

    Eric,
    Not do we have to find the BUGS, we also have to create an application and put it on a Plate for you!!!!! Really.
     
    All I did, was to take your own demo sample MVC2 application and added the following to the SampleController (which by the way would take you 5 seconds at most to do!!!) . Then just use your sample 1 view to upload a file and you will get the error I have been discussing.
     

    protected override void OnActionExecuting(ActionExecutingContext filterContext)

    {

    base.OnActionExecuting(filterContext);System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("ar-SA");

    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-SA");

    }
     
    Hopefully you now feel we have done enough of your work for you to be able to do the rest of it !!!
    Thanks.
  •  01-17-2011, 8:26 PM 65753 in reply to 65729

    Re: ERROR WHEN CULTURE IS SET TO ar-SA

    Hi hassan,
     
    This issue only happen on the trial license. Please change the CurrentCulture to "en-Us" before method below(red code) and than change back to "ar-SA" after it.
     
    CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);
     
     
    Below is the new code of Sample1
     
    1. public ActionResult Sample1(string myuploader)  
    2.         {  
    3.             using (CuteWebUI.MvcUploader uploader = new CuteWebUI.MvcUploader(System.Web.HttpContext.Current))  
    4.             {  
    5.                 uploader.UploadUrl = Response.ApplyAppPathModifier("~/UploadHandler.ashx");  
    6.                 //the data of the uploader will render as <input type='hidden' name='myuploader'>   
    7.                 uploader.Name = "myuploader";  
    8.                 uploader.AllowedFileExtensions = "*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar";  
    9.   
    10.                 uploader.InsertText = "Select a file to upload";  
    11.   
    12.                 //prepair html code for the view  
    13.                 ViewData["uploaderhtml"] = uploader.Render();  
    14.   
    15.                 //if it's HTTP POST:  
    16.                 System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-Us");  
    17.                 if (!string.IsNullOrEmpty(myuploader))  
    18.                 {  
    19.                     //for single file , the value is guid string  
    20.                     Guid fileguid = new Guid(myuploader);  
    21.                   
    22.                     CuteWebUI.MvcUploadFile file = uploader.GetUploadedFile(fileguid);  
    23.                     if (file != null)  
    24.                     {  
    25.                         //you should validate it here:  
    26.   
    27.                         //now the file is in temporary directory, you need move it to target location  
    28.                         //file.MoveTo("~/myfolder/" + file.FileName);  
    29.   
    30.                         //set the output message  
    31.                         ViewData["UploadedMessage"] = "The file " + file.FileName + " has been processed.";  
    32.                     }  
    33.                 }  
    34.                 System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("ar-SA");  
    35.   
    36.             }  
    37.   
    38.             return View();  
    39.         } 
     Regards,
     
    Ken
  •  01-18-2011, 3:47 AM 65767 in reply to 65753

    Re: ERROR WHEN CULTURE IS SET TO ar-SA

    hi Ken,
     
    Many thanks for your response.
     
    We don't really want to set the culture in this section of code as we prefer to keep it in the base controller class. However, if this is an issue only with the trial license , I am on my way to get the full license.
View as RSS news feed in XML