Пример #1
0
        public void MyGuidReturnCorrectObjectByGuid()
        {
            var guid   = MyGuid.GetAllPairsOfType <int>().FirstOrDefault().Key;
            var result = MyGuid.GetObjectByGuid <int>(guid);

            Assert.AreEqual(typeof(int), result.GetType());
        }
Пример #2
0
        public void MyGuidCreateCorrectCountOfObjects()
        {
            var countOfInt           = MyGuid.GetAllPairsOfType <int>().Count;
            var countOfStringBuilder = MyGuid.GetAllPairsOfType <StringBuilder>().Count;

            Assert.AreEqual(10, countOfInt);
            Assert.AreEqual(5, countOfStringBuilder);
        }
        public async Task <IHttpActionResult> GetMyGuid(int id)
        {
            MyGuid myGuid = await db.MyGuids.FindAsync(id);

            if (myGuid == null)
            {
                return(NotFound());
            }

            return(Ok(myGuid));
        }
        public async Task <IHttpActionResult> PostMyGuid(MyGuid myGuid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MyGuids.Add(myGuid);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = myGuid.ID }, myGuid));
        }
Пример #5
0
        public void Initialize()
        {
            for (int i = 0; i < 10; i++)
            {
                MyGuid.CreateObjectWithGuid <int>();
            }

            for (int i = 0; i < 5; i++)
            {
                MyGuid.CreateObjectWithGuid <StringBuilder>();
            }
        }
        public async Task <IHttpActionResult> DeleteMyGuid(int id)
        {
            MyGuid myGuid = await db.MyGuids.FindAsync(id);

            if (myGuid == null)
            {
                return(NotFound());
            }

            db.MyGuids.Remove(myGuid);
            await db.SaveChangesAsync();

            return(Ok(myGuid));
        }
        /// <summary>
        /// 处理发送结果正确。
        /// </summary>
        /// <param name="v"></param>
        private void SendRight(Send_Mod v)
        {
            Tb_PushMessage_Mod info = new Tb_PushMessage_Mod();

            info.LISTID       = MyGuid.Create();
            info.PUSHTYPE     = "2";
            info.PUSHNUMBER   = v.Phone;
            info.MESSAGETYPE  = "1";
            info.PROTOCOLTYPE = Info.PI_PROTOCOLTYPE;
            info.MESSAGE      = v.Content;
            info.PUSHTIME     = DateTime.Now;
            info.ISSUCCESS    = "1";
            info.SOURCEID     = v.SourceId;
            info.ISALARM      = "0";
            Tb_PushMessage_Dal.Insert(info);
        }
        public static Tb_EIdentitycardBung_Dal TableMod(CZW_2_Mod info)
        {
            Tb_EIdentitycardBung_Dal dal = new Tb_EIdentitycardBung_Dal();

            dal.LISTID         = MyGuid.Create();
            dal.IDENTITYCARDID = info.身份证id;
            dal.IDENTITYCARD   = info.身份证号;
            dal.DEVICETIME     = info.时间;
            dal.INTIME         = DateTime.Now;
            dal.STATUS         = "2";
            dal.OWERNAME       = info.姓名;
            dal.SEX            = info.性别;
            dal.NATION         = info.族;
            dal.BIRTHDAY       = info.出生年月日;
            dal.HJADDRESS      = info.住址;
            dal.POLICE         = info.签发机关;
            dal.VALIDITY       = GetValidity(info.起始日期, info.结束日期);

            dal.MJDEVICEID = info.设备编号.ToString();
            return(dal);
        }
Пример #9
0
 public PersonViewModel()
 {
     Id = MyGuid.Generate();
 }
Пример #10
0
 /// <summary>
 /// Constructor of IdentificatorBaseData.
 /// </summary>
 public IdentificatorBaseData()
 {
     random      = new Random(DateTime.Now.Millisecond);
     MyGuid      = MyGuid.GuidToString();
     Description = GetText(restriction);
 }
Пример #11
0
        public string SendMessage(string message, int timeout)
        {
            var s      = MyGuid.ToString() + "::" + myListenerPort.ToString() + "::" + message + "<EOF>";
            var str    = (string)null;
            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
            {
                SendTimeout    = timeout,
                ReceiveTimeout = timeout
            };

            byte[] numArray = new byte[1024];
            try
            {
                socket.Connect(remoteEP);
                byte[] bytes = Encoding.UTF8.GetBytes(s);
                socket.Send(bytes);
                while (true)
                {
                    var count = socket.Receive(numArray);
                    str += Encoding.UTF8.GetString(numArray, 0, count);
                    if (str.IndexOf("<EOF>") <= -1)
                    {
                        Thread.Sleep(1);
                    }
                    else
                    {
                        break;
                    }
                }
                if (socket.Connected)
                {
                    try
                    {
                        socket.Shutdown(SocketShutdown.Both);
                    }
                    catch (Exception ex)
                    {
                    }
                    try
                    {
                        socket.Close();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            catch (TimeoutException ex)
            {
                return("<TIMEDOUT>");
            }
            catch (Exception ex1)
            {
                ErrorLogger.LogException("Exception in SocketClient.SendMessage " + ex1.Message, ex1);
                try
                {
                    socket.Close();
                }
                catch (Exception ex2)
                {
                    ErrorLogger.LogException("Exception in SocketClient.SendMessage " + ex2.Message, ex2);
                }
                if (ex1 is ArgumentNullException)
                {
                    return("FAIL:ArgumentNullException : " + ex1.ToString());
                }

                if (ex1 is SocketException)
                {
                    return("FAIL:SocketException : " + ex1.ToString());
                }

                return("FAIL:Unexpected exception : " + ex1.ToString());
            }
            return(str.Substring(0, str.IndexOf("<EOF>")));
        }
Пример #12
0
        public void MyGuidReturnCorrectObject()
        {
            var result = MyGuid.GetAllPairsOfType <StringBuilder>().FirstOrDefault().Value;

            Assert.IsTrue(result is StringBuilder);
        }
Пример #13
0
        public void MyGuidDoesNotContainAnyExtraObject()
        {
            var countOfString = MyGuid.GetAllPairsOfType <string>().Count;

            Assert.AreEqual(0, countOfString);
        }