コード例 #1
0
        private List <PeopleInfo> GetPeopleName(string usercode)
        {
            List <PeopleInfo> list = new List <PeopleInfo>();

            //   string sql = @" select name from info1 where name like '" + usercode + "%' ";
            //   list = MyDBHelper.My_Test_ODBC_Link(sql);

            PeopleInfo iu = new PeopleInfo();

            if (usercode.Equals("212"))
            {
                iu.PeopleName = "212的名字返回了";
            }
            if (usercode.Equals("213"))
            {
                iu.PeopleName = "213的名字返回了";
            }
            if (usercode.Equals("215"))
            {
                iu.PeopleName = "215的名字返回了";
            }

            list.Add(iu);

            return(list);
        }
コード例 #2
0
ファイル: Record.cs プロジェクト: roczhang2018/smarthand
 public Record(Record record)
 {
     m_p            = record.People;
     m_diagnose     = record.Diagnose;
     m_allcost      = record.AllCost;
     m_compensation = record.Compensation;
     m_date         = record.Date;
 }
コード例 #3
0
ファイル: Record.cs プロジェクト: roczhang2018/smarthand
 public Record(PeopleInfo p, string diagose, float allcost, float compensation, string date)
 {
     m_p            = p;
     m_diagnose     = diagose;
     m_allcost      = allcost;
     m_compensation = compensation;
     m_date         = date;
 }
コード例 #4
0
ファイル: Main.cs プロジェクト: roczhang2018/smarthand
        private void SetCurrentRecord(PeopleInfo people)
        {
            this.numberText.Text  = people.No;
            this.ageText.Text     = people.Age.ToString();
            this.SexBox.Text      = people.Sex;
            this.addressText.Text = people.Address;

            m_currentRecord.People = people;
        }
コード例 #5
0
ファイル: Record.cs プロジェクト: roczhang2018/smarthand
        public Record(string name, string no, float age, string address, string sex, string diagose, float allcost,
                      float compensation, string date)

        {
            m_diagnose     = diagose;
            m_allcost      = allcost;
            m_compensation = compensation;
            m_date         = date;
            m_p            = new PeopleInfo(name, no, age, address, sex);
        }
コード例 #6
0
ファイル: CardInfo.cs プロジェクト: lxc1030/Unity5.6.1p4
    public void SetInit()
    {
        gameObject.tag = myTag.ToString();
        HpMax          = Hp;
        GameObject obj = null;

        obj   = PoolManager.instance.GetPoolObjByType(PreLoadType.PeopleInfo, Camera.main.transform, null, false);
        pInfo = obj.GetComponent <PeopleInfo>();
        pInfo.Init(GameManager.instance.gameCamera, transPeopleInfo, myName, GameManager.BackHpSpName(isEnemy));
        obj.SetActive(true);
    }
コード例 #7
0
        public List <PeopleInfo> Post([FromBody] PeopleInfo m)
        {
            List <PeopleInfo> l = new List <PeopleInfo>();

            //lst = new List<PeopleInfo>();
            if (m != null)
            {
                l.Add(m);
            }
            lst = l;
            return(l);
        }
コード例 #8
0
        public static PeopleInfo GetInfo(List <Person> personList)
        {
            var info = new PeopleInfo()
            {
                Total             = personList.Count(),
                AverageAge        = personList.Average(p => p.Age),
                MaxAge            = personList.Max(p => p.Age),
                MinAge            = personList.Min(p => p.Age),
                AnglesSaxonsTotal = personList.Count(p => p.Race == "AnglesSaxons"),
                JutesTotal        = personList.Count(p => p.Race == "Jutes"),
                HawaiianTotal     = personList.Count(p => p.Race == "Hawaiian")
            };

            return(info);
        }
コード例 #9
0
    void Start()
    {
//		string json="{\"name\":\"Napleon\",\"age\":18,\"attack\":1239.34}";
//		PlayerInfo p= new PlayerInfo();
//		p.name = "Napleon";
//		p.age = 18;
//		p.attack = 1233.34f;
//		Debug.Log(SerializeHelper.ToJson<PlayerInfo>(p));
//		SerializeHelper.SaveJson<PlayerInfo>(p,"TestJson.json");
//		p=SerializeHelper.LoadJson<PlayerInfo>("TestJson.json");
//		p.age = 22;
//		Debug.Log(p.name+" "+p.age+" "+p.attack);

        PeopleInfo pi = new PeopleInfo()
        {
            Name     = "Neack",
            Age      = 29,
            SaveTime = DateTime.Now,
            Address  = new Address()
            {
                Line1 = "Shanghai Pudong",
                Line2 = "Jiangsu Nanjing"
            }
        };

//		using (var file=System.IO.File.Create("TestProtoBuf.bin"))
//		{
//			Serializer.Serialize(file,pi);
//		}
//		PeopleInfo pp=new PeopleInfo();
//		using (var file=System.IO.File.OpenRead("TestProtoBuf.bin"))
//		{
//			pp=Serializer.Deserialize<PeopleInfo>(file);
//		}
//		Debug.Log(pp.ToString());
//		PeopleInfo pp=SerializeHelper.LoadProtoBuf<PeopleInfo>("TestPortoBuf.bin");
//		Debug.Log(pp.ToString());
//		pp.Age = 30;
        SerializeHelper.SaveProtoBuf <PeopleInfo>(pi, "TestPortoBuf.protobuf");
        PeopleInfo pp = SerializeHelper.LoadProtoBuf <PeopleInfo>("TestPortoBuf.protobuf");

        Debug.Log(pp.ToString());
    }
コード例 #10
0
        /// <summary>
        /// 设置IM用户资料
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public Response Execute(User currentUser, string request)
        {
            var        req     = JsonConvert.DeserializeObject <Request <PeopleInfo> >(request);
            PeopleInfo people  = new PeopleInfo();
            var        reqRest = new RestRequest("sns/friend_delete", Method.POST);

            people.To_Account.Add("160000000190");//只需修改此值即可调试
            people.TagList.Add("Tag_Profile_IM_Nick");

            reqRest.AddJsonBody(people);

            var        rsp = RestApiHelper.SendIMRequest <IMMessageResult>(reqRest);
            PeopleInfo peo = new PeopleInfo();

            return(new Response()
            {
                IsSuccess = rsp.Data.ErrorCode == 0, Message = rsp.Content
            });
        }
コード例 #11
0
 private void AssertGetPeopleInfoBasic(User user, PeopleInfo info)
 {
     Assert.Equal(user.Id, info.Id);
     Assert.Equal(user.Username, info.Username);
 }
コード例 #12
0
    public static void ReflectionWrite()
    {
        object obj = CreateClassInstanceByName("TestClass1");

        PropertyInfo info1 = obj.GetType().GetProperty("Id");
        //info1.SetValue(obj, System.Convert.ToInt32("123"),new object[] { });
        PropertyInfo info2 = obj.GetType().GetProperty("Name");
        //info2.SetValue(obj, "TestClass1", new object[] { });
        PropertyInfo info3 = obj.GetType().GetProperty("Height");
        //info3.SetValue(obj, System.Convert.ToSingle("182.3"), new object[] { });
        PropertyInfo info4 = obj.GetType().GetProperty("IsMale");
        //info4.SetValue(obj, System.Convert.ToBoolean("true"), new object[] { });
        PropertyInfo info5 = obj.GetType().GetProperty("testEnum");

        //object enumObj = TypeDescriptor.GetConverter(info5.PropertyType).ConvertFromInvariantString("Happy");
        //info5.SetValue(obj, enumObj, new object[] { });

        SetValueByType(info1, obj, "123", "int");
        SetValueByType(info2, obj, "TestClass1", "string");
        SetValueByType(info3, obj, "183.5", "float");
        SetValueByType(info4, obj, "true", "bool");
        SetValueByType(info5, obj, "Happy", "enum");

        //Type listType = typeof(List<>);
        //Type strtype = listType.MakeGenericType(new Type[] { typeof(string) });
        //object strListObj = Activator.CreateInstance(strtype);
        //for (int i = 0; i < 3; i++)
        //{
        //    object temp = " str " + i;
        //    strListObj.GetType().InvokeMember("Add", BindingFlags.Default | BindingFlags.InvokeMethod, null,
        //        strListObj, new object[] { temp });
        //}

        //obj.GetType().GetProperty("strList").SetValue(obj, strListObj, new object[] { });

        Type   listType = typeof(List <>);
        Type   pType    = listType.MakeGenericType(new Type[] { typeof(PeopleInfo) });
        object pListObj = Activator.CreateInstance(pType, new object[] { });

        for (int i = 0; i < 3; i++)
        {
            PeopleInfo p = new PeopleInfo()
            {
                Age  = i + 10,
                Name = i + " : name",
            };
            pListObj.GetType().InvokeMember("Add", BindingFlags.Default | BindingFlags.InvokeMethod, null,
                                            pListObj, new object[] { (object)p });
        }
        PropertyInfo[] pinfos = obj.GetType().GetProperties();
        foreach (var item in pinfos)
        {
            Debug.Log(item.Name);
        }
        obj.GetType().GetProperty("peopleList").SetValue(obj, pListObj, new object[] { });


        TestClass1 tc = obj as TestClass1;
        //Debug.Log(tc.Id + "    " + tc.Name + "    " + tc.Height + "    " + tc.IsMale + "    " + tc.testEnum);
        //foreach (var item in tc.strList)
        //{
        //    Debug.Log(item);
        //}

        //foreach (var item in tc.peopleList)
        //{
        //    Debug.Log(item.Age + "    " + item.Name);
        //}
    }
コード例 #13
0
ファイル: Main.cs プロジェクト: roczhang2018/smarthand
        private void ReaderCSV(string filePath)
        {
            string path = Path.GetDirectoryName(filePath);

            if (!Directory.Exists(path))
            {
                return;
            }

            // open the file "data.csv" which is a CSV file with headers
            using (CsvReader csv =
                       new CsvReader(new StreamReader(filePath, Encoding.GetEncoding("gb2312")), true))
            {
                int fieldCount = csv.FieldCount;

                int igore = 3; // don't read the header line
                               // igore the 2-4 line ( 0 , 1, 2, 3)
                int lineNum = 1;
                while (csv.ReadNextRecord())
                {
                    lineNum++;
                    if (igore > 0) // igore header in the first 4 lines
                    {
                        igore--;
                        continue;
                    }

                    // create one record
                    // //乡村名称	合疗证号	患者姓名	年龄	性别	就诊时间	诊 断	 总医药费	药品费	检查费	治疗费	材料费	自付	补偿

                    string address = csv[0].Trim().Replace("?", "");
                    string no      = csv[1].Trim().Replace("?", "");
                    string name    = csv[2].Trim().Replace("?", "");

                    if (string.IsNullOrEmpty(address) || string.IsNullOrEmpty(no) || string.IsNullOrEmpty(name))
                    {
                        continue;
                    }

                    float age = 0.0f;
                    if (!float.TryParse(csv[3].Trim().Replace("?", ""), out age))
                    {
                        ShowMesage(lineNum, "年龄不合法", csv[3].Trim().Replace("?", ""));
                    }

                    string     sex = csv[4].Trim().Replace("?", "");
                    PeopleInfo p   = new PeopleInfo(name, no, age, address, sex);

                    string date    = csv[5].Trim().Replace("?", "");
                    string diagose = csv[6].Trim().Replace("?", "");

                    float allcost = 0.0f;
                    if (!float.TryParse(csv[7].Trim().Replace("?", ""), out allcost))
                    {
                        ShowMesage(lineNum, "总费用不合法", csv[7].Trim());
                    }
                    //float selfPay = csv[12];

                    float compenation = 0.0f;
                    if (!float.TryParse(csv[13].Trim().Replace("?", ""), out compenation))
                    {
                        ShowMesage(lineNum, "补偿费用不合法", csv[13].Trim());
                    }

                    Record r = new Record(p, diagose, allcost, compenation, date);

                    m_recordList.Add(r);
                }
            }
        }
コード例 #14
0
        /*
         * return 1  | registrazione ok
         * return -1 | email gia esistente
         * return -2 | nickname gia esistente
         * return -3 | errore salvataggio credenziale email e password
         * return -4 | errore salvataggio info
         */
        public int RegisterNewPerson(Models.FromNg.NewUserToRegister _user)
        {
            _user.Email    = _user.Email.Trim().ToLower();
            _user.Password = HashString(_user.Password);
            int    result              = 0;
            string errorMessage        = "";
            string errorInnerException = "";


            using (var context = new TOOEZContext())
            {
                #region controllo email e nickname - dati unici
                // email gia esistente
                if (context.PeopleBasic.Any(b => b.Email == _user.Email))
                {
                    Dbg dbg = new Dbg()
                    {
                        DateTime       = DateTime.Now,
                        State          = 0,
                        Object         = "Registration Controller",
                        Info           = $"Controllo Primario fallito, email {_user.Email} già essitente.",
                        Message        = errorMessage,
                        InnerException = errorInnerException
                    };
                    context.Dbg.Add(dbg);
                    context.SaveChanges();
                    return(-1);
                }
                // nickname gia esistente
                if (context.PeopleInfo.Any(b => b.Nickname.Trim().ToLower() == _user.Nickname.Trim().ToLower()))
                {
                    Dbg dbg = new Dbg()
                    {
                        DateTime       = DateTime.Now,
                        State          = 0,
                        Object         = "Registration Controller",
                        Info           = $"Controllo Primario fallito, nickname {_user.Nickname} già essitente.",
                        Message        = errorMessage,
                        InnerException = errorInnerException
                    };
                    context.Dbg.Add(dbg);
                    context.SaveChanges();
                    return(-2);
                }
                #endregion

                #region people_basic
                PeopleBasic basic = new PeopleBasic()
                {
                    Email    = _user.Email,
                    Password = _user.Password
                };
                context.PeopleBasic.Add(basic);
                //context save changes
                try
                {
                    result = context.SaveChanges();
                    if (result == 1)
                    {
                        Dbg dbg = new Dbg()
                        {
                            DateTime       = DateTime.Now,
                            State          = 1,
                            Object         = "Registration Controller",
                            Info           = $"Registrazione Base riuscita per utente {basic.Email}",
                            Message        = errorMessage,
                            InnerException = errorInnerException
                        };
                        context.Dbg.Add(dbg);
                        context.SaveChanges();
                    }
                }
                catch (Exception ex) {
                    context.Entry(basic).State = EntityState.Detached;
                    int i = ex.InnerException.HResult;
                    errorMessage        = ex.Message;
                    errorInnerException = ex.InnerException.Message;
                    Dbg dbg = new Dbg()
                    {
                        DateTime       = DateTime.Now,
                        State          = 0,
                        Object         = "Registration Controller",
                        Info           = $"Registrazione Base fallita per utente {basic.Email}",
                        Message        = errorMessage,
                        InnerException = errorInnerException
                    };
                    context.Dbg.Add(dbg);
                    context.SaveChanges();
                    result = -3;
                }
                #endregion

                #region people_info
                //se la registrazione di basic è andata a buon fine
                if (result == 1)
                {
                    PeopleInfo info = new PeopleInfo()
                    {
                        BasicId         = basic.BasicId,
                        Name            = _user.Name,
                        Surname         = _user.Surname,
                        Nickname        = _user.Nickname,
                        ShowPrivateName = _user.ShowPrivateName
                    };
                    context.PeopleInfo.Add(info);
                    //context save changes
                    try
                    {
                        result = context.SaveChanges();
                        if (result == 1)
                        {
                            Dbg dbg = new Dbg()
                            {
                                DateTime       = DateTime.Now,
                                State          = 1,
                                Object         = "Registration Controller",
                                Info           = $"Registrazione Info riuscita per utente {basic.Email}",
                                Message        = errorMessage,
                                InnerException = errorInnerException
                            };
                            context.Dbg.Add(dbg);
                            context.SaveChanges();
                        }
                    }
                    catch (Exception ex) {
                        context.Entry(info).State = EntityState.Detached;
                        int i = ex.InnerException.HResult;
                        errorMessage        = ex.Message;
                        errorInnerException = ex.InnerException.Message;
                        Dbg dbg = new Dbg()
                        {
                            DateTime       = DateTime.Now,
                            State          = 0,
                            Object         = "Registration Controller",
                            Info           = $"Registrazione Info fallita per utente {basic.Email}",
                            Message        = errorMessage,
                            InnerException = errorInnerException
                        };
                        context.Dbg.Add(dbg);
                        context.SaveChanges();
                        result = -4;
                    }
                }
                #endregion
            }

            return(result);
        }
コード例 #15
0
        /*return values is encoded in the user basicId
         *  basicId = >= 0 | OK
         *  basicId = > -1 | Email non registrata
         *  basicId = > -2 | Email trovata ma password sbagliata
         */
        public Models.ToNg.User Login(Models.FromNg.LoginCredential credential)
        {
            credential.Email    = credential.Email.Trim().ToLower();
            credential.Password = HashString(credential.Password);
            int    result              = 0;
            string errorMessage        = "";
            string errorInnerException = "";

            //test inserimento nuova persona

            using (var context = new TOOEZContext())
            {
                bool exists = context.PeopleBasic.Any(p => p.Email == credential.Email);

                //email trovata
                if (exists)
                {
                    PeopleBasic      basic = context.PeopleBasic.FirstOrDefault(p => p.Email == credential.Email);
                    PeopleInfo       info  = context.PeopleInfo.FirstOrDefault(p => p.BasicId == basic.BasicId);
                    Models.ToNg.User user  = new Models.ToNg.User()
                    {
                        BasicId         = basic.BasicId,
                        Email           = basic.Email,
                        Name            = info.Name,
                        Surname         = info.Surname,
                        Nickname        = info.Nickname,
                        ShowPrivateName = info.ShowPrivateName,
                    };

                    //email e password corretti
                    if (basic.Password == credential.Password)
                    {
                        Dbg dbg = new Dbg()
                        {
                            DateTime = DateTime.Now,
                            State    = 1,
                            Object   = "LoginService",
                            Info     = $"Accesso effettuato con email [ {basic.Email} ]",
                        };
                        context.Dbg.Add(dbg);
                        context.SaveChanges();
                        return(user);
                    }

                    //email trovata ma password sbagliata
                    else
                    {
                        Dbg dbg = new Dbg()
                        {
                            DateTime = DateTime.Now,
                            State    = 0,
                            Object   = "LoginService",
                            Info     = $"Tentata registrazione con email [ {credential.Email} ] trovata ma password sbagliata.",
                        };
                        context.Dbg.Add(dbg);
                        context.SaveChanges();
                        return(new Models.ToNg.User()
                        {
                            BasicId = -2
                        });
                    }
                }

                //email non trovata
                else
                {
                    Dbg dbg = new Dbg()
                    {
                        DateTime = DateTime.Now,
                        State    = 0,
                        Object   = "LoginService",
                        Info     = $"Tentata registrazione con email non registrata [ {credential.Email} ]",
                    };
                    context.Dbg.Add(dbg);
                    context.SaveChanges();
                    return(new Models.ToNg.User()
                    {
                        BasicId = -1
                    });
                }
            }
        }