public ModelInvokeResult <OldManFamilyInfoPK> Nullify(string strId)
        {
            ModelInvokeResult <OldManFamilyInfoPK> result = new ModelInvokeResult <OldManFamilyInfoPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                int _Id = Convert.ToInt32(strId);
                OldManFamilyInfo oldManFamilyInfo = new OldManFamilyInfo {
                    Id = _Id, Status = 0
                };
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = oldManFamilyInfo.GetUpdateMethodName(), ParameterObject = oldManFamilyInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                });
                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new OldManFamilyInfoPK {
                    Id = _Id
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public InvokeResult NullifySelected(string strIds)
        {
            InvokeResult result = new InvokeResult {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                string[] arrIds = strIds.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arrIds.Length == 0)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                string statementName = new OldManFamilyInfo().GetUpdateMethodName();
                foreach (string strId in arrIds)
                {
                    OldManFamilyInfo oldManFamilyInfo = new OldManFamilyInfo {
                        Id = Convert.ToInt32(strId), Status = 0
                    };
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = statementName, ParameterObject = oldManFamilyInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });
                }
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public ModelInvokeResult <OldManFamilyInfoPK> Create(OldManFamilyInfo oldManFamilyInfo)
        {
            ModelInvokeResult <OldManFamilyInfoPK> result = new ModelInvokeResult <OldManFamilyInfoPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                if (oldManFamilyInfo.Id == -1)
                {
                    oldManFamilyInfo.Id = null;
                }
                oldManFamilyInfo.OperatedBy = NormalSession.UserId.ToGuid();
                oldManFamilyInfo.OperatedOn = DateTime.Now;
                oldManFamilyInfo.DataSource = GlobalManager.DIKey_00012_ManualEdit;
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = oldManFamilyInfo.GetCreateMethodName(), ParameterObject = oldManFamilyInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                });
                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new OldManFamilyInfoPK {
                    Id = oldManFamilyInfo.Id
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public ModelInvokeResult <OldManFamilyInfoPK> DeleteFamily(OldManFamilyInfo oldManFamilyInfo)
        {
            ModelInvokeResult <OldManFamilyInfoPK> result = new ModelInvokeResult <OldManFamilyInfoPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = new OldManFamilyInfo().GetDeleteMethodName(), ParameterObject = oldManFamilyInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.DELETE
                });
                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        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");
            }
        }