public Model.Request Map(Model.Request request, Code customerCode, Code groupCode, HalalTeam halal, Premise premise, Characteristic characteristic, RFA rfa, Log log, Attachment attachment, RequestLineItem lineItem, Review review, ReviewLineItem reviewLineItem, Characteristic lineItemChar) { return(InternalMap(request, customerCode, groupCode, lineItem, lineItemChar, halal, premise, characteristic, attachment, rfa, log, review, reviewLineItem)); }
public async Task <IActionResult> CreateTree(RequestCreateModel model1) { var process = new Process(model1.Process.Name); _context.Processes.Add(process); await _context.SaveChangesAsync(); Model.Request new_request = Model.Request.NodeCreateFlow(model1, process); _context.Requests.Add(new_request); await _context.SaveChangesAsync(); foreach (var rule in new_request.Process.Rules) { var f = await _context.Nodes.FirstOrDefaultAsync(r => r.Id == rule.CurrentNode.Id); var s = await _context.Nodes.FirstOrDefaultAsync(r => r.Id == rule.NextNode.Id); if (f != null && s != null) { f.AddChild(s); _context.Update(f); } } await _context.SaveChangesAsync(); return(Ok()); }
public static DataTable ToHalalTeamData(Model.Request req) { DataTable dh = new DataTable(); dh.Columns.Add("AltID", typeof(string)); dh.Columns.Add("Name", typeof(string)); dh.Columns.Add("Designation", typeof(string)); dh.Columns.Add("Role", typeof(string)); dh.Columns.Add("IsCertified", typeof(bool)); dh.Columns.Add("JoinedOn", typeof(DateTimeOffset)); dh.Columns.Add("ChangeType", typeof(int)); dh.Columns.Add("RequestID", typeof(long)); dh.Columns.Add("CreatedOn", typeof(DateTimeOffset)); dh.Columns.Add("ModifiedOn", typeof(DateTimeOffset)); if (req.Teams != null) { foreach (HalalTeam ht in req.Teams) { dh.Rows.Add( ht.AltID, ht.Name, ht.Designation, ht.Role, ht.IsCertified, ht.JoinedOn, ht.ChangeType, ht.RequestID, ht.CreatedOn, ht.ModifiedOn); } } return(dh); }
public static DataTable ToAttachmentData(Model.Request req) { DataTable da = new DataTable(); da.Columns.Add("FileID", typeof(Guid)); da.Columns.Add("FileName", typeof(string)); da.Columns.Add("Extension", typeof(string)); da.Columns.Add("Size", typeof(long)); da.Columns.Add("CreatedOn", typeof(DateTimeOffset)); da.Columns.Add("ModifiedOn", typeof(DateTimeOffset)); if (req.Attachments != null) { foreach (Attachment at in req.Attachments) { da.Rows.Add( at.FileID, at.FileName, at.Extension, at.Size, at.CreatedOn, at.ModifiedOn); } } return(da); }
public async Task <IActionResult> CreateWorkFlow(RequestCreateModel model1) { Model.Request new_request = Model.Request.CreateFlow(model1); _context.Requests.Add(new_request); await _context.SaveChangesAsync(); return(Ok(_mapper.Map <RequestViewModel>(new_request))); }
public HC01Certificate360Strategy(DbContext dbContext, Model.Request request, string certificateNumber) { _dbContext = dbContext; _request = request; _certificateNumber = certificateNumber; }
public static DataTable ToPremiseData(Model.Request req) { DataTable dp = new DataTable(); dp.Columns.Add("IsLocal", typeof(bool)); dp.Columns.Add("Name", typeof(string)); dp.Columns.Add("Type", typeof(int)); dp.Columns.Add("Area", typeof(string)); dp.Columns.Add("Schedule", typeof(string)); dp.Columns.Add("BlockNo", typeof(string)); dp.Columns.Add("UnitNo", typeof(string)); dp.Columns.Add("FloorNo", typeof(string)); dp.Columns.Add("BuildingName", typeof(string)); dp.Columns.Add("Address1", typeof(string)); dp.Columns.Add("Address2", typeof(string)); dp.Columns.Add("City", typeof(string)); dp.Columns.Add("Province", typeof(string)); dp.Columns.Add("Country", typeof(string)); dp.Columns.Add("Postal", typeof(string)); dp.Columns.Add("Longitude", typeof(double)); dp.Columns.Add("Latitude", typeof(double)); dp.Columns.Add("IsPrimary", typeof(bool)); dp.Columns.Add("ChangeType", typeof(int)); dp.Columns.Add("RequestID", typeof(long)); dp.Columns.Add("CreatedOn", typeof(DateTimeOffset)); dp.Columns.Add("ModifiedOn", typeof(DateTimeOffset)); if (req.Premises != null) { foreach (Premise pm in req.Premises) { dp.Rows.Add( pm.IsLocal, pm.Name, pm.Type, pm.Area, pm.Schedule, pm.BlockNo, pm.UnitNo, pm.FloorNo, pm.BuildingName, pm.Address1, pm.Address2, pm.City, pm.Province, pm.Country, pm.Postal, pm.Longitude, pm.Latitude, pm.IsPrimary, pm.ChangeType, pm.RequestID, pm.CreatedOn, pm.ModifiedOn); } } return(dp); }
public Model.Request Map(Model.Request request, RequestLineItem lineItem = null, Premise premise = null) { return(InternalMap(request, lineItem: lineItem, premise: premise )); }
public GenerateCertificateSubCommand(Model.Request requestBasic, Scheme scheme, Officer officer, DbContext dbContext) { _requestBasic = requestBasic; _scheme = scheme; _officer = officer; _dbContext = dbContext; }
public static DataTable ToRequestData(Model.Request req) { DataTable dt = new DataTable(); dt.Columns.Add("Step", typeof(int)); dt.Columns.Add("RequestorID", typeof(Guid)); dt.Columns.Add("RequestorName", typeof(string)); dt.Columns.Add("AgentID", typeof(Guid)); dt.Columns.Add("AgentName", typeof(string)); dt.Columns.Add("CustomerID", typeof(Guid)); dt.Columns.Add("CustomerCode", typeof(string)); dt.Columns.Add("CustomerName", typeof(string)); dt.Columns.Add("Type", typeof(int)); dt.Columns.Add("Status", typeof(int)); dt.Columns.Add("StatusMinor", typeof(int)); dt.Columns.Add("OldStatus", typeof(int)); dt.Columns.Add("RefID", typeof(string)); dt.Columns.Add("ParentId", typeof(long)); dt.Columns.Add("Expedite", typeof(bool)); dt.Columns.Add("EscalateStatus", typeof(int)); dt.Columns.Add("AssignedTo", typeof(Guid)); dt.Columns.Add("AssignedToName", typeof(string)); dt.Columns.Add("CreatedOn", typeof(DateTimeOffset)); dt.Columns.Add("TargetCompletion", typeof(DateTimeOffset)); dt.Columns.Add("DueOn", typeof(DateTimeOffset)); dt.Columns.Add("ModifiedOn", typeof(DateTimeOffset)); dt.Columns.Add("SubmittedOn", typeof(DateTimeOffset)); dt.Rows.Add( req.Step, req.RequestorID, req.RequestorName, req.AgentID, req.AgentName, req.CustomerID, req.CustomerCode, req.CustomerName, req.Type, req.Status, req.StatusMinor, req.OldStatus, req.RefID, req.ParentID, req.Expedite, req.EscalateStatus, req.AssignedTo, req.AssignedToName, req.CreatedOn?.ToUniversalTime(), req.TargetCompletion?.ToUniversalTime(), req.DueOn?.ToUniversalTime(), req.ModifiedOn?.ToUniversalTime(), req.SubmittedOn.ToUniversalTime()); return(dt); }
public HC04ApprovalProcessCommand(Model.Request requestBasic, Review review, IEventBus eventBus, DbContext dbContext) { _requestBasic = requestBasic; _review = review; _eventBus = eventBus; _dbContext = dbContext; }
public HC03Certificate360Strategy(DbContext dbContext, Model.Request request, Certificate certificate, Officer approvedBy) { _dbContext = dbContext; _request = request; _certificate = certificate; _approvedBy = approvedBy; }
public HC02Certificate360Strategy(DbContext dbContext, Model.Request request, string certificateNumber, Officer approvedBy) { _dbContext = dbContext; _request = request; _certificateNumber = certificateNumber; _approvedBy = approvedBy; }
private ushort[] GetData(ICodebook item) { byte readcode = item.Read ?? 0; if (readcode == 0) { throw new ArgumentNullException("readcode is not defined"); } Request request = new Model.Request(readcode, item.Start, item.NumberOfPoints); var data = _adapter.Transact(request).Data.ToArray();//.TakeWhile(c => c != 0).ToArray(); return(data); }
public Model.Request Map(Model.Request request, Code customerCode = null, RequestLineItem lineItem = null, Premise premise = null, RFA rfa = null, Characteristic lineItemChar = null) { return(InternalMap(request, customerCode, lineItem: lineItem, premise: premise, rfa: rfa, lineItemChar: lineItemChar)); }
public Email(DataType dataType, Model.Request request, string from, string to, string subject, string contents, byte[] attach, string server, string confirmEmail, string confirmPass, bool isSent, string client) { DataType = dataType; Request = request; From = from; To = to; Subject = subject; Contents = contents; Attach = attach; Server = server; ConfirmEmail = confirmEmail; ConfirmPass = confirmPass; IsSent = isSent; Client = client; }
public async Task <Model.Request> GetRequestByRefID(string refID) { var param = new DynamicParameters(); param.Add("@RefID", refID); var mapper = new RequestMapper(); return((await SqlMapper.QueryAsync(_unitOfWork.Connection, "GetRequestByRefID", new[] { typeof(Model.Request), typeof(HalalTeam), typeof(Premise), typeof(Characteristic), typeof(RFA), typeof(Log), typeof(Attachment), typeof(RequestLineItem), typeof(Review), typeof(ReviewLineItem), typeof(Characteristic) }, obj => { Model.Request re = obj[0] as Model.Request; HalalTeam ha = obj[1] as HalalTeam; Premise pr = obj[2] as Premise; Characteristic ch = obj[3] as Characteristic; RFA r = obj[4] as RFA; Log l = obj[5] as Log; Attachment att = obj[6] as Attachment; RequestLineItem rli = obj[7] as RequestLineItem; Review rev = obj[8] as Review; ReviewLineItem revli = obj[9] as ReviewLineItem; Characteristic licha = obj[10] as Characteristic; return mapper.Map(re, null, null, ha, pr, ch, r, l, att, rli, rev, revli, licha); }, param, splitOn: "ID,HalalTeamID,PremiseID,CharID,RFAID,LogID,AttID,LineItemID,ReviewID," + "ReviewLineItemID,LiCharID", commandType: CommandType.StoredProcedure, transaction: _unitOfWork.Transaction)).FirstOrDefault()); }
public static DataTable ToRequestLineItemData(Model.Request req, out DataTable lineItemCharacteristic) { lineItemCharacteristic = new DataTable(); lineItemCharacteristic.Columns.Add("Type", typeof(int)); lineItemCharacteristic.Columns.Add("Value", typeof(string)); lineItemCharacteristic.Columns.Add("Index", typeof(string)); lineItemCharacteristic.Columns.Add("RefIndex", typeof(string)); lineItemCharacteristic.Columns.Add("CreatedOn", typeof(DateTimeOffset)); lineItemCharacteristic.Columns.Add("ModifiedOn", typeof(DateTimeOffset)); DataTable dl = new DataTable(); dl.Columns.Add("Scheme", typeof(int)); dl.Columns.Add("SubScheme", typeof(int)); dl.Columns.Add("Index", typeof(int)); dl.Columns.Add("ComplianceHistoryID", typeof(long)); dl.Columns.Add("RequestID", typeof(long)); dl.Columns.Add("CreatedOn", typeof(DateTimeOffset)); dl.Columns.Add("ModifiedOn", typeof(DateTimeOffset)); int i = 0; if (req.LineItems != null) { foreach (RequestLineItem rl in req.LineItems) { dl.Rows.Add( rl.Scheme, rl.SubScheme, i = i + 1, rl.ChecklistHistoryID, rl.RequestID, rl.CreatedOn, rl.ModifiedOn); if (rl.Characteristics != null) { ToRequestLineItemCharacteristicData(rl, i, lineItemCharacteristic); } } } return(dl); }
public static DataTable ToIngredientData(Model.Request req) { DataTable di = new DataTable(); di.Columns.Add("ID", typeof(long)); di.Columns.Add("Text", typeof(string)); di.Columns.Add("SubText", typeof(string)); di.Columns.Add("RiskCategory", typeof(int)); di.Columns.Add("Approved", typeof(bool)); di.Columns.Add("Remarks", typeof(string)); di.Columns.Add("ReviewedBy", typeof(Guid)); di.Columns.Add("ReviewedByName", typeof(string)); di.Columns.Add("ReviewedOn", typeof(DateTimeOffset)); di.Columns.Add("ChangeType", typeof(int)); di.Columns.Add("RequestID", typeof(long)); di.Columns.Add("CreatedOn", typeof(DateTimeOffset)); di.Columns.Add("ModifiedOn", typeof(DateTimeOffset)); if (req.Ingredients != null) { foreach (Ingredient ing in req.Ingredients) { di.Rows.Add( ing.ID, ing.Text, ing.SubText, ing.RiskCategory, ing.Approved, ing.Remarks, ing.ReviewedBy, ing.ReviewedByName, ing.ReviewedOn, ing.ChangeType, ing.RequestID, ing.CreatedOn, ing.ModifiedOn); } } return(di); }
public static DataTable ToMenuData(Model.Request req) { DataTable dm = new DataTable(); dm.Columns.Add("ID", typeof(long)); dm.Columns.Add("Scheme", typeof(int)); dm.Columns.Add("Text", typeof(string)); dm.Columns.Add("SubText", typeof(string)); dm.Columns.Add("Approved", typeof(bool)); dm.Columns.Add("Remarks", typeof(string)); dm.Columns.Add("ReviewdBy", typeof(Guid)); dm.Columns.Add("ReviewedByName", typeof(string)); dm.Columns.Add("ReviewedOn", typeof(DateTimeOffset)); dm.Columns.Add("ChangeType", typeof(int)); dm.Columns.Add("RequestID", typeof(long)); dm.Columns.Add("CreatedOn", typeof(DateTimeOffset)); dm.Columns.Add("ModifiedOn", typeof(DateTimeOffset)); if (req.Menus != null) { foreach (Menu me in req.Menus) { dm.Rows.Add( me.ID, me.Scheme, me.Text, me.SubText, me.Approved, me.Remarks, me.ReviewedBy, me.ReviewedByName, me.ReviewedOn, me.ChangeType, me.RequestID, me.CreatedOn, me.ModifiedOn); } } return(dm); }
public async Task <long> UpdateRequest(Model.Request req) { DataTable dlc = null; var dt = DataConverter.ToRequestData(req); var ht = DataConverter.ToHalalTeamData(req); var dp = DataConverter.ToPremiseData(req); var dm = DataConverter.ToMenuData(req); var di = DataConverter.ToIngredientData(req); var dc = DataConverter.ToCharacteristicData(req.Characteristics?.ToArray()); var da = DataConverter.ToAttachmentData(req); var dl = DataConverter.ToRequestLineItemData(req, out dlc); var param = new DynamicParameters(); param.Add("@Request", dt.AsTableValuedParameter("dbo.ApplicationRequestType")); param.Add("@HalalTeam", ht.AsTableValuedParameter("dbo.HalalTeamType")); param.Add("@Menu", dm.AsTableValuedParameter("dbo.MenuType")); param.Add("@Ingredient", di.AsTableValuedParameter("dbo.IngredientType")); param.Add("@Premise", dp.AsTableValuedParameter("dbo.PremiseType")); param.Add("@Characteristics", dc.AsTableValuedParameter("dbo.CharacteristicsType")); param.Add("@Attachments", da.AsTableValuedParameter("dbo.AttachmentsType")); param.Add("@RequestLineItems", dl.AsTableValuedParameter("dbo.RequestLineItemType")); param.Add("@RequestLineItemCharacteristics", dlc.AsTableValuedParameter("dbo.RequestLineItemCharacteristicsType")); param.Add("@ID", req.ID, dbType: DbType.Int64, direction: ParameterDirection.Input); await SqlMapper.ExecuteAsync(_unitOfWork.Connection, "UpdateRequests", param, commandType : CommandType.StoredProcedure, transaction : _unitOfWork.Transaction); return(req.ID); }
public async Task<Unit> Invoke(IUnitOfWork unitOfWork) { var dbContext = DbContext.From(unitOfWork); unitOfWork.BeginTransaction(); var rfa = await dbContext.RFA.GetRFAByID(_id); if (_rfastatus <= rfa.Status) { throw new BadRequestException( await dbContext.Transalation.GetTranslation(Locale.EN, "Outdated")); } await dbContext.RFA.UpdateRFAStatus(_id, _rfastatus, _userID, _userName); if (_rfastatus == RFAStatus.Closed && _userID != rfa.RaisedBy) { _eventBus.Publish(new SendNotificationEvent { Module = "Request", RefID = $"{rfa.RequestID}", Title = await dbContext.Transalation.GetTranslation(Locale.EN, "RFAProcessedByTitle"), Body = string.Format( await dbContext.Transalation.GetTranslation(Locale.EN, "RFAProcessedByBody"), _userName), To = new string[] { rfa.RaisedBy.ToString() } }); } else if (_rfastatus == RFAStatus.Expired) { Model.Request request = dbContext.Request.GetRequestByID(rfa.RequestID).Result; if (request != null && request.ID > 0) { var logtext = await dbContext.Transalation.GetTranslation(Locale.EN, "ExpireRequestLapseRFABody"); if (!string.IsNullOrEmpty(logtext)) { var logid = await dbContext.Log.InsertLog(new Log { Action = logtext, UserID = (Guid)request.AssignedTo, UserName = request.AssignedToName }); await dbContext.Request.MapLog(request.ID, logid); } _eventBus.Publish(new SendNotificationEvent { Title = await dbContext.Transalation.GetTranslation(0, "ExpireRequestTitle"), Body = await dbContext.Transalation.GetTranslation(0, "ExpireRequestLapseRFABody"), Module = "Request", To = new List<string> { request.AssignedTo.ToString() } }); await dbContext.Request.UpdateStatus(request.ID, RequestStatus.Expired, null); } var logText = string.Format( await dbContext.Transalation.GetTranslation(0, "RFALapsedBody")); var logID = await dbContext.Log.InsertLog(new Log { Action = logText }); } unitOfWork.Commit(); return Unit.Default; }
public async Task <HttpResponseMessage> BookTicketInternational() { if (hepler.CheckHeader(Request)) { string responseString = string.Empty; HttpResponseMessage response = null; try { var searchParamterXml = await Request.Content.ReadAsByteArrayAsync(); string searchParameter = System.Text.Encoding.UTF8.GetString(searchParamterXml); XmlSerializer serializer = new XmlSerializer(typeof(Model.Request)); using (TextReader reader = new StringReader(searchParameter)) { Model.Request searchDetail = (Model.Request)serializer.Deserialize(reader); var searchRequestObject = TemplateXml.BookingStatusIntXml; searchRequestObject = searchRequestObject.Replace("OriginValue", searchDetail.Origin). Replace("DestinationValue", searchDetail.Destination). Replace("DepartDateValue", searchDetail.DepartDate). Replace("ReturnDateValue", searchDetail.ReturnDate). Replace("AdultCountValue", searchDetail.AdultPax). Replace("ChildCountValue", searchDetail.ChildPax). Replace("InfantCountValue", searchDetail.InfantPax). Replace("PreferredClassValue", searchDetail.Preferredclass). Replace("ModeValue", searchDetail.mode); //// Code to get all flight*** Start using (var httpClient = new HttpClient()) { var httpContent = new StringContent(searchRequestObject, Encoding.UTF8, "text/xml"); // Do the actual request and await the response var httpResponse = await httpClient.PostAsync("http://demo.arzoo.com:9301/Avalability", httpContent); // If the response contains content we want to read it! if (httpResponse.Content != null) { responseString = await httpResponse.Content.ReadAsStringAsync(); } } //*********End var serializer1 = new XmlSerializer(typeof(Arzoo_responseInt)); Arzoo_responseInt ArzooResponse; using (TextReader reader1 = new StringReader(responseString)) { ArzooResponse = (Arzoo_responseInt)serializer1.Deserialize(reader1); } if (ArzooResponse == null) { response = Request.CreateResponse <string>(HttpStatusCode.NoContent, "No Content Found"); } else if (!string.IsNullOrEmpty(ArzooResponse.Error)) { response = Request.CreateResponse <string>(HttpStatusCode.BadRequest, ArzooResponse.Error); } else { var selectedFlights = new OriginDestinationOptionInt(); //Check in depart flight if (ArzooResponse.AvailResponse != null) { var options = ArzooResponse.AvailResponse.OriginDestinationOptions.OriginDestinationOption.FirstOrDefault(o => o.Id == searchDetail.Id); if (options != null) { selectedFlights = options; } } if (selectedFlights == null) { response = Request.CreateResponse <string>(HttpStatusCode.NoContent, "No Content Found"); } else { var emptyNamepsaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty }); XmlSerializer xsSubmit = new XmlSerializer(typeof(OriginDestinationOptionInt)); var xml = ""; var settings = new XmlWriterSettings(); settings.Indent = true; settings.OmitXmlDeclaration = true; using (var sww = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sww, settings)) { xsSubmit.Serialize(writer, selectedFlights, emptyNamepsaces); xml = sww.ToString(); // Your XML } } Random generator = new Random(); int partnerRefIdValue = generator.Next(100000, 1000000); var bookingRequestXml = TemplateXml.BookingRequestXml; bookingRequestXml = bookingRequestXml.Replace("FlghtDetailXmlTemplate", xml). Replace("creditcardnoValue", searchDetail.creditcardno). Replace("phoneNumberValue", searchDetail.phoneNumber). Replace("emailAddressValue", searchDetail.emailAddress). Replace("AdultCountValue", searchDetail.AdultPax). Replace("ChildCountValue", searchDetail.ChildPax). Replace("InfantCountValue", searchDetail.InfantPax). Replace("partnerRefIdValue", partnerRefIdValue.ToString()); var endTag = "</personName>"; int startIndex = searchParameter.IndexOf("<personName>"); int endIndex = searchParameter.IndexOf("</personName>", startIndex) + endTag.Length; var personNameXml = searchParameter.Substring(startIndex, endIndex - startIndex); bookingRequestXml = bookingRequestXml.Replace("CustomerInformationXmlValue", personNameXml); /*****Call to book Flight* Start****/ //// Code to get all flight*** Start using (var httpClient = new HttpClient()) { var httpContent = new StringContent(bookingRequestXml, Encoding.UTF8, "text/xml"); // Do the actual request and await the response var httpResponse = await httpClient.PostAsync("http://demo.arzoo.com:9301/Booking", httpContent); // If the response contains content we want to read it! if (httpResponse.Content != null) { responseString = await httpResponse.Content.ReadAsStringAsync(); } } /*****Call to book Flight* End****/ if (string.IsNullOrEmpty(responseString)) { response = Request.CreateResponse <string>(HttpStatusCode.BadRequest, "Invalid Request"); } else { /*******Extract repsonse oject from xml******/ var serializer2 = new XmlSerializer(typeof(Bookingresponse)); BookingResponse BookingresponseDetail; using (TextReader reader1 = new StringReader(responseString)) { BookingresponseDetail = (BookingResponse)serializer2.Deserialize(reader1); } if (!string.IsNullOrEmpty(BookingresponseDetail.Error)) { response = Request.CreateResponse <string>(HttpStatusCode.BadRequest, BookingresponseDetail.Error); } else { XmlSerializer xsBooking = new XmlSerializer(typeof(BookingResponse)); var responseXml = ""; using (var sww = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sww)) { xsBooking.Serialize(writer, BookingresponseDetail); responseXml = sww.ToString(); // Your XML } } response = Request.CreateResponse <string>(HttpStatusCode.OK, responseXml); } } } } } } catch (Exception e) { responseString = e.Message; response = Request.CreateResponse <string>(HttpStatusCode.NotFound, responseString); } return(response); } return(null); }
public frmRequestDetails(Model.Request request) { _selectedRequest = request; InitializeComponent(); }
Model.Request InternalMap(Model.Request request, Code customerCode = null, Code groupCode = null, RequestLineItem lineItem = null, Characteristic lineItemChar = null, HalalTeam halalTeam = null, Premise premise = null, Characteristic characteristic = null, Attachment attachment = null, RFA rfa = null, Log log = null, Review review = null, ReviewLineItem reviewLineItem = null) { if (!_cache.TryGetValue(request.ID, out Model.Request result)) { _cache[request.ID] = request; result = request; } if ((customerCode?.ID ?? 0) > 0) { result.CustomerCode = customerCode; } if ((groupCode?.ID ?? 0) > 0) { result.GroupCode = groupCode; } RequestLineItem outLineItem = null; if ((lineItem?.ID ?? 0L) != 0L && !_lineItemCache.TryGetValue(lineItem.ID, out outLineItem)) { if (result.LineItems == null) { result.LineItems = new List <RequestLineItem>(); } result.LineItems.Add(lineItem); _lineItemCache[lineItem.ID] = lineItem; outLineItem = lineItem; } if (outLineItem != null && (lineItemChar?.ID ?? 0L) != 0L && !_lineItemCharCache.ContainsKey(lineItemChar.ID)) { if (outLineItem.Characteristics == null) { outLineItem.Characteristics = new List <Characteristic>(); } _lineItemCharCache[lineItemChar.ID] = lineItemChar; outLineItem.Characteristics.Add(lineItemChar); } if ((halalTeam?.ID ?? 0L) != 0L && !_halalCache.ContainsKey(halalTeam.ID)) { _halalCache[halalTeam.ID] = halalTeam; if (result.Teams == null) { result.Teams = new List <HalalTeam>(); } result.Teams.Add(halalTeam); } if ((premise?.ID ?? 0L) != 0L && result.Premises?.FirstOrDefault(e => e.ID == premise.ID) == null) { if (result.Premises == null) { result.Premises = new List <Premise>(); } result.Premises.Add(premise); } if ((characteristic?.ID ?? 0L) != 0L && !_characteristicsCache.ContainsKey(characteristic.ID)) { _characteristicsCache[characteristic.ID] = characteristic; if (result.Characteristics == null) { result.Characteristics = new List <Characteristic>(); } result.Characteristics.Add(characteristic); } if ((attachment?.ID ?? 0L) != 0L && !_attachmentCache.ContainsKey(attachment.ID)) { _attachmentCache[attachment.ID] = attachment; if (result.Attachments == null) { result.Attachments = new List <Attachment>(); } result.Attachments.Add(attachment); } if ((rfa?.ID ?? 0L) != 0L && !_rfaCache.ContainsKey(rfa.ID)) { _rfaCache[rfa.ID] = rfa; if (result.RFAs == null) { result.RFAs = new List <RFA>(); } result.RFAs.Add(rfa); } if ((log?.ID ?? 0L) != 0L && !_logCache.ContainsKey(log.ID)) { _logCache[log.ID] = log; if (result.Logs == null) { result.Logs = new List <Log>(); } result.Logs.Add(log); } Review outReview = null; if ((review?.ID ?? 0L) != 0L && !_reviewCache.TryGetValue(review.ID, out outReview)) { if (result.Reviews == null) { result.Reviews = new List <Review>(); } result.Reviews.Add(review); _reviewCache[review.ID] = review; outReview = review; } if (outReview != null && (reviewLineItem?.ID ?? 0L) != 0L && !_reviewLineItemCache.ContainsKey(reviewLineItem.ID)) { _reviewLineItemCache[reviewLineItem.ID] = reviewLineItem; if (outReview.LineItems == null) { outReview.LineItems = new List <ReviewLineItem>(); } outReview.LineItems.Add(reviewLineItem); } return(result); }
public static Model.Request CreateFlow(RequestCreateModel model1) { if (model1 is null) { return(null); } if (model1.Process is null) { return(null); } Process new_process = new Process { Name = model1.Process.Name, Actions = new List <Models.Action>(), States = new List <State>(), Rules = new List <TransitionRule>(), Roles = new List <Role>(), Activities = new List <Activity>() }; foreach (var state in model1.Process.States) { State new_state = new State { StateType = state.StateType, Name = state.Name, Description = state.Description, Activities = new List <Activity>(), Roles = new List <Role>(), ETA = state.ETA }; foreach (var activity in state.Activities) { if (activity.ActivityType == ActivityType.Email) { Activity new_activity = new EmailActivityOperator { ActivityType = activity.ActivityType, Name = activity.Name, Description = activity.Description, Duration = activity.Duration, IsRequired = activity.IsRequired, Discriminator = "EMAIL", Roles = new List <Role>(), Data = new List <Data>() }; if (activity.Roles != null) { foreach (var role in activity.Roles) { Role new_role = new Role { Name = role.Name }; new_process.Roles.Add(new_role); new_activity.Roles.Add(new_role); } new_process.Activities.Add(new_activity); new_state.Activities.Add(new_activity); } } else if (activity.ActivityType == ActivityType.Absent) { Activity new_activity = new TLActivityOperator { ActivityType = activity.ActivityType, Name = activity.Name, Description = activity.Description, Duration = activity.Duration, IsRequired = activity.IsRequired, Discriminator = "TALENT-LEAVE", Roles = new List <Role>(), Data = new List <Data>(), AbsentName = activity.AbsentName, ApproverName = activity.ApproverName, DayOff = activity.DayOff, IsReallyNotApproved = activity.IsReallyNotApproved, Reason = activity.Reason }; if (activity.Roles != null) { foreach (var role in activity.Roles) { Role new_role = new Role { Name = role.Name }; new_process.Roles.Add(new_role); new_activity.Roles.Add(new_role); new_state.Roles.Add(new_role); } new_process.Activities.Add(new_activity); new_state.Activities.Add(new_activity); } } else if (activity.ActivityType == ActivityType.Generic) { Activity new_activity = new GenericActivityOperator { ActivityType = activity.ActivityType, Name = activity.Name, Description = activity.Description, Duration = activity.Duration, IsRequired = activity.IsRequired, Roles = new List <Role>(), Data = new List <Data>(), }; if (activity.Roles != null) { foreach (var role in activity.Roles) { Role new_role = new Role { Name = role.Name }; new_process.Roles.Add(new_role); new_activity.Roles.Add(new_role); new_state.Roles.Add(new_role); } new_process.Activities.Add(new_activity); new_state.Activities.Add(new_activity); } } else if (activity.ActivityType == ActivityType.Campaign) { Activity new_activity = new CampaignActivityOperator { ActivityType = activity.ActivityType, Name = activity.Name, Description = activity.Description, Duration = activity.Duration, IsRequired = activity.IsRequired, CampaignName = activity.CampaignName, Subscribers = new List <Contact>(), IsRunning = activity.IsRunning, Roles = new List <Role>(), Data = new List <Data>(), Discriminator = "CAMPAIGN" }; // if (activity.Subscribers != null) // { // foreach (var item in activity.Subscribers) // { // ((CampaignActivityOperator)new_activity).Subscribers.Add(new Contact { // FullName = item.FullName, // Email = item.Email, // PhoneNumber = item.PhoneNumber, // Age = item.Age, // DataType = DataType.Contact // }) // } // } if (activity.Roles != null) { foreach (var role in activity.Roles) { Role new_role = new Role { Name = role.Name }; new_process.Roles.Add(new_role); new_activity.Roles.Add(new_role); new_state.Roles.Add(new_role); } new_process.Activities.Add(new_activity); new_state.Activities.Add(new_activity); } } } new_process.States.Add(new_state); } if (model1.Process.Actions != null) { foreach (var action in model1.Process.Actions) { var new_action = new Models.Action { Name = action.Name, Description = action.Description }; new_process.Actions.Add(new_action); } } if (model1.Process.Rules != null) { foreach (var rule in model1.Process.Rules) { TransitionRule new_rule = new TransitionRule { CurrentState = new_process.States.FirstOrDefault(s => s.Name == rule.CurrentState.Name), NextState = new_process.States.FirstOrDefault(s => s.Name == rule.NextState.Name), Action = new_process.Actions.FirstOrDefault(a => a.Name == rule.Action.Name) }; // if (rule.Trigger != null) { // var new_trigger = new Trigger { // Consequence = rule.Trigger.Consequence, // Events = rule.Trigger.Events // }; // new_rule.Trigger = new_trigger; // } new_process.Rules.Add(new_rule); } } var new_request = new Model.Request { Title = model1.Title, UserId = model1.UserId, UserName = model1.UserName, CurrentState = new_process.States.FirstOrDefault(s => s.StateType == StateType.start), DateRequested = model1.DateRequested, Histories = new List <ActivityLog>(), Tasks = new List <Model.Task>(), Data = new List <Data>() }; new_request.Process = new_process; new_request.Tasks = new List <Model.Task>(); foreach (var activity in new_process.Activities) { new_request.Tasks.Add(new Model.Task { Activity = activity, IsDone = false }); } return(new_request); }
public static Model.Request NodeCreateFlow(RequestCreateModel model1, Process process) { if (model1 is null) { return(null); } if (model1.Process is null) { return(null); } process.Actions = new List <Models.Action>(); process.States = new List <State>(); process.Rules = new List <TransitionRule>(); process.Roles = new List <Role>(); process.Activities = new List <Activity>(); process.Nodes = new List <Node>(); foreach (var node in model1.Process.Nodes) { Node new_node = new Node { Level = node.Level, Name = node.Name, Description = node.Description, Activities = new List <Activity>(), Iscompleted = node.Iscompleted, Roles = new List <Role>(), Actions = new List <Models.Action>(), Childs = new List <Node>() }; if (node.Actions != null) { foreach (var action in node.Actions) { var new_action = new Models.Action { Name = action.Name, Description = action.Description }; new_node.Actions.Add(new_action); process.Actions.Add(new_action); } } foreach (var activity in node.Activities) { if (activity.ActivityType == ActivityType.Email) { Activity new_activity = new EmailActivityOperator { ActivityType = activity.ActivityType, Name = activity.Name, Description = activity.Description, Duration = activity.Duration, IsRequired = activity.IsRequired, Discriminator = "EMAIL", Roles = new List <Role>(), Data = new List <Data>() }; if (activity.Roles != null) { foreach (var role in activity.Roles) { Role new_role = new Role { Name = role.Name }; process.Roles.Add(new_role); new_activity.Roles.Add(new_role); new_node.Roles.Add(new_role); } process.Activities.Add(new_activity); new_node.Activities.Add(new_activity); } } else if (activity.ActivityType == ActivityType.Absent) { Activity new_activity = new TLActivityOperator { ActivityType = activity.ActivityType, Name = activity.Name, Description = activity.Description, Duration = activity.Duration, IsRequired = activity.IsRequired, Discriminator = "TALENT-LEAVE", Roles = new List <Role>(), Data = new List <Data>(), AbsentName = activity.AbsentName, ApproverName = activity.ApproverName, DayOff = activity.DayOff, IsReallyNotApproved = activity.IsReallyNotApproved, Reason = activity.Reason }; if (activity.Roles != null) { foreach (var role in activity.Roles) { Role new_role = new Role { Name = role.Name }; process.Roles.Add(new_role); new_activity.Roles.Add(new_role); new_node.Roles.Add(new_role); } process.Activities.Add(new_activity); new_node.Activities.Add(new_activity); } } else if (activity.ActivityType == ActivityType.Generic) { Activity new_activity = new GenericActivityOperator { ActivityType = activity.ActivityType, Name = activity.Name, Description = activity.Description, Duration = activity.Duration, IsRequired = activity.IsRequired, Roles = new List <Role>(), Data = new List <Data>(), }; if (activity.Roles != null) { foreach (var role in activity.Roles) { Role new_role = new Role { Name = role.Name }; process.Roles.Add(new_role); new_activity.Roles.Add(new_role); new_node.Roles.Add(new_role); } process.Activities.Add(new_activity); new_node.Activities.Add(new_activity); } } else if (activity.ActivityType == ActivityType.Campaign) { Activity new_activity = new CampaignActivityOperator { ActivityType = activity.ActivityType, Name = activity.Name, Description = activity.Description, Duration = activity.Duration, IsRequired = activity.IsRequired, CampaignName = activity.CampaignName, Subscribers = new List <Contact>(), IsRunning = activity.IsRunning, Roles = new List <Role>(), Data = new List <Data>(), Discriminator = "CAMPAIGN" }; // if (activity.Subscribers != null) // { // foreach (var item in activity.Subscribers) // { // ((CampaignActivityOperator)new_activity).Subscribers.Add(new Contact { // FullName = item.FullName, // Email = item.Email, // PhoneNumber = item.PhoneNumber, // Age = item.Age, // DataType = DataType.Contact // }) // } // } if (activity.Roles != null) { foreach (var role in activity.Roles) { Role new_role = new Role { Name = role.Name }; process.Roles.Add(new_role); new_activity.Roles.Add(new_role); new_node.Roles.Add(new_role); } process.Activities.Add(new_activity); new_node.Activities.Add(new_activity); } } } process.Nodes.Add(new_node); } if (model1.Process.Rules != null) { foreach (var rule in model1.Process.Rules) { TransitionRule new_rule = new TransitionRule { CurrentNode = process.Nodes.FirstOrDefault(s => s.Name == rule.CurrentNode.Name), NextNode = process.Nodes.FirstOrDefault(s => s.Name == rule.NextNode.Name), Action = process.Actions.FirstOrDefault(a => a.Name == rule.Action.Name) }; process.Rules.Add(new_rule); } } var new_request = new Model.Request { Title = model1.Title, UserId = model1.UserId, UserName = model1.UserName, CurrentNode = process.Nodes.FirstOrDefault(s => s.Level == 0), DateRequested = model1.DateRequested, Histories = new List <ActivityLog>(), Tasks = new List <Model.Task>(), Data = new List <Data>() }; new_request.Process = process; new_request.Tasks = new List <Model.Task>(); foreach (var activity in process.Activities) { new_request.Tasks.Add(new Model.Task { Activity = activity, IsDone = false }); } return(new_request); }
public RFA Map(RFA rfa, RFALineItem li = null, Attachment liAtt = null, RFAReply rep = null, Attachment repAtt = null, Log rfaLog = null, Model.Request request = null) { if (!_rfaCache.TryGetValue(rfa.ID, out RFA result)) { if ((request?.ID ?? 0) > 0) { rfa.Request = request; } _rfaCache[rfa.ID] = rfa; result = rfa; } if ((rfaLog?.ID ?? 0) != 0 && !_rfaLogCache.ContainsKey(rfaLog.ID)) { _rfaLogCache[rfaLog.ID] = rfaLog; if (result.Logs == null) { result.Logs = new List <Log>(); } result.Logs.Add(rfaLog); } if ((li?.ID ?? 0) != 0) { if (!_liCache.TryGetValue(li.ID, out RFALineItem liOut)) { _liCache[li.ID] = li; liOut = li; if (result.LineItems == null) { result.LineItems = new List <RFALineItem>(); } result.LineItems.Add(li); } if ((liAtt?.ID ?? 0) != 0 && !_liAttCache.ContainsKey(liAtt.ID)) { if (liOut.Attachments == null) { liOut.Attachments = new List <Attachment>(); } liOut.Attachments.Add(liAtt); _liAttCache[liAtt.ID] = liAtt; } RFAReply repOut = null; if ((rep?.ID ?? 0) != 0 && !_repCache.TryGetValue(rep.ID, out repOut)) { rep.Attachments = new List <Attachment>(); _repCache[rep.ID] = rep; repOut = rep; if (liOut.Replies == null) { liOut.Replies = new List <RFAReply>(); } liOut.Replies.Add(rep); } if ((repAtt?.ID ?? 0) != 0 && !_repAttCache.ContainsKey(repAtt.ID)) { repOut.Attachments.Add(repAtt); _repAttCache[repAtt.ID] = repAtt; } } return(result); }
public async Task <Model.Request> Post([FromBody] Model.Request request, long rfaid, Guid userID, string userName) { return(await _requestservice.UpdateRequest(request)); }
public async Task <Model.Request> Post([FromBody] Model.Request request) { return(await _requestservice.SubmitRequest(request)); }