public class SysOperation
{
public SysOperation() {}
public static string OpenDialog(string msg)
{
return ("<script>alert('"+ msg +"')</script>");
}
public static bool StringNullChecked(string str)
{
if (str == null || str == "" || str.Length < 1)
{ return false; }
return true;
}
public static void SetListSelected(DropDownList list,string value)
{
if(list.Items.Count < 0 )
{
list.SelectedIndex = -1;
return;
}
for(int i=0; i < list.items.Count; i++)
{
if(list.Items[i].Value == value)
{
list.SelectedIndex = i;
return;
}
}
list.SelectedIndex = -1;
}
public static void SetListSelected(ListBox list,string value)
{
if(list.Items.Count <= 0)
{
list.SelectedIndex = -1;
return;
}
for(int i=0; i < list.Items.Count; i++)
{
if(list.Items[i].Value == value)
{
list.SelectedIndex = i;
return; }
}
list.SelectedIndex = -1;
}
public static string FormatErrorUrl(string url)
{
if(url.IndexOf("?")>0)
{ return (url.Substring(0,url,IndexOf("?")))}
return (url);
}
public static string FormatErrorPageUrl(string url,string msg)
{
return ("~/Portal/ErrorPage.aspx?ErrorMsg="+msg
+ "&ErrorUrl="+url.Replace("/n","").Replace("/t",""));
}
public static DataSet CacheCatalogData()
{
ICatalog catalog = new Catalog();
DataSet ds = (DataSet)SQLHelper.CacheData.GetCacheValue(SystemConst.Catalog_Cache_Value_Key);
if(ds==null)
{
ds = new DataSet();
catalog.GetCatalogDS(ref ds);
SQLHelper.CacheData.CacheObjectValue(SystemConst.Catalog_Cache_Value_Key,(object)ds);
}
return ds;
}
public static string CreateFileNameByDateTime()
{
DateTime now = DateTime.Now;
string fileName =now.Year.ToString()
+now.Month.ToString()
+now.Day.ToString()
+now.Hour.ToString()
+now.Minute.ToString()
+now.Second.ToString()
+now.Millisecond.ToString();
return (fileName);
}
public static string FormatStringLength(string str,int length)
{
if(SysOperation.StringNullChecked(str) == false)
{
return string.Empty;
}
if(Encoding.UTF8.GetByteCount(str) > str.Length)
{
length = length/2;
}
if(str.Length > length)
{
return str.Substring(0,length)+"...";
}
return str;
}
}