public void EqualToDepotObject(uint id, uint other, bool expectedResult) { Depot depot = new Depot(id); Depot depot2 = new Depot(other); Assert.Equal(depot.Equals((object)depot2), expectedResult); }
public static GameObject OpenDepotWindow(Depot depot) { Window window = OpenWindowByName("Depot"); window.Contente.GetComponent <DepotWindow>().depot = depot; return(window.gameObject); }
public void ImplicitConversionFromDepot(uint id) { Depot depot = new Depot(id); uint uintDepot = depot; Assert.Equal(depot.Value, uintDepot); }
/// <summary> /// 로딩 상황 끝. 이번 세션에 로딩한 (= 이번 세션에 필요한) 리소스만 남기고 해제한다. /// </summary> public static void EndLoadingSession() { Depot oldDepot = null; s_depotDict.TryGetValue(s_tempDepotName, out oldDepot); if (oldDepot != null) { HashSet <string> removeList = new HashSet <string>(); foreach (var resname in oldDepot.m_resourceDict.Keys) { if (!s_tempDepot.m_resourceDict.ContainsKey(resname)) // 새로 로딩된 리소스 중에 없는 것은 해제한다. (해제 목록에 넣는다) { removeList.Add(resname); } } foreach (var resname in removeList) // 해제 목록을 순회 { var box = oldDepot.m_resourceDict[resname]; if (box.type != null) // 만약 로더 구현이 존재하는 경우, 리소스 언로드를 실행 { var loader = s_loader[box.type]; loader.UnloadResource(box.res); } oldDepot.m_resourceDict.Remove(resname); } } s_tempDepot = null; // 임시 저장소 해제 Resources.UnloadUnusedAssets(); }
public DvrpProblemData(string paramsPath) { DvrpFilesReader reader = new DvrpFilesReader(paramsPath); uint count = reader.NUM_VISITS; Depots = new Depot[1]; Depots[0] = new Depot(reader.DepotLocationSection[0], reader.DepotTimeWindowSection[0]); //Clients = new Client[count]; var clientsList = new List <Client>(); var nextDayClients = new List <Client>(); double cutOffTime = CutOff * Depots[0].endTime; for (int i = 0; i < count; ++i) { if (cutOffTime > reader.TimeAvailSection[i]) { clientsList.Add(new Client(reader.LocationCordSection[i + 1], reader.TimeAvailSection[i], reader.DurationSection[i], reader.Demands[i], i.ToString())); } else { clientsList.Add(new Client(reader.LocationCordSection[i + 1], 0, reader.DurationSection[i], reader.Demands[i], i.ToString())); } } Clients = clientsList.ToArray(); Fleet = new Vehicles(reader.CAPACITIES, (int)reader.NUM_VEHICLES); }
private void tsbSave_Click(object sender, EventArgs e) { Depot Depot = new Depot(); Depot.DepotGuid = txtGuid.Text; Depot.DepotName = txtDepotName.Text; Depot.DepotPerson = txtDepotPerson.Text; if (txtTelephone.Text.Trim() == "") { Depot.Telephone = "0"; } else { Depot.Telephone = txtTelephone.Text; } if (cboRemark.Checked == true) { Depot.Remark = "1"; } else { Depot.Remark = "0"; } DepotManage.Save(Depot); LoadData(); this.ShowMessage("保存成功!"); }
private static void ProcessDepotCommand(byte[] data, DepotClient client) { var group = RdlCommandGroup.FromBytes(data); foreach (var cmd in group) { if (cmd.TypeName.ToUpper().Equals("MAPNAMES")) { client.Send(Depot.GetMapNames().ToBytes()); } else if (cmd.TypeName.ToUpper().Equals("MAPCHUNK")) { var mapName = cmd.GetArg <string>(0); var startX = cmd.GetArg <int>(1); var startY = cmd.GetArg <int>(2); var includeActors = cmd.GetArg <bool>(3); var result = Depot.GetMapChunk(mapName, startX, startY, includeActors).Tags; client.Send(Encoding.UTF8.GetBytes(result)); } else { client.Send(RdlTag.Empty.ToBytes()); } } }
public static void Main(string[] args) { Logger.Factory = new ConsoleLoggerFactory(); using (var container = new WindsorContainer()) { var currentContainer = container; container.Register( Classes.FromThisAssembly().BasedOn(typeof(IConsumer)).WithServiceAllInterfaces(), Component.For <IBus>().UsingFactoryMethod(() => { var settings = new DepotSettings { ConsumerFactoryBuilder = () => new WindsorConsumerFactory(currentContainer) }; settings.AddStartupConcern(new AutoRegisterConsumers(currentContainer)); return(Depot.Connect("localhost/castle_consumer", settings)); })); var bus = container.Resolve <IBus>(); bus.Publish(new PubSubMessage { Body = "published!" }); Console.WriteLine("Finished press any key to close"); Console.ReadKey(); } }
public void ShouldSubscribeToMessageInterfacesWithCustomMessageFactory() { var serializer = new JsonMessageSerializer( new CastleMessageTypeFactory()); var depotSettings = new DepotSettings(); depotSettings.MessageSerializers.Register(serializer); using (var bus = Depot.Connect("localhost/integration", depotSettings)) { IHelloWorldMessage lastReceived = null; bus.Subscribe((IHelloWorldMessage hwm) => { lastReceived = hwm; }); bus.Publish(new HelloWorldMessage { Message = "subscribe!" }); WaitForDelivery(); Assert.That(lastReceived, Is.Not.Null); Assert.That(lastReceived.Message, Is.EqualTo("subscribe!")); Assert.That(admin.Exists(IntegrationVHost, new Queue("HelloWorldMessage")), "did not create queue"); Assert.That(admin.Exists(IntegrationVHost, new Exchange("HelloWorldMessage")), "did not create exchange"); } }
public void TestMustHaveAtLeastOneDepot() { List <Depot> depots = new List <Depot>(); var ex = Assert.Throws <BadFieldException>(() => Depot.ValidateDepots(depots)); Assert.AreEqual("You must have at least one depot", ex.Message); }
/**@}*/ #endregion #region Order comparison /*! \name Order comparison */ /**@{*/ /// <summary> /// Generic IComparable implementation (default) for comparing AcProperty objects. /// Sorts by [[depot, stream] | principal] name then property name. /// </summary> /// <param name="other">An AcProperty object to compare with this instance.</param> /// <returns>Value indicating the relative order of the AcProperty objects being compared.</returns> /*! \sa [AcProperties constructor example](@ref AcUtils#AcProperties#AcProperties) */ public int CompareTo(AcProperty other) { int result = 0; if (AcProperty.ReferenceEquals(this, other)) { result = 0; } else { if (Depot != null && other.Depot != null) { result = Depot.CompareTo(other.Depot); } if (result == 0) { result = String.Compare(Name, other.Name); } if (result == 0) { result = String.Compare(PropName, other.PropName); } } return(result); }
protected void Page_Load(object sender, EventArgs e) { intProfile = Int32.Parse(Request.Cookies["profileid"].Value); oPage = new Pages(intProfile, dsn); oPlatform = new Platforms(intProfile, dsn); oType = new Types(intProfile, dsn); oLocation = new Locations(intProfile, dsn); oAsset = new Asset(intProfile, dsnAsset); oRacks = new Racks(intProfile, dsn); oClasses = new Classes(intProfile, dsn); oRooms = new Rooms(intProfile, dsn); oFloor = new Floor(intProfile, dsn); oEnvironment = new Environments(intProfile, dsn); oDepot = new Depot(intProfile, dsn); oDepotRoom = new DepotRoom(intProfile, dsn); oShelf = new Shelf(intProfile, dsn); oUser = new Users(intProfile, dsn); if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "") { intApplication = Int32.Parse(Request.QueryString["applicationid"]); } if (Request.QueryString["pageid"] != null && Request.QueryString["pageid"] != "") { intPage = Int32.Parse(Request.QueryString["pageid"]); } if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "") { intApplication = Int32.Parse(Request.Cookies["application"].Value); } if (!IsPostBack) { if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { LoadLists(); Load(Int32.Parse(Request.QueryString["id"])); txtDate.Text = DateTime.Today.ToShortDateString(); imgDate.Attributes.Add("onclick", "return ShowCalendar('" + txtDate.ClientID + "');"); btnSubmit.Attributes.Add("onclick", "return ValidateText('" + txtAsset.ClientID + "','Please enter the asset tag')" + " && ValidateDropDown('" + ddlDepot.ClientID + "','Please make a selection for the location of the asset')" + " && ValidateText('" + txtDepotRoom.ClientID + "','Please enter the depot room')" + " && ValidateText('" + txtShelf.ClientID + "','Please enter the shelf')" + " && ValidateNumber0('" + txtPorts.ClientID + "','Please enter a valid number of available ports')" + " && ValidateHidden0('" + hdnLocation.ClientID + "','ddlState','Please select a location')" + " && ValidateText('" + txtRoom.ClientID + "','Please enter the room')" + " && ValidateText('" + txtRack.ClientID + "','Please enter the rack')" + " && ValidateText('" + txtRackPosition.ClientID + "','Please enter the rack position')" + " && ValidateDropDown('" + ddlEnvironment.ClientID + "','Please make a selection for the environment')" + " && ValidateDropDown('" + ddlClass.ClientID + "','Please make a selection for the current class')" + " && ValidateText('" + txtName.ClientID + "','Please enter the device name')" + " && ValidateNumber0('" + txtIP1.ClientID + "','Please enter a valid IP address')" + " && ValidateNumber0('" + txtIP2.ClientID + "','Please enter a valid IP address')" + " && ValidateNumber0('" + txtIP3.ClientID + "','Please enter a valid IP address')" + " && ValidateNumber0('" + txtIP4.ClientID + "','Please enter a valid IP address')" + " && ValidateDate('" + txtDate.ClientID + "','Please enter a valid date')" + ";"); ddlClass.Attributes.Add("onchange", "PopulateEnvironments('" + ddlClass.ClientID + "','" + ddlEnvironment.ClientID + "',0);"); ddlEnvironment.Attributes.Add("onchange", "UpdateDropDownHidden('" + ddlEnvironment.ClientID + "','" + hdnEnvironment.ClientID + "');"); } } }
private void LbUpdateCookie2_MouseDown(object sender, MouseButtonEventArgs e) { if (txtSessionToken.Text != "") { MessageBox.Show(Translate("ikas_will_try_to_get_cookie,_which_will_take_seconds_to_minutes_to_finish._please_do_not_close_this_window.", true), "Ikas", MessageBoxButton.OK, MessageBoxImage.Information); // DISCLAIMER if (MessageBox.Show(Translate("automatic_cookie_generation_will_send_your_session_token_to_nintendo_and_non-nintendo_servers,_which_may_lead_to_privacy_breaches._please_read_the_instructions_in_the_readme_carefully._click_yes_to_continue,_or_click_no_to_view_other_methods.", true), "Ikas", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { // Fade in loading lbOk.IsEnabled = false; bdLoading.IsHitTestVisible = true; ((Storyboard)FindResource("fade_in")).Begin(bdLoading); // Automatic Cookie Generation _ = Depot.GetCookie(txtSessionToken.Text); } else { // Browse MitM way to get Cookie System.Diagnostics.Process.Start(FileFolderUrl.MitmInstruction); } } else { MessageBox.Show(Translate("you_may_enter_a_valid_session_token_before_update_cookie.", true), "Ikas", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void LbGetSessionToken_MouseDown(object sender, MouseButtonEventArgs e) { // Stop session token timer tmSessionToken.Stop(); if (!txtSessionToken.Text.Contains("session_token_code=")) { MessageBox.Show(Translate("you_will_be_led_to_a_nintendo_website._log_in,_right_click_on_select_this_person,_copy_the_link_address,_and_then_ikas_will_try_to_get_session_token.", true), "Ikas", MessageBoxButton.OK, MessageBoxImage.Information); // Clear the clipboard Clipboard.Clear(); // Authorize string url = Depot.LogIn(); System.Diagnostics.Process.Start(url); // Start session token timer tmSessionToken.Start(); } else { MessageBox.Show(Translate("ikas_will_try_to_get_session_token,_which_will_take_seconds_to_minutes_to_finish._please_do_not_close_this_window.", true), "Ikas", MessageBoxButton.OK, MessageBoxImage.Information); // Fade in loading lbOk.IsEnabled = false; bdLoading.IsHitTestVisible = true; ((Storyboard)FindResource("fade_in")).Begin(bdLoading); // Get session token string regex = Regex.Match(txtSessionToken.Text, @"de=(.*)&").Value; Depot.GetSessionToken(regex.Substring(3, regex.Length - 4)); } }
// GET: Depots public ActionResult Index(int?id) { DepotViewModel depotViewModel = new DepotViewModel(); if (id != null) { Depot depot = depotService.GetDepotById(id); depotViewModel = new DepotViewModel() { Id = depot.Id, IsActive = depot.IsActive, Code = depot.Code, GeolocationId = depot.GeolocationId, GeolocationName = depot.Geolocation.Address, DepotTypeId = depot.DepotTypeId, DepotTypeName = depot.DepotType.Name }; } ViewBag.DepotTypeList = new SelectList(genericService.GetList <DepotType>(), "Id", "Name"); ViewBag.GeolocationList = new SelectList(geolocationService.GetGeolocationList().Select(g => new { Id = g.Id, Name = g.Address + ", " + g.City.Name }), "Id", "Name"); return(View(depotViewModel)); }
public void InequalityOperator(uint id, uint other, bool expectedResult) { Depot depot = new Depot(id); Depot depot2 = new Depot(other); Assert.Equal(depot != depot2, expectedResult); }
public void ShouldCustomizePublisherWithContentType() { var settings = new DepotSettings(); settings.MessageSerializers.Register(new MessagePackMessageSerializer()); using (var bus = Depot.Connect("localhost/integration", settings)) { HelloWorldMessage lastReceived = null; bus.Subscribe((HelloWorldMessage hwm) => { lastReceived = hwm; }); using (var publisher = bus.CreatePublisher <HelloWorldMessage>( p => p.SerializeWith("application/x-msgpack"))) { publisher.Publish(new HelloWorldMessage { Message = "subscribe!" }); WaitForDelivery(); } Assert.That(lastReceived, Is.Not.Null); Assert.That(lastReceived.Message, Is.EqualTo("subscribe!")); } }
public void ShouldHaveDefaultSerializer() { var settings = new DepotSettings { MessageSerializers = { Default = new MessagePackMessageSerializer() } }; using (var bus = Depot.Connect("localhost/integration", settings)) { HelloWorldMessage lastReceived = null; bus.Subscribe((HelloWorldMessage hwm) => { lastReceived = hwm; }); bus.Publish(new HelloWorldMessage { Message = "subscribe!" }); WaitForDelivery(); Assert.That(lastReceived, Is.Not.Null); Assert.That(lastReceived.Message, Is.EqualTo("subscribe!")); } }
public bool SellRule() { // Verkaufe, wenn RelDiff > 2. Depot depot = this.RuleEngineInfo.Depot; WorkDate today = RuleEngineInfo.Today; if (depot.Contains("dbx1da")) { if (dax_rel_diff[today] > 0) { if (depot[0].TrailingGap > 2) { depot[0].TrailingGap -= 0.2; } } if (depot[0].StopLoss > depot[0].Price) { Sell("dbx1da"); sell_events[today] = dax_rel_diff[today]; sell_events_dax[today] = dax_close[today]; return(true); } } return(false); }
public void TerminerUnCombat(ResultatCombat resultats) { Level += XpGauge.AjouterExperience(resultats.Experience); ModifierArgent(resultats.Mise); Guide.AppliquerCorrespondance(Level); Statistiques.PokemonsDebloques = Guide.IdPokemonsDebloques.Count; Statistiques.CombatsTotal++; if (resultats.Victoire) { Statistiques.CombatsGagnes++; } else { Statistiques.CombatsPerdus++; } foreach (EmplacementPokemon emplacement in Depot.Emplacements) { if (emplacement.Equipe) { int indexPokemon = Depot.IndexPokemonsEquipes[(int)emplacement.Ordre]; emplacement.Pokemon.TerminerUnCombat(resultats); Pokemon evolution = emplacement.Pokemon.Evolution.EvoluerSiAtteintLeNiveau(emplacement.Pokemon); if (evolution != null) { emplacement.Pokemon = evolution; Depot.Evolution(indexPokemon, evolution); } } } }
public void EditDepot(Depot d) { using (connect = new MySqlConnection(_connectionString)) { connect.Open(); using (MySqlTransaction transaction = connect.BeginTransaction()) { try { string query = "EditRole"; var cmd = new MySqlCommand(query, connect) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("DepotID", d.ID); cmd.Parameters.AddWithValue("DepotName", d.DepotName); cmd.Parameters.AddWithValue("FloorSpace", d.FloorSpace); cmd.Parameters.AddWithValue("NumOfVehicles", d.NumVehicles); cmd.Parameters.AddWithValue("AddressID", d.Address); cmd.Parameters.AddWithValue("DepotManager", d.ManagerID); cmd.ExecuteNonQuery(); transaction.Commit(); connect.Close(); } catch (InvalidOperationException ioException) { transaction.Rollback(); connect.Close(); } } } }
public void ShouldShutdown() { var seen = 0; using (var bus = Depot.Connect("localhost/integration")) { var subscription = bus.Subscribe((HelloWorldMessage hwm) => { Console.WriteLine("!!! Starting message"); WaitForDelivery(); ++seen; Console.WriteLine("!!! Finished message"); }, o => o.DeliverUsing <WorkerPoolDeliveryStrategy>(s => s.NumWorkers = 1)); bus.Publish(new HelloWorldMessage { Message = "subscribe!" }); WaitForDelivery(); subscription.Dispose(); } Assert.That(seen, Is.EqualTo(1)); var count = admin.Messages(IntegrationVHost, new Queue("HelloWorldMessage")).Count(); Assert.That(count, Is.EqualTo(0)); }
public void ShouldReceivedPublishedMessage() { using (var bus = Depot.Connect("localhost/integration")) { HelloWorldMessage lastReceived = null; var numReceived = 0; bus.Subscribe((HelloWorldMessage hwm) => { lastReceived = hwm; ++numReceived; }); for (var i = 0; i < 100; ++i) { bus.Publish(new HelloWorldMessage { Message = "subscribe!" }); } WaitForDelivery(); Assert.That(lastReceived, Is.Not.Null); Assert.That(lastReceived.Message, Is.EqualTo("subscribe!")); Assert.That(numReceived, Is.EqualTo(100)); } }
// GET: Musique public ActionResult Index(int GenreId) { Depot depot = new Depot(); var lc = depot.Albums.List().Where(o => o.GenreId == GenreId).ToList(); return(View(lc)); }
public void ShouldCreateSubscriberWithTaskPoolStrategy() { using (var bus = Depot.Connect("localhost/integration")) { HelloWorldMessage lastReceived = null; var numReceived = 0; var handler = new Action <HelloWorldMessage>(hwm => { lastReceived = hwm; ++numReceived; }); using (var subscription = bus.Subscribe(handler, o => o.DeliverUsing <TaskDeliveryStrategy>())) { for (var i = 0; i < 100; ++i) { bus.Publish(new HelloWorldMessage { Message = "subscribe!" }); } WaitForDelivery(); Assert.That(lastReceived, Is.Not.Null); Assert.That(lastReceived.Message, Is.EqualTo("subscribe!")); Assert.That(numReceived, Is.EqualTo(100)); Assert.That(subscription.State.Workers.Count(), Is.EqualTo(0)); } } }
public IActionResult Update(string id, [FromBody] Depot depot) { // getting Pay roll ID, Depot var depotByID = _repo.Get(id); if (depotByID == null) { return(NotFound()); } else { // convert the depot status to DbModel depot status var dbDepotStatus = helper.ConvertToDbModelStatus(depot.Status); var dbModel = new DbModels.Depot(); dbModel.StreetName = depot.StreetName; dbModel.Suburb = depot.Suburb; dbModel.PostCode = depot.PostCode; dbModel.Status = dbDepotStatus; var result = _repo.Update(id, dbModel); if (result.Equals("-1")) { return(NotFound()); } else { return(Ok(result)); } } }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here Depot x = new Depot { nom = collection["nom"], ville = collection["ville"], pays = collection["pays"], telephone = collection["telephone"], email = collection["email"], adresse = collection["adresse"], localisation = collection["localisation"], //******* codeU = collection["codeU"], date_c = DateTime.Now, //codePRODUIT = "PDT20192208" }; dao.ajouter(x); return(RedirectToAction("afficherTous")); } catch (Exception ex) { ViewBag.Erreur = ex.Message; return(View()); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Set properties for controls (1/2) Topmost = Depot.AlwaysOnTop; if (!Depot.InUse) { if (Depot.StartX != double.MinValue && Depot.StartY != double.MinValue) { Left = Depot.StartX; Top = Depot.StartY; } } Depot.CurrentMode = Depot.StartMode; // In use #if DEBUG // Do not popup in use message in Debug #else if (Depot.InUse) { MessageBox.Show(string.Format(Translate("{0}._{1}", true), Translate("ikas_has_started,_or_ikas_failed_to_exit_normally"), Translate("after_you_solve_the_problems_above,_if_this_error_message_continues_to_appear,_please_consider_submitting_the_issue.") ), "Ikas", MessageBoxButton.OK, MessageBoxImage.Warning); } #endif Depot.InUse = true; // Check cookie if (Depot.Cookie == null || Depot.Cookie == "") { MessageBox.Show(Translate("welcome_to_ikas!_to_use_ikas,_you_may_set_up_your_cookie_first.", true), "Ikas", MessageBoxButton.OK, MessageBoxImage.Information); MenuItemSettings_Click(null, null); } // Automatic schedule and shift, battle, and job update if ((Depot.Cookie != null && Depot.Cookie != "") || Depot.UseSplatoon2InkApi) { tmSchedule.Start(); tmShift.Start(); } if (Depot.Cookie != null && Depot.Cookie != "") { tmBattle.Start(); tmJob.Start(); } // Update schedule or shift switch (Depot.CurrentMode) { case Depot.Mode.regular_battle: case Depot.Mode.ranked_battle: case Depot.Mode.league_battle: Depot.ForceGetSchedule(); break; case Depot.Mode.salmon_run: Depot.ForceGetShift(); break; default: throw new ArgumentOutOfRangeException(); } }
private void FindSequenceNumberOfRoutes(List <VehicleRoute> routes, Depot depot) { foreach (var vehicleRoute in routes) { FindSequenceNumberOfSubRoutes(vehicleRoute, depot); } }
private CeplexParameters GetCeplexParametersMultipleVehicleRoutingProblem(Depot depot, List <DeliveryTruckTrip> fractionedScheduledTrips) { var ceplexParameters = new CeplexParameters(); var availablesVehicles = _vehicleRepository.GetAvailableVehiclesByDepot(depot.DepotId); ceplexParameters.QuantityOfVehiclesAvailable = availablesVehicles.Count; ceplexParameters.QuantityOfClients = fractionedScheduledTrips.Count; ceplexParameters.VehiclesGreatestPossibleDemand = 11; ceplexParameters.GreatestPossibleDemand = (int)fractionedScheduledTrips.Max(trip => trip.QuantityProduct) + 1; var numberOfPoints = fractionedScheduledTrips.Count + 1; var distancesAndDurations = GetDistancesAndDurations(depot, fractionedScheduledTrips, ceplexParameters.QuantityOfClients); ceplexParameters.Distance = distancesAndDurations.Item1; ceplexParameters.Duration = distancesAndDurations.Item2; ceplexParameters.VehicleCapacity = new int[ceplexParameters.QuantityOfVehiclesAvailable]; for (int i = 0; i < ceplexParameters.QuantityOfVehiclesAvailable; i++) { ceplexParameters.VehicleCapacity[i] = 10; } ceplexParameters.ClientsDemand = new double[ceplexParameters.QuantityOfClients]; for (int i = 0; i < ceplexParameters.QuantityOfClients; i++) { ceplexParameters.ClientsDemand[i] = fractionedScheduledTrips[i].QuantityProduct; } return(ceplexParameters); }
protected void btnCreate_Click(object sender, EventArgs e) { string name = Request.Form[txtName.ID].Trim(); string contactPerson = Request.Form[txtContactPerson.ID].Trim(); string phone = Request.Form[txtPhone.ID].Trim(); string fax = Request.Form[txtFax.ID].Trim(); string address = Request.Form[txtAddress.ID].Trim(); if (string.IsNullOrEmpty(name) || Validator.IsMatchLessThanChineseCharacter(name, NAME_LENGTH)) { lblMsg.Text = "仓库名称不能为空,并且长度不能超过 " + NAME_LENGTH + " 个字符!"; return; } if (!string.IsNullOrEmpty(contactPerson) && Validator.IsMatchLessThanChineseCharacter(contactPerson, CONTACT_PERSON_LENGTH)) { lblMsg.Text = "联系人长度不能超过 " + CONTACT_PERSON_LENGTH + " 个字符!"; return; } if (!string.IsNullOrEmpty(phone) && Validator.IsMatchLessThanChineseCharacter(phone, PHONE_LENGTH)) { lblMsg.Text = "联系电话长度不能超过 " + PHONE_LENGTH + " 个字符!"; return; } if (!string.IsNullOrEmpty(fax) && Validator.IsMatchLessThanChineseCharacter(fax, FAX_LENGTH)) { lblMsg.Text = "传真长度不能超过 " + FAX_LENGTH + " 个字符!"; return; } if (!string.IsNullOrEmpty(address) && Validator.IsMatchLessThanChineseCharacter(address, ADDRESS_LENGTH)) { lblMsg.Text = "联系地址长度不能超过 " + ADDRESS_LENGTH + " 个字符!"; return; } Depot depot = new Depot(); depot.Name = name; depot.ContactPerson = contactPerson; depot.Phone = phone; depot.Fax = fax; depot.Address = address; depot.Status = slStatus.Value == "1" ? true : false; Department depart = DepartmentOperation.GetDepartmentById(int.Parse(ddlDepartment.SelectedItem.Value)); depot.Department = depart; if (DepotOperation.CreateDepot(depot)) { lblMsg.Text = "添加成功!"; } else { lblMsg.Text = "该仓库名称已经存在!"; return; } }
/// <summary> /// Register Partial handlers /// </summary> static void RegisterPartials() { Handle.GET("/warehouse/partials/organizations/{?}/newdepot", (string urlName) => { Organization organization = Db.SQL<Organization>("SELECT o FROM Warehouse.Organization o WHERE o.UrlName=?", urlName).First; if (organization == null) { return (ushort)System.Net.HttpStatusCode.NotFound; } SystemUser user = SystemUser.GetCurrentSystemUser(); if (OrganizationPermission.Check(user, ActionType.CreateDepot, organization)) { return Db.Scope(() => { Depot depot = new Depot() { Organization = organization }; new DepotPermission() { User = user, Depot = depot }; return new NewDepotPage() { Data = depot }; }); } return (ushort)System.Net.HttpStatusCode.Forbidden; }); // Depot Handle.GET("/warehouse/partials/organizations/{?}/depots/{?}", (string orgUrlName, string urlName) => { // TODO: Check for permissions Organization organization = Db.SQL<Organization>("SELECT o FROM Warehouse.Organization o WHERE o.UrlName=?", orgUrlName).First; if (organization != null) { Depot depot = Db.SQL<Depot>("SELECT o FROM Warehouse.Depot o WHERE o.UrlName=?", urlName).First; if (depot != null) { return new DepotPage() { Data = depot }; } } return (ushort)System.Net.HttpStatusCode.NotFound; }); // Depot Settings Handle.GET("/warehouse/partials/organizations/{?}/depots/{?}/settings", (string orgUrlName, string urlName) => { SystemUser user = SystemUser.GetCurrentSystemUser(); Organization organization = Db.SQL<Organization>("SELECT o FROM Warehouse.Organization o WHERE o.UrlName=?", orgUrlName).First; if (organization != null) { Depot depot = Db.SQL<Depot>("SELECT o FROM Warehouse.Depot o WHERE o.UrlName=?", urlName).First; if (depot != null) { if (DepotPermission.Check(user, ActionType.EditDepotSettings, depot)) { return Db.Scope(() => { DepotSettingsPage page = new DepotSettingsPage(); page.Depot.Data = depot; page.Data = depot; return page; }); } return (ushort)System.Net.HttpStatusCode.Forbidden; } } return (ushort)System.Net.HttpStatusCode.NotFound; }); // Depot Members Handle.GET("/warehouse/partials/organizations/{?}/depots/{?}/members", (string orgUrlName, string urlName) => { Organization organization = Db.SQL<Organization>("SELECT o FROM Warehouse.Organization o WHERE o.UrlName=?", orgUrlName).First; if (organization != null) { Depot depot = Db.SQL<Depot>("SELECT o FROM Warehouse.Depot o WHERE o.UrlName=?", urlName).First; if (depot != null) { if (DepotPermission.Check(SystemUser.GetCurrentSystemUser(), ActionType.ManageDepotMembers, depot)) { DepotMembersPage page = new DepotMembersPage(); page.Depot.Data = depot; return page; } return (ushort)System.Net.HttpStatusCode.Forbidden; } } return (ushort)System.Net.HttpStatusCode.NotFound; }); // Add Application to depot Handle.GET("/warehouse/partials/organizations/{?}/depots/{?}/addapplication", (string orgUrlName, string UrlName) => { Depot depot = Db.SQL<Depot>("SELECT o FROM Warehouse.Depot o WHERE o.Organization.UrlName=? AND o.UrlName=?", orgUrlName, UrlName).First; if (depot != null) { if (DepotPermission.Check(SystemUser.GetCurrentSystemUser(), ActionType.AddApplication, depot)) { AddApplicationToDepotPage page = new AddApplicationToDepotPage(); page.Depot.Data = depot; page.Init(); return page; } return (ushort)System.Net.HttpStatusCode.Forbidden; } return (ushort)System.Net.HttpStatusCode.NotFound; }); }
public static void DepotAdd(this DepotEntities db, string name, Guid campusId, Guid userId, int ordinal, string defaultObjectView, string defaultObjectType, string objectTypes) { var depot = new Depot { Id = db.GlobalId(), Name = name, CampusId = campusId, Ordinal = ordinal, DefaultObjectView = defaultObjectView[0].ToString(), DefaultObjectType = defaultObjectType[0].ToString(), ObjectTypes = objectTypes, Type = DepotType.通用库, State = State.启用 }; db.Depot.Add(depot); var depotRole = new DepotRole { Id = db.GlobalId(), DepotId = depot.Id, Name = "{0}管理组".Formatted(name), Rights = "*", Ordinal = 0, State = State.内置 }; db.DepotRole.Add(depotRole); var depotUserRole = new DepotUserRole { UserId = userId, DepotRoleId = depotRole.Id }; db.DepotUserRole.Add(depotUserRole); db.SaveChanges(); }
protected void Page_Load(object sender, EventArgs e) { int id = 0; if (int.TryParse(Request.QueryString["id"], out id)) { depot = DepotOperation.GetDepotById(id); } AdminCookie cookie = (AdminCookie)RuleAuthorizationManager.GetCurrentSessionObject(Context, true); User user = UserOperation.GetUserByUsername(cookie.Username); List<Department> result = DepartmentOperation.GetDepartmentByCompanyId(user.CompanyId); if (result == null) { lblMsg.Text = "请先添加部门!"; return; } if (!IsPostBack) { ddlDepartment.DataSource = result; ddlDepartment.DataTextField = "Name"; ddlDepartment.DataValueField = "Id"; ddlDepartment.DataBind(); FormDataBind(); } }