상속: MonoBehaviour, IBuilding, IWorkplace
        public static void InitWorkplaceAndPersonnel()
        {
            using (var db = new EngineContext())
            {
                foreach (var workplacePersonnel in
                         db.WorkplacePersonnels.Where(p2 => p2.Username == "admin"))
                {
                    db.Entry(workplacePersonnel).State = EntityState.Deleted;
                }


                var p = new Personnel();
                p.Name      = "علی ";
                p.LastName  = "قربانزاده";
                p.WorkGroup = new WorkGroup();
                db.Personnels.Add(p);
                db.SaveChanges();


                var wp = new Workplace
                {
                    Name = "دفتر کار",
                    IsNotificationsEnabled = true,
                    oneDeviceEnabled       = true,
                };

                wp.UserClockTypes.Add(new UserClockTypeViewModel
                {
                    order = 0,
                    type  = ClockType.Wifi,
                });
                wp.UserClockTypes.Add(new UserClockTypeViewModel
                {
                    order = 1,
                    type  = ClockType.CameraSelfie,
                });
                wp.UserClockTypes.Add(new UserClockTypeViewModel
                {
                    order = 2,
                    type  = ClockType.GPS,
                });
                wp.UserClockTypes.Add(new UserClockTypeViewModel
                {
                    order = 3,
                    type  = ClockType.QRCode,
                });

                wp.WorkplacePersonnels.Add(new WorkplacePersonnel
                {
                    Name        = "",
                    PersonnelId = p.Id,
                    Username    = "******",
                    Password    = "******",
                    IsAdmin     = true,
                });

                db.Workplaces.Add(wp);
                db.SaveChanges();
            }
        }
예제 #2
0
        public ActionResult Create(Workplace model)
        {
            ResultModel result = new ResultModel();

            try
            {
                #region 驗證Model
                if (!ModelState.IsValid)
                {
                    throw new Exception(ModelStateErrorClass.FormatToString(ModelState));
                }
                #endregion

                #region 前端資料變後端用資料ViewModel時用

                #endregion

                #region Service資料庫
                this._workplaceService.Create(model);
                #endregion

                #region  息頁面設定
                result.Status  = true;
                result.Message = "MessageComplete".ToLocalized();
                #endregion
            }
            catch (Exception ex)
            {
                #region  錯誤時錯誤訊息
                result.Status  = false;
                result.Message = ex.Message.ToString();
                #endregion
            }
            return(Json(result));
        }
예제 #3
0
        public List <Workplace> FindWorkplaces(Workplace ww)
        {
            AbstractGenericOperation ado = new FindWorkplaces();
            List <Workplace>         w   = (List <Workplace>)ado.ExecuteSO(ww);

            return(w);
        }
예제 #4
0
        public bool UpdateWorkplace(Workplace w)
        {
            AbstractGenericOperation ado = new UpdateWorkplace();
            bool success = (bool)ado.ExecuteSO(w);

            return(success);
        }
예제 #5
0
        public Task <Response> Do(Request request) =>
        TryCatch(async() => {
            var workplaceExists = await WorkplaceExists(request.Name);

            if (workplaceExists)
            {
                return(new Response {
                    Message = $"{request.Name} already exists",
                    Status = false
                });
            }

            var workplace = new Workplace
            {
                Name = request.Name
            };

            ValidateWorkplaceOnCreate(workplace);

            _ctx.Workplaces.Add(workplace);
            await _ctx.SaveChangesAsync();

            return(new Response {
                Message = $"Success {request.Name} is added",
                Status = true
            });
        });
예제 #6
0
        public async Task <IActionResult> PutWorkplace(long id, Workplace workplace)
        {
            if (id != workplace.Id)
            {
                return(BadRequest());
            }

            _context.Entry(workplace).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkplaceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #7
0
        public void Create(WorkplaceOrder workplaceOrder)
        {
            Workplace workplace = sheringDBContext.Workplace.FirstOrDefault(e => e.Id == workplaceOrder.WorkplaceId);

            sheringDBContext.WorkplaceOrder.Add(workplaceOrder);
            sheringDBContext.SaveChanges();
        }
예제 #8
0
        public void retrieveWorkplaces(int inUserID)
        {
            Array.Resize(ref lstCurWorkplaces, 0);
            //replace 1 with the variable for the currently selected user
            SQL_Connection_Functions.retrieveWorkplaces(inUserID);
            DataTable dt = new DataTable();

            SQL_Connection_Functions.sqlDA.Fill(dt);
            int curWorkplace = 0;

            foreach (DataRow row in dt.Rows)
            {
                Array.Resize(ref lstCurWorkplaces, lstCurWorkplaces.Length + 1);
                int    userID    = row.Field <int>(0);
                string placename = row.Field <string>(1);
                string startTime = row.Field <string>(2);
                string endTime   = row.Field <string>(3);
                lstCurWorkplaces[curWorkplace] = new Workplace(userID, placename, startTime, endTime);
                curWorkplace++;
            }
            for (int i = 0; i < lstCurWorkplaces.Length; i++)
            {
                lstBoxWorkplaces.Items.Add(lstCurWorkplaces[i].getName());
            }
        }
예제 #9
0
        /// <summary>
        /// Queuings the tx number.
        /// </summary>
        /// <param name="txType">Type of the transactions.</param>
        /// <returns></returns>
        public static string QueuingTxNumber(RT2020.DAL.Common.Enums.TxType txType)
        {
            string queuingNumber  = DateTime.Today.Year.ToString() + txType.ToString("d").PadLeft(2, '0');
            long   queuedTxNumber = long.Parse(queuingNumber.PadRight(12, '0'));

            string    lblLastNumber = "LastTxNumber_" + txType.ToString();
            Workplace oWp           = Workplace.Load(Common.Utility.CurrentWorkplaceId);

            if (oWp != null)
            {
                WorkplaceZone oZone = WorkplaceZone.Load(oWp.ZoneId);
                if (oZone != null)
                {
                    string lastNumber = oZone.GetMetadata(lblLastNumber);
                    if (lastNumber != null)
                    {
                        if (lastNumber.Length < 12 && lastNumber.Length > 6)
                        {
                            lastNumber = lastNumber.Insert(6, "00");
                        }

                        queuedTxNumber = long.Parse(lastNumber);
                    }

                    oZone.SetMetadata(lblLastNumber, (queuedTxNumber + 1).ToString());
                    oZone.Save();
                }
            }

            return(queuedTxNumber.ToString());
        }
 private void ExecuteInsertOfWorkplace(Workplace workplaceToInsert)
 {
     InsertWorkplace(workplaceToInsert);
     //InsertThreatsOfWorklplace(workplaceToInsert);
     NotifyOfPropertyChange(() => FilteredWorkplacesByCompany);
     ShowWorkplaceAddView();
 }
예제 #11
0
        private void CreateDefaultWorkplace()
        {
            Guid      UserId           = this._sessionTasks.GetAppUserId(HttpContext);
            Workplace defaultWorkplace = DbInitializer.getDefaultWorkplace();

            _workplaceRepository.Create(HttpContext, defaultWorkplace);
        }
예제 #12
0
            public async Task <WorkplaceDto> Handle(Command request, CancellationToken cancellationToken)
            {
                var client = await _context.Clients.FindAsync(request.ClientId);

                var workplace = new Workplace
                {
                    Name             = request.Name,
                    City             = request.City,
                    Street           = request.Street,
                    IsOpen           = true,
                    Client           = client,
                    Notifications    = new List <Notification>(),
                    Workdays         = new List <Workday>(),
                    WorkdayMaterials = new List <WorkdayMaterial>(),
                };

                await _context.Workplaces.AddAsync(workplace);

                var success = await _context.SaveChangesAsync() > 0;

                if (success)
                {
                    return(_mapper.Map <Workplace, WorkplaceDto>(workplace));
                }

                throw new Exception("Problem saving changes");
            }
예제 #13
0
    public int WorkDeathRisk()
    {
        if (!Employed)
        {
            return(0);
        }

        GameObject go = world.GetBuildingAt(workNode);

        if (go == null)
        {
            return(0);
        }

        Workplace wrk = go.GetComponent <Workplace>();

        //workplace accidents only happen with physical jobs
        if (wrk.laborType != LaborType.Physical)
        {
            return(0);
        }

        int excess         = wrk.WorkingDay - 8;
        int riskFromExcess = excess > 0 ? excess : 0;           //risk from working for too many hours

        int minus            = GetLaborBonus(LaborType.Physical) * -1;
        int riskFromPhysique = minus < 0 ? (minus + 1) : 0;                //risk from having weaker physique

        int ageDiff     = yearsOld - retirementAge;
        int riskFromAge = ageDiff > 0 ? (ageDiff + 1) : 0;              //risk from being too old to work physically

        return(riskFromAge + riskFromExcess + riskFromPhysique);        //multiple total risk by 2 if this prole does not prefer physical labor
    }
예제 #14
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Name")] Workplace workplace)
        {
            if (id != workplace.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workplace);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkplaceExists(workplace.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(workplace));
        }
예제 #15
0
        /// <summary>
        ///   Attempts to close all open documents belonging to the
        ///   given Workplace. If null, all documents will be closed.
        /// </summary>
        /// <param name="workplace">The workplace owning the documents to be closed.</param>
        /// <param name="askForUnsavedChanges">Asks confirmation before closing unsaved documents.</param>
        /// <returns>Returns true if all documents were closed, false if the operation was cancelled by the user.</returns>
        public bool CloseAllDocuments(Workplace workplace, bool askForUnsavedChanges)
        {
            IDockContent[] documents = dockPanel.DocumentsToArray();

            foreach (IDockContent content in documents)
            {
                if (content is SinapseDocumentView)
                {
                    SinapseDocumentView document = content as SinapseDocumentView;
                    if (askForUnsavedChanges && document.HasChanges)
                    {
                        DialogResult r = MessageBox.Show(String.Format("Save changes to {0}?", document.Name),
                                                         "Save changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                        if (r == DialogResult.Yes)
                        {
                            document.Save();
                        }
                        else if (r == DialogResult.Cancel)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
예제 #16
0
        public void OpenDocument(String fullName, Workplace owner)
        {
            // First: verify if the document isn't already open
            IDockContent[] openDocuments = dockPanel.DocumentsToArray();

            foreach (SinapseDocumentView openDocument in openDocuments)
            {
                if (openDocument.Document != null &&
                    openDocument.Document.File.FullName == fullName)
                {
                    // The document was already open
                    openDocument.DockHandler.Show(); // Activate it
                    return;
                }
            }

            // The document wasn't open, lets open it:
            ISinapseDocument document = DocumentManager.Open(fullName);

            document.Owner = owner; // If we have an owner Workplace, set it

            // Now lets determine the adequate viewer for this document type
            Type viewerType = SinapseDocumentView.GetViewer(Utils.GetExtension(fullName, true));

            // Activate the viewer,
            SinapseDocumentView viewer = Activator.CreateInstance(viewerType, this, document) as SinapseDocumentView;

            // And then lets show the new viewer on the main window.
            viewer.DockHandler.Show(dockPanel, DockState.Document);

            mruDocuments.Insert(fullName);
        }
예제 #17
0
        public bool CloseWorkplace()
        {
            if (activeWorkplace != null)
            {
                CancelEventArgs e = new CancelEventArgs();
                this.OnActiveWorkplaceClosing(e);
                if (e.Cancel == true)
                {
                    return(false);
                }

                if (this.CloseAllDocuments(this.activeWorkplace, true))
                {
                    this.activeWorkplace = null;
                    this.OnActiveWorkplaceClosed(EventArgs.Empty);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
예제 #18
0
    private static bool FindPage(IFrameworkInputElement page, Workplace workplace)
    {
        var type = (IsThisViewCanBeUsedWithViewsSubsystemAttribute)page.GetType()
                   .GetCustomAttribute(typeof(IsThisViewCanBeUsedWithViewsSubsystemAttribute));

        return(type.Workplace == workplace);
    }
예제 #19
0
        internal string UpdateWorkplace(Workplace w)
        {
            SendRequest(w, Operation.UpdateWorkplace);
            Response r = (Response)formatter.Deserialize(stream);

            return(r.Message);
        }
예제 #20
0
        public void Update(Workplace model)
        {
            #region 取資料
            Workplace query = this.Get(model.ID_Workplace);
            #endregion

            #region 邏輯驗證
            if (query == null)//沒有資料
            {
                throw new Exception("MessageNoData".ToLocalized());
            }
            #endregion

            #region 變為Models需要之型別及邏輯資料
            query.CX_Workplace         = model.CX_Workplace;
            query.NQ_Sort              = model.NQ_Sort;
            query.CX_Workplace_Remarks = model.CX_Workplace_Remarks;
            query.CX_Color             = model.CX_Color;
            #endregion

            #region Models資料庫
            this._repository.Update(query);
            this._unitOfWork.SaveChange();
            #endregion
        }
예제 #21
0
    public override string GetCauseOfDeath()
    {
        int roll = Random.Range(1, DeathChanceFromAge + DeathChanceFromDisease + WorkDeathRisk());

        //get death message for old age
        if (roll <= DeathChanceFromAge && Retired)
        {
            return("passed away peacefully.");
        }

        //get death message for disease
        else if (roll <= (DeathChanceFromAge + DeathChanceFromDisease) && diseased)
        {
            return("died of drinking dirty water.");
        }

        //get death message for workplace accident
        else if (roll <= DeathChanceFromAge + DeathChanceFromDisease + WorkDeathRisk() && Employed)
        {
            GameObject go = world.GetBuildingAt(workNode);

            if (go == null)
            {
                Debug.LogError("Workplace at " + workNode + " for " + this + " does not exist");
            }

            Workplace wrk = go.GetComponent <Workplace>();
            return(wrk.deathDesc);
        }

        return("died mysteriously.");
    }
예제 #22
0
    public void PlayerToggleLabor(bool b)
    {
        Workplace wp = (Workplace)obj;

        wp.ClosedByPlayer = !b;
        wp.ToggleLabor(b);
    }
예제 #23
0
        public async Task <Response <WorkplaceResponse> > UpdateAsync(Workplace target)
        {
            //Get current workplace
            var workplace = await workplaceRepository.GetAsync(target.WorkspaceGuid);

            if (workplace == null)
            {
                return(new Response <WorkplaceResponse>(
                           HttpStatusCode.NotFound,
                           $"Workplace with guid '{target.WorkspaceGuid}' was not found."));
            }

            var employeeResponse = await userServiceClient.GetUserAsync(
                new GetUserRequest()
            {
                UserGuid = target.UserGuid
            });

            if (employeeResponse.Status == ResponseResult.Error)
            {
                return(new Response <WorkplaceResponse>(
                           employeeResponse.Error.StatusCode, employeeResponse.Error.Message));
            }

            workplace.EmployeeId = employeeResponse.Result.Employee.EmployeeId;
            workplace.Map        = automapper.Map <DbMapFile>(workplace.Map);
            var result = workplaceRepository.UpdateAsync(workplace).Result;

            var response = new Response <WorkplaceResponse>(automapper.Map <WorkplaceResponse>(result));

            return(response);
        }
예제 #24
0
 public static void SaveToXml(this Workplace workplace, string fileName)
 {
     using (var writer = XmlWriter.Create(fileName, XmlIO.SimManningXmlWriterSettings))
     {
         workplace.SaveToXml(writer);
     }
 }
예제 #25
0
        static void Main(string[] args)
        {
            Workplace w = new Workplace(Mode.Towers);

            w.Draw();
            w.Update();
        }
            public TestEnvironment()
            {
                // TODO: REMOVE if not needed anymore
                // add some test values

                wp = new Workplace()
                {
                    name = "Gentlymad"
                };

                emp = new Employee()
                {
                    name     = "Tom",
                    worplace = wp,
                    age      = 41,
                    speed    = 0.95f
                };

                emp2 = new Employee()
                {
                    name     = "Wolfgang",
                    worplace = wp,
                    age      = 50,
                    speed    = 0.5f
                };

                wp.employees.Add(emp);
                wp.employees.Add(emp2);
            }
예제 #27
0
        public void Delete(Workplace model)
        {
            #region 取資料
            Model.Workplace query = this.Get(model.ID_Workplace);
            //var queryoverseastaff = this._overseaService.GetForOverType(query.ID_OverType);
            #endregion

            #region 邏輯驗證
            if (query == null)//沒有資料
            {
                throw new Exception("MessageNoData".ToLocalized());
            }

            //驗證
            //if (queryoverseastaff == null)//沒有資料
            //    throw new Exception("MessageDataHasLinking".ToLocalized());
            #endregion

            #region 變為Models需要之型別及邏輯資料

            #endregion

            #region Models資料庫
            this._repository.Delete(query);
            this._unitOfWork.SaveChange();
            #endregion
        }
            public object Create(object request, ISpecimenContext context)
            {
                var user      = new User(context.Create("email"), context.Create("password"), context.Create("lastName"), context.Create("firstName"), context.Create("patronymic"));
                var workplace = new Workplace(user);

                return(workplace);
            }
 public void ValidateWorkplace(Workplace workplace)
 {
     if (workplace is null)
     {
         throw new NullWorkplaceException();
     }
 }
예제 #30
0
        /// <inheritdoc />
        public bool SaveWorkplace(Workplace workplace)
        {
            ActualizeSectionsList(workplace);
            var schema = _entitySchemaManager.GetInstanceByName("SysWorkplace");
            var entity = schema.CreateEntity(_userConnection);

            entity.SetDefColumnValues();
            entity.FetchFromDB(workplace.Id);
            entity.PrimaryColumnValue = workplace.Id;
            //TODO #CRM-45621 Delete "if condition" after task completion - sets name column value unconditionally.
            if (entity.ChangeType == EntityChangeType.Inserted)
            {
                entity.SetColumnValue("Name", workplace.Name);
            }
            entity.SetColumnValue("Position", workplace.Position);
            if (GetIsFeatureEnabled("UseTypedWorkplaces"))
            {
                var workplaceType = GetWorkplaceTypeId(workplace.Type);
                if (workplaceType == null)
                {
                    return(false);
                }
                entity.SetColumnValue("TypeId", workplaceType);
            }
            var result = entity.Save();

            if (result)
            {
                ClearWorkplaceCache(workplace.Id);
            }
            return(result);
        }
예제 #31
0
 public WorkplaceControl(Workplace workplace)
 {
     Workplace = workplace;
     Workplace.Updated += new EventHandler((a, b) => { this.Invoke(new MethodInvoker(() => { this.Rebind(); })); });
     Workplace.Finished += new EventHandler((a, b) => { this.Invoke(new MethodInvoker(() => { this.Rebind(); })); });
     InitializeComponent();
     this.DoubleBuffered = true;
     Rebind();
     workplaceName.DataBindings.Add("Text", Workplace, "Identification");
     productLabel.DataBindings.Add("Text", Workplace, "Contents");
 }
예제 #32
0
 public void nie_można_utworzyć_miejsca_pracy_bez_nazwy_miejscowości()
 {
     //given
     var nazwa = "KG ŻW";
     var stanowisko = "SZEF WYDZIAŁU";
     var miejscowosc = "";
     var ulica = "DŁUGA";
     var nrDomu = "10";
     var nrLokalu = "";
     var kodPocztowy = "01-163";
     var jestAktualne = true;
     //when
     var mp = new Workplace(nazwa, stanowisko, miejscowosc, ulica, nrDomu, nrLokalu, kodPocztowy, jestAktualne);
     //then
     Assert.IsNull(mp);
 }
예제 #33
0
파일: Person.cs 프로젝트: alisious/NHbApp
 public virtual bool RemoveWorkplace(string workplaceName, string position, string city, string street, string streetNo, string placeNo, string postalCode)
 {
     var wp = new Workplace(workplaceName, position, city, street, streetNo, placeNo, postalCode);
     return _workplaces.Remove(wp);
 }
예제 #34
0
 /// <summary>
 ///   Creates a new SinapseDocumentInfo.
 /// </summary>
 /// <param name="path">
 ///    The path to the SinapseDocument. If workplace is specified, the given
 ///    path should be relative to this workplace. Otherwise, it should be absolute.
 /// </param>
 /// <param name="workplace">
 ///   The Workplace to which the path is relative to.
 /// </param>
 /// <param name="type">
 ///   The type of the Document being referenced. It should be one of the ISinapseDocument
 ///   types or null. Any other types will be treated as null.
 /// </param>
 public SinapseDocumentInfo(string filePath, Workplace workplace, Type type)
 {
     initialize(filePath, workplace, type);
 }
예제 #35
0
 public WorkplaceThread(Workplace workplace)
 {
     _workplace = workplace;
 }
예제 #36
0
        private void initialize(string filePath, Workplace workplace, Type type)
        {
            if (!typeof(ISinapseDocument).IsAssignableFrom(type))
            {
                this.type = null;
            }

            this.filePath = filePath;
            this.owner = workplace;
            this.type = type;
        }
예제 #37
0
    public string buildingFlavorText(string building)
    {
        if (building == "House")
        {
            House x = new House();
            return x.flavorText;
        }

        else if (building == "Farm")
        {
            Farm x = new Farm();
            return x.flavorText;
        }

        else if (building == "Factory")
        {
            Factory x = new Factory();
            return x.flavorText;
        }

        else if (building == "Executive Building")
        {
            ExecutiveBuilding x = new ExecutiveBuilding();
            return x.flavorText;
        }

        else if (building == "Educational Building")
        {
            EducationalBuilding x = new EducationalBuilding();
            return x.flavorText;
        }

        else if (building == "Hospital")
        {
            Hospital x = new Hospital();
            return x.flavorText;
        }

        else if (building == "Laboratory")
        {
            Laboratory x = new Laboratory();
            return x.flavorText;
        }

        else if (building == "Police Station")
        {
            PoliceStation x = new PoliceStation();
            return x.flavorText;
        }

        else if (building == "Workplace")
        {
            Workplace x = new Workplace();
            return x.flavorText;
        }

        else if (building == "Public Space")
        {
            PublicSpace x = new PublicSpace();
            return x.flavorText;
        }

        else if (building == "World Trade Center")
        {
            WTC x = new WTC();
            return x.flavorText;
        }

        else if (building == "Military Outpost")
        {
            MilitaryOutpost x = new MilitaryOutpost();
            return x.flavorText;
        }

        else if (building == "Food Territory")
        {
            FoodTerritory x = new FoodTerritory();
            return x.flavorText;
        }

        else if (building == "Materials Territory")
        {
            MaterialsTerritory x = new MaterialsTerritory();
            return x.flavorText;
        }

        else if (building == "Citizens Territory")
        {
            CitizensTerritory x = new CitizensTerritory();
            return x.flavorText;
        }

        else
            return "";
    }
예제 #38
0
 private void initialize(string filePath, Workplace workplace)
 {
     Type type = DocumentManager.GetType(Utils.GetExtension(filePath, true));
     initialize(filePath, workplace, type);
 }
예제 #39
0
파일: Person.cs 프로젝트: alisious/NHbApp
 public virtual bool AddWorkplace(string workplaceName, string position, string city, string street, string streetNo, string placeNo, string postalCode, bool isCurrent=true)
 {
     var wp = new Workplace(workplaceName, position, city, street, streetNo, placeNo, postalCode, isCurrent);
     if (_workplaces.Contains(wp))
         return false;
     _workplaces.Add(wp);
     return true;
 }