Ejemplo n.º 1
0
        public override void Execute()
        {
            RetCode rc;

            gOut.WriteLine();

            gEngine.PrintTitle(Title, true);

            gOut.Write("{0}{1}", Environment.NewLine, gEngine.BuildPrompt(55, '\0', 0, string.Format("Enter the uid of the {0} record to copy", RecordTypeName), "1"));

            Buf.Clear();

            rc = Globals.In.ReadField(Buf, Constants.BufSize01, null, '_', '\0', true, "1", null, gEngine.IsCharDigit, null);

            Debug.Assert(gEngine.IsSuccess(rc));

            var recordUid = Convert.ToInt64(Buf.Trim().ToString());

            gOut.Print("{0}", Globals.LineSep);

            var record = RecordTable.FindRecord(recordUid);

            if (record == null)
            {
                gOut.Print("{0} record not found.", RecordTypeName.FirstCharToUpper());

                goto Cleanup;
            }

            var record01 = Globals.CloneInstance(record);

            Debug.Assert(record01 != null);

            if (!Globals.Config.GenerateUids)
            {
                gOut.Write("{0}{1}", Environment.NewLine, gEngine.BuildPrompt(55, '\0', 0, string.Format("Enter the uid of the {0} record copy", RecordTypeName), null));

                Buf.Clear();

                rc = Globals.In.ReadField(Buf, Constants.BufSize01, null, '_', '\0', false, null, null, gEngine.IsCharDigit, null);

                Debug.Assert(gEngine.IsSuccess(rc));

                recordUid = Convert.ToInt64(Buf.Trim().ToString());

                gOut.Print("{0}", Globals.LineSep);

                if (recordUid > 0)
                {
                    record = RecordTable.FindRecord(recordUid);

                    if (record != null)
                    {
                        gOut.Print("{0} record already exists.", RecordTypeName.FirstCharToUpper());

                        goto Cleanup;
                    }

                    RecordTable.FreeUids.Remove(recordUid);

                    record01.Uid = recordUid;

                    record01.IsUidRecycled = false;
                }
                else
                {
                    record01.Uid = RecordTable.GetRecordUid();

                    record01.IsUidRecycled = true;
                }
            }
            else
            {
                record01.Uid = RecordTable.GetRecordUid();

                record01.IsUidRecycled = true;
            }

            var helper = Globals.CreateInstance <U>(x =>
            {
                x.Record = record01;
            });

            helper.ListRecord(true, true, false, true, false, false);

            PrintPostListLineSep();

            gOut.Write("{0}Would you like to save this {1} record (Y/N): ", Environment.NewLine, RecordTypeName);

            Buf.Clear();

            rc = Globals.In.ReadField(Buf, Constants.BufSize02, null, ' ', '\0', false, null, gEngine.ModifyCharToUpper, gEngine.IsCharYOrN, gEngine.IsCharYOrN);

            Debug.Assert(gEngine.IsSuccess(rc));

            Globals.Thread.Sleep(150);

            if (Buf.Length > 0 && Buf[0] == 'N')
            {
                record01.Dispose();

                goto Cleanup;
            }

            rc = RecordTable.AddRecord(record01);

            Debug.Assert(gEngine.IsSuccess(rc));

            UpdateGlobals();

Cleanup:

            ;
        }
Ejemplo n.º 2
0
        public override void Execute()
        {
            RetCode rc;

            var buf01 = new StringBuilder(Constants.BufSize);

            var recUids = new long[2];

            gOut.WriteLine();

            gEngine.PrintTitle(Title, true);

            var maxRecUid = RecordTable.GetRecordUid(false);

            gOut.Write("{0}{1}", Environment.NewLine, gEngine.BuildPrompt(43, '\0', 0, string.Format("Enter the starting {0} uid", RecordTypeName), "1"));

            Buf.Clear();

            rc = Globals.In.ReadField(Buf, Constants.BufSize01, null, '_', '\0', true, "1", null, gEngine.IsCharDigit, null);

            Debug.Assert(gEngine.IsSuccess(rc));

            recUids[0] = Convert.ToInt64(Buf.Trim().ToString());

            gOut.Print("{0}", Globals.LineSep);

            gOut.Write("{0}{1}", Environment.NewLine, gEngine.BuildPrompt(43, '\0', 0, string.Format("Enter the ending {0} uid", RecordTypeName), maxRecUid > 0 ? maxRecUid.ToString() : "1"));

            Buf.Clear();

            rc = Globals.In.ReadField(Buf, Constants.BufSize01, null, '_', '\0', true, maxRecUid > 0 ? maxRecUid.ToString() : "1", null, gEngine.IsCharDigit, null);

            Debug.Assert(gEngine.IsSuccess(rc));

            recUids[1] = Convert.ToInt64(Buf.Trim().ToString());

            var helper = Globals.CreateInstance <U>();

            var records = RecordTable.Records.Where(x => x.Uid >= recUids[0] && x.Uid <= recUids[1]);

            foreach (var record in records)
            {
                helper.Record = record;

                gOut.Print("{0}", Globals.LineSep);

                helper.ListRecord(true, Globals.Config.ShowDesc, Globals.Config.ResolveEffects, true, false, false);

                PrintPostListLineSep();

                gOut.Write("{0}Press any key to continue or X to exit: ", Environment.NewLine);

                Buf.Clear();

                rc = Globals.In.ReadField(Buf, Constants.BufSize02, null, ' ', '\0', true, null, gEngine.ModifyCharToNullOrX, null, gEngine.IsCharAny);

                Debug.Assert(gEngine.IsSuccess(rc));

                if (Buf.Length > 0 && Buf[0] == 'X')
                {
                    break;
                }
            }

            gOut.Print("{0}", Globals.LineSep);

            gOut.Print("Done listing {0} record details.", RecordTypeName);
        }