示例#1
0
        public String GetFilesList(String master_value)
        {
            Dictionary <String, String> dic = new Dictionary <String, String>();
            //String BasePath = Request.PhysicalApplicationPath;
            String         BasePath    = Server.MapPath("~/");
            ReturnAjaxData rAjaxResult = new ReturnAjaxData();

            try
            {
                String[] Files = Directory.GetFiles(BasePath + master_value);
                foreach (String S in Files)
                {
                    FileInfo Fi = new FileInfo(S);
                    dic.Add(Fi.Name, Fi.FullName.Replace(BasePath, ""));
                }
                rAjaxResult.result = true;
                rAjaxResult.data   = dic;
            }
            catch (Exception ex)
            {
                rAjaxResult.result  = false;
                rAjaxResult.message = ex.Message;
            }
            JavaScriptSerializer js = new JavaScriptSerializer()
            {
                MaxJsonLength = 65536
            };                                                                              //64K

            return(js.Serialize(rAjaxResult));
        }
示例#2
0
        public String ajax_SQLExecute(String SQL)
        {
            ReturnAjaxData rAjaxResult = new ReturnAjaxData();
            JavaScriptSerializer js = new JavaScriptSerializer() { MaxJsonLength = 65536 }; //64K
            String r = String.Empty;

            try
            {
                DataTable dt = getSQLConnection().ExecuteData(SQL);
                List<String> ColumnName = new List<String>();
                foreach (DataColumn dc in dt.Columns)
                {
                    ColumnName.Add(dc.ColumnName);
                }

                List<String[]> Rows = new List<String[]>();
                foreach (DataRow dr in dt.Rows)
                {
                    List<String> Cells = new List<String>();
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        Cells.Add(dr[i].ToString());
                    }
                    Rows.Add(Cells.ToArray());
                }

                r = js.Serialize(new { Columns = ColumnName.ToArray(), DataItems = Rows.ToArray(), result = true, message = "" });
            }
            catch (Exception ex)
            {
                r = js.Serialize(new { result = false, message = ex.Message });
            }
            return r;
        }
示例#3
0
        protected ReturnAjaxData HandleResultAjaxData <m>(RunOneDataEnd <m> h, String ReturnTrueMessage) where m : ModuleBase
        {
            ReturnAjaxData r = new ReturnAjaxData();

            if (!h.Result)
            {
                if (h.ErrType == BusinessErrType.Logic)
                {
                    r.result  = false;
                    r.message = GetRecMessage(h.Message);;
                    r.title   = Resources.Res.Log_Err_Title;
                    r.errtype = ReturnErrType.Logic;
                }

                if (h.ErrType == BusinessErrType.System)
                {
                    r.result  = false;
                    r.message = h.Message;
                    r.title   = Resources.Res.Sys_Err_Title;
                    r.errtype = ReturnErrType.System;
                }
            }
            else
            {
                r.result = true;
                r.data   = h.SearchData;
                if (h.Message == "")
                {
                    r.message = ReturnTrueMessage;
                }

                else
                {
                    r.title   = Resources.Res.Info_SystemAlert;
                    r.message = GetRecMessage(h.Message);;
                }
            }
            return(r);
        }
示例#4
0
        public String ajax_SQLExecute(String SQL)
        {
            ReturnAjaxData       rAjaxResult = new ReturnAjaxData();
            JavaScriptSerializer js          = new JavaScriptSerializer()
            {
                MaxJsonLength = 65536
            };                                                                              //64K
            String r = String.Empty;

            try
            {
                DataTable     dt         = getSQLConnection().ExecuteData(SQL);
                List <String> ColumnName = new List <String>();
                foreach (DataColumn dc in dt.Columns)
                {
                    ColumnName.Add(dc.ColumnName);
                }

                List <String[]> Rows = new List <String[]>();
                foreach (DataRow dr in dt.Rows)
                {
                    List <String> Cells = new List <String>();
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        Cells.Add(dr[i].ToString());
                    }
                    Rows.Add(Cells.ToArray());
                }

                r = js.Serialize(new { Columns = ColumnName.ToArray(), DataItems = Rows.ToArray(), result = true, message = "" });
            }
            catch (Exception ex)
            {
                r = js.Serialize(new { result = false, message = ex.Message });
            }
            return(r);
        }
示例#5
0
 public String GetFilesList(String master_value)
 {
     Dictionary<String, String> dic = new Dictionary<String, String>();
     //String BasePath = Request.PhysicalApplicationPath;
     String BasePath = Server.MapPath("~/");
     ReturnAjaxData rAjaxResult = new ReturnAjaxData();
     try
     {
         String[] Files = Directory.GetFiles(BasePath + master_value);
         foreach (String S in Files)
         {
             FileInfo Fi = new FileInfo(S);
             dic.Add(Fi.Name, Fi.FullName.Replace(BasePath, ""));
         }
         rAjaxResult.result = true;
         rAjaxResult.data = dic;
     }
     catch (Exception ex)
     {
         rAjaxResult.result = false;
         rAjaxResult.message = ex.Message;
     }
     JavaScriptSerializer js = new JavaScriptSerializer() { MaxJsonLength = 65536 }; //64K
     return js.Serialize(rAjaxResult);
 }