Example #1
0
 public HttpResponseBase Import()
 {
     string json = string.Empty;
     try
     {
         EdmGroupEmailQuery query = new EdmGroupEmailQuery();
         if (!string.IsNullOrEmpty(Request.Params["ImportCsv"]))
         {
             query.group_id = Convert.ToUInt32(Request.Params["group_id"]);
             HttpPostedFileBase file = Request.Files["ImportCsv"];
             FileManagement fileManagement = new FileManagement();
             string fileName = fileManagement.NewFileName(file.FileName);
             string newFileName = Server.MapPath(excelPath_export) + fileName;
             file.SaveAs(newFileName);
             DataTable _dt = CsvHelper.ReadCsvToDataTable_CN(newFileName, true);
             _edmGroup = new EdmGroupMgr(mySqlConnectionString);
             json = _edmGroup.Import(_dt, query);
         }
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }