Beispiel #1
0
 public void ResetToUnmodified()
 {
     if (CurrentRecord == null)
     {
         throw new InvalidOperationException(VenturaSqlStrings.CURRENT_RECORD_NOT_SET);
     }
     CurrentRecord.ResetToUnmodified();
 }
        //Get a particular field from the record by its zero-indexed position
        public string GetFieldByPosition(int position)
        {
            if (position < 0 || position >= HeaderRecord.Count())
            {
                throw new ArgumentOutOfRangeException(position.ToString(CultureInfo.InvariantCulture), "Position is out of range.");
            }

            return(CurrentRecord.ElementAt(position));
        }
Beispiel #3
0
        void ParseMapElement()
        {
            if (!IsHeader)
            {
                throw new InvalidOperationException("");
            }
            var element = CurrentRecord.ParseElement();

            NextRecord();
            while (IsNotEnd && !IsHeader)
            {
                ParseRecord(element);
                NextRecord();
            }
            _map.AddElement(element);
        }
Beispiel #4
0
 private void AddNameForm_Shown(object sender, EventArgs e)
 {
     textBox2.Text = (CurrentRecord != 999) ? CurrentRecord.ToString() : String.Empty;
 }
        public void Run()
        {
            var stop = false;

            while (!stop)
            {
                var numberOfPackages = CurrentProject.Packages.Count;

                var actionStartWork = new StartWorkOnPackage(State, CurrentProject, CurrentRecord, DataAccess, 0);

                //List current work state
                ListCurrentWorkState(2, CurrentProject, CurrentRecord, CurrentRecord.LastOpenEntry());
                //List actions
                ListActions(2, CurrentProject, CurrentRecord, CurrentRecord.LastOpenEntry(), actionStartWork);

                var answer = UserInterface.GetUserChar(1, "Select on what to do", null, x => StopReadUserInteraction(x, numberOfPackages), "please type sensible things > ? <", numberOfPackages.ToString().Length);

                answer.TrimEnd('\r').TrimEnd('\n');

                if (actionStartWork.MatchesIdentifier(answer) && int.TryParse(answer, out var number))
                {
                    actionStartWork.SetPackage(CurrentProject.Packages[number]);
                    actionStartWork.Run();
                    stop = true;
                }
                else if (answer.Equals(","))
                {
                    DataAccess.StopWorkOnOpenPackage(State, CurrentRecord);
                    stop = true;
                }
                else if (answer.Equals("+"))
                {
                    CreateNewPackage(State, CurrentProject);
                }
                else if (answer.Equals("-"))
                {
                    DeletePackage(State, CurrentProject);
                }
                else if (answer.Equals("*"))
                {
                    CurrentProject = SwitchProject(State);
                }
                else if (answer.Equals("l"))
                {
                    ListTodaysActivities(State, CurrentProject, CurrentRecord);
                }
                else if (answer.Equals("e"))
                {
                    EditRecordEntries(State, CurrentProject, CurrentRecord);
                }
                else if (answer.Equals("x"))
                {
                    Program.ExportAction();
                }
                else if (answer.Equals("q"))
                {
                    stop = true;
                }

                if (!stop)
                {
                    UserInterface.ClearConsole();
                }
            }
        }
Beispiel #6
0
 public virtual bool DeleteCurrentRecord()
 {
     return(DeleteObject(CurrentRecord, string.Format(ConstStrings.Get("DeleteRecord"), CurrentRecord.ToString()), (o) => { CurrentRecord = null; }));
 }
Beispiel #7
0
		public void ResetToExisting()
		{
			if (CurrentRecord == null) throw new InvalidOperationException(VenturaSqlStrings.CURRENT_RECORD_NOT_SET);
			CurrentRecord.ResetToExisting();
		}
Beispiel #8
0
        public void Read(BinaryReader binaryReader)
        {
            if (binaryReader == null)
            {
                // Error Message? Log?
                return;
            }

            this.MaxColumns          = 0;
            this.CurrentBinaryReader = binaryReader;
            this.CurrentRecord       = null;
            this.Records.Clear();
            string CurrentBuffer = "";             // new StringBuilder();

            try
            {
                int ich = this.CurrentBinaryReader.Read();

                while (ich >= 0)
                {
                    char ch = (char)ich;
                    CurrentBuffer += ch;

                    //if(this.LeftEnclosure.Length > 0 && this.RightEnclosure.Length > 0 && CurrentBuffer.ToString().StartsWith(LeftEnclosure))
                    //{

                    //}
                    //else
                    {
                        // EOL / End of Record ?
                        if (this.RecordDelimiter.Length > 0 && CurrentBuffer.ToString().EndsWith(this.RecordDelimiter))
                        {
                            //if(CurrentBuffer.Length > this.RecordDelimiter.Length)
                            string Data = CurrentBuffer.ToString().Substring(0, CurrentBuffer.Length - this.RecordDelimiter.Length);
                            CurrentRecord.Add(Data);

                            // clear buffer...
                            CurrentBuffer = "";

                            // Add delimiter?
                            if (IncludeRecordDelimiter)
                            {
                                CurrentRecord.Add(this.RecordDelimiter);
                            }

                            // Add before renewing...
                            if (CurrentRecord.Count > 0)                            // consider if empty...
                            {
                                if (!(this.Records.Contains(CurrentRecord)))
                                {
                                    this.Records.Add(CurrentRecord);
                                }
                            }

                            // Capture/Update MaxColumns...
                            if (CurrentRecord.Count > MaxColumns)
                            {
                                MaxColumns = (uint)CurrentRecord.Count;
                            }

                            // renew record (new object, NOT simply clear)
                            CurrentRecord = new List <string>();
                        }
                        // New Field?
                        else if (this.FieldDelimiter.Length > 0 && CurrentBuffer.ToString().EndsWith(this.FieldDelimiter))
                        {
                            bool   ConsumeFieldData = true;
                            string Data             = CurrentBuffer.ToString().Substring(0, CurrentBuffer.Length - this.FieldDelimiter.Length);

                            // Only if using Enclosures...
                            if (this.LeftEnclosure.Length > 0 && this.RightEnclosure.Length > 0)
                            {
                                // TODO - Need to Trim() before checking???
                                if (Data.StartsWith(LeftEnclosure))
                                {
                                    if (!(Data.EndsWith(RightEnclosure)))                                    // keep reading and appending to buffer...
                                    {
                                        ConsumeFieldData = false;
                                    }
                                }
                            }

                            if (ConsumeFieldData)
                            {
                                CurrentRecord.Add(Data);

                                // clear buffer...
                                CurrentBuffer = "";

                                // Add delimiter?
                                if (this.IncludeFieldDelimiter)
                                {
                                    CurrentRecord.Add(this.FieldDelimiter);
                                }
                            }
                        }
                    }

                    // finally, read for next iteration...
                    ich = this.CurrentBinaryReader.Read();
                }                 // end read loop


                if (CurrentBuffer.Length > 0)
                {
                    CurrentRecord.Add(CurrentBuffer);
                    CurrentBuffer = "";                     // clear
                }

                if (CurrentRecord.Count > 0)
                {
                    if (!(this.Records.Contains(CurrentRecord)))
                    {
                        this.Records.Add(CurrentRecord);
                    }
                }
            }
            catch (Exception e)
            {
                WriteLine("" + e);
            }
            finally
            {
                if (this.CurrentBinaryReader != null)
                {
                    try
                    {
                        this.CurrentBinaryReader.Close();
                    }
                    catch (Exception e)
                    {
                        WriteLine("" + e);
                    }
                }
            }


            WriteLine("Records.Count: " + this.Records.Count);
            WriteLine("MaxColumns: " + this.MaxColumns);
        }