public HttpResponseMessage Get() { try { var project = repository.Get().Select(b => new TaskModel() { Project_ID = b.Project_ID, Task_Name = b.Task_Name, Start_Date = b.Start_Date, End_Date = b.End_Date, Priority = (int)b.Priority, ParentTask_Name = b.ParentTask == null ? "" : b.ParentTask.Parent_Task, Parent_ID = b.Parent_ID, Task_ID = b.Task_ID, Status = b.Status }); return(ToJson(project)); } catch (Exception ex) { LogError.Log(ex); return(ToJson(null)); } }
public UserDO GetUserByUserName(string iUserName) { UserDO user = new UserDO(); //Create new instance try { //Create connection using (SqlConnection connectionToSql = new SqlConnection(_ConnectionString)) { //Create command //This command should retrieve a user by user name. using (SqlCommand storedcommand = new SqlCommand("GET_USER_BY_USERNAME", connectionToSql)) { try { //Command properties storedcommand.CommandType = CommandType.StoredProcedure; storedcommand.CommandTimeout = 30; //pull by username storedcommand.Parameters.AddWithValue("@Username", iUserName); connectionToSql.Open(); SqlDataReader commandReader = storedcommand.ExecuteReader(); while (commandReader.Read()) { //Read each property user.UserID = commandReader.GetInt64(0); user.FirstName = commandReader.GetString(1); user.LastName = commandReader.GetString(2); user.PhoneNumber = commandReader.GetInt64(3); user.HouseAptNumber = commandReader.GetString(4); user.StreetName = commandReader.GetString(5); user.City = commandReader.GetString(6); user.State = commandReader.GetString(7); user.Zip = commandReader.GetString(8); user.Role = commandReader.GetByte(9); user.Username = commandReader.GetString(10); user.Password = commandReader.GetString(11); } } catch (Exception e) { throw (e); } finally { connectionToSql.Close(); //Saftey connectionToSql.Dispose(); } } } } catch (Exception e) { LogError.Log(e); throw (e); } finally { //Onshore standards } return(user); //return user info }
private void SendButton_Click(object sender, EventArgs e) { bool connection = NetworkInterface.GetIsNetworkAvailable(); if (connection == true) { MailModel model = new MailModel(); model.MailFrom = tbFrom.Text; model.SetMailTo(tbTo.Text); model.Title = tbTitle.Text; model.Body = rtbBody.Text; if ((EmailCheck(tbTo, "Niepoprawny format email Adresatów") == true) && (EmailCheck(tbFrom, "Niepoprawny format email Wysyłającego") == true) && (TitleCheck(tbTitle, "Czy tytuł ma pozostać pusty") == true)) { MailService.Send(model); } } else { MessageBox.Show("Brak internetu ,sprawdź połączenie", "", MessageBoxButtons.OK, MessageBoxIcon.Information); LogError logError = new LogError(ErrorFileName); logError.Log("Internet connection error"); } }
public HttpResponseMessage GetProject(int i) { try { var project = repository.GetProject(i); var projectdto = new ProjectModel() { Project_ID = project.Project_ID, Project_Name = project.Project_Name, Start_Date = project.Start_Date, End_Date = project.End_Date, Priority = (int)project.Priority, NoOfTasks = project.Tasks.Count, CompletedTask = project.Tasks.Count == 0 ? 0 : ((double)project.Tasks.Count(c => c.Status == "C")) / project.Tasks.Count * 100 }; return(ToJson(projectdto)); // return ToJson(repository.GetProject(i)); } catch (Exception ex) { LogError.Log(ex); return(ToJson(null)); } }
protected static void LogPAPError(Exception ex, databaseCache cache) { //Save the cache for later checking and try again string fileName = LogError.Log(ex, "AIError_PAP"); cache.SaveToDisk("", fileName); }
public static bool Send(MailModel model) { try { LogInfo logInfo = new LogInfo(InfoFileName); logInfo.Log("Próba wysłania wiadomości"); var message = new MailMessage(); message.From = new MailAddress(model.MailFrom, "Karolina Kosakowska"); model.MailTo.ForEach(m => message.To.Add(new MailAddress(m))); message.Subject = model.Title; message.Body = model.Body; var smtp = new SmtpClient(); //To do App.config //smtp.UseDefaultCredentials = false; //To do App.config //smtp.Credentials = new NetworkCredential("sendermail589", ""); //To do App.config //smtp.EnableSsl = true; //To do App.config //smtp.Port = 587; //To do App.config smtp.Send(message); return(true); } catch (Exception ex) { LogError logError = new LogError(ErrorFileName); logError.Log($"{ex.Message}"); return(false); } }
public HttpResponseMessage GetTask(int i) { try { var task = repository.GetTask(i); var taskdto = new TaskModel() { Project_ID = task.Project_ID, Task_Name = task.Task_Name, Start_Date = task.Start_Date, End_Date = task.End_Date, Priority = (int)task.Priority, ParentTask_Name = task.ParentTask == null ? "" : task.ParentTask.Parent_Task, Parent_ID = task.Parent_ID, Task_ID = task.Task_ID, Status = task.Status }; return(ToJson(taskdto)); } catch (Exception ex) { LogError.Log(ex); return(ToJson(null)); } }
public void DoUpdateInfo(DecisionRequest decisionRequest)// long playerId, databaseCache genericGameCache, CacheTracker cacheTracker, RequestedInfoKey updateKey) { this.decisionRequest = decisionRequest; try { //Can set the random seed value here for all providers if necessary if (aiRandomControl.InfoProviderRandomPerHandSeedEnabled) { //var handDetails = decisionRequest.Cache.getCurrentHandDetails(); //var holeCards = decisionRequest.Cache.getPlayerHoleCards(decisionRequest.PlayerId); var hashFunc = new Func <long, long>((long key) => { key = (~key) + (key << 21); // key = (key << 21) - key - 1; key = key ^ (key >> 24); key = (key + (key << 3)) + (key << 8); // key * 265 key = key ^ (key >> 14); key = (key + (key << 2)) + (key << 4); // key * 21 key = key ^ (key >> 28); key = key + (key << 31); return(key); }); //long randomSeed = hashFunc( // hashFunc(991 + providerInitialisationSequenceNum) ^ // hashFunc(decisionRequest.Cache.getNumHandsPlayed()) ^ // hashFunc((decisionRequest.Cache.getActivePositions().Length - decisionRequest.Cache.getActivePositionsLeftToAct().Length + 1)) ^ // hashFunc(handDetails.dealerPosition + 1) ^ // hashFunc((long)(100 *handDetails.potValue)) ^ // hashFunc((1L << holeCards.holeCard1) + (1L << holeCards.holeCard2) + (1L << handDetails.tableCard1) + // (1L << handDetails.tableCard2) + (1L << handDetails.tableCard3) + (1L << handDetails.tableCard4) + // (1L << handDetails.tableCard5))); //(randomGen as CMWCRandom).ReSeed(randomSeed); (randomGen as CMWCRandom).ReSeed((long)(hashFunc(991 + providerInitialisationSequenceNum) ^ hashFunc(decisionRequest.Cache.TableRandomNumber) ^ decisionRequest.Cache.CurrentHandRandomNumber() ^ hashFunc(1 + decisionRequest.Cache.getCurrentHandSeqIndex()))); } updateInfo(); } catch (Exception ex) { string fileName = LogError.Log(ex, "InfoProviderError"); decisionRequest.Cache.SaveToDisk("", fileName); //If we are running in safe mode then we return defaults //If not we re throw the error if (decisionRequest.AIManagerInSafeMode) { SetAllProvidedTypesToDefault((from current in providedInfoTypes select current.InformationType).ToList()); } else { throw; } } }
public List <IDonationDO> ViewDonationsbyUserID(long UserID) { List <IDonationDO> userDonation = new List <IDonationDO>(); //create new instance of list try //Catch Exceptions { //Create connection using (SqlConnection connectionToSql = new SqlConnection(_ConnectionString)) { //Create command using (SqlCommand storedCommand = new SqlCommand("VIEW_DONATIONS_BY_USER_ID", connectionToSql)) { try { //Command properties storedCommand.CommandType = CommandType.StoredProcedure; storedCommand.CommandTimeout = 30; //pull only that users info storedCommand.Parameters.AddWithValue("@UserID", UserID); connectionToSql.Open(); SqlDataReader commandReader = storedCommand.ExecuteReader(); while (commandReader.Read()) { //Read all properties DonationDO donate = new DonationDO() //Create new instance { DonationID = commandReader.GetInt64(0), UserID = commandReader.GetInt64(1), Amount = commandReader.GetDecimal(2), CardNumber = commandReader.GetInt64(3), Rendered = commandReader.GetBoolean(4), }; userDonation.Add(donate); //Add all properites to list } } catch (Exception e) { throw (e); //throw to outer try catch } finally { connectionToSql.Close(); //Saftey connectionToSql.Dispose(); } } } } catch (Exception e) { LogError.Log(e); throw (e); //throw to controller } finally { //Onshore standards } return(userDonation); //Return List }
public void UpdateUser(IUserDO iUser) { try //Exception handling { //Create connection using (SqlConnection connectionToSql = new SqlConnection(_ConnectionString)) { //Create command using (SqlCommand command = new SqlCommand("UPDATE_USERS", connectionToSql)) { try { //interpret command command.CommandType = CommandType.StoredProcedure; command.CommandTimeout = 30; //30 second #region Parameters //Passing parameters in from Sql command.Parameters.AddWithValue("@UserID", iUser.UserID); command.Parameters.AddWithValue("@FirstName", iUser.FirstName); command.Parameters.AddWithValue("@LastName", iUser.LastName); command.Parameters.AddWithValue("@PhoneNumber", iUser.PhoneNumber); command.Parameters.AddWithValue("@HouseAptNumber", iUser.HouseAptNumber); command.Parameters.AddWithValue("@StreetName", iUser.StreetName); command.Parameters.AddWithValue("@City", iUser.City); command.Parameters.AddWithValue("@State", iUser.State); command.Parameters.AddWithValue("@Zip", iUser.Zip); command.Parameters.AddWithValue("@Role", iUser.Role); command.Parameters.AddWithValue("@UserName", iUser.Username); command.Parameters.AddWithValue("@Password", iUser.Password); #endregion connectionToSql.Open(); command.ExecuteNonQuery(); //no info returned } catch (Exception e) { throw (e); //throw to outside try catch } finally { connectionToSql.Close(); //Saftey connectionToSql.Dispose(); } } } } catch (Exception e) { LogError.Log(e); throw (e); //throw to controller } finally { //Onshore standards } }
public HttpResponseMessage GetParentTask(int i) { try { return(ToJson(repository.GetParentTask(i))); } catch (Exception ex) { LogError.Log(ex); return(ToJson(null)); } }
public HttpResponseMessage Put(int id, [FromBody] Task value) { try { return(ToJson(repository.Put(id, value))); } catch (Exception ex) { LogError.Log(ex); return(ToJson(null)); } }
public HttpResponseMessage Delete(int id) { try { return(ToJson(repository.Delete(id))); } catch (Exception ex) { LogError.Log(ex); return(ToJson(null)); } }
public HttpResponseMessage Post([FromBody] ParentTask value) { try { return(ToJson(repository.Post(value))); } catch (Exception ex) { LogError.Log(ex); return(ToJson(null)); } }
public void CreateUser(IUserDO iUser) { try { //create connection using (SqlConnection connectionToSql = new SqlConnection(_ConnectionString)) { //create command using (SqlCommand storedCommand = new SqlCommand("CREATE_USER", connectionToSql)) { try { storedCommand.CommandType = CommandType.StoredProcedure; storedCommand.CommandTimeout = 30; //seconds before timeout //Add the value of our parmeters storedCommand.Parameters.AddWithValue("@FirstName", iUser.FirstName); storedCommand.Parameters.AddWithValue("@LastName", iUser.LastName); storedCommand.Parameters.AddWithValue("@PhoneNumber", iUser.PhoneNumber); storedCommand.Parameters.AddWithValue("@HouseAptNumber", iUser.HouseAptNumber); storedCommand.Parameters.AddWithValue("@StreetName", iUser.StreetName); storedCommand.Parameters.AddWithValue("@City", iUser.City); storedCommand.Parameters.AddWithValue("@State", iUser.State); storedCommand.Parameters.AddWithValue("@Zip", iUser.Zip); storedCommand.Parameters.AddWithValue("@Role", iUser.Role); storedCommand.Parameters.AddWithValue("@Username", iUser.Username); storedCommand.Parameters.AddWithValue("@Password", iUser.Password); connectionToSql.Open(); storedCommand.ExecuteNonQuery(); } catch (Exception e) { throw (e); //throw to outer try catch } finally { connectionToSql.Close(); //safftey closing & disposing connectionToSql.Dispose(); } } } } catch (Exception e) { LogError.Log(e); throw (e); //throw to the controller } finally { //Onshore standards } }
public bool IsUploadingSessionAvailable() { lock (g_listUploadingSessions) { var available = g_listUploadingSessions.Count < BaseSettings.UploadingSessionsCount; if (!available) { LogError.Log("ErrorLog", new ApplicationException(string.Format("List of avaliable upload sessions:{0}", BaseSettings.UploadingSessionsCount))); } return(available); } }
public void Register(IUserDO iUser) { try //Catch Exceptions { //Create connection using (SqlConnection connectionToSql = new SqlConnection(_ConnectionString)) { //Create command using (SqlCommand storedCommand = new SqlCommand("CREATE_USER", connectionToSql)) { try { //Command properties storedCommand.CommandType = CommandType.StoredProcedure; storedCommand.CommandTimeout = 60; //Add value to the Parameter storedCommand.Parameters.AddWithValue("@FirstName", iUser.FirstName); storedCommand.Parameters.AddWithValue("@LastName", iUser.LastName); storedCommand.Parameters.AddWithValue("@PhoneNumber", iUser.PhoneNumber); storedCommand.Parameters.AddWithValue("@HouseAptNumber", iUser.HouseAptNumber); storedCommand.Parameters.AddWithValue("@StreetName", iUser.StreetName); storedCommand.Parameters.AddWithValue("@City", iUser.City); storedCommand.Parameters.AddWithValue("@State", iUser.State); storedCommand.Parameters.AddWithValue("@Zip", iUser.Zip); storedCommand.Parameters.AddWithValue("@Role", iUser.Role); storedCommand.Parameters.AddWithValue("@Username", iUser.Username); storedCommand.Parameters.AddWithValue("@Password", iUser.Password); connectionToSql.Open(); storedCommand.ExecuteNonQuery(); } catch (Exception e) { throw (e); //Throw to outer try catch } finally { connectionToSql.Close(); //Saftey connectionToSql.Dispose(); } } } } catch (Exception e) { LogError.Log(e); throw (e); } finally { //Onshore standards } }
protected HttpResponseMessage ToJson(dynamic obj) { try { var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JsonConvert.SerializeObject(obj), Encoding.UTF8, "application/json"); return(response); } catch (Exception ex) { LogError.Log(ex); var response = Request.CreateResponse(HttpStatusCode.InternalServerError); return(response); } }
public static PersonContract GetPersonInfo(Guid loginToken, Guid?moduleID, String personalID) { try { return(RpcInvoker.InvokeMethod <PersonContract>(loginToken, moduleID, personalID)); } catch (Exception ex) { LogError.Log("ErrorLog_PinService_", ex, stream => { stream.WriteLine(String.Format("HMIS GetPersonInfo Error: {0}", ex.Message )); }); throw; } }
public static Guid?Login(String loginName, String password, bool encryptedPassword) { try { return(RpcInvoker.InvokeMethod <Guid?>(loginName, password, encryptedPassword)); } catch (Exception ex) { LogError.Log("ErrorLog_PinService_", ex, stream => { stream.WriteLine(String.Format("HMIS Login Error: {0}", ex.Message )); }); throw; } }
/// <summary> /// Writes errors found during 506 file parsing into output file in xlsx format /// </summary> /// <param name="filePath"></param> /// <returns> /// 0 - success /// 1 - error /// </returns> public int WriteErrorsToFile(string filePath) { try { using (var fileProcessor = new Upload506FileProcessor(this)) { using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite)) { return(fileProcessor.WriteErrorsToStream(stream)); } } } catch (Exception ex) { LogError.Log("ErrorLog", ex); return(1); } }
public void DeleteUsers(long UserID) { try //Catch Exceptions { //Create connection using (SqlConnection connectionToSql = new SqlConnection(_ConnectionString)) { //Create command using (SqlCommand command = new SqlCommand("DELETE_USER", connectionToSql)) { try { //Command properties used command.CommandType = CommandType.StoredProcedure; command.CommandTimeout = 30; //only pull that one user command.Parameters.AddWithValue("@UserID", UserID); connectionToSql.Open(); command.ExecuteNonQuery(); } catch (Exception e) { throw (e); //throw to next try catch } finally { connectionToSql.Close(); //Saftey connectionToSql.Dispose(); } } } } catch (Exception e) { LogError.Log(e); throw (e); //Throw to student controller to log the error } finally { //Onshore Standards } }
public void Clear() { try { Items.Clear(); Duplicates.Clear(); m_lastErrorMessage = string.Empty; m_lastError = Upload506FileError.Success; FileName = null; FileContent = null; m_resultFileName = null; m_errorFileName = null; var disposable = StoredData as IDisposable; if (disposable != null) { disposable.Dispose(); } StoredData = null; if (m_errorsFile != null) { m_errorsFile.Dispose(); m_errorsFile = null; } if (m_resultFile != null) { m_resultFile.Dispose(); m_resultFile = null; } SetState(Upload506MasterState.ReadyForUpload); } catch (Exception ex) { LogError.Log("ErrorLog", ex); } }
public HttpResponseMessage Get() { try { var project = repository.Get().Select(b => new ProjectModel() { Project_ID = b.Project_ID, Project_Name = b.Project_Name, Start_Date = b.Start_Date, End_Date = b.End_Date, Priority = (int)b.Priority, NoOfTasks = b.Tasks.Count, CompletedTask = b.Tasks.Count == 0 ? 0 :((double)b.Tasks.Count(i => i.Status == "C")) / b.Tasks.Count * 100 }); return(ToJson(project)); } catch (Exception ex) { LogError.Log(ex); return(ToJson(null)); } }
private void LogErrorInternal(Exception ex) { LogError.Log("ErrorLog_mobile_", ex); }
public List <IItemDO> ViewItemsbyUserID(long UserID) { List <IItemDO> userItems = new List <IItemDO>(); //Create new instance of list try //Catch Exception { //Create connection using (SqlConnection connectionToSql = new SqlConnection(_ConnectionString)) { //Create command using (SqlCommand command = new SqlCommand("VIEW_ITEMS_BY_USER_ID", connectionToSql)) { try { //command Properties command.CommandType = CommandType.StoredProcedure; command.CommandTimeout = 30; //View that one users info command.Parameters.AddWithValue("@UserID", UserID); connectionToSql.Open(); using (SqlDataReader commandReader = command.ExecuteReader()) { while (commandReader.Read()) { //Read each property #region Properties ItemDO item = new ItemDO()//Create a new instance { ItemID = commandReader.GetInt64(0), UserID = commandReader.GetInt64(1), ItemName = commandReader.GetString(2), Used = commandReader.GetBoolean(3), Description = commandReader.GetString(4) }; userItems.Add(item); #endregion } } } catch (Exception e) { throw (e); //throw to outer try catch } finally { connectionToSql.Close(); //Saftey connectionToSql.Dispose(); } } } } catch (Exception e) { LogError.Log(e); throw (e); //throw to the controller } finally { //Onshore standards } return(userItems); //return List }
public List <IUserDO> ViewAllUsers() { List <IUserDO> viewUsers = new List <IUserDO>(); //create a new instance try { //create connection using (SqlConnection connectionToSql = new SqlConnection(_ConnectionString)) { //create command using (SqlCommand storedCommand = new SqlCommand("VIEW_USERS", connectionToSql)) { try { //interpret command storedCommand.CommandType = CommandType.StoredProcedure; storedCommand.CommandTimeout = 30; //30s connectionToSql.Open(); //going to execute the command using (SqlDataReader commandReader = storedCommand.ExecuteReader()) { while (commandReader.Read()) { IUserDO user = new UserDO() //create new instance { UserID = commandReader.GetInt64(0), FirstName = commandReader.GetString(1), LastName = commandReader.GetString(2), PhoneNumber = commandReader.GetInt64(3), HouseAptNumber = commandReader.GetString(4), StreetName = commandReader.GetString(5), City = commandReader.GetString(6), State = commandReader.GetString(7), Zip = commandReader.GetString(8), Role = commandReader.GetByte(9), Username = commandReader.GetString(10), Password = commandReader.GetString(11) }; viewUsers.Add(user); //Add each user to the list } } } catch (Exception e) { throw (e); } finally { connectionToSql.Close(); //saftey close and dispose connectionToSql.Dispose(); } } } } catch (Exception e) { LogError.Log(e); throw (e); //throw to the controller } finally { //Onshore standard } return(viewUsers); //return list }
private Tuple <Schema.Patient, string> _getFromPersonIdentityServiceInternal(Schema.Patient p) { var strPinVerificationSuffix = PinVerificationSuffix; string pin = p.strPersonID; string form = p.Parent is Schema.HumanCase ? "H02" : "H04"; string caseID = p.Parent is Schema.HumanCase ? (p.Parent as Schema.HumanCase).strCaseID : (p.Parent is Schema.ContactedCasePerson ? ((p.Parent as Schema.ContactedCasePerson).Parent as Schema.HumanCase).strCaseID : ""); DateTime?dtResponse = null; string resultCode = ""; Georgia.CommonDataWebSoapClient client = new Georgia.CommonDataWebSoapClient(); try { string codedUsername = Config.GetSetting("GgPinServiceUsr"); string codedPassword = Config.GetSetting("GgPinServicePwd"); string username = Cryptor.Decrypt(codedUsername); string password = Cryptor.Decrypt(codedPassword, username); var token = client.Login(username, password); if (token == null) { throw new Exception("PIN Service unreachable"); } var person = client.GetPersonInfoEx(token.Value, Guid.Empty, p.strPersonID, p.datDateofBirth.Value.Year); if (person == null) { resultCode = "NO_RECORDS_FOUND"; return(new Tuple <Schema.Patient, string>(null, string.Format("strPinNoRecordsFound{0}", strPinVerificationSuffix))); } dtResponse = DateTime.Now; resultCode = "OK"; using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { FilterParams filters = new FilterParams(); filters.Add("strPersonID", "=", p.strPersonID); var items = Schema.PatientListItem.Accessor.Instance(null).SelectListT(manager, filters); if (items != null && items.Count == 1) { var proot = Schema.Patient.Accessor.Instance(null).SelectByKey(manager, items[0].idfHumanActual); p = proot; } } p.PersonIDType = p.PersonIDTypeLookup.FirstOrDefault(i => i.idfsBaseReference == (long)PersonalIDType.PIN_GG); p.strPersonID = person.PrivateNumber; p.strFirstName = person.FirstName; p.strLastName = person.LastName; p.Gender = p.GenderLookup.FirstOrDefault(c => c.idfsBaseReference == (person.GenderID.Equals(PersonGendersEnum.Male) ? (long)GenderType.Male : (person.GenderID.Equals(PersonGendersEnum.Female) ? (long)GenderType.Female : 0))); p.bPINMode = true; DateTime xx; if ((person.BirthDate != null) && (DateTime.TryParseExact(person.BirthDate.ToString(), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out xx))) { p.datDateofBirth = xx; //person.BirthDate; } return(new Tuple <Schema.Patient, string>(p, null)); } catch (Exception ex) { LogError.Log("ErrorLog_PinService_", ex, stream => { stream.WriteLine(String.Format("PIN = {0}, Form = {1}, CaseID = {2}, UserID = {3}, UserName = {4}, UserOrganization = {5}, EIDSSDateTime = {6}, PINServiceDateTime = {7}, Result = {8}", pin, form, caseID, EidssUserContext.Instance.CurrentUser.LoginName, EidssUserContext.Instance.CurrentUser.FullName, EidssUserContext.Instance.CurrentUser.OrganizationEng, DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"), dtResponse.HasValue ? dtResponse.Value.ToString("yyyy-MM-ddTHH:mm:ss") : "", resultCode )); }); resultCode = "Exception:" + ex.Message; throw; } finally { if (client != null && client.State != System.ServiceModel.CommunicationState.Closed) { client.Close(); } LogError.Log("Log_PinService_", null, stream => { stream.WriteLine(String.Format("PIN = {0}, form = {1}, CaseID = {2}, UserID = {3}, UserName = {4}, UserOrganization = {5}, EIDSSDateTime = {6}, PINServiceDateTime = {7}, Result = {8}", pin, form, caseID, EidssUserContext.Instance.CurrentUser.LoginName, EidssUserContext.Instance.CurrentUser.FullName, EidssUserContext.Instance.CurrentUser.OrganizationEng, DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"), dtResponse.HasValue ? dtResponse.Value.ToString("yyyy-MM-ddTHH:mm:ss") : "", resultCode )); }, "{0}{3}.txt"); } }
private void UpdateWorker() { UpdateItem currentItem; do { try { currentItem = null; lock (updateQueue) { if (updateQueue.Count > 0) { currentItem = updateQueue.Dequeue(); } } if (currentItem != null) { Dictionary <long, tablePlayer> tablePlayersTempDict; //Create a copy of the tablePlayersDict lock (locker) tablePlayersTempDict = (from temp in tablePlayersDict select temp).ToDictionary(k => k.Key, k => k.Value); #region tablePlayer if (latestHandId < currentItem.HandId) { latestHandId = currentItem.HandId; } List <tablePlayer> alreadyAddedIdsList = (from current in tablePlayersTempDict.Values where currentItem.PlayerIds.Contains(current.PlayerId) select current).ToList(); //Refresh players we already knew about for (int i = 0; i < alreadyAddedIdsList.Count; i++) { alreadyAddedIdsList[i].Refresh(latestHandId); } //Add players which don't yet exist long[] newPlayerIds = (currentItem.PlayerIds.Except((from current in alreadyAddedIdsList select current.PlayerId).ToArray())).ToArray(); for (int i = 0; i < newPlayerIds.Length; i++) { if (!tablePlayersTempDict.ContainsKey(newPlayerIds[i])) { tablePlayersTempDict.Add(newPlayerIds[i], new tablePlayer(newPlayerIds[i], currentItem.TableId, latestHandId)); } } //Remove anything from cachePlayers which is now too old int numActiveTables = AllActiveTableIds().Length; tablePlayersTempDict = (from current in tablePlayersTempDict where current.Value.LastRefreshTime > DateTime.Now.AddMinutes(-activeTimeOutMins) || current.Value.LastRefreshHandId > latestHandId - (numActiveTables * CacheTracker.handsPerTableTimeout) select current).ToDictionary(k => k.Key, k => k.Value); lock (locker) tablePlayersDict = tablePlayersTempDict; #endregion tablePlayer #region tableCache //Delete any caches which have timed out lock (locker) tableCaches = (from current in tableCaches where current.Value.LastRefresh > DateTime.Now.AddMinutes(-activeTimeOutMins) select current).ToDictionary(k => k.Key, k => k.Value); #endregion tableCache } int queueCount = 0; lock (updateQueue) queueCount = updateQueue.Count; if (queueCount == 0) { Thread.Sleep(100); } } catch (Exception ex) { LogError.Log(ex, "CacheTracker"); } } while (!closeWorkerThread); }
/*public class PersonsComparer : IEqualityComparer<Person> * { * public bool Equals(Person x, Person y) * { * return x.Pin.CompareTo(y.Pin) == 0; * } * * public int GetHashCode(Person obj) * { * return obj.Pin.GetHashCode(); * } * }*/ private Schema.Patient _getFromPersonIdentityServiceInternal(Schema.Patient p) { IdentityServiceClient client = null; //IIdentityService client = null; try { /*var b = new WSHttpBinding(SecurityMode.TransportWithMessageCredential); * b.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; * b.Security.Message.ClientCredentialType = MessageCredentialType.UserName; * * var factory = new ChannelFactory<IIdentityService>(b); * factory.Credentials.UserName.UserName = "******"; * factory.Credentials.UserName.Password = "******"; * //factory.Credentials.Peer.PeerAuthentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.PeerTrust; * //factory.Credentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.TrustedPeople, X509FindType.FindBySubjectName, "localhost"); * * client = factory.CreateChannel(new EndpointAddress(new Uri("https://eservice.e-health.gov.az/EHealthWcf/IdentityService.svc"))); * ServicePointManager.ServerCertificateValidationCallback = * ((sender, certificate, chain, sslPolicyErrors) => * { * return true; * }); */ //client = new IdentityServiceClient("BasicHttpBinding_IIdentityService", "https://eservice.e-health.gov.az/EHealthWcf/IdentityService.svc"); client = new IdentityServiceClient(); var encryptedUser = Config.GetSetting("AzPinServiceUsr"); //"essiduser"; var enryptedPassword = Config.GetSetting("AzPinServicePwd");; //"ess1dUs3R"; var usr = Cryptor.Decrypt(encryptedUser); var pwd = Cryptor.Decrypt(enryptedPassword, usr); client.ClientCredentials.UserName.UserName = usr; client.ClientCredentials.UserName.Password = pwd; Person prs = null; if (p.idfsSearchMethod == 1) { var prsList = client.GetPersonByParams(p.strFirstName, p.strLastName, p.strSecondName, p.datDateofBirth /*.HasValue ? p.datDateofBirth.Value.ToString("yyyy-MM-ddT00:00:00") : null*/); if (prsList != null && prsList.Select(i => i.Pin).Distinct().Count() == 1) { prs = prsList[0]; if (prs != null) { try { prs = client.GetPersonByPin(prs.Pin); } catch (Exception) { } } } } else if (p.idfsSearchMethod == 2) { IdentityServiceDocumentType docType = IdentityServiceDocumentType.Passport; switch (p.idfsDocumentType) { case 1: docType = IdentityServiceDocumentType.Passport; break; case 2: docType = IdentityServiceDocumentType.IDCardForAdult; break; case 3: docType = IdentityServiceDocumentType.IDcardForChild; break; case 4: docType = IdentityServiceDocumentType.TemporaryResidencePermit; break; case 5: docType = IdentityServiceDocumentType.PermanentResidencePermit; break; case 6: docType = IdentityServiceDocumentType.BirthCertificate; break; } prs = client.GetPersonByDocumentNumber(p.strDocumentNumber, docType, docType == IdentityServiceDocumentType.BirthCertificate ? p.datDocumentDate : null); if (prs != null) { try { prs = client.GetPersonByPin(prs.Pin); } catch (Exception) { } } } else if (p.idfsSearchMethod == 3) { prs = client.GetPersonByPin(p.strPersonID); } else if (p.idfsSearchMethod == 4) { prs = new Person() { Pin = "0YR9DE3", Name = "İSMAYILOV", SurName = "RAMİL", FatherName = "TOFİQ OĞLU", DateOfBirth = new DateTime(1986, 1, 19), Sex = "M" }; } if (prs != null) { using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance)) { FilterParams filters = new FilterParams(); filters.Add("strPersonID", "=", prs.Pin); var items = Schema.PatientListItem.Accessor.Instance(null).SelectListT(manager, filters); if (items != null && items.Count == 1) { var proot = Schema.Patient.Accessor.Instance(null).SelectByKey(manager, items[0].idfHumanActual); p = proot; } } p.PersonIDType = p.PersonIDTypeLookup.FirstOrDefault(i => i.idfsBaseReference != 0 && i.idfsBaseReference != (long)PersonalIDType.Unknown); p.strPersonID = prs.Pin; p.strFirstName = prs.Name; p.strLastName = prs.SurName; p.strSecondName = prs.FatherName; p.datDateofBirth = prs.DateOfBirth; p.Gender = p.GenderLookup.FirstOrDefault(c => c.idfsBaseReference == (prs.Sex == "M" ? (long)GenderType.Male : (prs.Sex == "F" ? (long)GenderType.Female : 0))); return(p); } } catch (FaultException fex) { switch (fex.Code.Name) { case "2.1": case "2.2": case "2.3": return(null); case "0": case "1": default: LogError.Log("ErrorLog_PinService_", fex, stream => { stream.WriteLine(String.Format("SearchMethod = {0}, DocumentType = {1}, PersonID = '{2}', FirstName = '{3}', LastName = '{4}', SecondName = '{5}', DateofBirth = '{6}'", p.idfsSearchMethod, p.idfsDocumentType, p.strPersonID, p.strFirstName, p.strLastName, p.strSecondName, p.datDateofBirth.HasValue ? p.datDateofBirth.Value.ToString("yyyy-MM-ddT00:00:00") : "")); stream.WriteLine(String.Format("Code = {0}, Subcode = {1}, Reason = {2}", fex.Code.Name, fex.Code.SubCode == null ? "" : fex.Code.SubCode.Name, fex.Reason.ToString())); }); if (fex.InnerException != null) { LogError.Log("ErrorLog_PinService_", fex.InnerException); } throw; } } catch (Exception ex) { LogError.Log("ErrorLog_PinService_", ex, stream => { stream.WriteLine(String.Format("SearchMethod = {0}, DocumentType = {1}, PersonID = '{2}', FirstName = '{3}', LastName = '{4}', SecondName = '{5}', DateofBirth = '{6}'", p.idfsSearchMethod, p.idfsDocumentType, p.strPersonID, p.strFirstName, p.strLastName, p.strSecondName, p.datDateofBirth.HasValue ? p.datDateofBirth.Value.ToString("yyyy-MM-ddT00:00:00") : "")); }); if (ex.InnerException != null) { LogError.Log("ErrorLog_PinService_", ex.InnerException); } throw; } finally { if (client != null && client.State != System.ServiceModel.CommunicationState.Closed) { client.Close(); } } return(null); }