Example #1
0
        public bool DeleteClass(int studyClassID, SqlConnection conn = null)
        {
            bool succes = true;

            try
            {
                bool nullConnection = false;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_deleteClass", conn))
                {
                    cmd.Parameters.AddWithValue("@CLASS_ID", studyClassID);
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    cmd.ExecuteNonQuery();

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("DeleteClass() error. ClassId: " + studyClassID, e);
            }

            return(succes);
        }
Example #2
0
 /// <summary>
 /// Verifies a Digital Signature based on the encoding type
 /// </summary>
 /// <param name="encodingType"></param>
 /// <returns></returns>
 public bool VerifySignature(Encoding encodingType)
 {
     try
     {
         SignedData signedData = new SignedDataClass();
         Utilities  u          = new UtilitiesClass();
         if (_bDetached)
         {
             signedData.Content = u.ByteArrayToBinaryString(encodingType.GetBytes(Content));
             //signedData.set_Content(u.ByteArrayToBinaryString(encodingType.GetBytes(Content)));
         }
         signedData.Verify(SignedContent, Detached, CAPICOM_SIGNED_DATA_VERIFY_FLAG.CAPICOM_VERIFY_SIGNATURE_ONLY);
         SignerCert = null;
         Signer s = (Signer)signedData.Signers[1];
         SignerCert = (Certificate)s.Certificate;
         if (!_bDetached)
         {
             //Content = encodingType.GetString((byte[])u.BinaryStringToByteArray(signedData.get_Content()));
             Content = encodingType.GetString((byte[])u.BinaryStringToByteArray(signedData.Content));
         }
         return(true);
     }
     catch (COMException e)
     {
         Console.WriteLine("{0}: {1}", e.Source, e.Message);
         return(false);
     }
 }
Example #3
0
 public CustomMessage(MessagesTable m)
 {
     if (UtilitiesClass.getPatient(m.MessageTO) != null)
     {
         PatientsTable messageTo   = UtilitiesClass.getPatient(m.MessageTO);
         DoctorsTable  messageFrom = UtilitiesClass.getDoctor(m.MessageFROM);
         this.From = $"{messageFrom.FirstName.Trim()} {messageFrom.LastName.Trim()}";
         this.To   = $"{messageTo.FirstName.Trim()} {messageTo.LastName.Trim()}";
     }
     else
     {
         DoctorsTable  messageTo   = UtilitiesClass.getDoctor(m.MessageTO);
         PatientsTable messageFrom = UtilitiesClass.getPatient(m.MessageFROM);
         this.From = $"{messageFrom.FirstName.Trim()} {messageFrom.LastName.Trim()}";
         this.To   = $"{messageTo.FirstName.Trim()} {messageTo.LastName.Trim()}";
     }
     this.Date           = m.Date;
     this.MessagePreview = Regex.Replace(m.Message.Remove(40), @"\s+", " ");
     //CHECK
     if (m.Message.Length > 40)
     {
         this.MessagePreview += "...";
     }
     this.Read      = Convert.ToInt32(m.IsRead) == 0 ? "Unread" : "";
     this.MessageID = m.MessageID;
 }
Example #4
0
 protected void DeleteDoctorAppointButton_Click(object sender, EventArgs e) // same logic for deleting patient appointments
 {
     if (ShowDoctorAppointments.SelectedRow != null)
     {
         AppointmentsTable delete = new AppointmentsTable();
         string            input  = ShowDoctorAppointments.SelectedValue.ToString();
         int appointmentID        = Convert.ToInt32(input);
         delete = UtilitiesClass.createAppointment(appointmentID);
         foreach (AppointmentsTable appointment in dbcon.AppointmentsTables)
         {
             if (appointment.AppointmentID == delete.AppointmentID)
             {
                 dbcon.AppointmentsTables.Remove(appointment);
             }
         }
         dbcon.SaveChanges();
         ShowDoctorAppointments.DataBind();
         if (ShowDoctorAppointments.Rows.Count == 0)
         {
             DisplayNoAppointMessage.Text      = "You have no appointments set up.";
             DisplayNoAppointMessage.Visible   = true;
             DeleteDoctorAppointButton.Visible = false;
         }
     }
 }
Example #5
0
 protected void DeletePatientAppointButton_Click(object sender, EventArgs e)
 {
     if (ShowPatientAppointments.SelectedRow != null) // if appointment selected to delete on gridview, do this
     {
         AppointmentsTable delete = new AppointmentsTable();
         string            input  = ShowPatientAppointments.SelectedValue.ToString(); // gets AppointmentID of selected row
         int appointmentID        = Convert.ToInt32(input);
         delete = UtilitiesClass.createAppointment(appointmentID);                    // creates copy of appointment object to delete
         foreach (AppointmentsTable appointment in dbcon.AppointmentsTables)          // check if appointment exists
         {
             if (appointment.AppointmentID == delete.AppointmentID)                   // if appointment exists, delete it
             {
                 dbcon.AppointmentsTables.Remove(appointment);
             }
         }
         dbcon.SaveChanges();                         // save changes to database
         ShowPatientAppointments.DataBind();          // update changes to grid view displaying patient appointment
         if (ShowPatientAppointments.Rows.Count == 0) // if no appointments, display message
         {
             DisplayNoAppointMessage.Text       = "You have no appointments set up.";
             DisplayNoAppointMessage.Visible    = true;
             DeletePatientAppointButton.Visible = false; // makes delete appointment button invisible
         }
     }
 }
        public void AddOrUpdateQuestionAnswer(int questionID, int answerID, bool correct, SqlConnection conn = null)
        {
            try
            {
                bool nullConnection = false;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_insertQuestionAnswers", conn))
                {
                    cmd.Parameters.AddWithValue("@QUESTION_ID", questionID);
                    cmd.Parameters.AddWithValue("@ANSWER_ID", answerID);
                    cmd.Parameters.AddWithValue("@CORRECT", correct);
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    cmd.ExecuteNonQuery();

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("AddOrUpdateQuestionAnswer() error. QuestionId: " + questionID, e);
            }
        }
        private void ButtonSelectCollections_Click(object sender, EventArgs e)
        {
            using (BrowseCollectionDialog collectionDialog = new BrowseCollectionDialog(ConnectionManager))
            {
                collectionDialog.MultiSelect    = true;
                collectionDialog.CollectionType = CollectionType.Device;

                if (collectionDialog.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                foreach (IResultObject collection in collectionDialog.SelectedCollections)
                {
                    listViewCollections.Items.Add(new ListViewItem()
                    {
                        Text     = collection["Name"].StringValue,
                        SubItems =
                        {
                            collection["CollectionID"].StringValue
                        },
                        Tag = collection
                    });
                }

                listViewCollections.Focus();
                UtilitiesClass.UpdateListViewColumnsSize(listViewCollections, columnHeaderName);
            }

            ControlsInspector.InspectAll();
        }
Example #8
0
        private Vector2 GetDirectionToMouse()
        {
            Vector3 mousePosition = UtilitiesClass.GetWorldMousePosition();
            Vector3 aimDir        = (mousePosition - transform.position).normalized;

            return(aimDir);
        }
Example #9
0
 private void BackgroundWorkerQueryMachine_QueryProcessorCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     try
     {
         if (e.Error != null)
         {
             SccmExceptionDialog.ShowDialog(this, e.Error, "Error");
         }
         else if (e.Cancelled)
         {
             if (listViewSelectedResources.Items.Count > 0)
             {
                 listViewSelectedResources.Items[0].Selected = true;
                 listViewSelectedResources.Items[0].Focused  = true;
             }
         }
         else if (listViewSelectedResources.Items.Count > 0)
         {
             listViewSelectedResources.Items[0].Selected = true;
             listViewSelectedResources.Items[0].Focused  = true;
         }
     }
     finally
     {
         backgroundWorkerQueryMachine.Dispose();
         backgroundWorkerQueryMachine = null;
         UseWaitCursor = false;
         buttonSearch.Focus();
         buttonSearch.Text  = "Search";
         searchCompleteTime = DateTime.Now.Ticks;
         controlsInspector.InspectAll();
         UtilitiesClass.UpdateListViewColumnsSize(listViewSelectedResources, columnMachineName);
     }
 }
    void Update()
    {
        // Calc
        if (targetEnemy != null)
        {
            moveDirCache = (targetEnemy.transform.position -
                            transform.position).normalized;
            lastMoveDir = moveDirCache;
        }
        else
        {
            moveDirCache = lastMoveDir;
        }

        // Update position and rotation
        rotationCache.z       = UtilitiesClass.GetAngleFromVector(moveDirCache);
        transform.eulerAngles = rotationCache;
        transform.position   += moveDirCache * Time.deltaTime * speed;

        // Check
        timeToDestroy -= Time.deltaTime;
        if (timeToDestroy < 0f)
        {
            Destroy(gameObject);
        }
    }
        public void DeleteTeacherLecturesForTeacher(int teacherID, SqlConnection conn = null)
        {
            try
            {
                bool nullConnection = false;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_deleteTeacherLecturesForTeacher", conn))
                {
                    cmd.Parameters.AddWithValue("@TEACHER_ID", teacherID);
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    cmd.ExecuteNonQuery();

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("DeleteTeacherLecturesForTeacher() error. TeacherId: " + teacherID, e);
            }
        }
 public void ShootArrow(Vector3 playerDirection)
 {
     ParticleSystem.transform.forward = playerDirection;
     ParticleSystem.MainModule particleSystemMain = ParticleSystem.main;
     particleSystemMain.startSpeed    = 8f;
     particleSystemMain.startRotation = -UtilitiesClass.GetAngleFromVectorFloat(playerDirection) * Mathf.Deg2Rad;
     ParticleSystem.Play();
 }
Example #13
0
        private void LateUpdate()
        {
            SetOrigin(Vector3.zero);
            float angle         = StartingAngle;
            float angleIncrease = FieldOfViewValue / RayCount;

            Vector3[] vertices  = new Vector3[RayCount + 1 + 1];
            Vector2[] uv        = new Vector2[vertices.Length];
            int[]     triangles = new int[RayCount * 3];

            vertices[0] = Origin;

            int vertexIndex   = 1;
            int triangleIndex = 0;

            for (int i = 0; i <= RayCount; i++)
            {
                Vector3      vertex;
                RaycastHit2D raycastHit2D = Physics2D.Raycast(transform.position, UtilitiesClass.GetVectorFromAngle(angle), ViewDistance, LayerMask);
                if (raycastHit2D.collider == null)
                {
                    // No hit
                    vertex   = UtilitiesClass.GetVectorFromAngle(angle) * ViewDistance;
                    vertex.z = transform.position.z;
                }
                else
                {
                    // Hit object
                    if (raycastHit2D.collider.gameObject.CompareTag("Player"))
                    {
                        EnemyBehavior.SetTargetPlayer(raycastHit2D.collider.gameObject);
                    }
                    vertex   = (Vector3)raycastHit2D.point - transform.position;
                    vertex.z = transform.position.z;
                }

                vertices[vertexIndex] = vertex;

                if (i > 0)
                {
                    triangles[triangleIndex + 0] = 0;
                    triangles[triangleIndex + 1] = vertexIndex - 1;
                    triangles[triangleIndex + 2] = vertexIndex;

                    triangleIndex += 3;
                }

                vertexIndex++;
                angle -= angleIncrease;
            }


            Mesh.vertices  = vertices;
            Mesh.uv        = uv;
            Mesh.triangles = triangles;
        }
Example #14
0
 public bool RushToEnemyPosition()
 {
     DistanceToEnemy = Physics2D.Distance(PlayerCollider, PlayerController.TargetedEnemy.CircleCollider).distance;
     if (DistanceToEnemy < 0.2f)
     {
         return(true);
     }
     PlayerRigidBody.MovePosition(UtilitiesClass.CustomLerp(PlayerEndDashPosition, EnemyPosition, TimeStartLerping, LerpTime));
     return(false);
 }
        public override void InitializePageControl()
        {
            base.InitializePageControl();

            ControlsInspector.AddControl(listViewCollections, new ControlDataStateEvaluator(ValidateSelectedCollections), "Select collections for deployments");

            UtilitiesClass.UpdateListViewColumnsSize(listViewCollections, columnHeaderName);

            Initialized = true;
        }
Example #16
0
        private byte[] CoSignBuffer(byte[] data, byte[] signdata)
        {
            X509Certificate2 m_cert = cbCerts.SelectedItem as X509Certificate2;

            if (m_cert == null)
            {
                MessageBox.Show("не найден сертификат!");
                return(null);
            }
            SignedData signedData = new SignedDataClass();
            Utilities  utilities  = new UtilitiesClass();

            byte[] array = data;

            Signer signer = new SignerClass();
            IStore store  = new StoreClass();
            bool   flag2  = false;

            store.Open(CAPICOM_STORE_LOCATION.CAPICOM_CURRENT_USER_STORE, "My", CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_READ_ONLY);
            foreach (ICertificate certificate in store.Certificates)
            {
                if (certificate.Thumbprint == m_cert.Thumbprint)
                {
                    signer.Certificate = certificate;
                    flag2 = true;
                    break;
                }
            }
            if (!flag2)
            {
                throw new Exception("Не удалось найти сертификат подписи!");
            }
            CapiComRCW.Attribute attribute = new AttributeClass();
            attribute.Name  = CAPICOM_ATTRIBUTE.CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME;
            attribute.Value = DateTime.Now.ToUniversalTime();
            signer.AuthenticatedAttributes.Add(attribute);
            byte[] array3;
            byte[] array2 = signdata;
            ((CapiComRCW.ISignedData)signedData).set_Content(utilities.ByteArrayToBinaryString(array));
            signedData.Verify(Convert.ToBase64String(array2), true, CAPICOM_SIGNED_DATA_VERIFY_FLAG.CAPICOM_VERIFY_SIGNATURE_ONLY);
            Store store2 = new StoreClass();

            store2.Open(CAPICOM_STORE_LOCATION.CAPICOM_CURRENT_USER_STORE, "AddressBook", CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_READ_WRITE);
            for (int i = 1; i <= signedData.Signers.Count; i++)
            {
                Signer      signer2 = (Signer)signedData.Signers[i];
                Certificate pVal    = (Certificate)signer2.Certificate;
                store2.Add(pVal);
            }
            store2.Close();
            string s = signedData.CoSign(signer, CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BASE64);

            array3 = Convert.FromBase64String(s);
            return(array3);
        }
    private void SetTarget(Enemy enemy)
    {
        targetEnemy = enemy;

        // Set base information
        moveDirCache = (targetEnemy.transform.position -
                        transform.position).normalized;
        lastMoveDir           = moveDirCache;
        rotationCache.z       = UtilitiesClass.GetAngleFromVector(moveDirCache);
        transform.eulerAngles = rotationCache;
    }
Example #18
0
        static void Main()
        {
            int exitApp = 0;

            utilities        = new UtilitiesClass();
            myAppSettingsXML = new AppSettingsXML();
            myAppSettings    = new ApplicationSettings();



            utilities.setSkipAD(0);

            buildDateTime  = Properties.Resources.BuildDate.ToString();
            dateTimeString = Properties.Resources.VersionString.ToString();
            buildVersion   = "1.1.2." + dateTimeString;


            // read config
            if (File.Exists(configFilename))
            {
                myAppSettings = myAppSettingsXML.XmlDataReader(configFilename);

                Program.utilities.setConfigDefaults();

                if ((hasEncryptedConfigPassword == 0) || (triggerConfigSave == 1))
                {
                    // we'll save the new config file with encrypted password
                    myAppSettingsXML.XmlDataWriter(myAppSettings, configFilename);
                }

                myADAdminGroups                 = utilities.getADGroups(myAppSettings.myADSettings);
                myADAdminGroupsBS               = new BindingSource();
                myADAdminGroupsBS.DataSource    = myADAdminGroups.Tables["AD Groups"];
                myADReadOnlyGroups              = utilities.getADGroups(myAppSettings.myADSettings);
                myADReadOnlyGroupsBS            = new BindingSource();
                myADReadOnlyGroupsBS.DataSource = myADReadOnlyGroups.Tables["AD Groups"];

                utilities.ADAdministratorGroupDN = utilities.getGroupDNFromDB("ADAdministratorGroupDN");
                utilities.ADReadOnlyGroupDN      = utilities.getGroupDNFromDB("ADReadOnlyGroupDN");
            }
            else
            {
                MessageBox.Show("Application Config File not found!\n" + configFilename);
                exitApp = 1;
                System.Windows.Forms.Application.Exit();
            }

            if (exitApp == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new loginForm());
            }
        }
        public List <TestResults> GetTestsResults(SqlConnection conn = null)
        {
            List <TestResults> testsResults = new List <TestResults>();

            try
            {
                bool        nullConnection = false;
                TestResults testResults    = null;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getTestResults", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            testResults = new TestResults
                            {
                                TestID              = DataUtil.GetDataReaderValue <int>("TestID", reader),
                                StudentID           = DataUtil.GetDataReaderValue <int>("StudentID", reader),
                                AnswersResult       = DataUtil.GetDataReaderValue <string>("AnswersResult", reader),
                                Mark                = DataUtil.GetDataReaderValue <float>("Mark", reader),
                                Points              = DataUtil.GetDataReaderValue <float>("Points", reader),
                                TestResultDate      = DataUtil.GetDataReaderValue <DateTime>("TestResultDate", reader),
                                NrOfCorrectAnswers  = DataUtil.GetDataReaderValue <int>("NrOfCorrectAnswers", reader),
                                NrOfWrongAnswers    = DataUtil.GetDataReaderValue <int>("NrOfWrongAnswers", reader),
                                NrOfUnfilledAnswers = DataUtil.GetDataReaderValue <int>("NrOfUnfilledAnswers", reader)
                            };

                            testsResults.Add(testResults);
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetTestsResults() error.", e);
            }

            return(testsResults);
        }
        public async override System.Threading.Tasks.Task Initialize()
        {
            IsBusy            = true;
            selectedParameter = (SelectedParameter)NavigationParameter;
            // This Value will replace with actual  latitude and longitude  with using Xam.plugin Locator
            var myassistants = await getAssistantsRequest.GetAssistants(19.22, 72.85);

            Myassistants = new ObservableCollection <Myassistant>(myassistants);

            if (selectedParameter != null)
            {
                if (selectedParameter.selectedProfession != null)
                {
                    Myassistants = UtilitiesClass.ToObservableCollection(Myassistants.Where(c => c.profession == selectedParameter.selectedProfession).ToList <Myassistant>());
                }
                if (selectedParameter.selectedRatting != null)
                {
                    Myassistants = UtilitiesClass.ToObservableCollection(Myassistants.Where(c => c.ratting == selectedParameter.selectedRatting).ToList <Myassistant>());
                }
                if (selectedParameter.selectedLocalKnowlage != null)
                {
                    if (selectedParameter.selectedLocalKnowlage == "Yes")
                    {
                        Myassistants = UtilitiesClass.ToObservableCollection(Myassistants.Where(c => c.localplaceknowledge == 1).ToList <Myassistant>());
                    }
                    else
                    {
                        Myassistants = UtilitiesClass.ToObservableCollection(Myassistants.Where(c => c.localplaceknowledge == 0).ToList <Myassistant>());
                    }
                }
            }
            foreach (var item in Myassistants)
            {
                var pin = new Pin()
                {
                    ZIndex   = item.assistantId,
                    Type     = PinType.Place,
                    Label    = item.name,
                    Address  = "Profession : " + item.profession + " Wages($) " + item.wagesPerHour,
                    Position = new Position(item.lat, item.lng),
                };
                pin.Clicked += (sender, e) =>

                {
                    var clickPin = (Pin)sender;
                    Navigation.NavigateToAsync("AssistantView", clickPin.ZIndex);
                };
                Pins.Add(pin);
            }
            IsBusy = false;

            RaisePropertyChanged("Myassistants");
        }
Example #21
0
        public List <TestParameters> GetTestParameters(SqlConnection conn = null)
        {
            List <TestParameters> testsParams = new List <TestParameters>();

            try
            {
                bool           nullConnection = false;
                TestParameters testParams     = null;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getTestParameters", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            testParams = new TestParameters
                            {
                                TestID     = DataUtil.GetDataReaderValue <int>("TestID", reader),
                                TeacherID  = DataUtil.GetDataReaderValue <int>("TeacherID", reader),
                                ClassID    = DataUtil.GetDataReaderValue <int>("ClassID", reader),
                                Duration   = DataUtil.GetDataReaderValue <int>("Duration", reader),
                                Penalty    = DataUtil.GetDataReaderValue <float>("Penalty", reader),
                                StartTest  = DataUtil.GetDataReaderValue <DateTime>("StartTest", reader),
                                FinishTest = DataUtil.GetDataReaderValue <DateTime>("FinishTest", reader)
                            };

                            testsParams.Add(testParams);
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetTestParameters() error. ", e);
            }

            return(testsParams);
        }
Example #22
0
        public List <Student> GetStudents(SqlConnection conn = null)
        {
            List <Student> students = new List <Student>();

            try
            {
                bool    nullConnection = false;
                Student student        = null;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getStudents", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            student = new Student
                            {
                                StudentID = DataUtil.GetDataReaderValue <int>("StudentID", reader),
                                FirstName = DataUtil.GetDataReaderValue <string>("FirstName", reader),
                                LastName  = DataUtil.GetDataReaderValue <string>("LastName", reader),
                                Email     = DataUtil.GetDataReaderValue <string>("Email", reader),
                                ClassID   = DataUtil.GetDataReaderValue <int>("ClassID", reader),
                                UserID    = DataUtil.GetDataReaderValue <int>("UserID", reader)
                            };

                            students.Add(student);
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetStudents() error.", e);
            }

            return(students);
        }
Example #23
0
        public User GetUserByUsername(string username, SqlConnection conn = null)
        {
            User user = null;

            try
            {
                bool        nullConnection = false;
                List <User> studyClasses   = new List <User>();

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getUserByEmail", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@USERNAME", username);

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            user = new User
                            {
                                UserID   = DataUtil.GetDataReaderValue <int>("UserID", reader),
                                Username = DataUtil.GetDataReaderValue <string>("Username", reader),
                                Password = DataUtil.GetDataReaderValue <string>("Password", reader),
                                IsActive = DataUtil.GetDataReaderValue <bool>("IsActive", reader),
                                Role     = DataUtil.GetDataReaderValue <string>("Role", reader)
                            };
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetUserByUsername() error. Username: " + user.Username, e);
            }

            return(user);
        }
        public List <Question> GetQuestionsByTestID(int testID, SqlConnection conn = null)
        {
            List <Question> questions = new List <Question>();

            try
            {
                bool     nullConnection = false;
                Question question       = null;
                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getQuestionsByTestID", conn))
                {
                    cmd.Parameters.AddWithValue("@TEST_ID", testID);
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            question = new Question
                            {
                                QuestionID = DataUtil.GetDataReaderValue <int>("QuestionID", reader),
                                Content    = DataUtil.GetDataReaderValue <string>("Question", reader),
                                Points     = DataUtil.GetDataReaderValue <int>("Points", reader),
                                TestID     = DataUtil.GetDataReaderValue <int>("TestID", reader)
                            };

                            questions.Add(question);
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetQuestionsByTestID() error. TestId: " + testID, e);
            }

            return(questions);
        }
Example #25
0
    void Update()
    {
        // Wave will attack in -> text
        if (waveManager.GetWaveTimeToAttack() < 10f)
        {
            SetMessageText($"Next Wave In {waveManager.GetWaveTimeToAttack().ToString("F1")}s!");
        }
        else
        {
            SetMessageText(string.Empty);
        }

        // Arrow - Spawner - Rotation
        normlizedArrowCache = (waveManager.GetNextSpawnPosition() -
                               mainCam.transform.position).normalized;
        nextWaveArrow.anchoredPosition = normlizedArrowCache * 400f;
        arrowRotationCache.z           = UtilitiesClass.GetAngleFromVector(
            normlizedArrowCache);
        nextWaveArrow.eulerAngles = arrowRotationCache;
        nextWaveArrow.gameObject.SetActive(
            (waveManager.GetNextSpawnPosition() - mainCam.transform.position).magnitude >
            mainCam.orthographicSize * 1.5f
            );

        // Arrow - Enemy - Rotation
        if (Time.timeSinceLevelLoad > timerToNextEnemyCheck)
        {
            LocalizeEnemyTarget();
            timerToNextEnemyCheck = Time.timeSinceLevelLoad + 0.1f;
        }
        if (targetEnemy != null)
        {
            enemyPositionCache  = targetEnemy.transform.position;
            normlizedArrowCache = (enemyPositionCache -
                                   mainCam.transform.position).normalized;
            closestEnemyArrow.anchoredPosition = normlizedArrowCache * 350f;
            arrowRotationCache.z = UtilitiesClass.GetAngleFromVector(
                normlizedArrowCache);
            closestEnemyArrow.eulerAngles = arrowRotationCache;
            closestEnemyArrow.gameObject.SetActive(
                (enemyPositionCache - mainCam.transform.position).magnitude >
                mainCam.orthographicSize * 1.5f
                );
        }
        else
        {
            closestEnemyArrow.gameObject.SetActive(false);
        }
    }
Example #26
0
        public IEnumerable <Test> GetTests(SqlConnection conn = null)
        {
            List <Test> tests = new List <Test>();

            try
            {
                bool nullConnection = false;
                Test test           = null;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getTests", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            test = new Test
                            {
                                TestID    = DataUtil.GetDataReaderValue <int>("TestID", reader),
                                Naming    = DataUtil.GetDataReaderValue <string>("Name", reader),
                                TeacherID = DataUtil.GetDataReaderValue <int>("TeacherID", reader),
                                LectureID = DataUtil.GetDataReaderValue <int>("LectureID", reader)
                            };

                            tests.Add(test);
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetTests() error.", e);
            }

            return(tests);
        }
        public Teacher GetTeacherUserAuth(string email, SqlConnection conn = null)
        {
            Teacher teacher = null;

            try
            {
                bool nullConnection = false;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getTeacherUserByEmail", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@EMAIL", email);

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            teacher = new Teacher()
                            {
                                TeacherID = DataUtil.GetDataReaderValue <int>("TeacherID", reader),
                                FirstName = DataUtil.GetDataReaderValue <string>("FirstName", reader),
                                LastName  = DataUtil.GetDataReaderValue <string>("LastName", reader),
                                Email     = DataUtil.GetDataReaderValue <string>("Email", reader),
                                UserID    = DataUtil.GetDataReaderValue <int>("UserID", reader)
                            };
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetTeacherUserAuth() error. Teacher: " + teacher.FirstName + " " + teacher.LastName, e);
            }

            return(teacher);
        }
        public List <Lecture> GetLectures(SqlConnection conn = null)
        {
            List <Lecture> lectures = new List <Lecture>();

            try
            {
                bool    nullConnection = false;
                Lecture lecture        = null;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getLectures", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            lecture = new Lecture
                            {
                                LectureID   = DataUtil.GetDataReaderValue <int>("LectureID", reader),
                                Name        = DataUtil.GetDataReaderValue <string>("Name", reader),
                                YearOfStudy = DataUtil.GetDataReaderValue <int>("YearOfStudy", reader)
                            };

                            lectures.Add(lecture);
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetLectures() error.", e);
            }

            return(lectures);
        }
        public List <QuestionWithAnswers> GetQuestionAnswers(SqlConnection conn = null)
        {
            List <QuestionWithAnswers> questionsWithAnswers = new List <QuestionWithAnswers>();

            try
            {
                bool nullConnection = false;
                QuestionWithAnswers questionAnswer = null;
                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getQuestionAnswers", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            questionAnswer = new QuestionWithAnswers
                            {
                                QuestionID = DataUtil.GetDataReaderValue <int>("QuestionID", reader),
                                AnswerID   = DataUtil.GetDataReaderValue <int>("AnswerID", reader),
                                Correct    = DataUtil.GetDataReaderValue <bool>("Correct", reader)
                            };

                            questionsWithAnswers.Add(questionAnswer);
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetQuestionAnswers() error.", e);
            }

            return(questionsWithAnswers);
        }
Example #30
0
        public List <Answer> GetAnswers(SqlConnection conn = null)
        {
            List <Answer> answers = new List <Answer>();

            try
            {
                bool   nullConnection = false;
                Answer answer         = null;
                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_getAnswers", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            answer = new Answer
                            {
                                AnswerID = DataUtil.GetDataReaderValue <int>("AnswerID", reader),
                                Content  = DataUtil.GetDataReaderValue <string>("Answer", reader)
                            };

                            answers.Add(answer);
                        }
                    }

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("GetAnswers() error.", e);
            }

            return(answers);
        }
Example #31
0
 private void MakeResponse(ExchangeRequest req, string responseType, string refuseReason, string exportedReport, string xml)
 {
     RESFORM source = new RESFORM {
         TYPE_REQ = new RESFORMTYPE_REQ()
     };
     source.TYPE_REQ.QUERY_ID = req.QueryId;
     source.TYPE_REQ.GUID = req.Guid;
     source.TYPE_REQ.TYPE = req.Type;
     source.TYPE_REQ.TYPE_NAME = "Получение справки о начислениях и оплате для единого окна";
     source.TYPE_RES = new RESFORMTYPE_RES();
     source.TYPE_RES.TYPE = string.IsNullOrEmpty(exportedReport) ? ((byte) 1) : ((byte) 0);
     source.TYPE_RES.TYPE_NAME = responseType;
     source.TYPE_RES.DATE_RES = System.DateTime.Today.ToShortDateString();
     source.BODY_RES = new RESFORMBODY_RES();
     source.BODY_RES.USER = User.CurrentUser.Name;
     source.BODY_RES.AREA = AIS.SN.Model.Constants.OrgName;
     source.BODY_RES.REASON = refuseReason;
     source.BODY_RES.FORM = exportedReport;
     source.BODY_RES.FORMXML = xml;
     source.BODY_RES.FORM_SIGNATURE = new byte[0];
     source.BODY_RES.FORMXML_SIGNATURE = new byte[0];
     if (this.cbCrypt.get_Checked() && (exportedReport != ""))
     {
         Utilities utilities = new UtilitiesClass();
         source.BODY_RES.FORM_SIGNATURE = new ForBytes().Sign(System.Convert.FromBase64String(exportedReport));
         source.BODY_RES.FORMXML_SIGNATURE = new ForBytes().Sign((byte[]) utilities.BinaryStringToByteArray(xml));
     }
     string inxml = Serializer.ToXml<RESFORM>(source, (System.Text.Encoding) System.Text.Encoding.Unicode);
     string str2 = new DocsVisionWebService().RespondSnDg(inxml);
     XmlDocument document = new XmlDocument();
     document.LoadXml(str2);
     string str3 = document.GetElementsByTagName("CODE").get_ItemOf(0).get_InnerText();
     if (str3 != "0")
     {
         string str4 = document.GetElementsByTagName("ERROR").get_ItemOf(0).get_InnerText();
         System.ApplicationException exception = new System.ApplicationException(string.Concat((string[]) new string[] { "Ошибка отправки сообщения", System.Environment.get_NewLine(), "Код ошибки: ", str3, System.Environment.get_NewLine(), "Сообщение: ", str4 }));
         throw exception;
     }
     req.XmlOut = inxml;
     req.Status = ExchangeStatus.Processed;
     req.Update();
 }