Beispiel #1
0
 public ctransmitter(int id, ecommand command, string str /*,int ran*/)
 {
     this.id      = id.ToString();
     this.command = command.ToString();
     this.str     = str;
     //this.ran = ran.ToString();
 }
Beispiel #2
0
        public void delete(object obj, int id)
        {
            ecommand c = ecommand.ce;

            if (obj as caddressBook != null)
            {
                c = ecommand.daddressBook;
            }
            else if (obj as ccontacts != null)
            {
                c = ecommand.dcontacts;
            }
            else if (obj as cdiary != null)
            {
                c = ecommand.ddiary;
            }
            else if (obj as cmemorandum != null)
            {
                c = ecommand.dmemorandum;
            }
            else if (obj as cproperty != null)
            {
                c = ecommand.dproperty;
            }
            string       json        = JsonConvert.SerializeObject(id);
            ctransmitter transmitter = new ctransmitter(this.id, c, json);

            send(transmitter.ToString());
        }
Beispiel #3
0
        public void add <T>(T obj)
        {
            string temp = typeof(T).ToString();
            //int i = temp.LastIndexOf('.');
            //temp = temp.Substring(i + 1);
            ecommand c = ecommand.ce;

            if (string.Equals(temp, typeof(caddressBook).ToString()))
            {
                c = ecommand.addaddressBook;
            }
            else if (string.Equals(temp, typeof(ccontacts).ToString()))
            {
                c = ecommand.addcontacts;
            }
            else if (string.Equals(temp, typeof(cdiary).ToString()))
            {
                c = ecommand.adddiary;
            }
            else if (string.Equals(temp, typeof(cmemorandum).ToString()))
            {
                c = ecommand.addmemorandum;
            }
            else if (string.Equals(temp, typeof(cproperty).ToString()))
            {
                c = ecommand.addproperty;
            }

            string       json        = JsonConvert.SerializeObject(obj);
            ctransmitter transmitter = new ctransmitter(id, c, json);

            send(transmitter.ToString());
        }
 private void implement(string str)
 {
     try
     {
         ctransmitter transmitter = JsonConvert.DeserializeObject <ctransmitter>(str);
         ecommand     command     = (ecommand)Enum.Parse(typeof(ecommand), transmitter.command);
         int          id          = Convert.ToInt32(transmitter.id);
         switchimplement(id, command, transmitter.str);
     }
     catch (Exception e)
     {
         reminder("slaveComputer.implement:str不是ctransmitter " + e.Message);
         reminder(str);
     }
 }
 private void implement(string str)
 {
     try
     {
         ctransmitter transmitter = JsonConvert.DeserializeObject <ctransmitter>(str);
         ecommand     command     = (ecommand)Enum.Parse(typeof(ecommand), transmitter.command);
         switch (command)
         {
         case ecommand.ce:
             reminder("收到" + transmitter.id);
             break;
         }
     }
     catch (Exception e)
     {
         reminder("str不是ctransmitter " + e.Message);
     }
 }
Beispiel #6
0
        private void implement(int id, ecommand command, string str)
        {
            try
            {
                switch (command)
                {
                case ecommand.id:
                    fitid(str);
                    break;

                case ecommand.addressBook:
                    reminder = "上位机发来通讯录";
                    newaddressBook(str);
                    break;

                case ecommand.property:
                    reminder = "上位机发来个人财物";
                    newproperty(str);
                    break;

                case ecommand.diary:
                    reminder = "上位机发来日记";
                    newdiary(str);
                    break;

                case ecommand.memorandum:
                    reminder = "上位机发来信息";
                    newmemorandum(str);
                    break;

                default:
                    reminder = str;
                    break;
                }
            }
            catch (Exception e)
            {
                reminder = "model implement" + e.Message;
            }
        }
 private void implement(string str)
 {
     try
     {
         str = str.TrimEnd('\0');
         if (switchimplement != null && !string.IsNullOrEmpty(str))
         {
             ctransmitter transmitter = JsonConvert.DeserializeObject <ctransmitter>(str);
             ecommand     command     = (ecommand)Enum.Parse(typeof(ecommand), transmitter.command);
             int          id          = Convert.ToInt32(transmitter.id);
             switchimplement(id, command, transmitter.str);
         }
         //switch (command)
         //{
         //    case ecommand.ce:
         //        reminder("收到" + transmitter.id);
         //        break;
         //}
     }
     catch (Exception e)
     {
         reminder("str不是ctransmitter " + e.Message);
     }
 }
Beispiel #8
0
        public void send(ecommand command, string str)
        {
            ctransmitter transmitter = new ctransmitter(id, command, str);

            send(transmitter.ToString());
        }
Beispiel #9
0
        private void implement(int id, ecommand command, string str)
        {
            caddressBook addressbook;
            cdiary       diary;
            cmemorandum  memorandum;
            cproperty    property;

            switch (command)
            {
            case ecommand.ce:    //2015年11月26日08:56:10
                break;

            case ecommand.getdata:
                getdata();
                reminder = id.ToString() + "获取数据";
                return;

            case ecommand.addaddressBook:
                addressbook = Deserialize <caddressBook>(str);
                addaddressBook(addressbook);
                reminder = id.ToString() + "添加通讯录";
                break;

            case ecommand.newaddressBook:
                newaddressBook(str);
                break;

            case ecommand.daddressBook:
                addressbook = Deserialize <caddressBook>(str);
                deleteaddressBook(addressbook);
                break;

            case ecommand.adddiary:
                diary = Deserialize <cdiary>(str);
                adddiary(diary);
                break;

            case ecommand.ddiary:
                diary = Deserialize <cdiary>(str);
                ddiary(diary);
                break;

            case ecommand.newdiary:
                diary = Deserialize <cdiary>(str);
                newdiary(diary);
                break;

            case ecommand.addmemorandum:
                memorandum = Deserialize <cmemorandum>(str);
                addmemorandum(memorandum);
                break;

            case ecommand.dmemorandum:
                memorandum = Deserialize <cmemorandum>(str);
                dmemorandum(memorandum);
                break;

            case ecommand.newmemorandum:
                memorandum = Deserialize <cmemorandum>(str);
                newmemorandum(memorandum);
                break;

            case ecommand.addproperty:
                property = Deserialize <cproperty>(str);
                addproperty(property);
                break;

            case ecommand.dproperty:
                property = Deserialize <cproperty>(str);
                dproperty(property);
                break;

            case ecommand.newproperty:
                property = Deserialize <cproperty>(str);
                newproperty(property);
                break;

            default:
                reminder = str;
                break;
            }
            getdata();
        }