Exemplo n.º 1
0
        private DataTable GetUpdateTable(string selectQuery)
        {
            var tmpTable = controlParser.ReturnUpdateTable(selectQuery);
            var row      = tmpTable.Rows[0];

            //Add Add'l info
            if (MunisUser.Number != null && MunisUser.Number != string.Empty)
            {
                row[DevicesCols.CurrentUser] = MunisUser.Name;
                row[DevicesCols.MunisEmpNum] = MunisUser.Number;
            }
            else
            {
                if (currentViewDevice.CurrentUser != CurrentUserTextBox.Text.Trim())
                {
                    row[DevicesCols.CurrentUser] = CurrentUserTextBox.Text.Trim();
                    row[DevicesCols.MunisEmpNum] = DBNull.Value;
                }
                else
                {
                    row[DevicesCols.CurrentUser] = currentViewDevice.CurrentUser;
                    row[DevicesCols.MunisEmpNum] = currentViewDevice.CurrentUserEmpNum;
                }
            }
            row[DevicesCols.SibiLinkGuid] = DataConsistency.CleanDBValue(currentViewDevice.SibiLink);
            row[DevicesCols.LastModUser]  = NetworkInfo.LocalDomainUser;
            row[DevicesCols.LastModDate]  = DateTime.Now;
            return(tmpTable);
        }
Exemplo n.º 2
0
 private void PhoneNumberTextBox_Leave(object sender, EventArgs e)
 {
     if (!DataConsistency.ValidPhoneNumber(PhoneNumberTextBox.Text))
     {
         OtherFunctions.Message("Invalid phone number.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Error", this);
     }
 }
Exemplo n.º 3
0
 public static void OrgObjSearch(ExtendedForm parentForm)
 {
     try
     {
         using (var newDialog = new Dialog(parentForm))
         {
             string org = "";
             string obj = "";
             string fy  = "";
             newDialog.Text = "Org/Object Code Search";
             newDialog.AddTextBox("Org", "Org Code:");
             newDialog.AddTextBox("Obj", "Object Code:");
             newDialog.AddTextBox("FY", "Fiscal Year:");
             newDialog.SetControlValue("FY", DateTime.Now.Year);
             newDialog.ShowDialog();
             if (newDialog.DialogResult == DialogResult.OK)
             {
                 org = newDialog.GetControlValue("Org").ToString();
                 obj = newDialog.GetControlValue("Obj").ToString();
                 fy  = newDialog.GetControlValue("FY").ToString();
                 if (org.Trim() != "" && DataConsistency.IsValidYear(fy))
                 {
                     NewOrgObjView(org, obj, fy, parentForm);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ErrorHandling.ErrHandle(ex, System.Reflection.MethodBase.GetCurrentMethod());
     }
 }
Exemplo n.º 4
0
 private void PhoneNumTextBox_Leave(object sender, EventArgs e)
 {
     if (PhoneNumTextBox.Text.ToString().Trim() != "" && !DataConsistency.ValidPhoneNumber(PhoneNumTextBox.Text))
     {
         OtherFunctions.Message("Invalid phone number.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Error", this);
         PhoneNumTextBox.Focus();
     }
 }
Exemplo n.º 5
0
        public string InvokeRemotePSCommand(NetworkCredential credentials, Command pScommand)
        {
            try
            {
                var psCreds = new PSCredential(credentials.UserName, credentials.SecurePassword);

                string shellUri = "http://schemas.microsoft.com/powershell/Microsoft.PowerShell";
                WSManConnectionInfo connInfo = new WSManConnectionInfo(false, targetHostname, 5985, "/wsman", shellUri, psCreds);

                using (Runspace remoteRunSpace = RunspaceFactory.CreateRunspace(connInfo))
                {
                    remoteRunSpace.Open();
                    remoteRunSpace.SessionStateProxy.SetVariable("cred", psCreds);

                    using (var powerSh = PowerShell.Create())
                    {
                        powerSh.Runspace = remoteRunSpace;
                        powerSh.InvocationStateChanged -= Powershell_InvocationStateChanged;
                        powerSh.InvocationStateChanged += Powershell_InvocationStateChanged;
                        powerSh.Commands.AddCommand(pScommand);
                        CurrentPowerShellObject = powerSh;
                        Collection <PSObject> results = powerSh.Invoke();

                        StringBuilder stringBuilder = new StringBuilder();

                        foreach (var obj in results)
                        {
                            stringBuilder.AppendLine(obj.ToString());
                        }

                        remoteRunSpace.Close();
                        powerSh.Stop();
                        return(DataConsistency.CleanDBValue((stringBuilder.ToString())).ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                //Check for incorrect username/password error and rethrow a Win32Exception to be caught in the error handler.
                //Makes sure that the global admin credentials variable is cleared so that a new prompt will be shown on the next attempt. See: VerifyAdminCreds method.
                if (ex is PSRemotingTransportException)
                {
                    var transportEx = (PSRemotingTransportException)ex;
                    if (transportEx.ErrorCode == 1326)
                    {
                        throw new Win32Exception(1326);
                    }
                }
                return(ex.Message);
            }
        }
Exemplo n.º 6
0
        public async Task <bool> InvokePowerShellSession(PowerShell session)
        {
            CurrentPowerShellObject         = session;
            session.InvocationStateChanged -= Powershell_InvocationStateChanged;
            session.InvocationStateChanged += Powershell_InvocationStateChanged;

            try
            {
                var psResults = await Task.Run(() =>
                {
                    Collection <PSObject> results = session.Invoke();
                    StringBuilder stringBuilder   = new StringBuilder();


                    foreach (var obj in results)
                    {
                        stringBuilder.AppendLine(obj.ToString());
                    }
                    return(DataConsistency.CleanDBValue((stringBuilder.ToString())).ToString());
                });

                if (!string.IsNullOrEmpty(psResults))
                {
                    if (psResults.Contains("success"))
                    {
                        return(true);
                    }
                    else
                    {
                        OtherFunctions.Message(psResults, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Error Running Script");
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                session.Runspace.Close();
                session.Runspace.Dispose();
                session.Dispose();
            }
        }
Exemplo n.º 7
0
 private void SetHostname()
 {
     if (OSTypeComboBox.SelectedValue != null)
     {
         bool windowsSelected = OSTypeComboBox.Text.ToString().ToUpper().Contains("WIN");
         if (SerialTextBox.Text != "" && windowsSelected)
         {
             HostnameTextBox.Text = DataConsistency.DeviceHostnameFormat(SerialTextBox.Text);
         }
         else
         {
             HostnameTextBox.Text = string.Empty;
         }
     }
 }
Exemplo n.º 8
0
        private bool FieldsValid()
        {
            bool fieldsValid = true;

            fieldsValid = controlParser.ValidateFields();
            if (!DataConsistency.ValidPhoneNumber(PhoneNumberTextBox.Text))
            {
                fieldsValid = false;
                controlParser.SetError(PhoneNumberTextBox, false);
            }
            else
            {
                controlParser.SetError(PhoneNumberTextBox, true);
            }
            return(fieldsValid); //if fields are missing return false to trigger a message if needed
        }
Exemplo n.º 9
0
        private bool CheckFields()
        {
            bool validFields = true;

            validFields = controlParser.ValidateFields();

            LockUnlockUserField();

            if (PhoneNumTextBox.Text.Trim() != "" && !DataConsistency.ValidPhoneNumber(PhoneNumTextBox.Text))
            {
                validFields = false;
                controlParser.SetError(PhoneNumTextBox, false);
                OtherFunctions.Message("Invalid phone number.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Error", this);
            }

            return(validFields);
        }
Exemplo n.º 10
0
 private void ViewTrackingEntry(string entryGuid, Device device)
 {
     try
     {
         Waiting();
         using (DataTable results = DBFactory.GetDatabase().DataTableFromQueryString(Queries.SelectTrackingEntryByGuid(entryGuid)))
         {
             foreach (DataRow r in results.Rows)
             {
                 txtTimeStamp.Text = DataConsistency.NoNull(r[TrackablesCols.DateStamp]);
                 txtCheckType.Text = DataConsistency.NoNull(r[TrackablesCols.CheckType]);
                 if (txtCheckType.Text == "IN")
                 {
                     txtCheckType.BackColor = Colors.CheckIn;
                 }
                 else if (txtCheckType.Text == "OUT")
                 {
                     txtCheckType.BackColor = Colors.CheckOut;
                 }
                 txtDescription.Text  = device.Description;
                 txtGuid.Text         = DataConsistency.NoNull(r[TrackablesCols.DeviceGuid]);
                 txtCheckOutUser.Text = DataConsistency.NoNull(r[TrackablesCols.CheckoutUser]);
                 txtCheckInUser.Text  = DataConsistency.NoNull(r[TrackablesCols.CheckinUser]);
                 txtLocation.Text     = DataConsistency.NoNull(r[TrackablesCols.UseLocation]);
                 txtAssetTag.Text     = device.AssetTag;
                 txtCheckOutTime.Text = DataConsistency.NoNull(r[TrackablesCols.CheckoutTime]);
                 txtDueBack.Text      = DataConsistency.NoNull(r[TrackablesCols.DueBackDate]);
                 txtSerial.Text       = device.Serial;
                 txtCheckInTime.Text  = DataConsistency.NoNull(r[TrackablesCols.CheckinTime]);
                 txtNotes.Text        = DataConsistency.NoNull(r[TrackablesCols.Notes]);
                 txtEntryGuid.Text    = DataConsistency.NoNull(r[TrackablesCols.Guid]);
                 this.Text            = this.Text + " - " + DataConsistency.NoNull(r[TrackablesCols.DateStamp]);
             }
         }
     }
     catch (Exception ex)
     {
         ErrorHandling.ErrHandle(ex, System.Reflection.MethodBase.GetCurrentMethod());
     }
     finally
     {
         DoneWaiting();
     }
 }
Exemplo n.º 11
0
 public object GetDBControlValue(Control control)
 {
     if (control is TextBox)
     {
         var dbTxt = (TextBox)control;
         return(DataConsistency.CleanDBValue(dbTxt.Text));
     }
     else if (control is MaskedTextBox)
     {
         var dbMaskTxt = (MaskedTextBox)control;
         return(DataConsistency.CleanDBValue(dbMaskTxt.Text));
     }
     else if (control is DateTimePicker)
     {
         var dbDtPick = (DateTimePicker)control;
         return(dbDtPick.Value);
     }
     else if (control is ComboBox)
     {
         var dbCmb = (ComboBox)control;
         if (dbCmb.SelectedIndex > -1)
         {
             return(dbCmb.SelectedValue.ToString());
         }
         else
         {
             return(dbCmb.Text);
         }
     }
     else if (control is CheckBox)
     {
         var dbChk = (CheckBox)control;
         return(dbChk.Checked);
     }
     else
     {
         throw new Exception("Unexpected type.");
         //return null;
     }
 }
Exemplo n.º 12
0
        public static async void ReqSearch(ExtendedForm parentForm)
        {
            try
            {
                string reqNumber = "";
                string fy        = "";
                using (var newDialog = new Dialog(parentForm))
                {
                    newDialog.Text = "Req Search";
                    newDialog.AddTextBox("ReqNum", "Requisition #:");
                    newDialog.AddTextBox("FY", "FY:");
                    newDialog.ShowDialog();
                    if (newDialog.DialogResult == DialogResult.OK)
                    {
                        reqNumber = newDialog.GetControlValue("ReqNum").ToString();
                        fy        = newDialog.GetControlValue("FY").ToString();
                        if (DataConsistency.IsValidYear(fy))
                        {
                            parentForm.Waiting();

                            var blah = await NewMunisReqSearch(reqNumber, fy, parentForm);
                        }
                        else
                        {
                            OtherFunctions.Message("Invalid year.", MessageBoxButtons.OK, MessageBoxIcon.Information, "Invalid", parentForm);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.ErrHandle(ex, System.Reflection.MethodBase.GetCurrentMethod());
            }
            finally
            {
                parentForm.DoneWaiting();
            }
        }
Exemplo n.º 13
0
 private void FillControls(DataTable data)
 {
     controlParser.FillDBFields(data);
     this.Text = this.Text + " - " + DataConsistency.NoNull(data.Rows[0][HistoricalDevicesCols.ActionDateTime]);
 }