static void Main(string[] args) { DataTable logging = new DataTable(); logging.Columns.Add("Date", typeof(DateTime)); logging.Columns.Add("Severity", typeof(string)); logging.Columns.Add("id", typeof(string)); logging.Columns.Add("ID", typeof(string)); logging.Columns.Add("Msg", typeof(string)); XDocument docLog = XDocument.Load(LOG_XML_FILENAME); foreach (XElement log in docLog.Descendants("Log")) { DateTime date = (DateTime)log.Attribute("Date"); string severity = (string)log.Attribute("Severity"); string id = (string)log.Attribute("id"); string ID = (string)log.Attribute("ID"); string msg = (string)log.Attribute("Msg"); logging.Rows.Add(new object[] { date, severity, id, ID, msg }); } XDocument docStatus = XDocument.Load(STATUS_XML_FILENAME); Logic logic = Logic.AND; foreach (XElement Statuscode in docStatus.Descendants("Statuscode")) { DataTable status = null; List <KeyValuePair <string, object> > searchFields = new List <KeyValuePair <string, object> >(); foreach (XElement trigger in Statuscode.Descendants("Trigger")) { string searchField = (string)trigger.Attribute("searchField"); string searchText = (string)trigger.Attribute("searchText"); switch (searchField) { case "Date": searchFields.Add(new KeyValuePair <string, object>(searchField, (DateTime)trigger.Attribute("searchText"))); break; default: searchFields.Add(new KeyValuePair <string, object>(searchField, (string)trigger.Attribute("searchText"))); break; } } switch (logic) { case Logic.AND: status = logging.AsEnumerable() .Where(x => searchFields.All(field => (field.Value.GetType() == typeof(DateTime)) ? x.Field <DateTime>(field.Key) == (DateTime)field.Value : x.Field <string>(field.Key) == (string)field.Value)) .CopyToDataTable(); break; case Logic.OR: status = logging.AsEnumerable() .Where(x => searchFields.Any(field => (field.Value.GetType() == typeof(DateTime)) ? x.Field <DateTime>(field.Key) == (DateTime)field.Value : x.Field <string>(field.Key) == (string)field.Value)) .CopyToDataTable(); break; } } }
public ResponsePacket(Statuscode.Status status, string cmd = null) { Initialize( // ReSharper disable once SpecifyACultureInStringConversionExplicitly Statuscode.GetCode(status).ToString(), Statuscode.GetDescription(status), cmd ); }
static void Main(string[] args) { DataTable logging = new DataTable(); logging.Columns.Add("Date", typeof(DateTime)); logging.Columns.Add("Severity", typeof(string)); logging.Columns.Add("id", typeof(string)); logging.Columns.Add("ID", typeof(string)); logging.Columns.Add("Msg", typeof(string)); XDocument docLog = XDocument.Load(LOG_XML_FILENAME); foreach (XElement log in docLog.Descendants("Log")) { DateTime date = (DateTime)log.Attribute("Date"); string severity = (string)log.Attribute("Severity"); string id = (string)log.Attribute("id"); string ID = (string)log.Attribute("ID"); string msg = (string)log.Attribute("Msg"); logging.Rows.Add(new object[] { date, severity, id, ID, msg }); } XDocument docStatus = XDocument.Load(STATUS_XML_FILENAME); foreach (XElement Statuscode in docStatus.Descendants("Statuscode")) { DataTable status = logging.Clone(); foreach (XElement trigger in Statuscode.Descendants("Trigger")) { string searchField = (string)trigger.Attribute("searchField"); string searchText = (string)trigger.Attribute("searchText"); switch (searchField) { case "Date": logging.AsEnumerable().Where(x => x.Field <DateTime>(searchField) == (DateTime)trigger.Attribute(searchText)).CopyToDataTable(status, LoadOption.Upsert); break; default: logging.AsEnumerable().Where(x => x.Field <string>(searchField) == searchText).CopyToDataTable(status, LoadOption.Upsert); break; } } } }
public LoginResponsePacket(Statuscode.Status status, string username, bool isDoctor) : base(status, DefCmd) { Initialize(username, isDoctor); }
public Performanceappraisal CreateAssessment(AssessmentModels model) { Employee employee = _context.Employee.FirstOrDefault(x => x.Id == model.EmployeeId); Mobilitycode mobility = new Mobilitycode(); Performanceappraisal perfApp = new Performanceappraisal(); perfApp.Bodescriptivescore = model.BODescriptiveScore; perfApp.Bonumericscore = model.BONumericalScore; perfApp.Careeraspirationcomment = model.CareerAspirationComment; perfApp.Createdate = DateTime.Now; perfApp.Employee = employee; perfApp.Employeeid = model.EmployeeId; perfApp.Employeecomment = model.EmployeeComment; perfApp.Gbdescriptivescore = model.GBDescriptiveScore; perfApp.Gbnumericscore = model.GBNumericalScore; perfApp.Managercomment = model.ManagerComment; if (model.submit) { Statuscode status = _context.Statuscode.FirstOrDefault(x => x.Description == "SUBMITTED"); if (status != null) { perfApp.Status = status; perfApp.Statusid = status.Id; } else { status = _context.Statuscode.FirstOrDefault(x => x.Description == "PROGRESS"); perfApp.Status = status; perfApp.Statusid = status.Id; } } else { Statuscode status = _context.Statuscode.FirstOrDefault(x => x.Description == "PROGRESS"); perfApp.Status = status; perfApp.Statusid = status.Id; } if (!string.IsNullOrEmpty(model.MobilityStatusDesc)) { mobility = _context.Mobilitycode.FirstOrDefault(x => x.Id == 2); perfApp.Mobility = mobility; perfApp.MobilityId = 2; perfApp.Mobilitydesc = model.MobilityStatusDesc; } else { perfApp.MobilityId = model.MobilityStatusId; } perfApp.Overalldescriptivescore = model.OverallDescriptiveScore; perfApp.Overallnumericscore = model.OverallNumericalScore; perfApp.Statusid = 1; // 1.Progress 2.Submitted 3.Process 4.Finish perfApp._2ndlvlmanagercomment = model.SecondLevelManagerComment; //_context.Performanceappraisal.Add(perfApp); //this.SaveChange(); List <Businessobjective> BOList = new List <Businessobjective>(); for (int i = 0; i < model.BODescription.Count; i++) { Businessobjective bo = new Businessobjective(); bo.Description = model.BODescription.ElementAt(i); bo.Employeescore = string.IsNullOrEmpty(model.BOEmployeeScore.ElementAt(i).ToString()) ? null : model.BOEmployeeScore.ElementAt(i); bo.Goalachievement = string.IsNullOrEmpty(model.BOGoals.ElementAt(i)) ? null : model.BOGoals.ElementAt(i); bo.Weight = string.IsNullOrEmpty(model.BOWeight.ElementAt(i).ToString()) ? 0 : model.BOWeight.ElementAt(i); //bo.Performanceappraisalid = perfApp.Id; if (perfApp.Status.Description == "PROCESS") { bo.Managerscore = string.IsNullOrEmpty(model.BOManagerScore.ElementAt(i)) ? null : model.BOManagerScore.ElementAt(i); } bo.Performanceappraisal = perfApp; BOList.Add(bo); perfApp.Businessobjective.Add(bo); } //_context.Businessobjective.AddRange(BOList); //this.SaveChange(); List <Globalbehavior> GBList = new List <Globalbehavior>(); for (int i = 0; i < model.GBExpectedBehavior.Count; i++) { Globalbehavior gb = new Globalbehavior(); gb.Createdate = DateTime.Now; gb.Demonstratedbehavior = string.IsNullOrEmpty(model.GBDemonstatedBehavior.ElementAt(i)) ? "" : model.GBDemonstatedBehavior.ElementAt(i); gb.Employeescore = string.IsNullOrEmpty(model.GBEmployeeScore.ElementAt(i).ToString()) ? null : model.GBEmployeeScore.ElementAt(i); gb.Expectedbehavior = string.IsNullOrEmpty(model.GBExpectedBehavior.ElementAt(i)) ? "" : model.GBExpectedBehavior.ElementAt(i); if (perfApp.Status.Description == "PROCESS") { gb.Managerscore = string.IsNullOrEmpty(model.GBManagerScore.ElementAt(i).ToString()) ? null : model.GBManagerScore.ElementAt(i); } gb.Performanceappraisal = perfApp; //gb.Performanceappraisalid = perfApp.Id; GBList.Add(gb); perfApp.Globalbehavior.Add(gb); } //_context.Globalbehavior.AddRange(GBList); //this.SaveChange(); Developmentplan DP = new Developmentplan(); DP.Performanceappraisalid = perfApp.Id; DP.Createdate = DateTime.Now; DP.Developmentarea = model.DPDevelopmentArea; DP.Methods = model.DPMethods; DP.Performanceappraisal = perfApp; DP.Plan = model.DPPlan; DP.Strengtharea = model.DPStrengthArea; perfApp.Developmentplan.Add(DP); //_context.Developmentplan.Add(DP); //this.SaveChange(); _context.Performanceappraisal.Add(perfApp); this.SaveChange(); return(perfApp); }
private void button1_Click(object sender, EventArgs e) { DataTable errorLogDatatable = new DataTable(); errorLogDatatable.Columns.Add("Date", typeof(DateTime)); errorLogDatatable.Columns.Add("Severity", typeof(string)); errorLogDatatable.Columns.Add("id", typeof(string)); errorLogDatatable.Columns.Add("ID", typeof(string)); errorLogDatatable.Columns.Add("Msg", typeof(string)); XDocument docLog = XDocument.Load(LOG_XML_FILENAME); foreach (XElement log in docLog.Descendants("Log")) { DateTime date = (DateTime)log.Attribute("Date"); string severity = (string)log.Attribute("Severity"); string id = (string)log.Attribute("id"); string ID = (string)log.Attribute("ID"); string msg = (string)log.Attribute("Msg"); errorLogDatatable.Rows.Add(new object[] { date, severity, id, ID, msg }); } XDocument docStatus = XDocument.Load(STATUS_XML_FILENAME); Logic logic = Logic.AND; foreach (XElement Statuscode in docStatus.Descendants("Statuscode")) { StatusCode statusCode = new StatusCode() { Code = (string)Statuscode.Attribute("value"), Text = (string)Statuscode.Attribute("text") }; statusCodes.Add(statusCode); DataTable status = null; foreach (XElement trigger in Statuscode.Descendants("Trigger")) { string searchField = (string)trigger.Attribute("searchField"); string searchText = (string)trigger.Attribute("searchText"); statusCode.Triggers.Add(new Trigger() { SearchField = searchField, SearchText = (string)trigger.Attribute("searchText") }); } switch (logic) { case Logic.AND: status = errorLogDatatable.AsEnumerable() .Where(x => statusCode.Triggers.All(field => x.Field <string>(field.SearchField) == field.SearchText)) .CopyToDataTable(); break; case Logic.OR: status = errorLogDatatable.AsEnumerable() .Where(x => statusCode.Triggers.Any(field => x.Field <string>(field.SearchField) == field.SearchText)) .CopyToDataTable(); break; } var bindingSource = new BindingSource { DataSource = status, }; dataGridView1.DataSource = bindingSource; } }
public LoginResponsePacket(Statuscode.Status status, String authtoken, User u) : base(status, LoginRcmd) { Initialize(authtoken, u); }
public NinException(Statuscode code, string message) : base(message) { Code = code; }
public PushResponsePacket(Statuscode.Status status) : base(status, PushRcmd) { }