示例#1
0
        // Creates new Saturns5DashboardEntry based on the saturn 5 unit existing withing Saturns5DB, and specified with provided serial number.
        public void Create(Saturn5 saturn5)
        {
            if (saturn5 is null)
            {
                throw new ArgumentNullException(nameof(saturn5));
            }
            if (this.HasSerialNumberAssociatedEntry(saturn5.SerialNumber))
            {
                throw new ArgumentException("Saturns5DashboardRepository already contains dashboard entry associated with the provided Saturn5 serial number.", nameof(saturn5));
            }

            // Thread safety lock
            lock (this.DashboardDataLock)
            {
                // Get live spreadsheets database reference.
                LiveSpreadsheetsDb db = this._dataRepository.GoogleService.SpreadsheetsDb;

                // Get new dashboard entry row data
                IList <string> dashboardEntryRowData = this.GetNewDashboardEntryRowData(saturn5);

                // Append dashboard sheet with the row representing dashboard entry associated with provided Saturn5
                this._dashboardSheet.AppendRows(db, Saturns5DashboardRepository.Saturns5Dashboard_NewEntryRowsCount,
                                                new IList <string>[Saturns5DashboardRepository.Saturns5Dashboard_NewEntryRowsCount] {
                    dashboardEntryRowData
                });

                // Creates serial number-rowIndex association in the repository for the newly created
                this._dashboardRowIndexesBySerialNumbers.Add(saturn5.SerialNumber, this._dbRowIndexesBySerialNumbers[saturn5.SerialNumber] + 1);
            }
        }
示例#2
0
        public void Update(Saturn5 saturn5)
        {
            if (saturn5 is null)
            {
                throw new ArgumentNullException(nameof(saturn5));
            }
            if (!this.HasSerialNumberAssociatedEntry(saturn5.SerialNumber))
            {
                throw new ArgumentException("Saturns5DashboardRepository doesn't contain dashboard entry associated with the provided Saturn5.", nameof(saturn5));
            }

            // Thread safety lock
            lock (this.DashboardDataLock)
            {
                // Get live spreadsheets database reference.
                LiveSpreadsheetsDb db = this._dataRepository.GoogleService.SpreadsheetsDb;

                IList <string> updatedDashboardEntryRowData = this.GetUpdatedDashboardEntryRowData(saturn5);

                int     serialNumberDashboardRowIndex = this._dashboardRowIndexesBySerialNumbers[saturn5.SerialNumber];
                LiveRow saturns5DashboardEntry        = this._dashboardSheet[serialNumberDashboardRowIndex];

                saturns5DashboardEntry.SetDataFromStringsData(0, updatedDashboardEntryRowData);
                saturns5DashboardEntry.Upload(db);
            }
        }
示例#3
0
        private IList <string> GetUpdatedDashboardEntryRowData(Saturn5 saturn5)
        {
            IList <string> dashboardEntryRowData = new string[Saturns5DashboardRepository.Saturns5Dashboard_ColumnsCount];

            string saturnSpreadsheetId = this._dataRepository.Saturn5Repository.GetSaturn5LogSpreadsheetId(saturn5.SerialNumber);

            dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_SerialNumber]         = null;
            dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_ShortId]              = saturn5.ShortId;
            dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_SaturnSpreadsheetURL] = this.GetUrlFromSpreadsheetId(saturnSpreadsheetId);
            dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_Status]               = Saturn5StatusService.GetDashboardString(saturn5.Status);
            dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_PhoneNumber]          = saturn5.PhoneNumber;
            dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_LastSeenDate]         = saturn5.LastSeenDate;
            dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_LastSeenTime]         = saturn5.LastSeenTime;
            dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_LastSeenUserUsername] = saturn5.LastSeenUsername;

            try
            {
                dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_LastSeenUserFirstName] = this._dataRepository.UserRepository.GetUserFirstName(saturn5.LastSeenUsername);
                dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_LastSeenUserSurname]   = this._dataRepository.UserRepository.GetUserSurname(saturn5.LastSeenUsername);

                string userSpreadsheetId = this._dataRepository.UserRepository.GetUserLogSpreadsheetId(saturn5.LastSeenUsername);

                dashboardEntryRowData[Saturns5DashboardRepository.Saturns5Dashboard_LastSeenUserSpreadsheetURL] = this.GetUrlFromSpreadsheetId(userSpreadsheetId);
            }
            // If last seen username is associated with user which has been deleted since, catch an exception.
            catch (ArgumentException ex) when(ex.ParamName == "username")
            {
            }

            // Return constructed row data.
            return(dashboardEntryRowData);
        }
示例#4
0
        // 2)
        private void AddMissingSaturns5DashboardEntries(LiveSpreadsheetsDb db)
        {
            // ADD(append) MISSING ENTRIES IN THE DASHBOARD

            // Loop through all the serial numbers of the Saturn5 units existing in Saturns5Db,
            // and append dashboard with new row for each missing one.
            foreach (KeyValuePair <string, int> rowIndexBySerialNumber in this._dataRepository.Saturns5DB.RowIndexesBySerialNumbers.ToList())
            {
                // Get currently looped through saturns 5 database serial number
                string dbSerialNumber = rowIndexBySerialNumber.Key;

                if (this.HasSerialNumberAssociatedEntry(dbSerialNumber))
                {
                    continue;
                }

                // Get saturn5 associated with the serial number located on currently looped throw row in the Satruns5DB
                Saturn5 dbSaturn5 = this._dataRepository.Saturn5Repository.Read(dbSerialNumber);

                // Get new dashboard row entry data using obtained saturn.
                IList <string> newDashboardEntryRowData = this.GetNewDashboardEntryRowData(dbSaturn5);

                // Append current dashboard missing saturn 5 dashboard entry representing obtained saturn into this._dashboardSheet
                this._dashboardSheet.AppendRows(db, Saturns5DashboardRepository.Saturns5Dashboard_EntryRowsCount,
                                                new IList <string>[Saturns5DashboardRepository.Saturns5Dashboard_EntryRowsCount] {
                    newDashboardEntryRowData
                });

                // Rebuild dashboard serial numbers - entry row index quick access relativity index
                this.ReBuildDashboardSerialNumberIndex();
            }
        }
示例#5
0
        // Default constructor
        public EditSaturn5ReportCreationForm(App app, Saturn5 toBeEdited)
        {
            // Set reference to domain layer facade...
            this._app = app;

            // .. and instance of Saturn 5 to be edited.
            this.ToBeEdited = toBeEdited;

            // Initializes designer components.
            this.InitializeComponent();

            // Set the content of text boxes
            this.tbxSerialNumber.Text   = this.ToBeEdited.SerialNumber;
            this.tbxNewShortId.Text     = this.ToBeEdited.ShortId;
            this.tbxNewPhoneNumber.Text = this.ToBeEdited.PhoneNumber;
        }
示例#6
0
        // Default constructor
        public FaultReportCreationForm(App app, Saturn5 saturn5)
        {
            // Set reference to domain layer facade...
            this._app = app;

            // Initializes designer components.
            this.InitializeComponent();

            // ... and Saturn5 unit for which created report will be designated for.
            this._saturn5 = saturn5;

            // Set the content of the serial number text box.
            this.tbxSerialNumber.Text = saturn5.SerialNumber;
            this.tbxShortId.Text      = saturn5.ShortId;
            this.tbxPhoneNumber.Text  = saturn5.PhoneNumber;

            // Set content of tbxUsername to saturn 5 unit LastSeenUsername
            this.tbxUsername.Text = saturn5.LastSeenUsername;

            this.Shown += FaultReportCreationForm_Shown;
        }
示例#7
0
        // Default constructor
        public ResolveSaturn5IssueReportCreationForm(App app, Saturn5 saturn5)
        {
            // Set reference to domain layer facade...
            this._app = app;

            // Initializes designer components.
            this.InitializeComponent();

            // ... and Saturn5 unit for which created report will be designated for.
            this._saturn5 = saturn5;

            // Set the content of the serial number text box.
            this.tbxSerialNumber.Text = saturn5.SerialNumber;

            // Set content of user realted text boxes based on the currently logged user
            this.tbxUsername.Text  = this._app.LoggedUsername;
            this.tbxFirstName.Text = this._app.LoggedUser.FirstName;
            this.tbxSurname.Text   = this._app.LoggedUser.Surname;
            this.tbxUserType.Text  = this._app.LoggedUsername;

            this.Shown += ResolveSaturn5IssueReportCreationForm_Shown;
        }
 public AttemptToAllocateDamagedSaturn5Exception(User user, Saturn5 saturn5) : base(DefaultMessage)
 {
     this.User    = user;
     this.Saturn5 = saturn5;
 }
示例#9
0
 public UserWithFaultySaturn5EventArgs(User user, Saturn5 saturn5, Saturn5Issue saturn5Fault)
 {
     this.User         = user;
     this.Saturn5      = saturn5;
     this.Saturn5Fault = saturn5Fault;
 }
示例#10
0
 public UserWithDamagedSaturn5EventArgs(User user, Saturn5 saturn5, Saturn5Issue saturn5Damage)
 {
     this.User          = user;
     this.Saturn5       = saturn5;
     this.Saturn5Damage = saturn5Damage;
 }
 public Saturn5DamageReportEventArgs(Saturn5 saturn5, string username, string description)
 {
     this.Saturn5     = saturn5;
     this.Username    = username;
     this.Description = description;
 }
 public EditSaturn5EventArgs(Saturn5 toBeEdited, string newShortId, string newPhoneNumber)
 {
     this.ToBeEdited     = toBeEdited;
     this.NewShortId     = newShortId;
     this.NewPhoneNumber = newPhoneNumber;
 }
示例#13
0
 public UserUsernameWithSaturn5(string username, Saturn5 saturn5)
 {
     this.Username = username;
     this.Saturn5  = saturn5;
 }
 public Saturn5LastSeenUsernameIsInvalidException(Saturn5 saturn5, string message, Exception inner) : base(saturn5.LastSeenUsername, message, inner)
 {
     this.Saturn5 = saturn5;
 }
示例#15
0
 public UserWithSaturn5EventArgs(User user, Saturn5 saturn5)
 {
     this.User    = user;
     this.Saturn5 = saturn5;
 }
 public AttemptToAllocateDamagedSaturn5Exception(User user, Saturn5 saturn5, string message, Exception inner) : base(message, inner)
 {
     this.User    = user;
     this.Saturn5 = saturn5;
 }
 public FaultySaturn5EventArgs(Saturn5 saturn5, Saturn5Issue saturn5Fault)
 {
     this.Saturn5      = saturn5;
     this.Saturn5Fault = saturn5Fault;
 }
 public DamagedSaturn5EventArgs(Saturn5 saturn5, Saturn5Issue saturn5Damage)
 {
     this.Saturn5       = saturn5;
     this.Saturn5Damage = saturn5Damage;
 }
 public AttemptToAllocateFaultySaturn5Exception(User user, Saturn5 saturn5, string message) : base(message)
 {
     this.User    = user;
     this.Saturn5 = saturn5;
 }
 protected AttemptToAllocateDamagedSaturn5Exception(System.Runtime.Serialization.SerializationInfo info,
                                                    System.Runtime.Serialization.StreamingContext context) : base(info, context)
 {
     this.User    = info.GetValue("User", typeof(User)) as User;
     this.Saturn5 = info.GetValue("Saturn5", typeof(Saturn5)) as Saturn5;
 }
 public UserWithSaturn5FaultReportEventArgs(User user, Saturn5 saturn5, string description)
 {
     this.User        = user;
     this.Saturn5     = saturn5;
     this.Description = description;
 }
 public Saturn5LastSeenUsernameIsInvalidException(Saturn5 saturn5) : base(saturn5.LastSeenUsername, DefaultParamNameSaturn5MessageBegining + $"{saturn5.LastSeenUsername}")
 {
     this.Saturn5 = saturn5;
 }
 public AttemptToConfirmStarUserSaturn5Exception(User user, Saturn5 saturn5) : base(DefaultMessage)
 {
     this.User    = user;
     this.Saturn5 = saturn5;
 }
 protected Saturn5LastSeenUsernameIsInvalidException(System.Runtime.Serialization.SerializationInfo info,
                                                     System.Runtime.Serialization.StreamingContext context) : base(info, context)
 {
     this.Saturn5  = info.GetValue("Saturn5", typeof(Saturn5)) as Saturn5;
     this.Username = info.GetValue("Username", typeof(string)) as string;
 }
 public AttemptToConfirmStarUserSaturn5Exception(User user, Saturn5 saturn5, string message, Exception inner) : base(message, inner)
 {
     this.User    = user;
     this.Saturn5 = saturn5;
 }
 public Saturn5EventArgs(Saturn5 saturn5)
 {
     this.Saturn5 = saturn5;
 }
示例#27
0
 public static void AddRetrievingSaturn5DataSucceedLog(RichTextBox rtbDeBriefInfo, Saturn5 saturn5)
 {
     rtbDeBriefInfo.AppendLog($"Serial Number: {saturn5.SerialNumber} Barcode: {saturn5.ShortId}", _headerColor);
 }