public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            HttpPostedFile file = context.Request.Files["Filedata"];


            if (file != null)
            {
                string AreaId = context.Request.Form["AreaId"];
                IList <StringObjectDictionary> datas      = NPOIManager.GetSheetData(file.InputStream, 0, true);
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                FamilyMember familyMember = new FamilyMember()
                {
                    DataSource = GlobalManager.DIKey_00012_UploadFile, OperatedBy = NormalSession.UserId.ToGuid(), OperatedOn = DateTime.Now, AreaId = AreaId
                };
                foreach (var data in datas)
                {
                    familyMember.FamilyMemberId = Guid.NewGuid();
                    StringObjectDictionary       sod      = familyMember.ToStringObjectDictionary(false);
                    IDictionary <string, object> dataItem = sod.MixInObject(data, false, e0571.web.core.Other.CaseSensitive.NORMAL);

                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = familyMember.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                    });
                }
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            HttpPostedFile file = context.Request.Files["Filedata"];

            if (file != null)
            {
                string AreaId          = context.Request.Form["AreaId"];
                string AreaId2         = context.Request.Form["AreaId2"];
                string AreaId3         = context.Request.Form["AreaId3"];
                string conectId        = context.Request.Form["ConnectId"];
                string iResidentStatus = context.Request.Form["ResidentStatus"];
                int    iStatus         = int.Parse(context.Request.Form["Status"]);

                IList <StringObjectDictionary> datas      = NPOIManager.GetSheetData(file.InputStream, 0, true);
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();

                //数据转换
                List <ExcelError> errors = new List <ExcelError>();
                IList <StringObjectDictionary> basedatas = RetEffectiveDatas(datas, errors);

                XlsOfResidentBaseInfo residentBaseInfo = new XlsOfResidentBaseInfo()
                {
                    Status = (byte)iStatus, DataSource = GlobalManager.DIKey_00012_UploadFile, OperatedBy = NormalSession.UserId.ToGuid(), OperatedOn = DateTime.Now, AreaId = AreaId
                };
                foreach (var data in basedatas)
                {
                    residentBaseInfo.ResidentId = Guid.NewGuid();
                    StringObjectDictionary       sod      = residentBaseInfo.ToStringObjectDictionary(false);
                    IDictionary <string, object> dataItem = sod.MixInObject(data, false, e0571.web.core.Other.CaseSensitive.NORMAL);
                    dataItem["AreaId2"]        = AreaId2;
                    dataItem["AreaId3"]        = AreaId3;
                    dataItem["ResidentStatus"] = iResidentStatus;

                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = residentBaseInfo.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                    });
                }
                //先清空临时表
                BuilderFactory.DefaultBulder(conectId).ExecuteNativeSqlNoneQuery("Truncate table Tmp_XlsOfResidentBaseInfo");
                //插入数据
                BuilderFactory.DefaultBulder(conectId).ExecuteNativeSqlNoneQuery(statements);
                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                context.Response.Write(errors.ToJson());
            }
            else
            {
                context.Response.Write("0");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            HttpPostedFile file = context.Request.Files["Filedata"];


            if (file != null)
            {
                string parentId = context.Request.Form["AreaId"];
                //Guid areaId = new Guid(areaIdStr);
                IList <StringObjectDictionary> datas      = NPOIManager.GetSheetData(file.InputStream, 0, true);
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                Area area = new Area()
                {
                    ParentId = parentId, Status = 1, CheckInTime = DateTime.Now
                };
                foreach (var data in datas)
                {
                    StringObjectDictionary       sod      = area.ToStringObjectDictionary(false);
                    IDictionary <string, object> dataItem = sod.MixInObject(data, false, e0571.web.core.Other.CaseSensitive.NORMAL);

                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = area.GetCreateMethodName(), ParameterObject = dataItem, Type =

                            SqlExecuteType.INSERT
                    });
                }
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);

                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            HttpPostedFile file = context.Request.Files["Filedata"];

            if (file != null)
            {
                string AreaId        = context.Request.Form["AreaId"];
                string retFailInfo   = "";
                int    relationOfMan = 99999;
                int    count         = 0;

                IList <StringObjectDictionary> datas      = NPOIManager.GetSheetData(file.InputStream, 0, true);
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                List <IBatisNetBatchStatement> oldmanconfig_statements = new List <IBatisNetBatchStatement>();
                List <IBatisNetBatchStatement> familymember_statements = new List <IBatisNetBatchStatement>();
                List <IBatisNetBatchStatement> oldmanfamily_statements = new List <IBatisNetBatchStatement>();

                //获取图片
                //NPOI.HSSF.UserModel.HSSFWorkbook hssfworkbook = new NPOI.HSSF.UserModel.HSSFWorkbook(file.InputStream);
                //NPOI.SS.UserModel.ISheet sheet = hssfworkbook.GetSheetAt(0);
                //Dictionary<string, Byte[]> picDataDictionary = getSheetPictrues03((NPOI.HSSF.UserModel.HSSFSheet)sheet);
                //获取所有老人基本信息
                IList <OldManBaseInfo> oldManBaseInfoList = RetExistsIdNo(AreaId);
                //获取所有老人配置终端信息
                IList <OldManConfigInfo> oldManConfigInfoList = RetAllConfigCallNo();
                //获取所有老人的亲属资料
                IList <StringObjectDictionary> familyMemberList = RetAllFamilyMember();
                //获取所有街道社区信息
                IList <Area> AreaList = RetAllStreetCommunity();
                //保存图片地址
                //基本信息
                IList <StringObjectDictionary> basedatas = RetEffectiveDatas(datas, ref retFailInfo);
                OldManBaseInfo baseInfo = new OldManBaseInfo()
                {
                    DataSource = GlobalManager.DIKey_00012_UploadFile, OperatedBy = NormalSession.UserId.ToGuid(), OperatedOn = DateTime.Now, AreaId = AreaId
                };
                OldManConfigInfo oldmanconfig = new OldManConfigInfo();
                FamilyMember     familymember = new FamilyMember()
                {
                    Gender = "M", IDNo = "", Status = 1
                };
                OldManFamilyInfo oldmanfamily = new OldManFamilyInfo();

                foreach (var data in basedatas)
                {
                    //老人基本资料
                    baseInfo.OldManId = Guid.NewGuid();
                    count             = oldManBaseInfoList.Count(s => s.IDNo == data["IDNo"].ToString());
                    if (count > 0)
                    {
                        baseInfo.OldManId = oldManBaseInfoList.First(s => s.IDNo == data["IDNo"].ToString()).OldManId;
                    }
                    baseInfo.Status = 1;
                    baseInfo.HealthInsuranceFlag = Convert.ToByte(data["HealthInsuranceNumber"] != null);
                    baseInfo.SocialInsuranceFlag = Convert.ToByte(data["SocialInsuranceNumber"] != null);
                    StringObjectDictionary       sod      = baseInfo.ToStringObjectDictionary(false);
                    IDictionary <string, object> dataItem = sod.MixInObject(data, false, e0571.web.core.Other.CaseSensitive.NORMAL);

                    var tmpArea = AreaList.FirstOrDefault(s => s.AreaName.IndexOf(dataItem["AreaId2"].ToString()) > -1);
                    if (dataItem.ContainsKey("AreaId2") && dataItem["AreaId2"] != null && tmpArea != null)
                    {
                        dataItem["AreaId2"] = tmpArea.AreaId != null?tmpArea.AreaId.ToString().ToUpper() : "";
                    }
                    else
                    {
                        dataItem.Remove("AreaId2");
                    }
                    tmpArea = AreaList.FirstOrDefault(s => s.AreaName.IndexOf(dataItem["AreaId3"].ToString()) > -1);
                    if (dataItem.ContainsKey("AreaId3") && dataItem["AreaId3"] != null && tmpArea != null)
                    {
                        dataItem["AreaId3"] = tmpArea.AreaId != null?tmpArea.AreaId.ToString().ToUpper() : "";
                    }
                    else
                    {
                        dataItem.Remove("AreaId3");
                    }

                    if (count > 0)
                    {
                        statements.Add(new IBatisNetBatchStatement {
                            StatementName = baseInfo.GetUpdateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.UPDATE
                        });
                    }
                    else
                    {
                        statements.Add(new IBatisNetBatchStatement {
                            StatementName = baseInfo.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                        });
                    }
                    //老人呼叫设备资料,存在则跳过
                    if (dataItem.ContainsKey("CallNo") && dataItem["CallNo"] != null)
                    {
                        if (oldManConfigInfoList.Count(s => s.CallNo == dataItem["CallNo"].ToString()) == 0)
                        {
                            var configinfoitem = oldManConfigInfoList.FirstOrDefault(s => s.OldManId.ToString() == dataItem["OldManId"].ToString());
                            if (configinfoitem != null && configinfoitem.OldManId != null)
                            {
                                oldmanconfig_statements.Add(new IBatisNetBatchStatement {
                                    StatementName = oldmanconfig.GetUpdateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.UPDATE
                                });
                            }
                            else
                            {
                                oldmanconfig_statements.Add(new IBatisNetBatchStatement {
                                    StatementName = oldmanconfig.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                                });
                            }
                        }
                    }

                    //获取亲人信息
                    StringObjectDictionary sod2 = new StringObjectDictionary();
                    for (int i = 0; i < 3; i++)
                    {
                        string familyName = "FamilyName" + (i + 1).ToString();
                        string callNo     = "CallNo" + (i + 1).ToString();
                        if (!data.ContainsKey(familyName) || data[familyName] == null)
                        {
                            continue;
                        }
                        if (!data.ContainsKey(callNo) || data[callNo] == null)
                        {
                            continue;
                        }

                        oldmanfamily.RelationIdOfFamily = (relationOfMan - i).ToString();
                        oldmanfamily.RelationIdOfOldMan = (relationOfMan - i).ToString();

                        string callNoData = data[callNo].ToString();
                        familymember.FamilyMemberId   = Guid.NewGuid();
                        familymember.FamilyMemberName = data[familyName].ToString();
                        //匹配手机号
                        familymember.Mobile = System.Text.RegularExpressions.Regex.Match(callNoData, @"0*[1][358]\d{9}").Value;
                        if (familymember.Mobile.Length > 0)
                        {
                            callNoData = callNoData.Replace(familymember.Mobile, "");
                        }
                        //匹配座机
                        familymember.Tel = System.Text.RegularExpressions.Regex.Match(callNoData, @"((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))").Value;

                        if (count > 0)
                        {
                            sod2 = familyMemberList.FirstOrDefault(s => s["OldManId"].ToString() == baseInfo.OldManId.ToString() && s["RelationIdOfFamily"].ToString() == oldmanfamily.RelationIdOfFamily);
                            if (sod2 != null && sod2.Count > 0)
                            {
                                if (familyMemberList.Count(s => s["FamilyMemberName"].ToString() == familymember.FamilyMemberName && s["Mobile"].ToString() == familymember.Mobile && s["Tel"].ToString() == familymember.Tel) > 0)
                                {
                                    continue;
                                }
                                familymember.FamilyMemberId = sod2["FamilyMemberId"].ToString().ToGuid();
                            }
                        }
                        sod      = baseInfo.ToStringObjectDictionary(false);
                        dataItem = sod.MixInObject(familymember, false, e0571.web.core.Other.CaseSensitive.NORMAL);
                        if (sod2 != null && sod2.Count > 0)
                        {
                            familymember_statements.Add(new IBatisNetBatchStatement {
                                StatementName = familymember.GetUpdateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.UPDATE
                            });
                        }
                        else
                        {
                            familymember_statements.Add(new IBatisNetBatchStatement {
                                StatementName = familymember.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                            });
                            dataItem = sod.MixInObject(oldmanfamily, false, e0571.web.core.Other.CaseSensitive.NORMAL);
                            oldmanfamily_statements.Add(new IBatisNetBatchStatement {
                                StatementName = oldmanfamily.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                            });
                        }
                    }
                }

                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(oldmanconfig_statements);
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(familymember_statements);
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(oldmanfamily_statements);


                /*string saveName = @context.Request["saveName"];
                 * string fileType = file.FileName.Substring(file.FileName.LastIndexOf("."));
                 * string uploadPath = HttpContext.Current.Server.MapPath(@context.Request["folder"]);
                 * FileAdapter.EnsurePath(uploadPath);
                 * if (string.IsNullOrEmpty(saveName))
                 * {
                 *  file.SaveAs(uploadPath + file.FileName);
                 * }
                 * else
                 * {
                 *  file.SaveAs(uploadPath + saveName + fileType);
                 * }
                 */
                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }