public static ReturnValue<DataTable> GetData(FactoryEnum factory, string key, Dictionary<string, string> parameters = null) { var rv = new ReturnValue<DataTable>(); if (parameters == null) parameters = new Dictionary<string, string>(); SqlExecuteService.StatementResult sr; try { sr = ServiceClient.GetStatement(factory.ToString(), key, AF.Environment.AccessToken); if (!sr.Result) { rv.Result = false; rv.Message = sr.Message; return rv; } } catch (Exception ex) { rv.Result = false; rv.Message = ex.Message; return rv; } List<SqlParameter> sp = new List<SqlParameter>(); if (parameters.Count > 0) { foreach (var kv in parameters) sp.Add(new SqlParameter(kv.Key, kv.Value)); } return DB.ExecuteDataTable(sr.ConnectionString, sr.Statements, sp.ToArray()); }
public static void Main() { FactoryEnum selectedFactory = (FactoryEnum)Enum.Parse(typeof(FactoryEnum), Console.ReadLine()); IVehicleFactory factory = GetFactory(selectedFactory); ICar car = factory.GetCar(); Console.WriteLine(car.Type()); ITruck truck = factory.GetTruck(); Console.WriteLine(truck.Type()); }
public PageBox GetLocaTions(FactoryEnum locastate, string isdelete, string currentpage, string companyname, string locanumber, string factoryname1, string factoryname2) { if (currentpage == null) { currentpage = "1"; } var rolelist = localionServices.GetLocations(); if (locastate != 0) { rolelist = rolelist.Where(n => n.LocaState.Equals(locastate)).ToList(); } if (isdelete != null) { if (isdelete == "true") { isdelete = "1"; } else { isdelete = "0"; } rolelist = rolelist.Where(n => n.IsDelete.Equals(Convert.ToInt32(isdelete))).ToList(); } if (companyname != null) { rolelist = rolelist.Where(n => n.CompanyName.Contains(companyname)).ToList(); } if (locanumber != null) { rolelist = rolelist.Where(n => n.LocaNumber.Contains(locanumber)).ToList(); } if (factoryname1 != null) { rolelist = rolelist.Where(n => n.FactoryName1.Contains(factoryname1)).ToList(); } if (factoryname2 != null) { rolelist = rolelist.Where(n => n.FactoryName2.Contains(factoryname2)).ToList(); } int totlepage = rolelist.Count / 3 + (rolelist.Count % 3 == 0 ? 0 : 1); rolelist = rolelist.Skip((int.Parse(currentpage) - 1) * 3).Take(3).ToList(); PageBox pagebox = new PageBox(); pagebox.PageIndex = int.Parse(currentpage); pagebox.PageCount = totlepage; pagebox.Data = rolelist; return(pagebox); }
public static TaskMonitorBaseFactory CreateFactory(FactoryEnum factoryEnum) { switch (factoryEnum) { case FactoryEnum.FileDownloadFactory: return(TaskMonitorFileDownloadFactory.TaskMonitorFileDownloadFactoryInstance); case FactoryEnum.FileUploadFactory: return(TaskMonitorFileUploadFactory.TaskMonitorFileUploadFactoryInstance); default: throw new NotImplementedException(); } }
public static ReturnValue <DataTable> GetData(FactoryEnum factory, string key, Dictionary <string, string> parameters = null) { var rv = new ReturnValue <DataTable>(); if (parameters == null) { parameters = new Dictionary <string, string>(); } SqlExecuteService.StatementResult sr; try { sr = ServiceClient.GetStatement(factory.ToString(), key, AF.Environment.AccessToken); if (!sr.Result) { rv.Result = false; rv.Message = sr.Message; return(rv); } } catch (Exception ex) { rv.Result = false; rv.Message = ex.Message; return(rv); } List <SqlParameter> sp = new List <SqlParameter>(); if (parameters.Count > 0) { foreach (var kv in parameters) { sp.Add(new SqlParameter(kv.Key, kv.Value)); } } return(DB.ExecuteDataTable(sr.ConnectionString, sr.Statements, sp.ToArray())); }
public PageBox GetFacility(FactoryEnum IsSiren, string BitNumbers, string CompanyName, string FactoryName, string TypeName, string FacilityNumber, int PageIndex = 1) { List <FacilityNotMapp> facilitylist = FacilityServices.GetFacility(); if (IsSiren != 0) { facilitylist = facilitylist.Where(n => n.IsSiren.Equals(IsSiren)).ToList(); } if (FacilityNumber != null) { facilitylist = facilitylist.Where(n => n.FacilityNumber.Equals(FacilityNumber)).ToList(); } if (BitNumbers != null) { facilitylist = facilitylist.Where(n => n.BitNumbers.Equals(BitNumbers)).ToList(); } if (CompanyName != null) { facilitylist = facilitylist.Where(n => n.CompanyName.Equals(CompanyName)).ToList(); } if (FactoryName != null) { facilitylist = facilitylist.Where(n => n.FactoryName.Equals(FactoryName)).ToList(); } if (TypeName != null) { facilitylist = facilitylist.Where(n => n.TypeName.Equals(TypeName)).ToList(); } PageBox pageBox = new PageBox(); pageBox.PageIndex = PageIndex; pageBox.PageSize = PAGESIZE; pageBox.PageCount = facilitylist.Count / PAGESIZE + (facilitylist.Count % PAGESIZE == 0 ? 0 : 1); pageBox.Data = facilitylist.Skip((PageIndex - 1) * PAGESIZE).Take(PAGESIZE); return(pageBox); }
private static IVehicleFactory GetFactory(FactoryEnum selectedFactory) => selectedFactory switch {