public bool CheckCaseInDataBase() { string patientId = TestPerson.GetPersonId(GUID, caseBase.caseBase.IdLpu, caseBase.patient.patient.IdPatientMIS); TestAmbCase ac = TestAmbCase.BuildAmbCaseFromDataBaseData(GUID, caseBase.caseBase.IdLpu, caseBase.caseBase.IdCaseMis, patientId); //this.Equals(ac); return(this == ac); }
private void CaseWork(string guid, CaseBase c, string method) { try { CaseAmb ca = c as CaseAmb; if ((object)ca != null) { TestAmbCase example = null; switch (method) { case "AddCase": client.AddCase(guid, ca); example = new TestAmbCase(guid, ca); break; case "CreateCase": client.CreateCase(guid, ca); example = new TestAmbCase(guid, ca); break; case "CloseCase": string patientId = TestPerson.GetPersonId(guid, ca.IdLpu, ca.IdPatientMis); example = TestAmbCase.BuildAmbCaseFromDataBaseData(guid, ca.IdLpu, ca.IdCaseMis, patientId); client.CloseCase(guid, ca); example.ChangeUpdateAmbCase(guid, ca); break; case "UpdateCase": client.UpdateCase(guid, ca); example = new TestAmbCase(guid, ca); break; } if (!example.CheckCaseInDataBase()) { Global.errors1.AddRange(Global.errors2); Global.errors1.Add("Несовпадение"); } } CaseStat cs = c as CaseStat; if ((object)cs != null) { TestStatCase example = null; switch (method) { case "AddCase": client.AddCase(guid, cs); example = new TestStatCase(guid, cs); break; case "CreateCase": client.CreateCase(guid, cs); example = new TestStatCase(guid, cs); break; case "CloseCase": string patientId = TestPerson.GetPersonId(guid, cs.IdLpu, cs.IdPatientMis); example = TestStatCase.BuildAmbCaseFromDataBaseData(guid, cs.IdLpu, cs.IdCaseMis, patientId); client.CloseCase(guid, cs); example.ChangeUpdateStatCase(guid, cs); break; case "UpdateCase": client.UpdateCase(guid, cs); example = new TestStatCase(guid, cs); break; } if (!example.CheckCaseInDataBase()) { Global.errors1.AddRange(Global.errors2); Global.errors1.Add("Несовпадение"); } } } catch (System.ServiceModel.FaultException <List <PixServiseTests.EMKServise.RequestFault> > e) { getErrors(e.Detail); } catch (System.ServiceModel.FaultException <PixServiseTests.EMKServise.RequestFault[]> e) { getErrors(e.Detail); } catch (System.ServiceModel.FaultException <PixServiseTests.EMKServise.RequestFault> e) { Global.errors1.Add(e.Detail.PropertyName + " - " + e.Detail.Message); getErrors(e.Detail.Errors); } //catch (Exception e) //{ //} }
public void GetCasesByPeriod(string GUID, DateTime datestart, DateTime dateend) { List <TestCaseBase> MyFindedCase = new List <TestCaseBase>(); using (SqlConnection connection = Global.GetSqlConnection()) { string findCaseString = "SELECT * FROM \"Case\" WHERE OpenDate >= '" + datestart + "' AND OpenDate <= '" + dateend + "' AND CloseDate IS NOT NULL AND IsCancelled = 'False'"; SqlCommand command = new SqlCommand(findCaseString, connection); using (SqlDataReader IdCaseReader = command.ExecuteReader()) { while (IdCaseReader.Read()) { string guid = IdCaseReader["SystemGuid"].ToString(); string idCaseMis = IdCaseReader["IdCaseMIS"].ToString(); string idLpu = Global.GetIdIdLpu(IdCaseReader["IdLpu"].ToString()); string patientId = IdCaseReader["IdPerson"].ToString(); TestAmbCase ambCase = TestAmbCase.BuildAmbCaseFromDataBaseData(guid, idLpu, idCaseMis, patientId); if ((object)ambCase != null) { MyFindedCase.Add(ambCase); } TestStatCase statCase = TestStatCase.BuildAmbCaseFromDataBaseData(guid, idLpu, idCaseMis, patientId); if ((object)statCase != null) { MyFindedCase.Add(statCase); } string idCase = IdCaseReader["IdCase"].ToString(); } } } CaseBase[] cb = client.GetCasesByPeriod(GUID, datestart, dateend); List <TestCaseBase> FunctionFindedCase = new List <TestCaseBase>(); foreach (CaseBase i in cb) { CaseAmb ca = i as CaseAmb; if ((object)ca != null) { using (SqlConnection connection = Global.GetSqlConnection()) { string findCaseString = "SELECT TOP(1) [SystemGuid] FROM \"ExternalId\" WHERE IdLpu = '" + Global.GetIdInstitution(ca.IdLpu) + "' AND IdPersonMIS = '" + ca.IdPatientMis + "'"; SqlCommand command = new SqlCommand(findCaseString, connection); using (SqlDataReader IdCaseReader = command.ExecuteReader()) { while (IdCaseReader.Read()) { GUID = IdCaseReader["SystemGuid"].ToString(); } } } TestAmbCase tac = new TestAmbCase(GUID, (EMKServise.CaseAmb)ConvertCase(ca)); //if (!tac.CheckCaseInDataBase()) // Global.errors1.Add("Что-то пошло не так"); FunctionFindedCase.Add(tac); } CaseStat cs = i as CaseStat; if ((object)cs != null) { using (SqlConnection connection = Global.GetSqlConnection()) { string findCaseString = "SELECT TOP(1) [SystemGuid] FROM \"ExternalId\" WHERE IdLpu = '" + Global.GetIdInstitution(cs.IdLpu) + "' AND IdPersonMIS = '" + cs.IdPatientMis + "'"; SqlCommand command = new SqlCommand(findCaseString, connection); using (SqlDataReader IdCaseReader = command.ExecuteReader()) { while (IdCaseReader.Read()) { GUID = IdCaseReader["SystemGuid"].ToString(); } } } TestStatCase tsc = new TestStatCase(GUID, (EMKServise.CaseStat)ConvertCase(cs)); //if (!tsc.CheckCaseInDataBase()) // Global.errors1.Add("Что-то пошло не так"); FunctionFindedCase.Add(tsc); } } if (Global.GetLength(MyFindedCase) > Global.GetLength(FunctionFindedCase)) { Global.errors1.Add("Возвращено меньше, чем в базе"); } if (Global.GetLength(MyFindedCase) < Global.GetLength(FunctionFindedCase)) { Global.errors1.Add("Возвращено больше, чем в базе"); } if (Global.GetLength(MyFindedCase) == Global.GetLength(FunctionFindedCase)) { if (!Global.IsEqual(MyFindedCase.ToArray(), FunctionFindedCase.ToArray())) { Global.errors1.AddRange(Global.errors2); } } }