Exemplo n.º 1
0
        public frmViewComments(DailyMileEntry entry)
            : base()
        {
            _entry = entry;

            InitializeComponent();
        }
Exemplo n.º 2
0
        public static DailyMileEntries MergeEntry(string fileName, DailyMileEntry entry)
        {
            BindingListView<DailyMileEntry> fileentries;
            DailyMileEntries murgedEntries;

            try
            {

                fileentries = new BindingListView<DailyMileEntry>(DailyMileAPI.GetStoredEntries(fileName).Entries);
                if (fileentries.Exists("ID", entry.ID) == true)
                {
                    fileentries.RemoveItems("ID", entry.ID);
                }
                fileentries.Add(entry);

                using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
                {

                    using (BinaryWriter binWriter = new BinaryWriter(fs))
                    {
                        murgedEntries = new DailyMileEntries();
                        fileentries.SortDirection = ListSortDirection.Descending;
                        fileentries.SortFields = "ID";
                        murgedEntries.Entries = fileentries.GetList();

                        binWriter.Write(SerializersJSON.Serialize<DailyMileEntries>(murgedEntries));
                    }
                }

            }
            catch (VSException ve)
            {
                throw ve;
            }
            catch (System.Exception ex)
            {
                throw new VSException(string.Format("MergeEntries FileName({0}) Exception {1}", fileName, ex.Message));
            }

            return murgedEntries;
        }
Exemplo n.º 3
0
        public DailyMileEntry PostEntry(DailyMileEntry entry)
        {
            DailyMileEntry retVal = null;

            try
            {
                byte[] data = SerializersJSON.Serialize<DailyMileEntry>(entry);

                string results;

                if (LogonDailyMile() == true)
                {
                    string getAuth = string.Format("{0}/entries.json?oauth_token={1}", _connectionInfo.DailyMileURL, _connectionInfo.ServerKey);
                    results = PostData(getAuth, data);
                    retVal = SerializersJSON.Deserialise<DailyMileEntry>(Encoding.ASCII.GetBytes(results));
                }
            }
            catch (VSException ve)
            {
                throw ve;
            }
            catch (Exception ex)
            {
                throw new VSException(string.Format("PostEntry Exception {0}", ex.Message));
            }
            return retVal;
        }
Exemplo n.º 4
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            DailyMileEntry entry = new DailyMileEntry();
            entry.WorkOut = new DailyMileWorkOut();
            entry.Message = "Hey";
            entry.WorkOut.Activity_type = enumActivityType.Running;
            entry.WorkOut.Distance = new DailyMileDistance();
            entry.WorkOut.Distance.Units = "miles";
            entry.WorkOut.Distance.Value = 4;

            _APIWrapper.PostEntry(entry);

            //byte[] rew = SerializersJSON.Serialize<DailyMileEntry>(entry);
               // string x = Encoding.ASCII.GetString(rew);
        }