コード例 #1
0
        // GET: Internal/Details/5
        public ActionResult Details(int id)
        {
            var service = new InternalService();
            var model   = service.GetInternalById(id);

            return(View(model));
        }
コード例 #2
0
 public ResultModel GET_QUEUE_NUM([FromBody] BusinessModel param)
 {
     try
     {
         if (param == null)
         {
             return(new ResultModel {
                 StatusCode = "000003", Result = "请求错误,请检查输入参数!"
             });
         }
         // if (!PermissionCheck.CheckLevelPermission(param, _dbUserDbc))
         //// if (!PermissionCheck.Check(param))
         // {
         //     return new ResultModel { StatusCode = "000007", Result = "没有权限" };
         // }
         InputLog(param);
         // var oo = new OracleOperation();
         return(new ResultModel {
             StatusCode = "000000", BussinessModel = new BusinessModel {
                 queueNum = InternalService.GetOrdinal(param).ToString()
             }
         });
     }
     catch (Exception ex)
     {
         Log.Error("GET_QUEUE_NUM", ex);
         return(new ResultModel {
             StatusCode = "000003", Result = ex.Message
         });
     }
 }
コード例 #3
0
    /*
     *	Return service that has smallest queue and active employee
     *	Also has to match category
     */
    public InternalService GetPassengerService(string category)
    {
        InternalService service = null;

        foreach (InternalService p_service in passengerServices)
        {
            if (p_service.category == category)
            {
                if (service == null)
                {
                    service = p_service;
                }
                else if (p_service.PassengerPriority() > service.PassengerPriority())
                {
                    service = p_service;
                }
            }
        }


        if (service == null)
        {
            print("no service found for passenger at building" + this.gameObject.name);
        }

        return(service);
    }
        public void InjectProperties_InjectingPropertyInInternalClass_ThrowsExpectedExceptionMessage()
        {
            // Arrange
            string expectedMessage = "Unable to inject properties into type ";

            var container = new Container();

            container.Register <ITimeProvider, RealTimeProvider>();

            var instance = new InternalService();

            try
            {
                // Act
#pragma warning disable 618
                container.InjectProperties(instance);
#pragma warning restore 618

                Assert.Fail("Injection was expected to fail due to running in the Silverlight sandbox.");
            }
            catch (ActivationException ex)
            {
                AssertThat.StringContains(expectedMessage, ex.Message);
            }
        }
コード例 #5
0
 public void EditPassword(String oldPassword, String newPassword)
 {
     try
     {
         Person person = CurrentManager.GetPerson(View.LoggedUserId);
         if (InternalService.EditPassword(person, oldPassword, newPassword, true))
         {
             if (person.AcceptPolicy || !PolicyService.UserHasPolicyToAccept(person))
             {
                 View.LogonUser(person, InternalService.GetDefaultLogonCommunity(person), View.LoggedProviderId, RootObject.InternalLogin(false), true, CurrentManager.GetUserDefaultIdOrganization(person.Id));
             }
             else
             {
                 View.DisplayPrivacyPolicy(person.Id, View.LoggedProviderId, RootObject.InternalLogin(false), true);
             }
         }
         else
         {
             View.DisplayPasswordNotChanged();
         }
     }
     catch (lm.Comol.Core.Authentication.SamePasswordException ex)
     {
         View.DisplaySamePasswordException();
     }
     catch (lm.Comol.Core.Authentication.InvalidPasswordException ex)
     {
         View.DisplayInvalidPassword();
     }
     catch (Exception ex)
     {
         View.DisplayPasswordNotChanged();
     }
 }
コード例 #6
0
 public CommonResult GetTabulationOrdinal([FromBody] BasisRequest param)
 {
     try
     {
         if (param == null)
         {
             return(new CommonResult {
                 StatusCode = "000003", Result = "请求错误,请检查输入参数!"
             });
         }
         var today = DateTime.Now;
         return(new CommonResult
         {
             StatusCode = "000000",
             Result = string.Format("{0}{1}{2}{3}{4}", ((int)param.CountyCode).ToString("D2"),
                                    today.Year, today.Month.ToString("D2"), today.Day.ToString("D2"),
                                    InternalService.GetTabulationOrdinal(param).ToString("D4"))
         });
     }
     catch (Exception ex)
     {
         Log.Error("GetTabulationOrdinal", ex);
         return(new CommonResult {
             StatusCode = "000003", Result = ex.Message
         });
     }
 }
コード例 #7
0
        public void InitView()
        {
            Int32  idUser = View.PreloggedUserId;
            Person person = CurrentManager.GetPerson(idUser);

            if (person == null)
            {
                View.PreloggedUserId     = 0;
                View.PreloggedProviderId = 0;
                View.GotoInternalAuthenticationPage();
            }
            else if (InternalService.ExpiredPassword(person))
            {
                View.LoggedUserId     = idUser;
                View.LoggedProviderId = View.PreloggedProviderId;
                lm.Comol.Core.Authentication.InternalLoginInfo loginInfo = InternalService.GetLoginInfo(person);
                if (loginInfo != null && loginInfo.PasswordExpiresOn.HasValue && loginInfo.PasswordExpiresOn.Value < DateTime.Now)
                {
                    View.DisplayPasswordExpiredOn(loginInfo.PasswordExpiresOn.Value);
                }
                else
                {
                    View.DisplayMustChangePassword(loginInfo.ResetType);
                }
            }
            else
            {
                View.LogonUser(person, InternalService.GetDefaultLogonCommunity(person), View.PreloggedProviderId, RootObject.InternalLogin(false), true, CurrentManager.GetUserDefaultIdOrganization(idUser));
            }
        }
コード例 #8
0
ファイル: DriversController.cs プロジェクト: hedulewei/cdm
        public ResultModel DueAndChangeCertification([FromBody] BusinessModel param)
        {
            try
            {
                if (param == null)
                {
                    return(new ResultModel {
                        StatusCode = "000003", Result = "请求错误,请检查输入参数!"
                    });
                }
                if (!PermissionCheck.CheckLevelPermission(param, _dbUserDbc))
                // if (!PermissionCheck.Check(param))
                {
                    return(new ResultModel {
                        StatusCode = "000007", Result = "没有权限"
                    });
                }
                InputLog(param);

                var ret = dueAndChangeCertification(param);

                return(new ResultModel {
                    StatusCode = ret == 1 ? "000000" : "000004", BussinessModel = new BusinessModel {
                        queueNum = InternalService.GetOrdinal(param).ToString()
                    }
                });
            }
            catch (Exception ex)
            {
                Log.Error("dueAndChangeCertification", ex);
                return(new ResultModel {
                    StatusCode = "000003", Result = ex.Message
                });
            }
        }
コード例 #9
0
 public TrainingPlan WorkoutPlanOperation(Token token, WorkoutPlanOperationParam param)
 {
     return(exceptionHandling(token, () =>
     {
         return InternalService.WorkoutPlanOperation(token, param);
     }));
 }
コード例 #10
0
        /// <summary>
        /// Called when an admin report is sent.
        /// </summary>
        /// <param name="sender">The task manager reporting the event.</param>
        /// <param name="e">The event arguments.</param>
        private void adminReportHandler(Object sender, EventArgs e)
        {
            AdminReportEventArgs adminReportArgs = e as AdminReportEventArgs;

            // Now report the event.
            InternalService.OnAdminNotification(adminReportArgs.Report, adminReportArgs.SendToAll);
        }
コード例 #11
0
        // GET: Internal
        public ActionResult Index()
        {
            var service = new InternalService();
            var exList  = service.GetAllInternals();

            return(View(exList));
        }
コード例 #12
0
ファイル: MVC3RazorHelper.cs プロジェクト: dvchinh/HTQLNHCS
 public void Dispose()
 {
     InternalService.Dispose();
     if (_connection != null)
     {
         _connection.Close();
     }
 }
コード例 #13
0
ファイル: MVC3RazorHelper.cs プロジェクト: dvchinh/HTQLNHCS
        /// <summary>
        /// Return translation for inputted key
        /// By default, this function will auto detect current language and site to get the most benefit translation
        /// You can define lang_id by your own
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public virtual string T(string key, long lang_id = -1)
        {
            if (lang_id == -1 && CurrentLanguage != null)
            {
                lang_id = CurrentLanguage.Id;
            }

            return(InternalService.Language_GetTranslation(key, lang_id));
        }
コード例 #14
0
    //int canVisitCounter = 0;
    public bool CanVisit(InternalBuildingNode startNode)
    {
        // first get correct category
        string behaviourString = behaviours[currentBehaviour];

        string[] data     = behaviourString.Split(new char[] { ' ' });
        string   category = "";

        if (data.Length > 1)
        {
            category = data [1];
        }

        //Debug.Log("Category = " + category);

        // do test path
        Vector2[]            path    = null;
        InternalBuildingNode curNode = currentNode;

        currentNode = startNode;
        //p_service = building.GetService(person);
        if (employee && category == "employee")
        {
            p_service = building.GetService(person);
            path      = building.GetPathToEndNode(currentNode, p_service.GetEmployeeSpot());
        }
        else
        {
            //Debug.Log("data[0] = " + data[0]);
            if (data[0] == "queue")
            {
                p_service = building.GetPassengerService(category);
                path      = building.GetPathToEndNode(currentNode, p_service.JoinQueueNode());
                p_service = null;
            }
            else if (data[0] == "exit")
            {
//				Debug.Log("from " + curNode.name + " to " + startNode.name);
                path = building.GetPathToEndNode(curNode, startNode);                 // entrance (startNode) is destination
            }
            else
            {
                path = building.GetPathToEndNode(currentNode, category);
            }
        }

        currentNode = curNode;

        if (path == null)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
コード例 #15
0
ファイル: AdapterClient.cs プロジェクト: AEMLoviji/DPWorkouts
        public void Run()
        {
            IDateService dateService = new InternalService();

            Console.WriteLine($"Result from internal service: {dateService.GetDateTime()}");

            dateService = new ExternalServiceAdapter(new ExternalService());
            Console.WriteLine($"Result from external service: {dateService.GetDateTime()}");
        }
コード例 #16
0
        public ActionResult DeleteInternal(int id)
        {
            var service = new InternalService();

            service.DeleteInternal(id);

            TempData["SaveResult"] = "Your Internal drive entry was deleted.";
            return(RedirectToAction("Index"));
        }
コード例 #17
0
        // GET: Internal/Delete/5
        public ActionResult Delete(int id)
        {
            var service = new InternalService();
            var model   = service.GetInternalById(id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
コード例 #18
0
        public ActionResult Create(InternalCreate ex)
        {
            var service = new InternalService();

            if (ModelState.IsValid)
            {
                service.CreateInternal(ex);
                return(RedirectToAction("Index"));
            }
            return(View(ex));
        }
コード例 #19
0
        public void CreateProfile(dtoBaseProfile profile, Int32 idProfileType, String ProfileName, Int32 idOrganization)
        {
            List <ProfilerError> errors = InternalService.VerifyProfileInfo(profile);

            if (errors.Count == 0)
            {
                InternalAuthenticationProvider provider = InternalService.GetActiveProvider();
                ProfileSubscriptionMessage     message  = View.CreateProfile(profile, idProfileType, ProfileName, idOrganization, AuthenticationProviderType.Internal, (provider == null) ? (long)0 : provider.Id);
                Int32 idPerson = View.IdProfile;
                if (idPerson > 0)
                {
                    PolicyService.SaveUserSelection(CurrentManager.GetPerson(idPerson), View.GetPolicyInfo);
                }
                if (message == ProfileSubscriptionMessage.CreatedWithAutoLogon && idPerson > 0)
                {
                    Person person = CurrentManager.GetPerson(View.IdProfile);
                    View.LogonUser(person, provider.Id, lm.Comol.Core.BaseModules.AuthenticationManagement.RootObject.InternalLogin(false), true, CurrentManager.GetUserDefaultIdOrganization(idPerson));
                }
                else
                {
                    if (message == ProfileSubscriptionMessage.CreatedWithAutoLogon)
                    {
                        message = ProfileSubscriptionMessage.Created;
                    }
                    View.LoadRegistrationMessage(message);
                }
            }
            else
            {
                if (errors.Contains(ProfilerError.loginduplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.LoginDuplicated);
                }
                else if (errors.Contains(ProfilerError.mailDuplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.MailDuplicated);
                }
                else if (errors.Contains(ProfilerError.taxCodeDuplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.TaxCodeDuplicated);
                }
                else if (errors.Contains(ProfilerError.uniqueIDduplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.MatriculaDuplicated);
                }
                else
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.UnknownError);
                }
            }
        }
コード例 #20
0
        static private void Save(IDockContent form)
        {
            if (form is BaseEditViewForm)
            {
                BaseEditViewForm view = (BaseEditViewForm)form;
                if (view.IsModified)
                {
                    view.Save();

                    ///两个文件触发这个事件,还有个地方是EditView.cs
                    InternalService.OnWorkDocumentSaved(
                        new WorkDocumentEventArgs(view.WorkDocumentType, view.Id));
                }
            }
        }
コード例 #21
0
        private void MoveFromStepProfileUserData()
        {
            View.SaveUserPassword();
            List <ProfilerError> errors = InternalService.VerifyProfileInfo(View.ProfileInfo, View.SelectedProviderId, View.GetExternalCredentials);

            if (errors.Count > 0)
            {
                View.LoadProfileInfoError(errors);
            }
            else
            {
                View.UnloadProfileInfoError();
                View.GotoStep(ProfileWizardStep.Summary);
            }
        }
コード例 #22
0
        public virtual ActionResult Detail(string slug)
        {
            var result = InternalService.GetObject(slug, CanSeeUnpublished);

            if (result.Status == ResultStatus.NotFound)
            {
                return(HttpNotFound());
            }

            if (result.Status == ResultStatus.MustRedirect)
            {
                return(RedirectToActionPermanent("Detail", new { result.Object.Slug }));
            }

            return(View(GenerateDetailViewModel(result)));
        }
コード例 #23
0
    /*
     *	EmployeeController assigns employee
     */
    public void AssignEmployee(Employee employee)
    {
        //print("assigning employee");
        InternalService highestPriority = null;

        foreach (InternalService p_service in passengerServices)
        {
            if (!p_service.HasPerson(employee))             // make sure it hasn't been assigned yet to this service
            {
                if (!p_service.HasEmployee())
                {
                    p_service.AssignEmployee(employee);
                    return;
                }
            }
        }
    }
コード例 #24
0
        public void CreateProfile(dtoBaseProfile profile, Int32 idProfileType, String ProfileName, Int32 idOrganization)
        {
            List <ProfilerError> errors = InternalService.VerifyProfileInfo(profile);

            if (errors.Count == 0)
            {
                ProfileSubscriptionMessage message = View.CreateProfile(profile, idProfileType, ProfileName, idOrganization, View.OtherSelectedOrganizationId, GetAuthenticationProvider(View.SelectedProviderId), View.GetExternalCredentials);
                Int32  idPerson = View.IdProfile;
                Person person   = CurrentManager.GetPerson(idPerson);
                if (idPerson > 0 && person != null)
                {
                    View.LoadProfiles(person);
                }
                else
                {
                    View.LoadRegistrationMessage(message);
                }
            }
            else
            {
                if (errors.Contains(ProfilerError.loginduplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.LoginDuplicated);
                }
                else if (errors.Contains(ProfilerError.mailDuplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.MailDuplicated);
                }
                else if (errors.Contains(ProfilerError.taxCodeDuplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.TaxCodeDuplicated);
                }
                else if (errors.Contains(ProfilerError.uniqueIDduplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.MatriculaDuplicated);
                }
                else if (errors.Contains(ProfilerError.externalUniqueIDduplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.externalUniqueIDduplicate);
                }
                else
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.UnknownError);
                }
            }
        }
コード例 #25
0
        public virtual ActionResult Index()
        {
            int p;

            int.TryParse(Request.QueryString["p"] ?? "1", out p);

            var result = IsListPaging
                ? InternalService.GetAll(ListPageSize, p)
                : InternalService.GetAll();

            if (IsListPaging && Request.IsAjaxRequest())
            {
                return(PartialView("IndexPartial", GenerateListViewModel(result, p)));
            }

            return(View(GenerateListViewModel(result, p)));
        }
コード例 #26
0
        // GET: Internal/Edit/5
        public ActionResult Edit(int id)
        {
            var service = new InternalService();
            var detail  = service.GetInternalById(id);
            var model   = new InternalEdit
            {
                Id           = detail.Id,
                Name         = detail.Name,
                Manufacturer = detail.Manufacturer,
                Capacity     = detail.Capacity,
                Interface    = detail.Interface,
                Type         = detail.Type,
                FormFactor   = detail.FormFactor,
                NVME         = detail.NVME,
                IsAvailable  = detail.IsAvailable
            };

            return(View(model));
        }
コード例 #27
0
        public ActionResult Edit(int id, InternalEdit model)
        {
            if (model.Id != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = new InternalService();

            if (service.UpdateInternal(model))
            {
                TempData["SaveResult"] = "Your Internal drive information was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your Internal drive information could not be updated.");
            return(View());
        }
コード例 #28
0
        void MainDockPanel_ActiveDocumentChanged(object sender, EventArgs e)
        {
            ///设置Service.Workbench里的值
            if (this.ActiveView == null)
            {
                InternalService.SetActiveWorkDocument(WorkDocumentType.None, "", null);
            }
            else
            {
                InternalService.SetActiveWorkDocument(this.ActiveView.WorkDocumentType, this.ActiveView.Id, this.ActiveView);
            }

            ///触发Service.Workbench的ActiveWorkDocumentChanged事件
            InternalService.OnActiveWorkDocumentChanged(new EventArgs <Form>(this.ActiveView));

            ///处理属性面板
            MainPropertyPad.RefreshAutoPanel();

            ///处理预览服务器
            MainPreviewPad.RefreshWebBrowser();
        }
コード例 #29
0
        private void MoveFromStepInternalCredentials()
        {
            dtoInternalCredentials credentials = View.GetInternalCredentials;
            InternalLoginInfo      info        = InternalService.GetAuthenticatedUser(credentials.Login, credentials.Password);

            if (info == null || info.Person == null)
            {
                View.DisplayInvalidCredentials();
            }
            else
            {
                UrlAuthenticationProvider provider = GetProvider();
                if (provider == null)
                {
                    View.DisplayInternalCredentialsMessage(ProfileSubscriptionMessage.ProviderUnknown);
                }
                else
                {
                    ExternalLoginInfo account = UrlService.AddFromInternalAccount(info, provider, View.UrlIdentifierValue);
                    if (account == null)
                    {
                        View.DisplayInternalCredentialsMessage(ProfileSubscriptionMessage.UnableToConnectToInternalProvider);
                    }
                    else if (account != null && account.Person.isDisabled)
                    {
                        View.LoadRegistrationMessage(ProfileSubscriptionMessage.AccountDisabled);
                    }
                    else if (PolicyService.UserHasPolicyToAccept(account.Person))
                    {
                        View.IdProfile = account.Person.Id;
                        InternalService.UpdateUserAccessTime(account.Person);
                        View.DisplayPrivacyPolicy(account.Person.Id, provider.Id, provider.RemoteLoginUrl, false);
                    }
                    else
                    {
                        View.LogonUser(account.Person, View.idProvider, provider.RemoteLoginUrl, false, CurrentManager.GetUserDefaultIdOrganization(account.Person.Id));
                    }
                }
            }
        }
コード例 #30
0
    Vector2[] Visit(string category, bool nodeAvailable)
    {
        Vector2[] path;

        if (employee && category == "employee")
        {
            p_service = building.GetService(person);
            path      = building.GetPathToEndNode(currentNode, p_service.GetEmployeeSpot());
        }
        else
        {
            path = building.GetPathToEndNode(currentNode, category);
        }

        person.VisitPosition(path);

        // set currentNode to next node
        currentNode           = building.GetEndNode(path[0]);
        currentNode.available = nodeAvailable;

        return(path);
    }
コード例 #31
0
    /*
     *	Only do this when building is created!
     */
    void SetupNodes()
    {
        BuildingNode node;
        List<BuildingNode> tempNodes = new List<BuildingNode>();
        List<PassengerServiceFactory> tempPassengerServices = new List<PassengerServiceFactory>();

        // add edge nodes to temp list
        foreach(Transform child in edgeNodeParent.transform) {
            node = child.gameObject.GetComponent<BuildingNode>();
            tempNodes.Add(node);

            // also add passenger service if it exists
            PassengerServiceFactory p_service = child.gameObject.GetComponent<PassengerServiceFactory>();
            if (p_service != null) {
                tempPassengerServices.Add(p_service);
            }
        }

        // add connecting nodes to temp list, and set up edge node connections
        foreach(Transform child in connectingParent.transform) {
            node = child.gameObject.GetComponent<BuildingNode>();
            node.SetupAutoConnection();
            node.SetupEdgeNodeConnections();
            tempNodes.Add(node);
        }

        // for each building node, create internal node to replace old one
        foreach(BuildingNode bNode in tempNodes) {
            bNode.internalNode = new InternalBuildingNode(bNode, this.transform.position,
                                        bNode.transform.position, bNode.door, bNode.gameObject.name);
        }

        // loop last time to add internal node connections, and add to final list
        foreach(BuildingNode bNode in tempNodes) {
            bNode.internalNode.nodeConnections = bNode.GetInternalConnections();
            internalNodes.Add(bNode.internalNode);

            if (bNode.edgeNode)
                edgeNodes.Add(bNode.internalNode);
            if (bNode.entrance)
                entrances.Add(bNode.internalNode);

        }

        // also convert passengerService references to internal
        foreach(PassengerServiceFactory p_service in tempPassengerServices) {
            InternalService new_service = new InternalService(p_service);
            passengerServices.Add(new_service);
        }

        // destroy gameObjects
        DestroyOldGameObjects();
    }
コード例 #32
0
    //int canVisitCounter = 0;
    public bool CanVisit(InternalBuildingNode startNode)
    {
        // first get correct category
        string behaviourString = behaviours[currentBehaviour];
        string[] data = behaviourString.Split(new char[] {' '});
        string category = "";
        if (data.Length > 1)
            category = data [1];

        //Debug.Log("Category = " + category);

        // do test path
        Vector2[] path = null;
        InternalBuildingNode curNode = currentNode;
        currentNode = startNode;
        //p_service = building.GetService(person);
        if (employee && category == "employee") {
            p_service = building.GetService(person);
            path = building.GetPathToEndNode(currentNode, p_service.GetEmployeeSpot());
        } else {
            //Debug.Log("data[0] = " + data[0]);
            if (data[0] == "queue") {
                p_service = building.GetPassengerService(category);
                path = building.GetPathToEndNode(currentNode, p_service.JoinQueueNode());
                p_service = null;

            } else if (data[0] == "exit") {
        //				Debug.Log("from " + curNode.name + " to " + startNode.name);
                path = building.GetPathToEndNode(curNode, startNode); // entrance (startNode) is destination

            } else {
                path = building.GetPathToEndNode(currentNode, category);
            }
        }

        currentNode = curNode;

        if (path == null)
            return false;
        else
            return true;
    }
コード例 #33
0
    Vector2[] Visit(string category, bool nodeAvailable)
    {
        Vector2[] path;

        if (employee && category == "employee") {
            p_service = building.GetService(person);
            path = building.GetPathToEndNode(currentNode, p_service.GetEmployeeSpot());
        } else {
            path = building.GetPathToEndNode(currentNode, category);
        }

        person.VisitPosition(path);

        // set currentNode to next node
        currentNode = building.GetEndNode(path[0]);
        currentNode.available = nodeAvailable;

        return path;
    }
コード例 #34
0
    public bool ExecuteBehaviour()
    {
        if (currentBehaviour >= behaviours.Length) {
            return false;
        }

        string behaviourString = behaviours[currentBehaviour];
        string[] data = behaviourString.Split(new char[] {' '});
        //Debug.Log("executing behaviour number: " + currentBehaviour);

        if (data[0] == "visit") { // eg. visit sink
            bool nodeAvailability = false; // will this edge node be available (for others) when visiting?
            if (data.Length > 2) { // eg. visit sink door    or    visit toilet door 2
                if (data[2] == "door") {
                    Vector2[] path = Visit(data[1]); // get current node and path
                    path[0] = new Vector2(currentNode.door.transform.position.x,
                                          currentNode.door.transform.position.z);
                    person.VisitPosition(path);

                    // differentiate between single pass through door or double pass
                    if (data.Length > 3)
                        doubleDoor = true;
                    //else
                    //	doubleDoor = false;

                    if (door == null)
                        door = currentNode.door;

                    currentTask = data[2]; // current task = door
                    return true;
                } else if (data[2] == "available")
                    nodeAvailability = true;
            }
            Visit(data[1], nodeAvailability);

        } else if (data[0] == "wait") { // eg. wait 10-15 or wait 12
            // if unlimited waiting (wait for )
            if (data.Length == 1) {
                currentTask = "wait infinite";
                return true;
            } else {
                string[] waitTime = data[1].Split(new char[] {'-'});
                if (waitTime.Length == 1)
                    Wait(int.Parse(waitTime[0]));
                else if (waitTime.Length > 1)
                    Wait(Random.Range(int.Parse(waitTime[0]), int.Parse(waitTime[1])));
                else
                    Debug.Log("PROBLEM - Don't understand this wait string");
            }
        } else if (data[0] == "exit") { // eg. exit
            Exit();
        } else if (data[0] == "queue") {
            if (p_service == null) {
                // setup p_service and add to queue for service
                p_service = building.GetPassengerService(data[1]);
                InternalBuildingNode endNode = p_service.JoinQueue((Passenger) person);

                // set on way
                Vector2[] path = building.GetPathToEndNode(currentNode, endNode);
                person.VisitPosition(path);
                currentNode = endNode;

                currentTask = "visitQueue";
                return true;
            } else if (currentTask == "visitQueue") {
                finalPosition = p_service.GetQueuePosition((Passenger) person);
                person.VisitPosition(finalPosition);
                currentTask = "enteringQueue";
                return true;
            } else if (currentTask == "enteringQueue") {
                // waiting in queue
            } else {
                Debug.Log("waiting in queue, currentTask = " + currentTask);
                return true;
            }
        } else if (data[0] == "plane") { // go the airplane and enter
            Passenger passenger = (Passenger) person;
            passenger.EnterAirplane();
        } else {

            Debug.Log("can't find this command: " + data[0]);
        }

        doubleDoor = false;
        currentTask = data[0];
        //currentBehaviour++;

        return true;
    }