Пример #1
0
        public ModelInvokeResult <OldManConfigInfoPK> Create(OldManConfigInfo oldManConfigInfo)
        {
            ModelInvokeResult <OldManConfigInfoPK> result = new ModelInvokeResult <OldManConfigInfoPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                if (oldManConfigInfo.OldManId == GlobalManager.GuidAsAutoGenerate)
                {
                    oldManConfigInfo.OldManId = Guid.NewGuid();
                }
                /***********************begin 自定义代码*******************/
                oldManConfigInfo.OperatedBy = NormalSession.UserId.ToGuid();
                oldManConfigInfo.OperatedOn = DateTime.Now;
                oldManConfigInfo.DataSource = GlobalManager.DIKey_00012_ManualEdit;
                /***********************end 自定义代码*********************/
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = oldManConfigInfo.GetCreateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                });
                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new OldManConfigInfoPK {
                    OldManId = oldManConfigInfo.OldManId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
Пример #2
0
        public ModelInvokeResult <OldManConfigInfoPK> PamConfigInfo(string strOldManId, OldManConfigInfo oldManConfigInfo)
        {
            ModelInvokeResult <OldManConfigInfoPK> result = new ModelInvokeResult <OldManConfigInfoPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                Guid?_OldManId = strOldManId.ToGuid();
                if (_OldManId == null)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                oldManConfigInfo.OldManId = _OldManId;
                /***********************begin 自定义代码*******************/
                oldManConfigInfo.OperatedBy = NormalSession.UserId.ToGuid();
                oldManConfigInfo.OperatedOn = DateTime.Now;
                oldManConfigInfo.DataSource = GlobalManager.DIKey_00012_ManualEdit;


                string        sqlCount    = "select a.OldManId,CallNo,CallNo2,CallNo3 from Oca_OldManConfigInfo a left join Oca_OldManBaseInfo b on a.OldManId=b.OldManId where b.Status=3 And a.OldManId <> '" + oldManConfigInfo.OldManId.ToString() + "'";
                List <string> whereClause = new List <string>();
                if (oldManConfigInfo.CallNo != null && oldManConfigInfo.CallNo.Trim() != "")
                {
                    whereClause.Add(" a.CallNo='" + oldManConfigInfo.CallNo + "' ");
                }
                if (oldManConfigInfo.CallNo2 != null && oldManConfigInfo.CallNo2.Trim() != "")
                {
                    whereClause.Add(" a.CallNo2='" + oldManConfigInfo.CallNo2 + "' ");
                }
                if (oldManConfigInfo.CallNo3 != null && oldManConfigInfo.CallNo3.Trim() != "")
                {
                    whereClause.Add(" a.CallNo3='" + oldManConfigInfo.CallNo3 + "' ");
                }
                if (whereClause.Count > 0)
                {
                    sqlCount += " And (" + string.Join("OR", whereClause.ToArray()) + ")";
                    //检测号码是否库内唯一
                    if (BuilderFactory.DefaultBulder().ExecuteNativeSqlForCount(sqlCount) > 0)
                    {
                        result.Success   = false;
                        result.ErrorCode = 51001;
                        return(result);
                    }
                }

                /***********************end 自定义代码*********************/
                if (BuilderFactory.DefaultBulder().ExecuteNativeSqlForCount(string.Format("select * from {0} where OldManId='{1}'", oldManConfigInfo.GetMappingTableName(), strOldManId)) == 1)
                {
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = oldManConfigInfo.GetUpdateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });
                }
                else
                {
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = oldManConfigInfo.GetCreateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                    });
                }

                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new OldManConfigInfoPK {
                    OldManId = _OldManId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
Пример #3
0
        public ModelInvokeResult <OldManConfigInfoPK> NEWUPDATE(string strIDNo, OldManConfigInfo oldManConfigInfo)
        {
            ModelInvokeResult <OldManConfigInfoPK> result = new ModelInvokeResult <OldManConfigInfoPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();


                var oldmanbaseinfo = BuilderFactory.DefaultBulder().ExecuteNativeSqlForQuery("select OldManId from Oca_OldManBaseInfo where IDNo='" + strIDNo + "'");

                string OldManId = "";
                foreach (var item in oldmanbaseinfo)
                {
                    OldManId = item["OldManId"].ToString();
                }
                // string a = OldManBaseInfo.GetProperty("OldManId").ToString();
                // var oldManBaseInfo = BuilderFactory.DefaultBulder().Load<OldManBaseInfo, OldManBaseInfoPK>(new OldManBaseInfoPK { IDNo = strOldManId });


                Guid?_OldManId = OldManId.ToGuid();
                if (_OldManId == null)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                oldManConfigInfo.OldManId = _OldManId;
                /***********************begin 自定义代码*******************/
                oldManConfigInfo.OperatedBy = NormalSession.UserId.ToGuid();
                oldManConfigInfo.OperatedOn = DateTime.Now;
                oldManConfigInfo.DataSource = GlobalManager.DIKey_00012_ManualEdit;


                if (oldManConfigInfo.CallNo != null && oldManConfigInfo.CallNo.Trim() != "")
                {
                    //检测号码是否库内唯一
                    if (BuilderFactory.DefaultBulder().ExecuteNativeSqlForCount("select OldManId,CallNo from Oca_OldManConfigInfo where CallNo='" + oldManConfigInfo.CallNo + "' and OldManId <> '" + oldManConfigInfo.OldManId.ToString() + "'") > 0)
                    {
                        result.Success   = false;
                        result.ErrorCode = 51001;
                        return(result);
                    }
                }
                /***********************end 自定义代码*********************/
                if (BuilderFactory.DefaultBulder().ExecuteNativeSqlForCount(string.Format("select * from {0} where OldManId='{1}'", oldManConfigInfo.GetMappingTableName(), OldManId)) == 1)
                {
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = oldManConfigInfo.GetUpdateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });
                }
                else
                {
                    statements.Add(new IBatisNetBatchStatement {
                        StatementName = oldManConfigInfo.GetCreateMethodName(), ParameterObject = oldManConfigInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.INSERT
                    });
                }

                /***********************begin 自定义代码*******************/
                /***********************此处添加自定义代码*****************/
                /***********************end 自定义代码*********************/
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                result.instance = new OldManConfigInfoPK {
                    OldManId = _OldManId
                };
            }
            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");
            }
        }