public DC_Message SyncSupplierStaticHotel(Guid log_id, Guid supplier_Id, string CreatedBy) { try { Guid LogId; using (ConsumerEntities context = new ConsumerEntities()) { var iScheduledCount = (from dlr in context.DistributionLayerRefresh_Log where (dlr.Status == "Scheduled" || dlr.Status == "Running") && dlr.Element == "Hotels" && dlr.Type == "Static" select true).Count(); if (iScheduledCount > 0) { return(new DC_Message { StatusMessage = "Supplier Static Hotel sync has already been scheduled.", StatusCode = ReadOnlyMessage.StatusCode.Information }); } else { LogId = Guid.NewGuid(); DataLayer.DistributionLayerRefresh_Log objNew = new DistributionLayerRefresh_Log(); objNew.Id = LogId; objNew.Element = "Hotels"; objNew.Type = "Static"; objNew.Create_Date = DateTime.Now; objNew.Create_User = CreatedBy;// System.Web.HttpContext.Current.User.Identity.Name; objNew.Status = "Scheduled"; objNew.Supplier_Id = supplier_Id; objNew.Edit_Date = DateTime.Now; objNew.Edit_User = CreatedBy; context.DistributionLayerRefresh_Log.Add(objNew); context.SaveChanges(); } if (log_id == Guid.Empty) { using (DHSVCProxyAsync DHP = new DHSVCProxyAsync()) { string strURI = string.Format(System.Configuration.ConfigurationManager.AppSettings["Load_SupplierStaticHotels"], LogId.ToString(), supplier_Id.ToString()); DHP.GetAsync(ProxyFor.SqlToMongo, strURI); } } else { //Code goes here for Indert Update or Delete of a specific country } return(new DC_Message { StatusMessage = "Supplier Static Hotel sync has been scheduled successfully.", StatusCode = ReadOnlyMessage.StatusCode.Success }); } } catch (Exception ex) { return(new DC_Message { StatusMessage = ex.Message, StatusCode = ReadOnlyMessage.StatusCode.Failed }); } }
private DC_Message InsertDistributionLogNewEntryForMLDataAPI(DC_Distribution_MLDataRQ obj) { DC_Message msg = new DC_Message(); try { using (ConsumerEntities context = new ConsumerEntities()) { IncomingWebRequestContext woc = WebOperationContext.Current.IncomingRequest; string CallingAgent = woc.Headers["CallingAgent"]; string CallingUser = woc.Headers["CallingUser"]; DataLayer.DistributionLayerRefresh_Log objNew = new DistributionLayerRefresh_Log(); objNew.Id = (obj.Logid ?? Guid.NewGuid()); objNew.Element = obj.Element.Trim(); objNew.Type = obj.Type.Trim(); objNew.Create_Date = DateTime.Now; objNew.Create_User = CallingUser; objNew.Status = obj.Status; context.DistributionLayerRefresh_Log.Add(objNew); context.SaveChanges(); msg.StatusCode = ReadOnlyMessage.StatusCode.Success; msg.StatusMessage = "Sync has been scheduled successfully."; } } catch (Exception) { throw; } return(msg); }
private DC_Message InsertDistributionLogNewEntry(Guid LogId, string elementName, string Type, string status, string CreatedBy) { DC_Message msg = new DC_Message(); DataLayer.DistributionLayerRefresh_Log objNew = new DistributionLayerRefresh_Log(); objNew.Id = LogId; objNew.Element = elementName; objNew.Type = Type; objNew.Create_Date = DateTime.Now; objNew.Create_User = CreatedBy; objNew.Status = status; using (ConsumerEntities context = new ConsumerEntities()) { context.DistributionLayerRefresh_Log.Add(objNew); context.SaveChanges(); } msg.StatusCode = ReadOnlyMessage.StatusCode.Success; msg.StatusMessage = elementName + " " + Type + "Sync has been scheduled successfully."; return(msg); }