public async static Task <ExceptionEntity> WriteAsync(this ExceptionLogger logger, Exception exception, HttpContext httpContext, Dictionary <string, string> customData = null, [CallerFilePath] string sourceFile = null, [CallerLineNumber] int lineNumber = 0) { var log = new ExceptionEntity(logger.AppName, exception) { UserName = httpContext.User.Identity.Name, MethodName = httpContext.Request.Path.Value, QueryString = httpContext.Request.QueryString.Value, HttpMethod = httpContext.Request.Method, Cookies = GetCookies(httpContext.Request.Cookies), CustomData = customData, SourceFile = sourceFile, LineNumber = lineNumber }; if (httpContext.Request.Method.ToLower().Equals("post")) { log.FormValues = GetFormValues(httpContext.Request.Form); } await logger.WriteLogAsync(log); return(log); }
public async Task WriteLogAsync(ExceptionEntity log) { CloudTable table = await InitTableAsync(); var operation = TableOperation.Insert(log); await table.ExecuteAsync(operation); }
public HttpResponseMessage getSite() { try { using (PRINCE_STGEntities enBI = new PRINCE_STGEntities()) { enBI.Configuration.LazyLoadingEnabled = false; List <Site> siteList = enBI.Site.Where(a => a.Status == "A").OrderBy(od => od.Description).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, siteList)); } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
public List <TEMP_DC> getStoreDc() { try { TransList trans = new TransList(); using (PRINCE_STGEntities enBi = new PRINCE_STGEntities()) { List <TEMP_DC> listDc = enBi.TEMP_DC.AsNoTracking().ToList(); // trans.data = listDc; return(listDc); } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
//private void ConnectToTfs(ExceptionEntity exception, IApplicationInfo applicationInfo) //{ // //new NetworkCredential(@"os-lab\oslabadmin", "Y67uJi)9"); // var credentials = CredentialCache.DefaultNetworkCredentials;//new NetworkCredential(@"partner\xNataliaA", "xNataliaA62");// // tfs = new TfsTeamProjectCollection(new Uri(applicationInfo.TfsServer + "/" + applicationInfo.TeamProject), credentials); // tfs.EnsureAuthenticated(); // if (!tfs.HasAuthenticated) // { // throw new ExceptionReporterException("Failed to authenticate to TFS."); // } //} //private WorkItemType GetWorkItemType(ExceptionEntity exception, IApplicationInfo applicationInfo) //{ // var store = tfs.GetService<WorkItemStore>(); // var teamProject = store.Projects[applicationInfo.TeamProject]; // return teamProject.WorkItemTypes[ExceptionWorkItemType]; //} //private void AddLinkedWorkItem(WorkItem linkedWi, WorkItem wi) //{ // try // { // var rl = new RelatedLink(linkedWi.Id); // wi.Links.Add(rl); // } // catch (System.Exception ex) // { // ServiceLog.Warning( // $"Failed to link work item {linkedWi.Id} while create new exception with stackTrace CRC {wi.Fields[StackChecksumFieldName].Value}" + ex.Message); // } //} //protected virtual void Dispose(bool disposing) //{ // if (disposing) // { // // dispose managed resources // tfs?.Dispose(); // } // // free native resources //} //public void Dispose() //{ // Dispose(true); // GC.SuppressFinalize(this); //} public ExceptionEntity GetWorkItem(ExceptionEntity exceptionEntity) { var workItems = new ExceptionWorkItemCollection(exceptionEntity, this.ApplicationInfo); var wi = workItems.OpenWorkItems.FirstOrDefault(); if (wi == null) { throw new System.Exception("Failed to find Exception Work item same stack trace"); } // wi.Fields[AssignedToFieldName].Value = applicationInfo.AssignedTo; return(new ExceptionEntity() { ApplicationName = wi.Field(Application), Reporter = wi.Field(ExceptionReporterFieldName), Version = wi.Field(BuildVersionFieldName), ExceptionMessage = wi.Field(ExceptionMessageFieldName), ExceptionType = wi.Field(ExceptionTypeFieldName), ExceptionClass = wi.Field(ClassFieldName), ExceptionMethod = wi.Field(MethodFieldName), ExceptionSource = wi.Field(SourceFieldName), StackTrace = wi.Field(StackTraceFieldName), Comment = wi.Field(CommentFieldName), ExceptionTitle = wi.Field("System.Title") }); }
public List <User> getUser() { try { using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities()) { List <User> user = (from u in entPrince.User select u).ToList(); return(user); } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
public HttpResponseMessage updateSite(dynamic pSite) { try { using (var dbCtx = new PRINCE_STGEntities()) { int tempSite = pSite.SiteId; String tempSiteDesc = pSite.Description; Site site = dbCtx.Site.AsNoTracking().Where(wr => wr.SiteId == tempSite).SingleOrDefault(); site.Description = tempSiteDesc; site.Status = pSite.Status; dbCtx.Entry(site).State = System.Data.Entity.EntityState.Modified; dbCtx.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Site " + site.Description.Trim() + " is successfully Updated.")); } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
public static bool Log(string eventType, ExceptionEntity exception = null) { if (!Started) { return(false); } try { using (Transaction tr = Transaction.ForceNew()) { using (ExecutionMode.Global()) new SystemEventLogEntity { Date = TimeZoneManager.Now, MachineName = Environment.MachineName, User = UserHolder.Current?.ToLite(), EventType = eventType, Exception = exception?.ToLite() }.Save(); tr.Commit(); } return(true); } catch (Exception e) { e.LogException(ex => ex.ControllerName = "SystemEventLog.Log"); return(false); } }
public List <Menu> getMenu(int id) { try { using (PRINCE_STGEntities enBi = new PRINCE_STGEntities()) { int iId = id; int?[] arMenu = (from a in enBi.UserMenu.AsNoTracking() where a.UserId == iId && a.Status == "A" select a.MenuId).ToArray(); var menu = (from a in enBi.Menu.AsNoTracking() where a.Status == "A" && arMenu.Contains(a.Id) select a).OrderBy(c => c.LevelNo).ThenBy(d => d.SortNo).ToList(); return(menu); } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
public ExceptionWorkItemJson CreateNewException(ExceptionEntity exception, IApplicationInfo applicationInfo) { //ensure no problem with string NG 255 var wi = new ExceptionWorkItemJson(exception, applicationInfo); return(wi); }
public HttpResponseMessage getSiteById(int id) { try { using (PRINCE_STGEntities enCarina = new PRINCE_STGEntities()) { enCarina.Configuration.LazyLoadingEnabled = false; Site site = enCarina.Site.Where(wr => wr.SiteId == id).SingleOrDefault(); return(Request.CreateResponse(HttpStatusCode.OK, site)); } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
public UserMenu getUserMenu(int pUserCode, int pMenuId) { try { using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities()) { UserMenu menu = (from m in entPrince.UserMenu where m.UserId == pUserCode && m.MenuId == pMenuId select m).SingleOrDefault(); return(menu); } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
//public HttpResponseMessage addStoreMerch(dynamic sStoreMerch) //{ // try // { // using (PRINCE_STGEntities dbCtx = new PRINCE_STGEntities()) // { // STG_merch merch = new STG_merch(); // merch.merch_DATE = sStoreMerch.merch_DATE; // merch.GEO_LEVEL1_CODE = "99999"; // merch.GEO_LEVEL2_CODE = "99999"; // merch.GEO_LEVEL3_CODE = "99999"; // merch.STORE_CODE = sStoreMerch.STORE_CODE; // merch.PROD_LEVEL1_CODE = sStoreMerch.PROD_LEVEL1_CODE; // merch.PROD_LEVEL2_CODE = sStoreMerch.PROD_LEVEL2_CODE; // merch.PROD_LEVEL3_CODE = sStoreMerch.PROD_LEVEL3_CODE; // merch.PROD_LEVEL4_CODE = "99999"; // merch.PROD_LEVEL5_CODE = "99999"; // merch.PRODUCT_CODE = "99999"; // merch.merch_VERSION = 99999; // merch.merch_SALE_QTY = 99999; // merch.merch_SALE_VAL_AT_PRICE = sStoreMerch.merch_SALE_VAL_AT_PRICE; // merch.merch_SALE_VAL_AT_COST = 99999; // merch.merch_MARKDOWN_QTY = 0; // merch.merch_MARKDOWN_VAL = 0; // merch.merch_SHRINKAGE_VAL = 0; // merch.merch_PURCHASE_QTY = 0; // merch.merch_PURCHASE_VAL = 0; // merch.merch_INV_OPENING_QTY = 0; // merch.merch_OPENING_VAL_AT_COST = 0; // merch.merch_OPENING_VAL_AT_PRICE = 0; // merch.merch_OTH1 = 99999; // merch.merch_OTH2 = 99999; // merch.merch_OTH3 = 99999; // merch.merch_OTH4 = 99999; // merch.merch_OTH5 = 99999; // merch.ARC_DATE = DateTime.Now; // dbCtx.STG_merch.Add(merch); // dbCtx.SaveChanges(); // return Request.CreateResponse(HttpStatusCode.Created, "merch successfully created."); // } // } // catch (Exception ex) // { // Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex); // } // return Request.CreateResponse(HttpStatusCode.OK); //} public HttpResponseMessage updateStoreMerch(dynamic sStoreMerch) { try { using (PRINCE_STGEntities enBi = new PRINCE_STGEntities()) { using (var dbCtxTran = enBi.Database.BeginTransaction()) { //DateTime merchdate = sStoreMerch.merch_DATE; int id = sStoreMerch.ID; //string storecode = sStoreMerch.STORE_CODE; STG_STR_MERCH_DET merch = enBi.STG_STR_MERCH_DET.Find(id); if (merch != null) { merch.ID = sStoreMerch.ID; merch.STRMRGRP_DATE = sStoreMerch.STRMRGRP_DATE; merch.STORE_CODE = sStoreMerch.STORE_CODE; merch.PROD_LEVEL1_CODE = sStoreMerch.PROD_LEVEL1_CODE; merch.PROD_LEVEL2_CODE = sStoreMerch.PROD_LEVEL2_CODE; merch.PROD_LEVEL3_CODE = sStoreMerch.PROD_LEVEL3_CODE; merch.PROD_LEVEL4_CODE = sStoreMerch.PROD_LEVEL4_CODE; merch.SELLING_AREA = sStoreMerch.SELLING_AREA; merch.TOTAL_AREA = sStoreMerch.TOTAL_AREA; merch.PERMENANT_FTE = sStoreMerch.PERMENANT_FTE; merch.CONTRACT_FTE = sStoreMerch.CONTRACT_FTE; merch.OTH_DET1 = sStoreMerch.OTH_DET1; merch.OTH_DET2 = sStoreMerch.OTH_DET2; merch.OTH_DET3 = sStoreMerch.OTH_DET3; merch.OTH_DET4 = sStoreMerch.OTH_DET4; merch.OTH_DET5 = sStoreMerch.OTH_DET5; merch.ARC_DATE = sStoreMerch.ARC_DATE; enBi.Entry(merch).State = System.Data.Entity.EntityState.Modified; enBi.SaveChanges(); dbCtxTran.Commit(); return(Request.CreateResponse(HttpStatusCode.OK, "Store Merch successfully Updated.")); } } } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } return(Request.CreateResponse(HttpStatusCode.OK, "Storemerch successfully Updated.")); }
public HttpResponseMessage updateTarget(dynamic pTarget) { try { using (PRINCE_STGEntities enBi = new PRINCE_STGEntities()) { using (var dbCtxTran = enBi.Database.BeginTransaction()) { //DateTime merchdate = sStoreMerch.merch_DATE; int id = pTarget.ID; //string storecode = sStoreMerch.STORE_CODE; STG_TARGET target = enBi.STG_TARGET.Find(id); if (target != null) { target.ID = pTarget.ID; target.TARGET_DATE = pTarget.TARGET_DATE; target.GEO_LEVEL1_CODE = pTarget.GEO_LEVEL1_CODE; target.GEO_LEVEL2_CODE = pTarget.GEO_LEVEL2_CODE; target.GEO_LEVEL3_CODE = pTarget.GEO_LEVEL3_CODE; target.STORE_CODE = pTarget.STORE_CODE; target.PROD_LEVEL1_CODE = pTarget.PROD_LEVEL1_CODE; target.PROD_LEVEL2_CODE = pTarget.PROD_LEVEL2_CODE; target.PROD_LEVEL3_CODE = pTarget.PROD_LEVEL3_CODE; target.PROD_LEVEL4_CODE = pTarget.PROD_LEVEL4_CODE; target.PROD_LEVEL5_CODE = pTarget.PROD_LEVEL5_CODE; target.PRODUCT_CODE = pTarget.PRODUCT_CODE; target.TARGET_SALE_QTY = pTarget.TARGET_SALE_QTY; target.TARGET_SALE_VAL_AT_PRICE = pTarget.TARGET_SALE_VAL_AT_PRICE; target.TARGET_SALE_VAL_AT_COST = pTarget.TARGET_SALE_VAL_AT_COST; target.ARC_DATE = pTarget.ARC_DATE; enBi.Entry(target).State = System.Data.Entity.EntityState.Modified; enBi.SaveChanges(); dbCtxTran.Commit(); return(Request.CreateResponse(HttpStatusCode.OK, "Target successfully Updated.")); } } } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } return(Request.CreateResponse(HttpStatusCode.OK, "Target successfully Updated.")); }
public HttpResponseMessage getUserMenuList(int pUserCode) { try { using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities()) { // List<UserMenu> menu = (from m in entPrince.UserMenu where m.UserId == pUserCode select m).ToList(); var menuList = from um in entPrince.UserMenu join m in entPrince.Menu on um.MenuId equals m.Id where um.UserId == pUserCode select new { m.Code, m.Name, m.ParentId, m.LevelNo, m.SortNo, um.CanAdd, um.CanDelete, um.CanEdit, um.CanView, um.UserId }; List <TempUserMenu> tempUserMenu = new List <TempUserMenu>(); foreach (var m in menuList) { TempUserMenu tu = new TempUserMenu(); tu.Code = m.Code; tu.Name = m.Name; tu.ParentId = m.ParentId; tu.LevelNo = m.LevelNo; tu.SortNo = m.SortNo; tu.canAdd = m.CanAdd; tu.canDelete = m.CanDelete; tu.canEdit = m.CanEdit; tu.canView = m.CanView; tu.UserId = m.UserId; tempUserMenu.Add(tu); } return(Request.CreateResponse(HttpStatusCode.OK, tempUserMenu)); } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
public static ExceptionViewModel ToMvcException(this ExceptionEntity exception) { return(new ExceptionViewModel() { Id = exception.Id, ExceptionMessage = exception.ExceptionMessage, ControllerName = exception.ControllerName, ActionName = exception.ActionName, StackTrace = exception.StackTrace, Date = exception.Date }); }
public TransList getSite(int pg, int tk, string fnd) { try { int skip = tk * (pg - 1); // skip the record TransList transList = new TransList(); using (PRINCE_STGEntities db = new PRINCE_STGEntities()) { db.Configuration.LazyLoadingEnabled = false; if (string.IsNullOrEmpty(fnd)) { List <Site> site = db.Site.AsNoTracking() .OrderBy(od => od.Description) .Skip(skip) .Take(tk) .ToList(); transList.totalCount = db.Site.AsNoTracking().Count(); transList.data = site; } else { List <Site> site = db.Site.AsNoTracking() .Where(wr => wr.Description.Contains(fnd) || wr.Status.Contains(fnd)) .OrderBy(od => od.Description) .Skip(skip) .Take(tk) .ToList(); transList.totalCount = db.Site.AsNoTracking().Where(wr => wr.Description.Contains(fnd) || wr.Status.Contains(fnd)).Count(); transList.data = site; } } return(transList); } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
public HttpResponseMessage updateStockAge(dynamic sStockAge) { try { using (PRINCE_STGEntities enBi = new PRINCE_STGEntities()) { using (var dbCtxTran = enBi.Database.BeginTransaction()) { //DateTime merchdate = sStoreMerch.merch_DATE; int id = sStockAge.ID; string bndDesc = sStockAge.PRICE_BAND_CODE; string lvlCode = sStockAge.PROD_LEVEL1_CODE; //string storecode = sStoreMerch.STORE_CODE; STG_DIM_STOCKAGE_BAND stockage = enBi.STG_DIM_STOCKAGE_BAND.Find(id, bndDesc, lvlCode); if (stockage != null) { stockage.ID = sStockAge.ID; stockage.STOCKAGE_BAND_DESC = sStockAge.PRICE_BAND_DESC; stockage.STKAGE_PROD_LEVEL1_CODE = sStockAge.PROD_LEVEL1_CODE; stockage.STOCKAGE_BAND_LOWER = sStockAge.PRICE_BAND_LOWER; stockage.STOCKAGE_BAND_UPPER = sStockAge.PRICE_BAND_UPPER; stockage.STOCKAGE_BAND_SEQ = sStockAge.STOCKAGE_BAND_SEQ; stockage.LATEST = sStockAge.LATEST; stockage.ARC_DATE = sStockAge.ARC_DATE; enBi.Entry(stockage).State = System.Data.Entity.EntityState.Modified; enBi.SaveChanges(); dbCtxTran.Commit(); return(Request.CreateResponse(HttpStatusCode.OK, "Price Band successfully Updated.")); } } } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } return(Request.CreateResponse(HttpStatusCode.OK, "Price Band successfully Updated.")); }
public HttpResponseMessage updateStore(StoreDc pStore) { try { using (PRINCE_STGEntities enBi = new PRINCE_STGEntities()) { using (var dbCtxTran = enBi.Database.BeginTransaction()) { TEMP_STORE store = enBi.TEMP_STORE.Where(wr => wr.STORE_CODE == pStore.STORE_CODE).FirstOrDefault(); if (store != null) { store.STORE_DESCRIPTION = pStore.STORE_DESCRIPTION; store.AREA_MANAGER = pStore.AREA_MANAGER; store.AREA_MANAGER_DESC = pStore.AREA_MANAGER_DESC; store.REGIONAL_MANAGER = pStore.REGIONAL_MANAGER; store.REGIONAL_MANAGER_DESC = pStore.REGIONAL_MANAGER_DESC; store.SOM = pStore.SOM; store.SOM_DESC = pStore.SOM_DESC; store.SENIOR_SOM = pStore.SENIOR_SOM; store.SENIOR_SOM_DESC = pStore.SENIOR_SOM_DESC; store.STORE_OPENING_HOUR = pStore.STORE_OPENING_HOUR; store.STORE_CLOSING_HOUR = pStore.STORE_CLOSING_HOUR; store.STORE_LATITUDE = pStore.STORE_LATITUDE; store.STORE_LONGITUDE = pStore.STORE_LONGITUDE; enBi.Entry(store).State = EntityState.Modified; enBi.SaveChanges(); dbCtxTran.Commit(); } } } } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } return(Request.CreateResponse(HttpStatusCode.OK)); }
public HttpResponseMessage saveUserMenu(List <TempUserMenu> pUser) { try { if (pUser.Count > 0) { int?userId = pUser[0].UserId; using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities()) { List <UserMenu> listUserMenu = (from um in entPrince.UserMenu where um.UserId == userId select um).ToList(); foreach (UserMenu uMenu in listUserMenu) { foreach (TempUserMenu tUmenu in pUser) { if (uMenu.Code == tUmenu.Code) { uMenu.CanAdd = tUmenu.canAdd; uMenu.CanEdit = tUmenu.canEdit; uMenu.CanDelete = tUmenu.canDelete; uMenu.CanView = tUmenu.canView; break; } } entPrince.Entry(uMenu).State = EntityState.Modified; } entPrince.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "User Access Successfully Updated!")); } } return(Request.CreateResponse(HttpStatusCode.NotModified)); } catch (DbEntityValidationException ex) { ExceptionEntity exDesc = new ExceptionEntity(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
public virtual void BuildPageModel(ref PageModel pageModel, IPage page, IEnumerable<IPage> includes, Localization localization) { using (new Tracer(pageModel, page, includes, localization)) { pageModel = CreatePageModel(page, localization); RegionModelSet regions = pageModel.Regions; // Create predefined Regions from Page Template Metadata CreatePredefinedRegions(regions, page.PageTemplate); // Create Regions/Entities from Component Presentations IConditionalEntityEvaluator conditionalEntityEvaluator = SiteConfiguration.ConditionalEntityEvaluator; foreach (IComponentPresentation cp in page.ComponentPresentations) { MvcData cpRegionMvcData = GetRegionMvcData(cp); RegionModel region; if (regions.TryGetValue(cpRegionMvcData.ViewName, out region)) { // Region already exists in Page Model; MVC data should match. if (!region.MvcData.Equals(cpRegionMvcData)) { Log.Warn("Region '{0}' is defined with conflicting MVC data: [{1}] and [{2}]. Using the former.", region.Name, region.MvcData, cpRegionMvcData); } } else { // Region does not exist in Page Model yet; create Region Model and add it. region = CreateRegionModel(cpRegionMvcData); regions.Add(region); } EntityModel entity; try { entity = ModelBuilderPipeline.CreateEntityModel(cp, localization); } catch (Exception ex) { //if there is a problem mapping the item, we replace it with an exception entity //and carry on processing - this should not cause a failure in the rendering of //the page as a whole Log.Error(ex); entity = new ExceptionEntity(ex) { MvcData = GetMvcData(cp) // TODO: The regular View won't expect an ExceptionEntity model. Should use an Exception View (?) }; } if (conditionalEntityEvaluator == null || conditionalEntityEvaluator.IncludeEntity(entity)) { region.Entities.Add(entity); } } // Create Regions from Include Pages if (includes != null) { foreach (IPage includePage in includes) { PageModel includePageModel = ModelBuilderPipeline.CreatePageModel(includePage, null, localization); // Model Include Page as Region: RegionModel includePageRegion = GetRegionFromIncludePage(includePage); RegionModel existingRegion; if (regions.TryGetValue(includePageRegion.Name, out existingRegion)) { // Region with same name already exists; merge include Page Region. existingRegion.Regions.UnionWith(includePageModel.Regions); if (existingRegion.XpmMetadata != null) { existingRegion.XpmMetadata.Remove(RegionModel.IncludedFromPageIdXpmMetadataKey); existingRegion.XpmMetadata.Remove(RegionModel.IncludedFromPageTitleXpmMetadataKey); existingRegion.XpmMetadata.Remove(RegionModel.IncludedFromPageFileNameXpmMetadataKey); } Log.Info("Merged Include Page [{0}] into Region [{1}]. Note that merged Regions can't be edited properly in XPM (yet).", includePageModel, existingRegion); } else { includePageRegion.Regions.UnionWith(includePageModel.Regions); regions.Add(includePageRegion); } #pragma warning disable 618 // Legacy WebPage.Includes support: pageModel.Includes.Add(includePage.Title, includePageModel); #pragma warning restore 618 } if (pageModel.MvcData.ViewName != "IncludePage") { pageModel.Title = ProcessPageMetadata(page, pageModel.Meta, localization); } } } }