private static void Main() { FileSystemManager.Initialize(); MasterLog.Initialize(); using (Game1 game = new Game1()) { game.Run(); } }
public override void MakePreparations(Living l) { Tile tile = World.Data.World.GetTile(l.Dimension, this.Target.X, this.Target.Y); this.Minable = tile.Resources; if (tile.Resources == null) { MasterLog.DebugWriteLine("Minable is null"); } }
public Aggregator(IPAddress myIP, Func <WorldInitializer, World> generateWorld) { sync = new ActionSyncronizer(); host = new GlobalHost(sync.GetProxy(), myIP, sync.TimedAction); myClient = new Client(host, this, generateWorld); ILog statsLog = MasterLog.GetFileLog("stats.log"); sync.TimedAction.AddAction(() => Log.EntryNormal(statsLog, this.GetStats())); }
/// <summary> /// How the server handles tick messages. /// </summary> /// <param name="msg"></param> public static void Tick(ServerTickMessage msg) { UInt64 ticksBehind = msg.Tick - GameTick - 1; if (ticksBehind != 0) { MasterLog.DebugWriteLine("Running " + ticksBehind.ToString() + " tick(s) behind"); } TickLoop(ticksBehind + 1); }
internal static void Tick(UInt64 tickSentAt) { UInt64 ticksBehind = tickSentAt - GameTick - 1; if (ticksBehind != 0) { MasterLog.DebugWriteLine("Running " + ticksBehind.ToString() + " tick(s) behind"); } TickLoop(ticksBehind + 1); }
private void RenderableIRecipe_ClickEvent(object sender, MagicalLifeGUIWindows.GUI.Reusable.Event.ClickEventArgs e) { if (Keyboard.GetState().IsKeyDown(Keys.LeftShift)) { MasterLog.DebugWriteLine("Special click"); this.BarItem.SpecialClicked(); } else { this.BarItem.Clicked(); } }
public static T Deserialize <T>(byte[] data) { try { using (MemoryStream ms = new MemoryStream(data)) { return((T)TypeModel.DeserializeWithLengthPrefix(ms, null, typeof(T), PrefixStyle.Base128, 0)); } } catch (Exception e) { MasterLog.DebugWriteLine(e.Message); return(default);
public static T Deserialize <T>(string data) { try { using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(data))) { return((T)TypeModel.Deserialize(ms, null, typeof(T))); } } catch (Exception e) { MasterLog.DebugWriteLine(e.Message); return(default);
/// <summary> /// Starts the network server. /// </summary> internal void Start(int port) { this.Server.Start(port); foreach (System.Net.IPAddress item in this.Server.GetListeningIPs()) { MasterLog.DebugWriteLine("Server listening on: " + item.ToString()); } this.Server.ClientConnected += this.Server_ClientConnected; this.Server.ClientDisconnected += this.Server_ClientDisconnected; this.Server.DataReceived += this.Server_DataReceived; }
/// <summary> /// Sends a message to the client. /// </summary> /// <param name="message"></param> public static void Send <T>(T message) where T : BaseMessage { MasterLog.DebugWriteLine("Sending message: " + message.GetType().FullName); if (NetworkSettings.Mode == EngineMode.ServerAndClient) { ServerSendRecieve.Recieve(message); } else { TCPClient.Send <T>(message); } }
/// <summary> /// Sends a message to all connected clients. /// </summary> /// <param name="message"></param> public static void SendAll <T>(T message) where T : BaseMessage { MasterLog.DebugWriteLine("Sending message: " + message.GetType().FullName); if (Local == EngineMode.ServerAndClient) { ClientSendRecieve.Recieve(message); } else { TCPServer.Broadcast <T>(message); } }
public static MasterLog MasterLog(string appname = "AWP_Master_Log") { var set = Pull.Setting(appname); if (set == null) { Push.MasterLog(Global._MasterLog); return(Global._MasterLog); } var ml = new MasterLog().DeserializeFromXmlString <MasterLog>(set.XmlData); return(ml); }
/// <summary> /// Sends a message to the server. /// </summary> /// <param name="message"></param> public static void Send <T>(T message) where T : BaseMessage { TotalSent++; MasterLog.DebugWriteLine("Sent total: " + TotalSent.ToString()); if (NetworkSettings.Mode == EngineMode.ServerAndClient) { ServerSendRecieve.Recieve(message); } else { TCPClient.Send <T>(message); } }
/// <summary> /// Draws a tile. /// </summary> private static void DrawTile(Tile tile, ref SpriteBatch spBatch, Point2D start) { Microsoft.Xna.Framework.Rectangle target = new Microsoft.Xna.Framework.Rectangle(start.ToXNA(), RenderingPipe.tileSize); if (tile.GetRenderable().TextureID != 15 || tile.GetRenderable().TextureID != 28) { MasterLog.DebugWriteLine("Drawing transition texture!" + tile.Location.ToString()); } spBatch.Draw(AssetManager.Textures[tile.GetRenderable().TextureID], target, RenderingPipe.colorMask); DrawStone(tile, ref spBatch, target); DrawItems(ref spBatch, tile, target); }
/// <summary> /// Loads all the mods stored in this registry. /// </summary> internal static void LoadAllMods() { Loader loader = new Loader(); string message = string.Empty; foreach (IMod item in LoadedMods) { ModInformation info = item.GetInfo(); MasterLog.DebugWriteLine("Loading mod: " + info.DisplayName + "(" + info.ModID + ")"); ProtoUtil.RegisterAssembly(item.GetType().Assembly); List <Load.IGameLoader> loadJobs = item.Load(); loader.LoadAll(ref message, loadJobs); MasterLog.DebugWriteLine("Done loading: " + info.DisplayName + "(" + info.ModID + ")"); } }
public void Initialize(Dimension dimension) { this.Grid = new Grid(dimension.Width * Chunk.Width, dimension.Height * Chunk.Height, 1); foreach (Tile item in dimension) { Position pos = new Position(item.Location.X, item.Location.Y); this.Grid.SetCellCost(pos, item.MovementCost); if (!item.IsWalkable) { this.Grid.BlockCell(pos); MasterLog.DebugWriteLine("Blocking tile: " + pos.ToString()); } } }
public static bool MasterLog(MasterLog log, string appname = "AWP_Master_Log") { try { var xml = log.SerializeToXmlString(log); return(Push.Setting(new SettingsDBData() { Appname = appname, XmlData = xml })); } catch (Exception) { return(false); } }
/// <summary> /// Begins execution of the jobs. /// </summary> /// <param name="message"></param> public void ExecuteJobs(ref string message) { IGameLoader job; MasterLog.DebugWriteLine("Executing loading jobs!"); while (this.Jobs.Count > 0) { job = this.Jobs.Dequeue(); job.InitialStartup(); this.JobsCompleted++; message = this.JobsCompleted.ToString() + " out of " + this.JobCount.ToString() + " jobs completed"; MasterLog.DebugWriteLine(message); } }
/// <summary> /// Deserializes the message from bytes. /// </summary> /// <param name="data"></param> /// <returns></returns> public static BaseMessage Deserialize(byte[] data) { try { using (MemoryStream ms = new System.IO.MemoryStream(data)) { BaseMessage Base = (BaseMessage)TypeModel.DeserializeWithLengthPrefix(ms, null, typeof(BaseMessage), ProtoBuf.PrefixStyle.Base128, 0); return(Base); } } catch (IndexOutOfRangeException e) { MasterLog.DebugWriteLine(e, "Unknown message type!"); return(null); } }
private void MouseListner_MouseWheelMoved(object sender, MonoGame.Extended.Input.InputListeners.MouseEventArgs e) { float previous = e.PreviousState.ScrollWheelValue; float current = e.ScrollWheelValue; float change = (previous - current) / 1000; //Ensure that zoom is above the minimum. float aboveMin = Math.Max(ZoomHandler.MinZoom, RenderingPipe.Zoom - change); //Ensure that zoom is below the maximum. float belowMaxAndAboveMin = Math.Min(ZoomHandler.MaxZoom, aboveMin); RenderingPipe.Zoom = belowMaxAndAboveMin; MasterLog.DebugWriteLine("Zoom: " + RenderingPipe.Zoom.ToString()); }
private void HandleEscapeKey() { //Show main menu. MasterLog.DebugWriteLine("Escape key pressed"); if (World.Dimensions.Count > 0) { //Ingame: Open up in game menu InGameEscapeMenu.Initialize(); } else { //Pregame: MenuHandler.Back(); } }
private static void ContainerMouseScroll(MouseEventArgs e) { foreach (GuiContainer item in GUIWindows) { GuiContainer youngest = GetYoungestChild(item); if (youngest.Visible && youngest.DrawingBounds.Contains(e.Position)) { Scroll(e, youngest.Controls, youngest); MasterLog.DebugWriteLine("Clicking in menu: " + youngest.GetType().FullName); return; } } //If the click isn't in a GUI, then it must be in the map... ScrollMap(e); }
public void Initialize(Dimension dimension) { this.Grid = new Grid(dimension.Width * Chunk.Width, dimension.Height * Chunk.Height, 1); foreach (Tile item in dimension) { ComponentSelectable selected = item.GetExactComponent <ComponentSelectable>(); Position pos = new Position(selected.MapLocation.X, selected.MapLocation.Y); this.Grid.SetCellCost(pos, item.MovementCost); if (!item.IsWalkable) { this.Grid.BlockCell(pos); MasterLog.DebugWriteLine("Blocking tile: " + pos.ToString()); } } }
public OverlayHost(OverlayHostName hostName, IPEndPoint address, ActionSyncronizerProxy processQueue, ProcessorAssigner messageProcessorAssigner, MemoryStream extraHandshakeInfo, TimerThread tt, TimeSpan inactivityPeriod) { this.inactivityPeriod = inactivityPeriod; this.hostName = hostName; this.IpAddress = address; this.processQueue = processQueue; this.processorAssigner = messageProcessorAssigner; this.extraHandshakeInfo = extraHandshakeInfo; log = MasterLog.GetFileLog("network", hostName.ToString() + ".log"); tt.AddAction(this.DisconnectInactiveNodes); }
/// <summary> /// Handles container clicks before handling normal UI elements. /// </summary> /// <param name="clickData"></param> /// <returns></returns> private static void ContainerClick(MouseEventArgs clickData) { foreach (GUIContainer item in GUIWindows) { GUIContainer youngest = GetYoungestChild(item); if (youngest.Visible && youngest.DrawingBounds.Contains(clickData.Position)) { Click(clickData, youngest.Controls, youngest); MasterLog.DebugWriteLine("Clicking in menu: " + youngest.GetType().FullName); return; } } //If the click isn't in a GUI, then it must be in the map... InputHistory.MapMouseClick(clickData); }
/// <summary> /// Serializes the object to string. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="data"></param> /// <returns></returns> public static byte[] Serialize <T>(T data) { try { using (MemoryStream outputStream = new MemoryStream()) { TypeModel.SerializeWithLengthPrefix(outputStream, data, typeof(T), ProtoBuf.PrefixStyle.Base128, 0); return(outputStream.GetBuffer()); } } catch (Exception e) { MasterLog.DebugWriteLine(e.Message); return(null); } }
/// <summary> /// Write Log For Employee /// </summary> /// <param name="oldInfo"></param> /// <param name="newInfo"></param> /// <param name="action"></param> public void WriteLogForGroup(Group oldInfo, Group newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; switch (action) { case ELogAction.Insert: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.CreatedBy, ELogTable.Group.ToString(), action.ToString()); // Write Insert Log WriteInsertLogForGroup(newInfo, logId); break; case ELogAction.Update: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Group.ToString(), action.ToString()); // Write Update Log bool isUpdated = WriteUpdateLogForGroup(newInfo, logId); if (!isUpdated) { commonDao.DeleteMasterLog(logId); } break; case ELogAction.Delete: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Group.ToString(), action.ToString()); // Write Delete Log string key = "Group name '" + newInfo.GroupName + "'"; commonDao.InsertLogDetail(logId, "GroupId", "Key for Delete ", key, null); break; } } catch (Exception ex) { throw ex; } }
private void Client_DataReceived(object sender, Message e) { MasterLog.DebugWriteLine("Receiving " + e.Data.Length + " bytes"); this.MsgBuffer.ReceiveData(e.Data); while (this.MsgBuffer.IsMessageAvailible()) { BaseMessage msg = this.MsgBuffer.GetMessageData(); if (msg is JobAssignedMessage) { JobAssignedMessage m = (JobAssignedMessage)msg; MasterLog.DebugWriteLine("Job ID After: " + m.Task.Dependencies.ElementAt(0).Key.ToString()); } ClientProcessor.Process(msg); } }
/// <summary> /// Handles container clicks before handling normal UI elements. /// </summary> /// <param name="clickData"></param> /// <returns></returns> private static void ContainerClick(MouseEventArgs clickData) { foreach (GUIContainer item in GUIWindows) { if (item.Visible && item.DrawingBounds.Contains(clickData.Position)) { Click(clickData, item.Controls, item); MasterLog.DebugWriteLine("Clicking in menu: " + item.GetType().FullName); return; } } if (!Click(clickData, Bounds)) { InputHistory.MapMouseClick(clickData); } }
/// <summary> /// Write Log For Employee /// </summary> /// <param name="oldInfo"></param> /// <param name="newInfo"></param> /// <param name="action"></param> public void WriteLogForCandidate(Candidate oldInfo, Candidate newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; switch (action) { case ELogAction.Insert: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.CreatedBy, ELogTable.Candidate.ToString(), action.ToString()); // Write Insert Log WriteInsertLogForCandidate(newInfo, logId); break; case ELogAction.Update: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Candidate.ToString(), action.ToString()); // Write Update Log bool isUpdated = WriteUpdateLogForCandidate(newInfo, logId); if (!isUpdated) { commonDao.DeleteMasterLog(logId); } break; case ELogAction.Delete: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Candidate.ToString(), action.ToString()); // Write Delete Log string key = newInfo.ID.ToString() + " [" + newInfo.FirstName + " " + newInfo.MiddleName + " " + newInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Delete", key, null); break; } } catch (Exception ex) { throw ex; } }
/// <summary> /// Write Log For Employee /// </summary> /// <param name="oldInfo"></param> /// <param name="newInfo"></param> /// <param name="action"></param> public void WriteLogForWorkflowAdmin(UserAdmin_WFRole oldInfo, UserAdmin_WFRole newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; switch (action) { case ELogAction.Insert: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.CreatedBy, ELogTable.WorkFlowAdmin.ToString(), action.ToString()); // Write Insert Log WriteInsertLogForWorkflowAdmin(newInfo, logId); break; case ELogAction.Update: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.WorkFlowAdmin.ToString(), action.ToString()); // Write Update Log bool isUpdated = WriteUpdateLogForWorkflowAdmin(newInfo, logId); if (!isUpdated) { commonDao.DeleteMasterLog(logId); } break; case ELogAction.Delete: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString()); // Write Delete Log string key = newInfo.ID + " [" + oldInfo.UserAdmin.UserName + "] with Role [" + oldInfo.WFRole.Name + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Delete", key, null); break; } } catch (Exception ex) { throw ex; } }
/// <summary> /// Begins execution of the jobs. /// </summary> /// <param name="message"></param> public void ExecuteJobs(ref string message) { IGameLoader job; int progress; MasterLog.DebugWriteLine("Executing loading jobs!"); while (this.Jobs.Count > 0) { progress = 0; job = this.Jobs.Dequeue(); job.InitialStartup(ref progress); this.JobsCompleted += job.GetTotalOperations(); message = this.JobsCompleted.ToString() + " out of " + this.JobCount.ToString() + " jobs completed"; MasterLog.DebugWriteLine(message); } }
public void WriteLogForJobRequest(JobRequest oldInfo, JobRequest newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; switch (action) { case ELogAction.Insert: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.CreatedBy, ELogTable.JobRequest.ToString(), action.ToString()); // Write Insert Log WriteInsertLogForJobRequest(newInfo, logId); break; case ELogAction.Update: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.JobRequest.ToString(), action.ToString()); // Write Update Log bool isUpdated = WriteUpdateLogForJobRequest(newInfo, logId); if (!isUpdated) { commonDao.DeleteMasterLog(logId); } break; case ELogAction.Delete: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.JobRequest.ToString(), action.ToString()); // Write Delete Log string key = newInfo.ID.ToString() + " [" + newInfo.UserAdmin.UserName + " (Requestor) ]"; commonDao.InsertLogDetail(logId, "ID", "Key for Delete", key, null); break; } } catch (Exception ex) { throw ex; } }
/// <summary> /// Write Log For Employee /// </summary> /// <param name="oldInfo"></param> /// <param name="newInfo"></param> /// <param name="action"></param> public void WriteLogForContract(Contract oldInfo, Contract newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; switch (action) { case ELogAction.Insert: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.CreatedBy, ELogTable.Contract.ToString(), action.ToString()); // Write Insert Log WriteInsertLogForContract(newInfo, logId); break; case ELogAction.Update: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Contract.ToString(), action.ToString()); // Write Update Log bool isUpdated = WriteUpdateLogForContract(newInfo, logId); if (!isUpdated) { commonDao.DeleteMasterLog(logId); } break; case ELogAction.Delete: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Contract.ToString(), action.ToString()); // Write Delete Log string key = "Contract on " + newInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW) + " of " + newInfo.EmployeeId + " [" + newInfo.Employee.FirstName + " " + newInfo.Employee.LastName + "]"; commonDao.InsertLogDetail(logId, "ContractId", "Key for Delete", key, null); break; } } catch (Exception ex) { throw ex; } }
public void TestInitialize() { if (!this.Initialized) { MasterLog.Initialize(); Loader load = new Loader(); string msg = string.Empty; SettingsManager.Initialize(); FileSystemManager.Initialize(); load.LoadAll(ref msg, new List <IGameLoader> { new ProtoTypeLoader(), new ProtoManager(), }); this.Initialized = true; } }
public void WriteLogForRemoveContractCV(Contract newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Contract.ToString(), action.ToString()); Contract oldInfo = new ContractRenewalDao().GetById(newInfo.ContractId); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { foreach (string item in oldInfo.ContractFile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX)) { if (!newInfo.ContractFile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX).Contains(item)) { commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", item, ""); isUpdated = true; } } if (isUpdated) { // Insert Key Name string key ="Contract on Start Date " + oldInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW) + (oldInfo.EndDate.HasValue?" to " +oldInfo.EndDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"") + " of " + oldInfo.EmployeeId + " [" + oldInfo.Employee.FirstName + " " + oldInfo.Employee.LastName + "]"; commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Delete", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Insert Master Log /// </summary> /// <param name="logId"></param> /// <param name="username"></param> /// <param name="tableName"></param> /// <param name="actionName"></param> public void InsertMasterLog(string logId, string username, string tableName, string actionName) { try { if ((logId != null) && (!string.Empty.Equals(username))) { // Set info MasterLog objInfo = new MasterLog(); objInfo.LogId = logId; objInfo.Username = username; objInfo.LogDate = DateTime.Now; objInfo.TableName = tableName; objInfo.ActionName = actionName; // Insert to DB dbContext.MasterLogs.InsertOnSubmit(objInfo); dbContext.SubmitChanges(); } } catch (Exception ex) { throw ex; } }
public void WriteLogForRemoveAttachFile(STT_RefResult newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.STT.ToString(), action.ToString()); STT_RefResult oldInfo = new STTRefResultDao().GetById(newInfo.SttID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { foreach (string item in oldInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX)) { if (!newInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX).Contains(item)) { commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", item, ""); isUpdated = true; } } if (isUpdated) { // Insert Key Name STT obj = new STTDao().GetById(oldInfo.SttID); string key = oldInfo.SttID + " [" + obj.FirstName + " " + obj.MiddleName + " " + obj.LastName + "]"; commonDao.InsertLogDetail(logId, "STT_ID", "Key for Delete", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
public void WriteLogForUpdateJR(Candidate newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Candidate.ToString(), action.ToString()); Candidate oldInfo = new CandidateDao().GetById(newInfo.ID.ToString()); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.JRId != oldInfo.JRId) { commonDao.InsertLogDetail(logId, "JRId", "Job Request", oldInfo.JRId.HasValue ? oldInfo.JRId.Value.ToString() : "", newInfo.JRId.HasValue ? newInfo.JRId.Value.ToString() : ""); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Write Insert Log For Employee /// </summary> /// <param name="objInfo"></param> /// <param name="logId"></param> public bool WriteLogForSetUpApproval(PurchaseRequest newInfo, List<PurchaseRequestApproval> listApproval, bool insertApproval) { bool isUpdated = false; try { MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.PurchaseRequest.ToString(), ELogAction.Update.ToString()); // Get old info PurchaseRequest oldInfo = new PurchaseRequestDao().GetByID(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.WFResolutionID != oldInfo.WFResolutionID) { commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, new ResolutionDao().GetByID(newInfo.WFResolutionID).Name); isUpdated = true; } if (newInfo.WFStatusID != oldInfo.WFStatusID) { commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new StatusDao().GetByID(newInfo.WFStatusID).Name); isUpdated = true; } if (insertApproval) { foreach (PurchaseRequestApproval item in listApproval) { commonDao.InsertLogDetail(logId, "Approval", "Approval", string.Empty, new UserAdminDao().GetById(item.ApproverId).UserName + " (" + new RoleDao().GetByID(item.ApproverGroup).Name + ")"); isUpdated = true; } } else { if (newInfo.AssignRole != oldInfo.AssignRole || newInfo.AssignID != oldInfo.AssignID) { commonDao.InsertLogDetail(logId, "Assign", "Assign", oldInfo.UserAdmin.UserName + " (" + oldInfo.WFRole.Name + ")", ((newInfo.AssignID.HasValue ? new UserAdminDao().GetById(newInfo.AssignID.Value).UserName : string.Empty) + " (" + (newInfo.AssignRole.HasValue ? new RoleDao().GetByID(newInfo.AssignRole.Value).Name : string.Empty) + ")")); isUpdated = true; } } if (isUpdated) { // Insert Key Name string key = Constants.PER_REVIEW_EFORM_MASTER_PREFIX + oldInfo.ID.ToString(); commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } return isUpdated; }
public void WriteLogForUpdateAddress(Employee newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString()); Employee oldInfo = new EmployeeDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.PermanentAddress != oldInfo.PermanentAddress) { commonDao.InsertLogDetail(logId, "PermanentAddress", "Permanent Address", oldInfo.PermanentAddress, newInfo.PermanentAddress); isUpdated = true; } if (newInfo.PermanentArea != oldInfo.PermanentArea) { commonDao.InsertLogDetail(logId, "PermanentArea", "Permanent Ward", oldInfo.PermanentArea, newInfo.PermanentArea); isUpdated = true; } if (newInfo.PermanentDistrict != oldInfo.PermanentDistrict) { commonDao.InsertLogDetail(logId, "PermanentDistrict", "Permanent District", oldInfo.PermanentDistrict, newInfo.PermanentDistrict); isUpdated = true; } if (newInfo.PermanentCityProvince != oldInfo.PermanentCityProvince) { commonDao.InsertLogDetail(logId, "PermanentCityProvince", "Permanent City Province", oldInfo.PermanentCityProvince, newInfo.PermanentCityProvince); isUpdated = true; } if (newInfo.PermanentCountry != oldInfo.PermanentCountry) { commonDao.InsertLogDetail(logId, "PermanentCountry", "Permanent Country", oldInfo.PermanentCountry, newInfo.PermanentCountry); isUpdated = true; } if (newInfo.TempAddress != oldInfo.TempAddress) { commonDao.InsertLogDetail(logId, "TempAddress", "Temp Address", oldInfo.TempAddress, newInfo.TempAddress); isUpdated = true; } if (newInfo.TempArea != oldInfo.TempArea) { commonDao.InsertLogDetail(logId, "TempArea", "Temp Area", oldInfo.TempArea, newInfo.TempArea); isUpdated = true; } if (newInfo.TempDistrict != oldInfo.TempDistrict) { commonDao.InsertLogDetail(logId, "TempDistrict", "Temp District", oldInfo.TempDistrict, newInfo.TempDistrict); isUpdated = true; } if (newInfo.TempCityProvince != oldInfo.TempCityProvince) { commonDao.InsertLogDetail(logId, "TempCityProvince", "Temp City Province", oldInfo.TempCityProvince, newInfo.TempCityProvince); isUpdated = true; } if (newInfo.TempCountry != oldInfo.TempCountry) { commonDao.InsertLogDetail(logId, "TempCountry", "Temp Country", oldInfo.TempCountry, newInfo.TempCountry); isUpdated = true; } if (newInfo.VnPermanentAddress != oldInfo.VnPermanentAddress) { commonDao.InsertLogDetail(logId, "VnPermanentAddress", "Vn Permanent Address", oldInfo.VnPermanentAddress, newInfo.VnPermanentAddress); isUpdated = true; } if (newInfo.VnPermanentArea != oldInfo.VnPermanentArea) { commonDao.InsertLogDetail(logId, "VnPermanentArea", "Vn Permanent Area", oldInfo.VnPermanentArea, newInfo.VnPermanentArea); isUpdated = true; } if (newInfo.VnPermanentDistrict != oldInfo.VnPermanentDistrict) { commonDao.InsertLogDetail(logId, "VnPermanentDistrict", "Vn Permanent District", oldInfo.VnPermanentDistrict, newInfo.VnPermanentDistrict); isUpdated = true; } if (newInfo.VnPermanentCityProvince != oldInfo.VnPermanentCityProvince) { commonDao.InsertLogDetail(logId, "VnPermanentCityProvince", "Vn Permanent City Province", oldInfo.VnPermanentCityProvince, newInfo.VnPermanentCityProvince); isUpdated = true; } if (newInfo.VnPermanentCountry != oldInfo.VnPermanentCountry) { commonDao.InsertLogDetail(logId, "VnPermanentCountry", "Vn Permanent Country", oldInfo.VnPermanentCountry, newInfo.VnPermanentCountry); isUpdated = true; } if (newInfo.VnTempAddress != oldInfo.VnTempAddress) { commonDao.InsertLogDetail(logId, "VnTempAddress", "Vn Temp Address", oldInfo.VnTempAddress, newInfo.VnTempAddress); isUpdated = true; } if (newInfo.VnTempArea != oldInfo.VnTempArea) { commonDao.InsertLogDetail(logId, "VnTempArea", "Vn Temp Area", oldInfo.VnTempArea, newInfo.VnTempArea); isUpdated = true; } if (newInfo.VnTempCityProvince != oldInfo.VnTempCityProvince) { commonDao.InsertLogDetail(logId, "VnTempCityProvince", "Vn Temp City Province", oldInfo.VnTempCityProvince, newInfo.VnTempCityProvince); isUpdated = true; } if (newInfo.VnTempCountry != oldInfo.VnTempCountry) { commonDao.InsertLogDetail(logId, "VnTempCountry", "Vn Temp Country", oldInfo.VnTempCountry, newInfo.VnTempCountry); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
public void WriteLogForEditResult(STT_RefResult newInfo, ELogAction action) { try { if (newInfo == null) { return; } bool isUpdated = false; MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.STT.ToString(), action.ToString()); STT oldSTTInfo = new STTDao().GetById(newInfo.SttID); STT_RefResult oldInfo = new STTRefResultDao().GetById(newInfo.SttID); if ((oldSTTInfo != null) && (newInfo != null) && (logId != null)) { if (oldInfo.Remarks != newInfo.Remarks) { commonDao.InsertLogDetail(logId, "Remarks", "Remarks", oldInfo.Remarks, newInfo.Remarks); isUpdated = true; } if (oldInfo.Attachfile != newInfo.Attachfile) { //string[] arrayNew = newInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX); //foreach (string fileNew in arrayNew) //{ // if (!oldInfo.Attachfile.Contains(fileNew)) // { // commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", "", fileNew); // isUpdated = true; // } //} string[] Attachfile = newInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX); foreach (string item in oldInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX))//case delete file { if (!newInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX).Contains(item)) { commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", item, ""); isUpdated = true; } } foreach (string fileNew in Attachfile) //case add new file { if (!oldInfo.Attachfile.Contains(fileNew)) { commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", "", fileNew); isUpdated = true; } } } if (oldInfo.ResultId != newInfo.ResultId) { if (newInfo.ResultId == Constants.STT_RESULT_FAIL) { isUpdated = true; commonDao.InsertLogDetail(logId, "ResultId", "Result", oldInfo.STT_Result.Name,new STTResultDao().GetById(newInfo.ResultId).Name); commonDao.InsertLogDetail(logId, "STTStatusId", "Status", oldSTTInfo.STT_Status.Name, new STTStatusDao().GetById(Constants.STT_STATUS_REJECTED).Name); } if (newInfo.ResultId == Constants.STT_RESULT_PASS) { isUpdated = true; commonDao.InsertLogDetail(logId, "ResultId", "Result", oldInfo.STT_Result.Name, new STTResultDao().GetById(newInfo.ResultId).Name); commonDao.InsertLogDetail(logId, "STTStatusId", "Status", oldSTTInfo.STT_Status.Name, new STTStatusDao().GetById(Constants.STT_STATUS_NEED_TO_PROMOTED).Name); } } if (oldInfo.EndDate != newInfo.EndDate) { isUpdated = true; commonDao.InsertLogDetail(logId, "EndDate", "End Date", oldInfo.EndDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.EndDate.ToString(Constants.DATETIME_FORMAT_VIEW)); } // Insert Key Name if (isUpdated) { string key = oldSTTInfo.ID + " [" + oldSTTInfo.FirstName + " " + oldSTTInfo.MiddleName + " " + oldSTTInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "STT_ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
public void WriteLogForUpdatePromoted(STT newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.STT.ToString(), action.ToString()); STT oldSTTInfo = new STTDao().GetById(newInfo.ID); if ((oldSTTInfo != null) && (newInfo != null) && (logId != null)) { commonDao.InsertLogDetail(logId, "STTStatusId", "Status", oldSTTInfo.STT_Status.Name, new STTStatusDao().GetById(Constants.STT_STATUS_PROMOTED).Name); // Insert Key Name string key = oldSTTInfo.ID + " [" + oldSTTInfo.FirstName + " " + oldSTTInfo.MiddleName + " " + oldSTTInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "STT_ID", "Key for Update", key, null); } } catch (Exception ex) { throw ex; } }
public void WriteLogForUpdateRemarks(Employee newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString()); Employee oldInfo = new EmployeeDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.Remarks != oldInfo.Remarks) { commonDao.InsertLogDetail(logId, "Remarks", "Remarks", oldInfo.Remarks, newInfo.Remarks); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
public void WriteLogForUpdateContact(Employee newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString()); Employee oldInfo = new EmployeeDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.HomePhone != oldInfo.HomePhone) { commonDao.InsertLogDetail(logId, "HomePhone", "Home Phone", oldInfo.HomePhone, newInfo.HomePhone); isUpdated = true; } if (newInfo.CellPhone != oldInfo.CellPhone) { commonDao.InsertLogDetail(logId, "CellPhone", "Cell Phone", oldInfo.CellPhone, newInfo.CellPhone); isUpdated = true; } if (newInfo.ExtensionNumber != oldInfo.ExtensionNumber) { commonDao.InsertLogDetail(logId, "ExtensionNumber", "Extension Number", oldInfo.ExtensionNumber, newInfo.ExtensionNumber); isUpdated = true; } if (newInfo.LocationCode != oldInfo.LocationCode) { commonDao.InsertLogDetail(logId, "LocationCode", "LocationCode", CommonFunc.GenerateStringOfLocation(oldInfo.LocationCode), CommonFunc.GenerateStringOfLocation(newInfo.LocationCode)); isUpdated = true; } if (newInfo.SkypeId != oldInfo.SkypeId) { commonDao.InsertLogDetail(logId, "SkypeId", "SkypeId", oldInfo.SkypeId, newInfo.SkypeId); isUpdated = true; } if (newInfo.YahooId != oldInfo.YahooId) { commonDao.InsertLogDetail(logId, "YahooId", "YahooId", oldInfo.YahooId, newInfo.YahooId); isUpdated = true; } if (newInfo.PersonalEmail != oldInfo.PersonalEmail) { commonDao.InsertLogDetail(logId, "PersonalEmail", "Personal Email", oldInfo.PersonalEmail, newInfo.PersonalEmail); isUpdated = true; } if (newInfo.OfficeEmail != oldInfo.OfficeEmail) { commonDao.InsertLogDetail(logId, "OfficeEmail", "Office Email", oldInfo.OfficeEmail, newInfo.OfficeEmail); isUpdated = true; } if (newInfo.EmergencyContactName != oldInfo.EmergencyContactName) { commonDao.InsertLogDetail(logId, "EmergencyContactName", "Emergency Contact Name", oldInfo.EmergencyContactName, newInfo.EmergencyContactName); isUpdated = true; } if (newInfo.EmergencyContactPhone != oldInfo.EmergencyContactPhone) { commonDao.InsertLogDetail(logId, "EmergencyContactPhone", "Emergency Contact Phone", oldInfo.EmergencyContactPhone, newInfo.EmergencyContactPhone); isUpdated = true; } if (newInfo.EmergencyContactRelationship != oldInfo.EmergencyContactRelationship) { commonDao.InsertLogDetail(logId, "EmergencyContactRelationship", "Emergency Contact Relationship", oldInfo.EmergencyContactRelationship, newInfo.EmergencyContactRelationship); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
public void WriteLogForUpdatePersonal(Employee newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString()); Employee oldInfo = new EmployeeDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.VnIDIssueLocation != oldInfo.VnIDIssueLocation) { commonDao.InsertLogDetail(logId, "VnIDIssueLocation", "Vn Issue Location", oldInfo.VnIDIssueLocation, newInfo.VnIDIssueLocation); isUpdated = true; } if (newInfo.Race != oldInfo.Race) { commonDao.InsertLogDetail(logId, "Race", "Race", oldInfo.Race, newInfo.Race); isUpdated = true; } if (newInfo.Major != oldInfo.Major) { commonDao.InsertLogDetail(logId, "Major", "Major", oldInfo.Major, newInfo.Major); isUpdated = true; } if (newInfo.IDIssueLocation != oldInfo.IDIssueLocation) { commonDao.InsertLogDetail(logId, "IDIssueLocation", "Issue Location", oldInfo.IDIssueLocation, newInfo.IDIssueLocation); isUpdated = true; } if (newInfo.Degree != oldInfo.Degree) { commonDao.InsertLogDetail(logId, "Degree", "Degree", oldInfo.Degree, newInfo.Degree); isUpdated = true; } if (newInfo.OtherDegree != oldInfo.OtherDegree) { commonDao.InsertLogDetail(logId, "OtherDegree", "Other Degree", oldInfo.OtherDegree, newInfo.OtherDegree); isUpdated = true; } if (newInfo.VnPlaceOfOrigin != oldInfo.VnPlaceOfOrigin) { commonDao.InsertLogDetail(logId, "VnPlaceOfOrigin", "Vn Place Of Origin", oldInfo.VnPlaceOfOrigin, newInfo.VnPlaceOfOrigin); isUpdated = true; } if (newInfo.VnPOB != oldInfo.VnPOB) { commonDao.InsertLogDetail(logId, "VnPOB", "Vn Place Of Birth", oldInfo.VnPOB, newInfo.VnPOB); isUpdated = true; } if (newInfo.VnLastName != oldInfo.VnLastName) { commonDao.InsertLogDetail(logId, "VnLastName", "Vn Last Name", oldInfo.VnLastName, newInfo.VnLastName); isUpdated = true; } if (newInfo.VnMiddleName != oldInfo.VnMiddleName) { commonDao.InsertLogDetail(logId, "VnMiddleName", "Vn Middle Name", oldInfo.VnMiddleName, newInfo.VnMiddleName); isUpdated = true; } if (newInfo.VnFirstName != oldInfo.VnFirstName) { commonDao.InsertLogDetail(logId, "VnFirstName", "Vn First Name", oldInfo.VnFirstName, newInfo.VnFirstName); isUpdated = true; } if (newInfo.LastName != oldInfo.LastName) { commonDao.InsertLogDetail(logId, "LastName", "Last Name", oldInfo.LastName, newInfo.LastName); isUpdated = true; } if (newInfo.MiddleName != oldInfo.MiddleName) { commonDao.InsertLogDetail(logId, "MiddleName", "Middle Name", oldInfo.MiddleName, newInfo.MiddleName); isUpdated = true; } if (newInfo.FirstName != oldInfo.FirstName) { commonDao.InsertLogDetail(logId, "FirstName", "First Name", oldInfo.FirstName, newInfo.FirstName); isUpdated = true; } if (newInfo.Gender != oldInfo.Gender) { commonDao.InsertLogDetail(logId, "Gender", "Gender",oldInfo.Gender.HasValue?(oldInfo.Gender.Value == Constants.MALE ? "Male" : "Famale"):"", newInfo.Gender.HasValue?(newInfo.Gender.Value == Constants.MALE ? "Male" : "Famale"):""); isUpdated = true; } if (newInfo.DOB != oldInfo.DOB) { commonDao.InsertLogDetail(logId, "DOB", "Date Of Birth",oldInfo.DOB.HasValue?oldInfo.DOB.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.DOB.HasValue?newInfo.DOB.Value.ToString(Constants.DATETIME_FORMAT_VIEW):""); isUpdated = true; } if (newInfo.POB != oldInfo.POB) { commonDao.InsertLogDetail(logId, "POB", "Place Of Birth", oldInfo.POB, newInfo.POB); isUpdated = true; } if (newInfo.Nationality != oldInfo.Nationality) { commonDao.InsertLogDetail(logId, "Nationality", "Nationality", oldInfo.Nationality, newInfo.Nationality); isUpdated = true; } if (newInfo.PlaceOfOrigin != oldInfo.PlaceOfOrigin) { commonDao.InsertLogDetail(logId, "PlaceOfOrigin", "Place Of Origin", oldInfo.PlaceOfOrigin, newInfo.PlaceOfOrigin); isUpdated = true; } if (newInfo.IDNumber != oldInfo.IDNumber) { commonDao.InsertLogDetail(logId, "IDNumber", "ID Number", oldInfo.IDNumber, newInfo.IDNumber); isUpdated = true; } if (newInfo.IssueDate != oldInfo.IssueDate) { commonDao.InsertLogDetail(logId, "IssueDate", "Issue Date",oldInfo.IssueDate.HasValue?oldInfo.IssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"", newInfo.IssueDate.HasValue?newInfo.IssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):""); isUpdated = true; } if (newInfo.MarriedStatus != oldInfo.MarriedStatus) { commonDao.InsertLogDetail(logId, "Married Status", "Married Status", oldInfo.MarriedStatus.HasValue?(oldInfo.MarriedStatus.Value == Constants.SINGLE ? "Single" : "Married"):"", newInfo.MarriedStatus.HasValue?(newInfo.MarriedStatus.Value == Constants.SINGLE ? "Single" : "Married"):""); isUpdated = true; } if (newInfo.Religion != oldInfo.Religion) { commonDao.InsertLogDetail(logId, "Religion", "Religion", oldInfo.Religion, newInfo.Religion); isUpdated = true; } if (newInfo.EmpStatusId != oldInfo.EmpStatusId) { commonDao.InsertLogDetail(logId, "EmpStatusId", "Employee Status", oldInfo.EmpStatusId.HasValue ? oldInfo.EmployeeStatus.StatusName : "", newInfo.EmpStatusId.HasValue ? new EmployeeStatusDao().GetById(newInfo.EmpStatusId.Value).StatusName : ""); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Write Log For Employee /// </summary> /// <param name="oldInfo"></param> /// <param name="newInfo"></param> /// <param name="action"></param> public void WriteLogForEmployee(Employee oldInfo, Employee newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; switch (action) { case ELogAction.Insert: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.CreatedBy, ELogTable.Employee.ToString(), action.ToString()); // Write Insert Log WriteInsertLogForEmployee(newInfo, logId); break; case ELogAction.Update: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString()); // Write Update Log bool isUpdated = WriteUpdateLogForEmployee(newInfo, logId); if (!isUpdated) { commonDao.DeleteMasterLog(logId); } break; case ELogAction.Delete: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString()); // Write Delete Log string key = newInfo.ID + " [" + newInfo.FirstName + " " + newInfo.MiddleName + " " + newInfo.LastName + "]"; if (newInfo.EmpStatusId == Constants.RESIGNED) { commonDao.InsertLogDetail(logId, "ID", "Key for Resign", key, null); if (newInfo.ResignedAllowance.HasValue) { commonDao.InsertLogDetail(logId, "ResignedAllowance", "Resigned Allowance", newInfo.ResignedAllowance.HasValue?newInfo.ResignedAllowance.Value.ToString():"", null); } if (!string.IsNullOrEmpty(newInfo.ResignedReason)) { commonDao.InsertLogDetail(logId, "ResignedReason", "Resigned Reason", newInfo.ResignedReason, null); } commonDao.InsertLogDetail(logId, "ResignedDate", "Resigned Date",newInfo.ResignedDate.HasValue? newInfo.ResignedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"", null); } else { commonDao.InsertLogDetail(logId, "ID", "Key for Delete", key, null); } break; } } catch (Exception ex) { throw ex; } }
public void WriteLogForUpdateCompany(Employee newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString()); Employee oldInfo = new EmployeeDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.JR != oldInfo.JR) { commonDao.InsertLogDetail(logId, "JR", "Job Request", oldInfo.JR, newInfo.JR); isUpdated = true; } if (newInfo.Project != oldInfo.Project) { commonDao.InsertLogDetail(logId, "Project", "JProject", oldInfo.Project, newInfo.Project); isUpdated = true; } if (newInfo.ManagerId != oldInfo.ManagerId) { commonDao.InsertLogDetail(logId, "Manager", "Manager", oldInfo.ManagerId, newInfo.ManagerId); isUpdated = true; } if (newInfo.JRApproval != oldInfo.JRApproval) { commonDao.InsertLogDetail(logId, "JRApproval", "Job Request Approval", oldInfo.JRApproval, newInfo.JRApproval); isUpdated = true; } if (newInfo.StartDate != oldInfo.StartDate) { commonDao.InsertLogDetail(logId, "StartDate", "Start Date", oldInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW)); isUpdated = true; } if (newInfo.ContractedDate != oldInfo.ContractedDate) { commonDao.InsertLogDetail(logId, "ContractedDate", "Contracted Date",oldInfo.ContractedDate.HasValue?oldInfo.ContractedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"", newInfo.ContractedDate.HasValue?newInfo.ContractedDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):""); isUpdated = true; } if (newInfo.DepartmentId != oldInfo.DepartmentId) { Department sub = new DepartmentDao().GetById(newInfo.DepartmentId); commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", oldInfo.Department.DepartmentName, sub.DepartmentName); isUpdated = true; } if (newInfo.TitleId != oldInfo.TitleId) { JobTitleLevel title = new JobTitleLevelDao().GetById(newInfo.TitleId); commonDao.InsertLogDetail(logId, "TitleId", "Job Title", oldInfo.JobTitleLevel.DisplayName, title.DisplayName); isUpdated = true; } if (newInfo.LaborUnion != oldInfo.LaborUnion) { commonDao.InsertLogDetail(logId, "LaborUnion", "Labor Union",oldInfo.LaborUnion.HasValue?(oldInfo.LaborUnion == true?"Yes":"No"):"", newInfo.LaborUnion.HasValue?(newInfo.LaborUnion == true?"Yes":"No"):""); isUpdated = true; } if (newInfo.LaborUnionDate != oldInfo.LaborUnionDate) { commonDao.InsertLogDetail(logId, "LaborUnionDate", "Labor Union date", oldInfo.LaborUnionDate.HasValue?oldInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.LaborUnionDate.HasValue?newInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):""); isUpdated = true; } if (newInfo.TaxID != oldInfo.TaxID) { commonDao.InsertLogDetail(logId, "TaxID", "TaxID", oldInfo.TaxID, newInfo.TaxID); isUpdated = true; } if (newInfo.TaxIssueDate != oldInfo.TaxIssueDate) { commonDao.InsertLogDetail(logId, "TaxIssueDate", "Tax Issue Date", oldInfo.TaxIssueDate.HasValue?oldInfo.TaxIssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.TaxIssueDate.HasValue?newInfo.TaxIssueDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):""); isUpdated = true; } if (newInfo.SocialInsuranceNo != oldInfo.SocialInsuranceNo) { commonDao.InsertLogDetail(logId, "SocialInsuranceNo", "Insurance Book No", oldInfo.SocialInsuranceNo, newInfo.SocialInsuranceNo); isUpdated = true; } if (newInfo.InsuranceHospitalID != oldInfo.InsuranceHospitalID) { commonDao.InsertLogDetail(logId, "InsuranceHospitalID", "Insurance Hospital", oldInfo.InsuranceHospitalID, newInfo.InsuranceHospitalID); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
public void WriteLogForUpdateBanks(STT newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.STT.ToString(), action.ToString()); STT oldInfo = new STTDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.BankName != oldInfo.BankName) { commonDao.InsertLogDetail(logId, "BankName", "Bank Name", oldInfo.BankName, newInfo.BankName); isUpdated = true; } if (newInfo.BankAccount != oldInfo.BankAccount) { commonDao.InsertLogDetail(logId, "BankAccount", "Bank Account", oldInfo.BankAccount, newInfo.BankAccount); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Write Log For Employee /// </summary> /// <param name="oldInfo"></param> /// <param name="newInfo"></param> /// <param name="action"></param> public void WriteLogForSR(SR_ServiceRequest oldInfo, SR_ServiceRequest newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; string[] colNameArr = new string[] { "CategoryID", "Title", "Description", "SubmitUser", "RequestUser", "CCList", "UrgencyID", "Files", "OldId","StatusID", "AssignUser", "DueDate"}; string[] colDisplayNameArr = new string[] { "Category", "Title", "Description", "Submit User", "Request User", "CCList", "Urgency", "Attachments", "Related SR","Status", "Assign User", "Due Date"}; string[] oldValueArr = null; if (oldInfo != null) { oldValueArr = new string[] { oldInfo.CategoryID.ToString(), CommonFunc.SubStringRoundWord(oldInfo.Title, 100), CommonFunc.SubStringRoundWord(oldInfo.Description, 100), oldInfo.SubmitUser, oldInfo.RequestUser, oldInfo.CCList, oldInfo.UrgencyID.ToString(), oldInfo.Files, oldInfo.OldId.HasValue ? oldInfo.OldId.Value.ToString() : null, oldInfo.StatusID.ToString(), oldInfo.AssignUser, oldInfo.DueDate.HasValue ? oldInfo.DueDate.Value.ToString(Constants.DATETIME_FORMAT_FULL) : null}; } string[] newValueArr = new string[] { newInfo.CategoryID.ToString(), CommonFunc.SubStringRoundWord(newInfo.Title, 100), CommonFunc.SubStringRoundWord(newInfo.Description, 100), newInfo.SubmitUser, newInfo.RequestUser, newInfo.CCList, newInfo.UrgencyID.ToString(), newInfo.Files, newInfo.OldId.HasValue ? newInfo.OldId.Value.ToString() : null, newInfo.StatusID.ToString(), newInfo.AssignUser, newInfo.DueDate.HasValue ? newInfo.DueDate.Value.ToString(Constants.DATETIME_FORMAT_FULL) : null}; switch (action) { case ELogAction.Delete: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.ServiceRequest.ToString(), action.ToString()); // Write Delete Log string key = newInfo.ID + " [" + newInfo.Title + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Delete", key, null); break; case ELogAction.Insert: commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.ServiceRequest.ToString(), action.ToString(), LogType.ServiceRequest); commonDao.InsertLogDetail(logId, "ID", "Key for Insert", null, newInfo.ID.ToString()); for (int i = 0; i < colNameArr.Length; i++) commonDao.InsertLogDetail(logId, colNameArr[i], colDisplayNameArr[i], null, newValueArr[i]); break; case ELogAction.Update: commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.ServiceRequest.ToString(), action.ToString(), LogType.ServiceRequest); bool isChanged = false; for (int i = 0; i < colNameArr.Length; i++) { if (oldValueArr[i] != newValueArr[i]) { commonDao.InsertLogDetail(logId, colNameArr[i], colDisplayNameArr[i], oldValueArr[i], newValueArr[i]); isChanged = true; } } if(isChanged) commonDao.InsertLogDetail(logId, "ID", "Key for Update", oldInfo.ID.ToString() + "[" + newInfo.UpdatedBy + "]", null); break; default: break; } } catch (Exception ex) { throw ex; } }
public void WriteLogForUpdateCompany(STT newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.STT.ToString(), action.ToString()); STT oldInfo = new STTDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.JR != oldInfo.JR) { commonDao.InsertLogDetail(logId, "JR", "Job Request", oldInfo.JR, newInfo.JR); isUpdated = true; } if (newInfo.Project != oldInfo.Project) { commonDao.InsertLogDetail(logId, "Project", "Project", oldInfo.Project, newInfo.Project); isUpdated = true; } if (newInfo.ManagerId != oldInfo.ManagerId) { commonDao.InsertLogDetail(logId, "Manager", "Manager", oldInfo.ManagerId, newInfo.ManagerId); isUpdated = true; } if (newInfo.JRApproval != oldInfo.JRApproval) { commonDao.InsertLogDetail(logId, "JRApproval", "Job Request Approval", oldInfo.JRApproval, newInfo.JRApproval); isUpdated = true; } if (newInfo.StartDate != oldInfo.StartDate) { commonDao.InsertLogDetail(logId, "StartDate", "Start Date", oldInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.StartDate.ToString(Constants.DATETIME_FORMAT_VIEW)); isUpdated = true; } if (newInfo.ExpectedEndDate != oldInfo.ExpectedEndDate) { commonDao.InsertLogDetail(logId, "ContractedDate", "Contracted Date",oldInfo.ExpectedEndDate.HasValue? oldInfo.ExpectedEndDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):"",newInfo.ExpectedEndDate.HasValue? newInfo.ExpectedEndDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):""); isUpdated = true; } if (newInfo.DepartmentId != oldInfo.DepartmentId) { Department sub = new DepartmentDao().GetById(newInfo.DepartmentId); commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", oldInfo.Department.DepartmentName, sub.DepartmentName); isUpdated = true; } if (newInfo.LaborUnion != oldInfo.LaborUnion) { commonDao.InsertLogDetail(logId, "LaborUnion", "Labor Union",oldInfo.LaborUnion.HasValue? oldInfo.LaborUnion == true ? "Yes" : "No":"",oldInfo.LaborUnion.HasValue? newInfo.LaborUnion == true ? "Yes" : "No":""); isUpdated = true; } if (newInfo.LaborUnionDate != oldInfo.LaborUnionDate) { commonDao.InsertLogDetail(logId, "LaborUnionDate", "Labor Union date", oldInfo.LaborUnionDate.HasValue ? oldInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW) : "", newInfo.LaborUnionDate.HasValue ? newInfo.LaborUnionDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW) : ""); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Write Insert Log For Employee /// </summary> /// <param name="objInfo"></param> /// <param name="logId"></param> public bool WriteLogForPurchasingConfirm(PurchaseRequest newInfo) { bool isUpdated = false; try { MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.PurchaseRequest.ToString(), ELogAction.Update.ToString()); // Get old info PurchaseRequest oldInfo = new PurchaseRequestDao().GetByID(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.WFResolutionID != oldInfo.WFResolutionID) { commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, new ResolutionDao().GetByID(newInfo.WFResolutionID).Name); isUpdated = true; } if (newInfo.AssignRole != oldInfo.AssignRole || newInfo.AssignID != oldInfo.AssignID) { commonDao.InsertLogDetail(logId, "Assign", "Assign", oldInfo.UserAdmin.UserName + " (" + oldInfo.WFRole.Name + ")", ((newInfo.AssignID.HasValue ? new UserAdminDao().GetById(newInfo.AssignID.Value).UserName : string.Empty) + " (" + (newInfo.AssignRole.HasValue ? new RoleDao().GetByID(newInfo.AssignRole.Value).Name : string.Empty) + ")")); isUpdated = true; } if (!string.IsNullOrEmpty(newInfo.PurchaseAppoval) && newInfo.PurchaseAppoval != oldInfo.PurchaseAppoval) { commonDao.InsertLogDetail(logId, "PurchaseAppoval", "Purchase Appoval", oldInfo.PurchaseAppoval, newInfo.PurchaseAppoval); isUpdated = true; } if (!string.IsNullOrEmpty(newInfo.PaymentAppoval) && newInfo.PaymentAppoval != oldInfo.PaymentAppoval) { commonDao.InsertLogDetail(logId, "PaymentAppoval", "Payment Appoval", oldInfo.PaymentAppoval, newInfo.PaymentAppoval); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = Constants.PER_REVIEW_EFORM_MASTER_PREFIX + oldInfo.ID.ToString(); commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } return isUpdated; }
/// <summary> /// /// </summary> /// <param name="newInfo"></param> /// <param name="action"></param> public void WriteLogForUpdatePosition(Employee newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Employee.ToString(), action.ToString()); Employee oldInfo = new EmployeeDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.ManagerId != oldInfo.ManagerId) { commonDao.InsertLogDetail(logId, "Manager", "Manager", oldInfo.ManagerId, newInfo.ManagerId); isUpdated = true; } if (newInfo.Project != oldInfo.Project) { commonDao.InsertLogDetail(logId, "Project", "Project", oldInfo.Project, newInfo.Project); isUpdated = true; } if (newInfo.Floor != oldInfo.Floor) { commonDao.InsertLogDetail(logId, "Floor", "Floor", oldInfo.Floor, newInfo.Floor); isUpdated = true; } if (newInfo.SeatCode != oldInfo.SeatCode) { commonDao.InsertLogDetail(logId, "SeatCode", "SeatCode", oldInfo.SeatCode, newInfo.SeatCode); isUpdated = true; } if (newInfo.LocationCode != oldInfo.LocationCode) { commonDao.InsertLogDetail(logId, "LocationCode", "LocationCode", CommonFunc.GenerateStringOfLocation(oldInfo.LocationCode), CommonFunc.GenerateStringOfLocation(newInfo.LocationCode)); isUpdated = true; } if (isUpdated) { // Insert Key Name string key = oldInfo.ID + " [" + oldInfo.FirstName + " " + oldInfo.MiddleName + " " + oldInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
public void WriteLogForUpdateResult(STT_RefResult newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.STT.ToString(), action.ToString()); STT oldSTTInfo = new STTDao().GetById(newInfo.SttID); if ((oldSTTInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.ResultId != oldSTTInfo.ResultId) { commonDao.InsertLogDetail(logId, "ResultId", "Result", oldSTTInfo.ResultId.HasValue?oldSTTInfo.STT_Result.Name:"", new STTResultDao().GetById(newInfo.ResultId).Name); if (newInfo.ResultId == Constants.STT_RESULT_FAIL) { commonDao.InsertLogDetail(logId, "STTStatusId", "Status", oldSTTInfo.STT_Status.Name, new STTStatusDao().GetById(Constants.STT_STATUS_REJECTED).Name); } else { commonDao.InsertLogDetail(logId, "STTStatusId", "Status", oldSTTInfo.STT_Status.Name, new STTStatusDao().GetById(Constants.STT_STATUS_NEED_TO_PROMOTED).Name); } } commonDao.InsertLogDetail(logId, "EndDate", "End Date", null, newInfo.EndDate.ToString(Constants.DATETIME_FORMAT_VIEW)); if (!string.IsNullOrEmpty(newInfo.Remarks)) { commonDao.InsertLogDetail(logId, "Remarks", "Remarks", null, newInfo.Remarks); } string[] array = newInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX); if (array.Count() > 0) { foreach (string item in array) { commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", null, item); } } // Insert Key Name string key = oldSTTInfo.ID + " [" + oldSTTInfo.FirstName + " " + oldSTTInfo.MiddleName + " " + oldSTTInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "ID", "Key for Update", key, null); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Write Log For Employee /// </summary> /// <param name="oldInfo"></param> /// <param name="newInfo"></param> /// <param name="action"></param> public void WriteLogForInterview(Interview oldInfo, Interview newInfo, ELogAction action) { try { if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; switch (action) { //case ELogAction.Insert: // // Insert to Master Log // commonDao.InsertMasterLog(logId, newInfo.CreatedBy, ELogTable.Interview.ToString(), action.ToString()); // // Write Insert Log // WriteInsertLogForInterview(newInfo, logId); // break; //case ELogAction.Update: // // Insert to Master Log // commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Interview.ToString(), action.ToString()); // // Write Update Log // bool isUpdated = WriteUpdateLogForInterview(newInfo, logId); // if (!isUpdated) // { // commonDao.DeleteMasterLog(logId); // } // break; case ELogAction.Delete: // Insert to Master Log commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.Candidate.ToString(), action.ToString()); // Write Delete Log string key = newInfo.CandidateId.ToString() + " [" + newInfo.Candidate.FirstName + " " + newInfo.Candidate.MiddleName + " " + newInfo.Candidate.LastName + "]" + " for Interview in round " + (newInfo.Round.HasValue?newInfo.Round.Value.ToString():"") + " in " + (newInfo.InterviewDate.HasValue?newInfo.InterviewDate.Value.ToString(Constants.DATETIME_FORMAT_VIEW):""); commonDao.InsertLogDetail(logId, "ID", "Key for Delete", key, null); break; } } catch (Exception ex) { throw ex; } }