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() }; } }
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 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 TransList getUser(int pg, int tk, string fnd) { try { int skip = tk * (pg - 1); // skip the record TransList transList = new TransList(); using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities()) { var user = (from u in entPrince.User select new { u.Id, u.Code, u.EmailAdd, u.FirstName, u.LastName, u.Status }) .OrderBy(od => od.LastName) .Skip(skip) .Take(tk) .ToList(); transList.totalCount = entPrince.User.AsNoTracking().Count(); transList.data = user; return(transList); } } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
public TransList getUserActive() { try { TransList transList = new TransList(); using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities()) { var user = (from u in entPrince.User where u.Status == "A" select new { u.Id, u.Code, u.EmailAdd, u.FirstName, u.LastName, u.Status }) .OrderBy(od => od.LastName) .ToList(); transList.totalCount = entPrince.User.AsNoTracking().Count(); transList.data = user; return(transList); } } catch (Exception ex) { ExceptionDescription exDesc = new ExceptionDescription(ex); throw new ApiException() { HttpStatus = HttpStatusCode.BadRequest, ErrorCode = (int)HttpStatusCode.BadRequest, ErrorDescription = exDesc.GetDescException() }; } }
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 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() }; } }
/// <summary> /// Converts an ExceptionDescription enum value to the description string. /// </summary> /// <param name="description">The description.</param> /// <returns><see cref="string" />.</returns> private static string GetDescription(ExceptionDescription description) { string result; switch (description) { case ExceptionDescription.PacketAsPayloadPacket: { result = "A packet cannot have itself as its payload."; break; } case ExceptionDescription.TotalLengthBelowMinimumHeaderLength: { result = "The total length is below the minimum header length."; break; } case ExceptionDescription.UrgentPointerSet: { result = "Options with the urgent pointer set are not yet implemented."; break; } default: { return(String.Empty); } } return(result); }
internal ExceptionDescription GetExceptionDescription(bool anonymous) { var oldCulture = System.Threading.Thread.CurrentThread.CurrentCulture; var oldUiCulture = System.Threading.Thread.CurrentThread.CurrentUICulture; System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; var osVersion = Environment.OSVersion; var os = string.Format("os={0};v={1};spname={2}", osVersion.Platform, osVersion.Version, osVersion.ServicePack); var exceptionDescription = new ExceptionDescription { ClrVersion = Environment.Version.ToString(), OS = os, CrashDate = DateTime.UtcNow, PCID = GetAnonymousMachineId(), Exception = ConvertToExceptionInfo(AnonymousData.Exception, anonymous), ExceptionString = anonymous ? null : AnonymousData.Exception.ToString(), }; System.Threading.Thread.CurrentThread.CurrentCulture = oldCulture; System.Threading.Thread.CurrentThread.CurrentUICulture = oldUiCulture; return(exceptionDescription); }
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 APIException createException(RESTClient client) { APIException resultException = null; ExceptionDescription exceptionDesc = null; try { var responseInJSON = JObject.Parse(client.RawResponse); var status = responseInJSON.Value <string>(DefaultAPIResponseValidator.FIELD_STATUS); if (status != null && status == DefaultAPIResponseValidator.STATUS_ERROR) { var result = responseInJSON.Value <JObject>(APIMethod.FIELD_RESULT); if (result != null) { exceptionDesc = result.ToObject <ExceptionDescription>(); resultException = createException(exceptionDesc.Exception, client, exceptionDesc.ErrorMessage, exceptionDesc.Name); } } if (resultException == null) { resultException = new APIException(client, (exceptionDesc != null ? exceptionDesc.ErrorMessage : "")); } } catch (Newtonsoft.Json.JsonReaderException) { resultException = new APIException(client, "Invalid json with error description"); } return(resultException); }
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 ErrorResponse(Exception ex, bool includeFullExceptionInfo) { Error = new ExceptionDescription(ex); if (includeFullExceptionInfo) { Error.Exception = ex; } }
//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 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 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 override bool Equals(object obj) { ExceptionDescription other = obj as ExceptionDescription; if (other == null) { return(false); } return(other.exceptionDescriptionstring == this.exceptionDescriptionstring); }
public static TestCase Dummy(string className) { LastAction lastAction = new LastAction(LastAction.LASTACTION_MARKER + "none"); ExceptionDescription exception = ExceptionDescription.NoException(); Collection <string> imports = new Collection <string>(); Collection <string> assemblies = new Collection <string>(); Collection <string> testCode = new Collection <string>(); testCode.Add("/* Source code printing failed. */"); return(new TestCase(lastAction, exception, imports, assemblies, className, testCode)); }
/// <summary> /// Create a TestCase by specifying all its components. /// </summary> public TestCase(LastAction lastAction, ExceptionDescription exception, Collection <string> imports, Collection <string> assemblies, string className, Collection <string> testCode) { this.lastAction = lastAction ?? throw new ArgumentNullException(); this.exception = exception ?? throw new ArgumentNullException(); // Imports. if (imports == null) { throw new ArgumentNullException(); } this.imports = new Collection <string>(); foreach (string s in imports) { if (s == null) { throw new ArgumentNullException(); } this.imports.Add(s); } // Referenced assemblies. refAssemblies = new Collection <RefAssembly>(); foreach (string s in assemblies) { if (s == null) { throw new ArgumentNullException(); } refAssemblies.Add(new RefAssembly(RefAssembly.REFASSEMBLY_MARKER + s)); } // Class name. if (className == null) { throw new ArgumentNullException(); } this.className = className; // Test code. if (testCode == null) { throw new ArgumentNullException(); } this.testCode = new Collection <string>(); foreach (string s in testCode) { if (s == null) { throw new ArgumentNullException(); } this.testCode.Add(s); } }
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 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 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 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 void ShouldCollectInformation() { // Given const string message = "<Message>"; const string innerMessage = "<Inner_Message>"; void Action() { void InnerAction() => throw new ArgumentException(innerMessage); try { InnerAction(); } catch (Exception e) { throw new InvalidOperationException(message, e); } } //When Exception exception = null; try { Action(); } catch (Exception e) { exception = e; } var exceptionStringDescription = new ExceptionDescription(exception).ToString(); // Then Assert.Contains(message, exceptionStringDescription, StringComparison.InvariantCultureIgnoreCase); Assert.Contains(exception.GetType().ToString(), exceptionStringDescription, StringComparison.InvariantCultureIgnoreCase); Assert.Contains(exception.StackTrace, exceptionStringDescription, StringComparison.InvariantCultureIgnoreCase); Assert.Contains(innerMessage, exceptionStringDescription, StringComparison.InvariantCultureIgnoreCase); Assert.Contains(exception.InnerException.GetType().ToString(), exceptionStringDescription, StringComparison.InvariantCultureIgnoreCase); Assert.Contains(exception.InnerException.StackTrace, exceptionStringDescription, StringComparison.InvariantCultureIgnoreCase); }
public dynamic getAllMenu() { try { using (PRINCE_STGEntities enBi = new PRINCE_STGEntities()) { int?[] arMenu = (from a in enBi.UserMenu.AsNoTracking() where a.Status == "A" select a.MenuId).ToArray(); var menu = (from a in enBi.Menu.AsNoTracking() where a.Status == "A" && arMenu.Contains(a.Id) && a.ParentId != 0 select new { a.Code, a.Name, canAdd = false, canEdit = false, canDelete = false, canView = false, a.LevelNo, a.SortNo } ).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 HttpResponseMessage addSite(dynamic pSite) { try { using (PRINCE_STGEntities dbCtx = new PRINCE_STGEntities()) { int tempSite = pSite.SiteId; String tempSiteDesc = pSite.Description; Site site = dbCtx.Site.AsNoTracking().Where(wr => wr.SiteId == tempSite).SingleOrDefault(); if (site != null) { return(Request.CreateResponse(HttpStatusCode.Conflict, "Site Id: " + tempSite.ToString() + " already exist.")); } Site objSite = new Site(); objSite.SiteId = tempSite; objSite.Description = tempSiteDesc.Trim(); objSite.Status = "A"; dbCtx.Site.Add(objSite); dbCtx.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created, "Site " + objSite.Description.Trim() + " is successfully created.")); } } 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 login(User pUser) { try { String emailAdd = pUser.EmailAdd; String password = pUser.Password; using (PRINCE_STGEntities entPrince = new PRINCE_STGEntities()) { User user = (from u in entPrince.User where u.EmailAdd == emailAdd && u.Status == "A" select u).SingleOrDefault(); if (user.Password == password) { TempUser tempUser = new TempUser(); tempUser.Id = user.Id; tempUser.Code = user.Code; tempUser.EmailAdd = user.EmailAdd; tempUser.FirstName = user.FirstName; tempUser.LastName = user.LastName; tempUser.Status = user.Status; return(Request.CreateResponse(HttpStatusCode.Accepted, tempUser)); } return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } } 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 ActionResult SaveData(List <STG_DIM_STOCKAGE_BAND> stockage) { try { bool status = false; if (ModelState.IsValid) { using (PRINCE_STGEntities enBi = new PRINCE_STGEntities()) { foreach (var i in stockage) { enBi.STG_DIM_STOCKAGE_BAND.Add(i); } enBi.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); } 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() }; } }
/// <summary> /// Writes this test case to a file. /// IMPORTANT: KEEP IN SYNC WITH TestCase(string filePath). /// </summary> public void Write(TextWriter w) { w.WriteLine(lastAction.ToString()); w.WriteLine(exception.ToString()); foreach (string s in imports) { w.WriteLine(s); } //w.WriteLine("using System.Diagnostics;"); //[email protected] added w.WriteLine("public class " + className); w.WriteLine("{"); w.WriteLine("\tpublic static int Main()"); w.WriteLine("\t{"); w.WriteLine("\t\ttry"); w.WriteLine("\t\t{"); w.WriteLine("\t\t\t" + BEGIN_TEST_MARKER); foreach (string s in testCode) { w.WriteLine("\t\t\t" + s); } w.WriteLine("\t\t\t" + END_TEST_MARKER); if (exception.IsNoException()) { w.WriteLine("\t\t\tSystem.Console.WriteLine(\"This was expected behavior. Will exit with code 100.\");"); w.WriteLine("\t\t\treturn 100;"); } else { w.WriteLine("\t\t\tSystem.Console.WriteLine(\"This was unexpected behavior (expected an exception). Will exit with code 99.\");"); w.WriteLine("\t\t\treturn 99;"); } w.WriteLine("\t\t}"); // TODO the two clauses below mean the same thing. pick one and make sure it's used throughout. if (!exception.IsNoException() && !exception.Equals(assertionViolation)) { w.WriteLine("\t\tcatch (" + exception.exceptionDescriptionstring + " e)"); w.WriteLine("\t\t{"); w.WriteLine("\t\t\tSystem.Console.WriteLine(\"" + ExceptionDescription.EXCEPTION_DESCRIPTION_MARKER + "\" + e.GetType().FullName);"); w.WriteLine("\t\t\tSystem.Console.WriteLine(\"This was expected behavior. Will exit with code 100.\");"); w.WriteLine("\t\t\treturn 100;"); w.WriteLine("\t\t}"); } if (!exception.Equals(ExceptionDescription.GetDescription(typeof(Exception)))) { w.WriteLine("\t\tcatch (System.Exception e)"); w.WriteLine("\t\t{"); w.WriteLine("\t\t\tSystem.Console.WriteLine(\"" + ExceptionDescription.EXCEPTION_DESCRIPTION_MARKER + "\" + e.GetType().FullName);"); w.WriteLine("\t\t\tSystem.Console.WriteLine(\"//STACK TRACE:\");"); w.WriteLine("\t\t\tSystem.Console.WriteLine(e.StackTrace);"); w.WriteLine("\t\t\tSystem.Console.WriteLine();"); w.WriteLine("\t\t\tSystem.Console.WriteLine(\"This was unexpected behavior. Will exit with code 99.\");"); w.WriteLine("\t\t\treturn 99;"); w.WriteLine("\t\t}"); } w.WriteLine("\t}"); w.WriteLine("}"); // Print referenced assemblies at the end // to avoid too much ugliness at top of file. foreach (RefAssembly ra in refAssemblies) { w.WriteLine(ra.ToString()); } w.Flush(); w.Close(); }
/// <summary> /// Creates a TestCase given a file. /// IMPORTANT: KEEP IN SYNC WITH TestCase.Write(). /// </summary> public TestCase(FileInfo filePath) { StreamReader reader = null; try { reader = new StreamReader(filePath.FullName); } catch (Exception e) { Enviroment.Fail("Encountered a problem when attempting to read file " + filePath + ". Exception message: " + e.Message); } string line; try { // Read lastAction. line = reader.ReadLine(); if (line == null || !line.StartsWith(LastAction.LASTACTION_MARKER)) { throw new TestCaseParseException(filePath); } line = line.Trim(); lastAction = new LastAction(line); // Read exception. line = reader.ReadLine(); if (line == null || !line.StartsWith(ExceptionDescription.EXCEPTION_DESCRIPTION_MARKER)) { throw new TestCaseParseException(filePath); } line = line.Trim(); exception = new ExceptionDescription(line); // Read imports. imports = new Collection <string>(); while (((line = reader.ReadLine()) != null) && line.Trim().StartsWith("using")) { imports.Add(line.Trim()); } // Read class name. if (line == null || !line.Trim().StartsWith("public class")) { throw new TestCaseParseException(filePath); } className = line.Trim().Substring("public class".Length); // Read open bracket (class). line = reader.ReadLine(); if (line == null || !line.Trim().Equals("{")) { throw new TestCaseParseException(filePath); } // Main method declaration line. line = reader.ReadLine(); line = line.Trim(); if (line == null || !line.StartsWith("public static int")) { throw new TestCaseParseException(filePath); } if (line == null || !line.EndsWith("()")) { throw new TestCaseParseException(filePath); } // Read open bracket (method). line = reader.ReadLine(); if (line == null || !line.Trim().Equals("{")) { throw new TestCaseParseException(filePath); } // Read "try". line = reader.ReadLine(); if (line == null || !line.Trim().Equals("try")) { throw new TestCaseParseException(filePath); } // Read open bracket (try). line = reader.ReadLine(); if (line == null || !line.Trim().Equals("{")) { throw new TestCaseParseException(filePath); } // Read testCode. testCode = new Collection <string>(); line = reader.ReadLine(); if (line == null || !line.Trim().Equals(BEGIN_TEST_MARKER)) { throw new TestCaseParseException(filePath); } while (((line = reader.ReadLine()) != null) && !line.Trim().Equals(END_TEST_MARKER)) { testCode.Add(line.Trim()); } if (line == null || !line.Trim().Equals(END_TEST_MARKER)) { throw new TestCaseParseException(filePath); } // Read test plan collections from testCode. --- [email protected] adds for sequence-based reducer testPlanCollection = new Collection <string>(); bool planStart = false; foreach (string testline in testCode) { if (testline.Trim().StartsWith("/*")) { planStart = true; continue; //skip to the next line, the beginning of plans } if ((planStart == true) && !(testline.Trim().StartsWith("*/"))) { if ((testline == null) || !testline.Trim().StartsWith("plan")) { throw new TestCaseParseException(filePath); } testPlanCollection.Add(testline.Trim()); } if (testline.Trim().StartsWith("*/")) { break; } } // Everything that remains to read are the assemblies referenced. // Read assemblies referenced. refAssemblies = new Collection <RefAssembly>(); while (((line = reader.ReadLine()) != null)) { if (line.Trim().StartsWith(RefAssembly.REFASSEMBLY_MARKER)) { refAssemblies.Add(new RefAssembly(line.Trim())); } } } finally { reader.Close(); } }
/// <summary> /// Create a TestCase by specifying all its components. /// </summary> public TestCase(LastAction lastAction, ExceptionDescription exception, Collection<string> imports, Collection<string> assemblies, string className, Collection<string> testCode) { // Last action. if (lastAction == null) throw new ArgumentNullException(); this.lastAction = lastAction; // Exception. if (exception == null) throw new ArgumentNullException(); this.exception = exception; // Imports. if (imports == null) throw new ArgumentNullException(); this.imports = new Collection<string>(); foreach (string s in imports) { if (s == null) throw new ArgumentNullException(); this.imports.Add(s); } // Referenced assemblies. this.refAssemblies = new Collection<RefAssembly>(); foreach (string s in assemblies) { if (s == null) throw new ArgumentNullException(); this.refAssemblies.Add(new RefAssembly(RefAssembly.REFASSEMBLY_MARKER + s)); } // Class name. if (className == null) throw new ArgumentNullException(); this.className = className; // Test code. if (testCode == null) throw new ArgumentNullException(); this.testCode = new Collection<string>(); foreach (string s in testCode) { if (s == null) throw new ArgumentNullException(); this.testCode.Add(s); } }
/// <summary> /// Creates a TestCase given a file. /// IMPORTANT: KEEP IN SYNC WITH TestCase.Write(). /// </summary> public TestCase(FileInfo filePath) { StreamReader reader = null; try { reader = new StreamReader(filePath.FullName); } catch (Exception e) { RandoopEnvironment.Instance.Fail("Encountered a problem when attempting to read file " + filePath + ". Exception message: " + e.Message); } string line; try { // Read lastAction. line = reader.ReadLine(); if (line == null || !line.StartsWith(LastAction.LASTACTION_MARKER)) throw new TestCaseParseException(filePath); line = line.Trim(); this.lastAction = new LastAction(line); // Read exception. line = reader.ReadLine(); if (line == null || !line.StartsWith(ExceptionDescription.EXCEPTION_DESCRIPTION_MARKER)) throw new TestCaseParseException(filePath); line = line.Trim(); this.exception = new ExceptionDescription(line); // Read imports. this.imports = new Collection<string>(); while (((line = reader.ReadLine()) != null) && line.Trim().StartsWith("using")) { this.imports.Add(line.Trim()); } // Read class name. if (line == null || !line.Trim().StartsWith("public class")) throw new TestCaseParseException(filePath); this.className = line.Trim().Substring("public class".Length); // Read open bracket (class). line = reader.ReadLine(); if (line == null || !line.Trim().Equals("{")) throw new TestCaseParseException(filePath); // Main method declaration line. line = reader.ReadLine(); line = line.Trim(); if (line == null || !line.StartsWith("public static int")) throw new TestCaseParseException(filePath); if (line == null || !line.EndsWith("()")) throw new TestCaseParseException(filePath); // Read open bracket (method). line = reader.ReadLine(); if (line == null || !line.Trim().Equals("{")) throw new TestCaseParseException(filePath); // Read "try". line = reader.ReadLine(); if (line == null || !line.Trim().Equals("try")) throw new TestCaseParseException(filePath); // Read open bracket (try). line = reader.ReadLine(); if (line == null || !line.Trim().Equals("{")) throw new TestCaseParseException(filePath); // Read testCode. this.testCode = new Collection<string>(); line = reader.ReadLine(); if (line == null || !line.Trim().Equals(BEGIN_TEST_MARKER)) throw new TestCaseParseException(filePath); while (((line = reader.ReadLine()) != null) && !line.Trim().Equals(END_TEST_MARKER)) { this.testCode.Add(line.Trim()); } if (line == null || !line.Trim().Equals(END_TEST_MARKER)) throw new TestCaseParseException(filePath); // Everything that remains to read are the assemblies referenced. // Read assemblies referenced. this.refAssemblies = new Collection<RefAssembly>(); while (((line = reader.ReadLine()) != null)) { if (line.Trim().StartsWith(RefAssembly.REFASSEMBLY_MARKER)) { this.refAssemblies.Add(new RefAssembly(line.Trim())); } } } finally { reader.Close(); } }
internal ExceptionDescription GetExceptionDescription(bool anonymous) { var oldCulture = System.Threading.Thread.CurrentThread.CurrentCulture; var oldUiCulture = System.Threading.Thread.CurrentThread.CurrentUICulture; System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; var osVersion = Environment.OSVersion; var os = string.Format("os={0};v={1};spname={2}", osVersion.Platform, osVersion.Version, osVersion.ServicePack); var exceptionDescription = new ExceptionDescription { ClrVersion = Environment.Version.ToString(), OS = os, CrashDate = DateTime.UtcNow, PCID = GetAnonymousMachineId(), Exception = ConvertToExceptionInfo(AnonymousData.Exception, anonymous), ExceptionString = anonymous ? null : AnonymousData.Exception.ToString(), }; System.Threading.Thread.CurrentThread.CurrentCulture = oldCulture; System.Threading.Thread.CurrentThread.CurrentUICulture = oldUiCulture; return exceptionDescription; }
/// <summary> /// Creates a TestCase given a file. /// IMPORTANT: KEEP IN SYNC WITH TestCase.Write(). /// </summary> public TestCase(FileInfo filePath) { StreamReader reader = null; try { reader = new StreamReader(filePath.FullName); } catch (Exception e) { Common.Enviroment.Fail("Encountered a problem when attempting to read file " + filePath + ". Exception message: " + e.Message); } string line; try { // Read lastAction. line = reader.ReadLine(); if (line == null || !line.StartsWith(LastAction.LASTACTION_MARKER)) throw new TestCaseParseException(filePath); line = line.Trim(); this.lastAction = new LastAction(line); // Read exception. line = reader.ReadLine(); if (line == null || !line.StartsWith(ExceptionDescription.EXCEPTION_DESCRIPTION_MARKER)) throw new TestCaseParseException(filePath); line = line.Trim(); this.exception = new ExceptionDescription(line); // Read imports. this.imports = new Collection<string>(); while (((line = reader.ReadLine()) != null) && line.Trim().StartsWith("using")) { this.imports.Add(line.Trim()); } // Read class name. if (line == null || !line.Trim().StartsWith("public class")) throw new TestCaseParseException(filePath); this.className = line.Trim().Substring("public class".Length); // Read open bracket (class). line = reader.ReadLine(); if (line == null || !line.Trim().Equals("{")) throw new TestCaseParseException(filePath); // Main method declaration line. line = reader.ReadLine(); line = line.Trim(); if (line == null || !line.StartsWith("public static int")) throw new TestCaseParseException(filePath); if (line == null || !line.EndsWith("()")) throw new TestCaseParseException(filePath); // Read open bracket (method). line = reader.ReadLine(); if (line == null || !line.Trim().Equals("{")) throw new TestCaseParseException(filePath); // Read "try". line = reader.ReadLine(); if (line == null || !line.Trim().Equals("try")) throw new TestCaseParseException(filePath); // Read open bracket (try). line = reader.ReadLine(); if (line == null || !line.Trim().Equals("{")) throw new TestCaseParseException(filePath); // Read testCode. this.testCode = new Collection<string>(); line = reader.ReadLine(); if (line == null || !line.Trim().Equals(BEGIN_TEST_MARKER)) throw new TestCaseParseException(filePath); while (((line = reader.ReadLine()) != null) && !line.Trim().Equals(END_TEST_MARKER)) { this.testCode.Add(line.Trim()); } if (line == null || !line.Trim().Equals(END_TEST_MARKER)) throw new TestCaseParseException(filePath); // Read test plan collections from testCode. --- [email protected] adds for sequence-based reducer this.testPlanCollection = new Collection<string>(); bool planStart = false; foreach (string testline in testCode) { if (testline.Trim().StartsWith("/*")) { planStart = true; continue; //skip to the next line, the beginning of plans } if ((planStart == true) && !(testline.Trim().StartsWith("*/"))) { if ((testline == null) || !testline.Trim().StartsWith("plan")) throw new TestCaseParseException(filePath); this.testPlanCollection.Add(testline.Trim()); } if (testline.Trim().StartsWith("*/")) break; } // Everything that remains to read are the assemblies referenced. // Read assemblies referenced. this.refAssemblies = new Collection<RefAssembly>(); while (((line = reader.ReadLine()) != null)) { if (line.Trim().StartsWith(RefAssembly.REFASSEMBLY_MARKER)) { this.refAssemblies.Add(new RefAssembly(line.Trim())); } } } finally { reader.Close(); } }