//public static List<Fp_Model.Sample_Group> GetAll(string url) //{ // List<Fp_Model.Sample_Group> List = Fp_DAL.DataWithFP.getdata<Fp_Model.Sample_Group>(url, Fp_Common.FpMethod.sample_groups, "", "SampleGroups"); // return List; //} public static Fp_Model.Sample_Group GetBy(Fp_Common.UnameAndPwd up, string name) { List<Fp_Model.Sample_Group> List = GetAll(up); Fp_Model.Sample_Group sample_Group = new Fp_Model.Sample_Group(); if (List!=null&&List.Count>0) { sample_Group = List.Where<Fp_Model.Sample_Group>(a => a.name == name).FirstOrDefault(); } return sample_Group; }
//{"Total":1,"Freezers":[{"id":1,"name":"001号冰箱","description":"001号冰箱","access":0,"subdivisions":4,"boxes":0,"barcode_tag":"7000000001","rfid_tag":"355AB1CBC000007000000001"}]} //获取冰箱结构 public static List<Fp_Model.Freezer> GetAll(Fp_Common.UnameAndPwd up) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("username", up.UserName); dic.Add("password", up.PassWord); dic.Add("method", Fp_Common.FpMethod.freezers.ToString()); FpUtility.Fp_DAL.CallApi call = new FpUtility.Fp_DAL.CallApi(dic); List<Freezer> list = call.getdata<Freezer>("Freezers"); return list; }
public static SampleTypes GetBy(Fp_Common.UnameAndPwd up, string name) { List<SampleTypes> list = GetAll(up); SampleTypes sample = new SampleTypes(); if (list != null && list.Count > 0) { sample = list.Where(a => a.name == name).FirstOrDefault(); } return sample; }
public static List<Fp_Model.UserFields> GetAll(Fp_Common.UnameAndPwd up) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("username", up.UserName); dic.Add("password", up.PassWord); dic.Add("method", Fp_Common.FpMethod.userfields.ToString()); Fp_DAL.CallApi call = new CallApi(dic); List<Fp_Model.UserFields> list = call.getdata<Fp_Model.UserFields>("UserFields"); return list; }
/// <summary> /// 转化一下 /// </summary> /// <param name="up"></param> /// <param name="name"></param> /// <returns></returns> public static Fp_Model.UserFields GetBy(Fp_Common.UnameAndPwd up, string name) { List<Fp_Model.UserFields> List = GetAll(up); Fp_Model.UserFields userFields = new Fp_Model.UserFields(); if (List != null && List.Count > 0) { } return userFields; }
public static List<Fp_Model.SampleSourceTypes> GetAll(Fp_Common.UnameAndPwd up) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("username", up.UserName); dic.Add("password", up.PassWord); dic.Add("method", Fp_Common.FpMethod.sample_source_types.ToString()); Fp_DAL.CallApi call = new Fp_DAL.CallApi(dic); List<Fp_Model.SampleSourceTypes> List = call.getdata<Fp_Model.SampleSourceTypes>("SampleSourceTypes"); return List; }
public Fp_Model.SampleSourceTypes GetSampleSourceTypeByTypeName(Fp_Common.UnameAndPwd up, string name) { List<Fp_Model.SampleSourceTypes> list = GetAll(up); Fp_Model.SampleSourceTypes resObj = new Fp_Model.SampleSourceTypes(); if (list != null && list.Count > 0) { resObj = list.Where<Fp_Model.SampleSourceTypes>(a => a.name == name).FirstOrDefault(); } return resObj; }
public static Dictionary<string, string> GetAllIdAndNameDic(Fp_Common.UnameAndPwd up) { Dictionary<string, string> dic = new Dictionary<string, string>(); List<Fp_Model.Sample_Group> sample_Group = GetAll(up); foreach (var item in sample_Group) { dic.Add(item.id, item.name); } return dic; }
public static List<Fp_Model.Sample_Group> GetAll(Fp_Common.UnameAndPwd up) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("username", up.UserName); dic.Add("password", up.PassWord); dic.Add("method", Fp_Common.FpMethod.sample_groups.ToString()); FreezerProUtility.Fp_DAL.CallApi call = new FreezerProUtility.Fp_DAL.CallApi(dic); List<Fp_Model.Sample_Group> List = call.getdata<Fp_Model.Sample_Group>("SampleGroups"); return List; }
public static List<Fp_Model.Subdivision> GetAll(Fp_Common.UnameAndPwd up, string id) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("username", up.UserName); dic.Add("password", up.PassWord); dic.Add("method", Fp_Common.FpMethod.subdivisions.ToString()); dic.Add("id", id); FreezerProUtility.Fp_DAL.CallApi call = new FreezerProUtility.Fp_DAL.CallApi(dic); List<Fp_Model.Subdivision> List = call.getdata<Fp_Model.Subdivision>("Subdivision"); return List; }
public static List<Box> GetAll(Fp_Common.UnameAndPwd up, string id) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("username", up.UserName); dic.Add("password", up.PassWord); dic.Add("method", Fp_Common.FpMethod.boxes.ToString()); dic.Add("id", id); dic.Add("show_empty", "true"); FpUtility.Fp_DAL.CallApi call = new FpUtility.Fp_DAL.CallApi(dic); List<Box> boxes = call.getdata<Box>("Boxes"); return boxes; }
public static User GetBy(Fp_Common.UnameAndPwd up, string name) { List<User> list = GetAll(up); if (list != null && list.Count > 0) { return list.Where(a => a.uesrname == name).FirstOrDefault(); } else { return new User(); } }
/// <summary> /// 获取所有样品类型名称和id字典 /// </summary> /// <param name="url">带有username和password的url</param> /// <returns></returns> public static Dictionary<string, string> GetAllIdAndNamesDic(Fp_Common.UnameAndPwd up) { Dictionary<string, string> dic = new Dictionary<string, string>(); List<SampleTypes> list = GetAll(up); if (list != null && list.Count > 0) { foreach (var item in list) { dic.Add(item.id, item.name); } } return dic; }
/// <summary> /// 获取传回来的数据转化为字典 /// </summary> /// <param name="up"></param> /// <returns></returns> public static Dictionary<string, string> GetAllIdAndNamesDic(Fp_Common.UnameAndPwd up) { Dictionary<string, string> dic = new Dictionary<string, string>(); List<FreezerProUtility.Fp_Model.UserFields> list = GetAll(up); if (list != null && list.Count > 0) { foreach (var item in list) { dic.Add(item.name, item.values); } } return dic; }
/// <summary> /// 导入多条临床数据 /// </summary> /// <param name="url"></param> /// <param name="test_data_type"></param> /// <param name="dataDicList">需指定Sample Source</param> /// <returns></returns> public static string ImportTestData(Fp_Common.UnameAndPwd up, string test_data_type, List<Dictionary<string, string>> dataDicList) { string result = string.Empty; string jsonDicList = Fp_Common.FpJsonHelper.DictionaryListToJsonString(dataDicList); if (!string.IsNullOrEmpty(jsonDicList)) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("test_data_type", test_data_type); dic.Add("json", jsonDicList); result = ImportTestDataToFp(up, dic); } return result; }
/// <summary> /// 导入临床数据 /// </summary> /// <param name="url"></param> /// <param name="test_data_type"></param> /// <param name="dataDic">需指定Sample Source</param> /// <returns></returns> public static string ImportTestData(Fp_Common.UnameAndPwd up, string test_data_type, Dictionary<string, string> dataDic) { string result = string.Empty; //string jsonDic = Fp_Common.FpJsonHelper.DictionaryToJsonString(dataDic); string jsonDic = JsonConvert.SerializeObject(dataDic); if (!string.IsNullOrEmpty(jsonDic)) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("test_data_type", test_data_type); dic.Add("json", jsonDic); result = ImportTestDataToFp(up, dic); } return result; }
/// 查询指定冰箱指定位置是否存在符合条件的盒子 public static string get_perfect_box(Fp_Common.UnameAndPwd up, string space, string freezer_name) { string resultStr = string.Empty; Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("username", up.UserName); dic.Add("password", up.PassWord); dic.Add("method", Fp_Common.FpMethod.get_perfect_box.ToString()); dic.Add("freezer_name", freezer_name); dic.Add("space", space); FreezerProUtility.Fp_DAL.CallApi call = new FreezerProUtility.Fp_DAL.CallApi(dic); resultStr = call.GetData(); return resultStr; //暂时如此,直接返回查询之后的结果,能不能查到得到都返回,后期需要将返回结果解析之后返回 //http://192.168.183.130/api?username=admin&password=123456&method=get_perfect_box&freezer_name=tem->admin->06&space=8 //{"success":true,"box_id":1351,"location":"tem->admin->06->02->1"} }
public static string ImportSampleSourceDataToFp(Fp_Common.UnameAndPwd up, string sampleSourceTypeName, Dictionary<string, string> jsonDic) { string result = string.Empty; Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("username", up.UserName); dic.Add("password", up.PassWord); dic.Add("method", Fp_Common.FpMethod.import_sources.ToString()); dic.Add("sample_source_type", sampleSourceTypeName); if (jsonDic != null && jsonDic.Count > 0) { dic.Add("json", Fp_Common.FpJsonHelper.DictionaryToJsonString(jsonDic)); } Fp_DAL.CallApi call = new Fp_DAL.CallApi(dic); result = call.PostData(); return result; }
private static string ImportTestDataToFp(Fp_Common.UnameAndPwd up, Dictionary<string, string> jsonDic) { string result = string.Empty; Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("username", up.UserName); dic.Add("password", up.PassWord); dic.Add("method", Fp_Common.FpMethod.import_tests.ToString()); if (jsonDic != null && jsonDic.Count > 0) { foreach (KeyValuePair<string, string> item in jsonDic) { dic.Add(item.Key, item.Value); } } FreezerProUtility.Fp_DAL.CallApi call = new FreezerProUtility.Fp_DAL.CallApi(dic); result = call.PostData(); return result; }
//提交数据新方法,一个dg一次提交 public static string ImportSamplesToFp(Fp_Common.UnameAndPwd up, Box_Path box_path, List<Dictionary<string, string>> dataDicList) { string jsonsampledata = string.Empty; List<Dictionary<string, string>> jsonDicList = new List<Dictionary<string, string>>(); string box_type = "bag"; //默认放入袋子中 string create_storage = string.Empty; create_storage = string.Format("{0},{1},{2},{3}", box_path.Freezer, box_path.Level1, box_path.Level2, box_path.Level3); foreach (var dataDic in dataDicList) { if (!dataDic.ContainsKey("Freezer")) { dataDic.Add("Freezer", box_path.Freezer);//Tem } if (!dataDic.ContainsKey("Level1")) { dataDic.Add("Level1", box_path.Level1);//Username } if (!dataDic.ContainsKey("Level2")) { dataDic.Add("Level2", box_path.Level2);//月 } if (!dataDic.ContainsKey("Level3")) { dataDic.Add("Level3", box_path.Level3);//日 } if (dataDic.ContainsKey("Box")) { dataDic["Box"]= box_path.Box;//盒子 } else { dataDic.Add("Box", box_path.Box); } } jsonsampledata = FreezerProUtility.Fp_Common.FpJsonHelper.ObjectToJsonStr(dataDicList); Dictionary<string, string> jsonDic = new Dictionary<string, string>(); jsonDic.Add("create_storage", create_storage); jsonDic.Add("box_type", box_type); jsonDic.Add("json", jsonsampledata); string importRes = ImportSampleToFp(up, jsonDic); return importRes; }
//public static List<Subdivision> GetAll(string url, string id) //{ // List<Subdivision> subdivisionList = Fp_DAL.DataWithFP.getdata<Subdivision>(url, Fp_Common.FpMethod.subdivisions, "&id=" + id, "Subdivision"); // return subdivisionList; //} //传入位置(返回名称id???) //tem→admin→06月→02日--直接生成 public static Fp_Model.Subdivision CheckBy(Fp_Common.UnameAndPwd up,string freezerId, string location) { List<Fp_Model.Subdivision> subdivisionList = GetAll(up, freezerId); Fp_Model.Subdivision subdivision = new Subdivision(); string[] l = location.Split('→'); for (int i = 1; i < l.Length; i++) { subdivision = subdivisionList.Where(a => a.name == l[i]).FirstOrDefault();//冰箱结构重名取第一个结构 if (subdivision == null || subdivision.name.Contains("日")) { //找不到对应的节点就跳出 break; } else { subdivisionList = GetAll(up, subdivision.id); } } return subdivision; }
//判断指定名称的盒子是否存在 public static bool CheckBoxesByGetAll(Fp_Common.UnameAndPwd up, string id, string boxName) { List<Box> boxes = GetAll(up, id); if (boxes == null) { return false; } else { Box box = boxes.Where(a => a.name == boxName).FirstOrDefault(); if (box == null) { return false; } else { return true; } } }
/// <summary> /// 使用样本源类型名称获取样本源类型中的字段集合list<string> /// </summary> /// <param name="typeName">指定样本元类型名称</param> /// <returns>字段集合</returns> public static List<string> GetSampleSourceTypeFieldByTypeName(Fp_Common.UnameAndPwd up, string typeName) { List<string> sampleSourceTypeField = new List<string>(); Fp_Model.SampleSourceTypes ss = GetSampleSourceTypeByTypeName(up, typeName); if (ss != null) { string fieldsStr = ss.fields; if (fieldsStr != null) { string[] fields = ((fieldsStr.Replace("<br>", "$")).Replace("</br>", "$")).Split('$'); foreach (string item in fields) { if (!String.IsNullOrEmpty(item)) { sampleSourceTypeField.Add(item); } } } } return sampleSourceTypeField; }
public static Freezer GetBy(Fp_Common.UnameAndPwd up, string name) { Fp_Model.Freezer freezer = GetAll(up).Where<Fp_Model.Freezer>(a => a.name == name).FirstOrDefault(); return freezer; }
//第一步到指定位置查找空位 //第二部找到位置就添加样本 //第三部没好到就添加样本盒(样本盒名称怎么获取)--获取冰箱(根据名称)--->根据冰箱名获取冰箱id-->根据冰箱id获取冰箱分支---->根据用户名获取对应的分支id---->月份分支---->日分支id----->boxes获取当前分支下的所有盒子,判断盒子是否存在(根据名字判断盒子) //生成默认临时储存结构的方法--目的,查看对应位置是否存在可以存放样本的孔 private static Fp_Model.Box_Path CreatTemFreezerPath(Fp_Common.UnameAndPwd up, string department, out bool creat) { FreezerProUtility.Fp_Model.Box_Path box_path = new Box_Path(); ////Tem-->username-->month-->day(-->box) //string box_path = string.Empty; string username = Fp_Common.CookieHelper.GetCookieValue("username"); string freezerName = "Tem--" + department; if (!string.IsNullOrEmpty(username)) { Fp_Model.Freezer freezer = Freezers.GetBy(up, freezerName); string _path = string.Format("{0}→{1}→{2}月→{3}日", freezerName, username, DateTime.Now.Month, DateTime.Now.Date.ToString("dd"));//创建盒子路径 //获取次路径下的盒子 if (freezer != null) { Fp_Model.Subdivision subdivision = Subdivisions.CheckBy(up, freezer.id, _path); //要判断是否为空 if (subdivision != null) { if (subdivision.name.Contains("日")) { List<Fp_Model.Box> boxsList = Fp_BLL.Boxes.GetAll(up, subdivision.id); if (boxsList.Count > 0) { //日期节点下有盒子 Fp_Model.Box maxBox = boxsList.OrderByDescending(a => a.name).FirstOrDefault(); string maxBoxName = maxBox.name.Replace(maxBox.location + "→", "").Trim(); if (!string.IsNullOrEmpty(maxBoxName)) { box_path.Freezer = "Tem--" + department; box_path.Level1 = username; box_path.Level2 = DateTime.Now.Month + "月"; box_path.Level3 = DateTime.Now.Date.ToString("dd") + "日"; box_path.Box = maxBoxName; creat = false; //此处还需要判断当前的bag中是否有位置存放样品 } else { int max = 0; //意外报错 if (int.TryParse(maxBoxName, out max)) { box_path.Freezer = "Tem--" + department; box_path.Level1 = username; box_path.Level2 = DateTime.Now.Month + "月"; box_path.Level3 = DateTime.Now.Date.ToString("dd") + "日"; box_path.Box = (max + 1).ToString(); } creat = true; } } else { creat = true; //日期节点下没盒子 box_path.Freezer = "Tem--" + department; box_path.Level1 = username; box_path.Level2 = DateTime.Now.Month + "月"; box_path.Level3 = DateTime.Now.Date.ToString("dd") + "日"; box_path.Box = "1"; } } else { //不包含日 creat = true; //当前节点下没盒子 box_path.Freezer = "Tem--" + department; box_path.Level1 = username; box_path.Level2 = DateTime.Now.Month + "月"; box_path.Level3 = DateTime.Now.Date.ToString("dd") + "日"; box_path.Box = "1"; } } else { creat = true; //当前节点下没盒子 box_path.Freezer = "Tem--" + department; box_path.Level1 = username; box_path.Level2 = DateTime.Now.Month + "月"; box_path.Level3 = DateTime.Now.Date.ToString("dd") + "日"; box_path.Box = "1"; } } else { creat = true; box_path.Freezer = "Tem--" + department; box_path.Level1 = username; box_path.Level2 = DateTime.Now.Month + "月"; box_path.Level3 = DateTime.Now.Date.ToString("dd") + "日"; box_path.Box = "1"; ; } } else { creat = true; } return box_path; }
//创建盒子保存样本 private static string ImportSamplesToFp(Fp_Common.UnameAndPwd up, string sample_type, string count, Box_Path box_path, Dictionary<string, string> dataDic) { string jsonsampledata = string.Empty; List<Dictionary<string, string>> jsonDicList = new List<Dictionary<string, string>>(); string box_type = "bag"; //默认放入袋子中 string create_storage = string.Empty; int kk = 1; Random rand = new Random(); int ALIQUOT = rand.Next(1, 1000); #region 创建样本信息字符串&json= if (int.TryParse(count, out kk)) { if (!dataDic.ContainsKey("ALIQUOT")) { dataDic.Add("ALIQUOT", ALIQUOT.ToString()); } if (!dataDic.ContainsKey("Sample Type")) { dataDic.Add("Sample Type", sample_type); } if (!dataDic.ContainsKey("Freezer")) { dataDic.Add("Freezer", box_path.Freezer);//Tem } if (!dataDic.ContainsKey("Level1")) { dataDic.Add("Level1", box_path.Level1);//Username } if (!dataDic.ContainsKey("Level2")) { dataDic.Add("Level2", box_path.Level2);//月 } if (!dataDic.ContainsKey("Level3")) { dataDic.Add("Level3", box_path.Level3);//日 } create_storage = string.Format("{0},{1},{2},{3}", box_path.Freezer, box_path.Level1, box_path.Level2, box_path.Level3); if (dataDic.ContainsKey("Box")) { dataDic["Box"] = box_path.Box; } else { dataDic.Add("Box", box_path.Box);//袋子中不需要指定位置 } if (string.IsNullOrEmpty(jsonsampledata)) { if (kk == 1) { //单条数据 jsonsampledata = FpJsonHelper.DictionaryToJsonString(dataDic); } else if (kk > 1 && kk < 500) { for (int i = 0; i < kk; i++) { //扩展数据成多条 Dictionary<string, string> tem = new Dictionary<string, string>(); //字典复制需要两次循环,这里是利用字典的序列化和反序列化 tem = Fp_Common.FpJsonHelper.DeserializeObject<Dictionary<string, string>>(Fp_Common.FpJsonHelper.DictionaryToJsonString(dataDic)); jsonDicList.Add(tem); } //多条数据 jsonsampledata = FpJsonHelper.DictionaryListToJsonString(jsonDicList); } } } #endregion Dictionary<string, string> jsonDic = new Dictionary<string, string>(); jsonDic.Add("create_storage", create_storage); jsonDic.Add("box_type", box_type); jsonDic.Add("json", jsonsampledata); string importRes = ImportSampleToFp(up, jsonDic); return importRes; }
/// <summary> /// 构造函数 /// </summary> /// <param name="username">用户名</param> /// <param name="password">密码</param> public Token(Fp_Common.UnameAndPwd up) { UserName = up.UserName; PassWord = up.PassWord; }
public static string Import_Sample(Fp_Common.UnameAndPwd up, string department, string sample_type, string count, Dictionary<string, string> dataDic) { string username = Fp_Common.CookieHelper.GetCookieValue("username"); string result = string.Empty; bool check; Box_Path box_path = CreatTemFreezerPath(up, department, out check); if (check)//正常操作时需要判断是否存在当前结果以判断是否需要创建结构 { //需要创建盒子 result = ImportSamplesToFp(up, sample_type, count, box_path, dataDic); } else { result = ImportSamplesToFp(up, sample_type, count, box_path, dataDic); } if (result.Contains(@"\u8d85\u51fa\u6837\u54c1\u76d2.")) { int k; if (int.TryParse(box_path.Box, out k)) { box_path.Box = (k + 1).ToString(); } result = ImportSamplesToFp(up, sample_type, count, box_path, dataDic); } return result; }