Example #1
0
        internal List <T> getdata <T>(string datawith)
        {
            List <T> list     = new List <T>();
            string   str_Json = PostData();

            if (ValidationData.checkTotal(str_Json))
            {
                list = FpJsonHelper.JObjectToList <T>(datawith, str_Json);
            }
            return(list);
        }
Example #2
0
        internal T getdata <T>() where T : class, new()
        {
            T      t        = new T();
            string str_Json = PostData();

            if (ValidationData.checkTotal(str_Json))
            {
                t = FpJsonHelper.DeserializeObject <T>(str_Json);
            }
            return(t);
        }
Example #3
0
        /// <summary>
        /// 数据转换
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="fpMethod"></param>
        /// <param name="param"></param>
        /// <param name="datawith"></param>
        /// <returns></returns>
        public static List <T> getdata <T>(FpMethod fpMethod, Dictionary <string, string> param, string datawith)
        {
            List <T> list = new List <T>();
            // string str_Json = dataWithFP.getDateFromFp(fpMethod, param);
            string str_Json = ""
            ; //默认取出来的数据只有100条

            if (ValidationData.checkTotal(str_Json))
            {
                list = FpJsonHelper.JObjectToList <T>(datawith, str_Json);
            }
            return(list);
        }
Example #4
0
        /// <summary>
        ///创建盒子保存样本
        /// </summary>
        /// <param name="up"></param>
        /// <param name="sample_type"></param>
        /// <param name="count"></param>
        /// <param name="box_path"></param>
        /// <param name="dataDic"></param>
        /// <returns></returns>
        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);
        }