示例#1
0
        public IActionResult ContactImport_Upload()
        {
            if (!B_ARoleAuth.AuthCheckEx(ZLEnum.Auth.office, "crm"))
            {
            }
            var file = Request.Form.Files["file_up"];

            if (file == null)
            {
                return(WriteErr("未指定文件"));
            }
            if (file.Length < 100)
            {
                return(WriteErr("文件为空"));
            }
            string ext = Path.GetExtension(file.FileName).ToLower();

            if (ext != ".xlsx")
            {
                return(WriteErr("只允许上传xlsx文件"));
            }
            DataTable excelDT = Import_Logical.Excel_ToDT(XMLPath_Contact, file.OpenReadStream());

            //将数据直接写入数据库,或将其转换为模型再写入
            foreach (DataRow dr in excelDT.Rows)
            {
                M_CRMS_Contact model = new M_CRMS_Contact().GetModelFromReader(dr);
                contactBll.Insert(model);
            }
            return(WriteOK("联系人导入成功", "ClientImport"));
        }
示例#2
0
        public IActionResult Import_Submit()
        {
            var file = Request.Form.Files["file_up"];

            if (file == null)
            {
                return(WriteErr("未指定文件"));
            }
            if (file.Length < 100)
            {
                return(WriteErr("文件为空"));
            }
            string ext = Path.GetExtension(file.FileName).ToLower();

            if (ext != ".xlsx")
            {
                return(WriteErr("只允许上传xlsx文件"));
            }
            //-------------------------
            DataTable   excelDT = Import_Logical.Excel_ToDT(XMLPath, file.OpenReadStream());
            B_CodeModel codeBll = new B_CodeModel(excelDT.TableName);
            DataTable   modelDT = codeBll.SelStruct();

            //将数据直接写入数据库,或将其转换为模型再写入
            foreach (DataRow dr in excelDT.Rows)
            {
                //将第一列作为主键忽略掉
                codeBll.Insert(dr, modelDT.Columns[0].ColumnName);
            }
            return(WriteOK("数据导入完成"));
        }
示例#3
0
        public void Import_Client()
        {
            if (!B_ARoleAuth.AuthCheckEx(ZLEnum.Auth.office, "crm"))
            {
                return;
            }
            var file = Request.Files["file_up"];

            if (file == null)
            {
                function.WriteErrMsg("未指定文件"); return;
            }
            if (file.ContentLength < 100)
            {
                function.WriteErrMsg("文件为空"); return;
            }
            string ext = Path.GetExtension(file.FileName).ToLower();

            if (ext != ".xlsx")
            {
                function.WriteErrMsg("只允许上传xlsx文件"); return;
            }
            DataTable excelDT = Import_Logical.Excel_ToDT(XMLPath_Client, file.InputStream);
            DataTable typeDT  = attrBll.Sel("ctype");

            //将数据直接写入数据库,或将其转换为模型再写入
            foreach (DataRow dr in excelDT.Rows)
            {
                M_CRMS_Client model = new M_CRMS_Client().GetModelFromReader(dr);
                //clientType统一让用户填中文,转化为中文
                //model.ClientType = StrHelper.IdsFormat(model.ClientType);
                #region ClientType
                if (!string.IsNullOrEmpty(model.ClientType))
                {
                    model.ClientType = model.ClientType.Replace(" ", "");
                    string[] ctypeArr = model.ClientType.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    foreach (string ctype in ctypeArr)
                    {
                        typeDT.DefaultView.RowFilter = "Value='" + ctype + "'";
                        if (typeDT.DefaultView.ToTable().Rows.Count < 1)
                        {
                            //新增ClientType
                            M_CRMS_Attr attrMod = new M_CRMS_Attr();
                            attrMod.ZType = "ctype";
                            attrMod.Value = ctype;
                            attrBll.Insert(attrMod);
                            typeDT = attrBll.Sel("ctype");
                        }
                    }
                }
                #endregion
                clientBll.Insert(model);
            }
            function.WriteSuccessMsg("客户信息导入成功", "ClientImport");
        }
示例#4
0
 public void ContactImport_Down()
 {
     Import_Logical.Excel_CreateByXML(XMLPath_Contact, "ContactTlp");
 }
示例#5
0
 public void Import_DownTlp()
 {
     //string csv = Import_Logical.CreateCSVByXML(XMLPath_Client);
     //SafeC.DownStr(csv, "客户模板.xls", Encoding.Default);
     Import_Logical.Excel_CreateByXML(XMLPath_Client, "ClientTlp");
 }
示例#6
0
 public IActionResult Import_DownTlp()
 {
     Import_Logical.Excel_CreateByXML(XMLPath, "Template");
     return(View());
 }