Пример #1
0
        private void ValidateEmployeeAccess()
        {
            Int32 employeeId = Convert.ToInt32(Session["EmployeeID"]);
            SqlConnection con = new SqlConnection(Configuration.ConnectionString);
            var Engineer = new Engineer();
            bool pmFiscalSummary = false;
            bool picFiscalSummary = false;

            con.Open();
            SqlDataReader dr = Engineer.GetByEmployeeID(employeeId, con);

            if (dr.HasRows)
            {
                dr.Read();
                pmFiscalSummary = dr.GetValueOrDefault<bool>("PMFiscalSummary");
                picFiscalSummary = dr.GetValueOrDefault<bool>("PICFiscalSummary");
            }

            con.Close();
            dr.Close();
            con = null;
            dr = null;

            bool displayFiscalSummary = pmFiscalSummary | picFiscalSummary;
            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "displayFiscalSummary", string.Format("displayFiscalSummary = '{0}'", displayFiscalSummary), true);
        }
Пример #2
0
 public List<Task> GetAssignedTasks(Engineer e, Task task)
 {
     target = e;
     assignedTasks = new List<Task>();
     Visit((dynamic)task);
     return assignedTasks;
 }
        public ActionResult AddMachine(Engineer engineer, int MachineId)
        {
            var joinExists = _db.EngineerMachine.FirstOrDefault(join => join.MachineId == MachineId && join.EngineerId == engineer.EngineerId);

            if (joinExists != null)
            {
                return(RedirectToAction("Details", new { id = engineer.EngineerId }));
            }

            if (MachineId != 0)
            {
                _db.EngineerMachine.Add(new EngineerMachine()
                {
                    MachineId = MachineId, EngineerId = engineer.EngineerId
                });
            }

            _db.SaveChanges();
            return(RedirectToAction("Details", new { id = engineer.EngineerId }));
        }
Пример #4
0
 void SaveToMemory()
 {
     double[] Data      = { sL, sR, sB, sT };
     double[] SenseData = { pL, pR, pB, pT };
     Memory.Add(Data);
     MemorySense.Add(SenseData);
     if (Memory.Count > 2000)
     {
         if (nearcount == 0)
         {
             World.Remove(this);
             Engineer newlife = new Engineer(World, x, y);
             World.Add(newlife);
         }
         Memory.RemoveAt(0);
         MemorySense.RemoveAt(0);
     }
     //Console.SetCursorPosition(0, 3);
     //Console.Write(Memory.Count.ToString());
 }
Пример #5
0
        public Engineer CreateEngineer()
        {
            var id = GenerateId();

            if (id.IsEmpty)
            {
                return(null);
            }
            var setup    = SelectSetup();
            var engineer = new Engineer(
                id,
                setup.FixTime.Random(),
                new Money(setup.Price.RandomInclusive()),
                new Money(setup.Salary.RandomInclusive()),
                setup.Level,
                false
                );

            return(engineer);
        }
Пример #6
0
 public ActionResult Create(Engineer engineers, int MachineId, int LocationId)
 {
     _db.Engineers.Add(engineers);
     if (MachineId != 0)
     {
         _db.EngineerLocationMachine.Add(new EngineerLocationMachine()
         {
             MachineId = MachineId, EngineerId = engineers.EngineerId
         });
     }
     if (LocationId != 0)
     {
         _db.EngineerLocationMachine.Add(new EngineerLocationMachine()
         {
             LocationId = LocationId, EngineerId = engineers.EngineerId
         });
     }
     _db.SaveChanges();
     return(RedirectToAction("Details", new { id = engineers.EngineerId }));
 }
Пример #7
0
        private static IEngineer CreateEngineer(string[] cmdArgs, int id, string firstName, string lastName, decimal salary, string corps)
        {
            IEngineer engineer = new Engineer(id, firstName, lastName, salary, corps);

            string[] repairArgs = cmdArgs
                                  .Skip(6)
                                  .ToArray();

            for (int i = 0; i < repairArgs.Length; i += 2)
            {
                string partName    = repairArgs[i];
                int    hoursWorked = int.Parse(repairArgs[i + 1]);

                IRepair repair = new Repair(partName, hoursWorked);

                engineer.AddRepair(repair);
            }

            return(engineer);
        }
        private ISoldier GetEngineer(int id, string firstName, string lastName, decimal salary, string[] inputArgs)
        {
            string corpsAsString = inputArgs[5];

            if (!Enum.TryParse(corpsAsString, out Corps corps))
            {
                return(null);
            }
            IEngineer engineer = new Engineer(id, firstName, lastName, salary, corps);

            for (int i = 6; i < inputArgs.Length; i += 2)
            {
                string partName    = inputArgs[i];
                int    workedHours = int.Parse(inputArgs[i + 1]);

                IRepair repair = new Repair(partName, workedHours);
                engineer.Repairs.Add(repair);
            }
            return(engineer);
        }
Пример #9
0
        static void Main(string[] args)
        {
            #region Static
            //Student s1 = new Student();
            //s1.Name = "Kamran";
            //Student.Count = 5;
            //Console.WriteLine(Student.Count);
            //s1.Test();
            #endregion

            #region Sealed
            Engineer engineer = new Engineer();
            #endregion

            #region Generic
            //MyList<int> intList = new MyList<int>();
            //MyList<string> strList = new MyList<string>();
            MyList <Student, Person> list = new MyList <Student, Person>();
            Area area = new Area();
            #endregion

            #region Extension
            string word = "Hello";
            //Console.WriteLine(word.GetFirstChar());
            #endregion

            #region Boxing,Upcasting
            //object str = "Aqil";
            #endregion

            #region Downcasting
            object s = "Word";
            int    x = (int)s;
            #endregion

            #region Operator overloading
            Student s1 = new Student();
            Student s2 = new Student();
            Console.WriteLine(s1 > s2);
            #endregion
        }
        private ISoldier GenerateEngineer(int id, string firstName, string lastName, string[] args)
        {
            string corpsAsString = args[5];

            if (!Enum.TryParse(corpsAsString, out Corps corps))
            {
                return(null);
            }
            IEngineer engineer = new Engineer(firstName, lastName, id, decimal.Parse(args[4]), corps);

            for (int i = 6; i < args.Length; i += 2)
            {
                string partName    = args[i];
                int    hoursWorked = int.Parse(args[i + 1]);

                IRepairs repair = new Repair(partName, hoursWorked);
                engineer.AddRepair(repair);
            }

            return(engineer);
        }
Пример #11
0
 public bool GenerateEngineer(int amount)
 {
     if (engineerPrefab != null)
     {
         for (int i = 0; i < amount; i++)
         {
             float    spawnPosX = UnityEngine.Random.Range(floorBounds.bounds.min.x, floorBounds.bounds.max.x);
             float    spawnPosY = UnityEngine.Random.Range(floorBounds.bounds.min.z, floorBounds.bounds.max.z);
             Vector3  spawnPos  = new Vector3(spawnPosX, 0, spawnPosY);
             Engineer e         = Instantiate(
                 engineerPrefab,
                 spawnPos,
                 Quaternion.Euler(0, UnityEngine.Random.Range(0, 359), 0),
                 engineerContainer.transform
                 );
             e.gameObject.SetActive(true);
         }
         return(true);
     }
     return(false);
 }
Пример #12
0
    private static void ExecuteEngineerCommand(List <string> inputLineArgs)
    {
        int       id        = int.Parse(inputLineArgs[0]);
        string    firstName = inputLineArgs[1];
        string    lastName  = inputLineArgs[2];
        double    salary    = double.Parse(inputLineArgs[3]);
        string    corps     = inputLineArgs[4];
        IEngineer engineer  = new Engineer(id, firstName, lastName, salary, corps);

        var repairPairs = inputLineArgs.Skip(5).ToList();

        for (int i = 0; i < repairPairs.Count - 1; i += 2)
        {
            string  partName = repairPairs[i];
            int     hours    = int.Parse(repairPairs[i + 1]);
            IRepair repair   = new Repair(partName, hours);
            engineer.Repairs.Add(repair);
        }

        Console.WriteLine(engineer.ToString());
    }
Пример #13
0
    public static void AddEngineer(string[] info, List <ISoldier> soldiers)
    {
        var           id        = int.Parse(info[1]);
        var           firstName = info[2];
        var           lastName  = info[3];
        double        salary    = double.Parse(info[4]);
        string        corps     = info[5];
        List <Repair> repairs   = new List <Repair>();

        if (corps == "Airforces" || corps == "Marines")
        {
            for (int i = 6; i < info.Length; i += 2)
            {
                Repair repair = new Repair(info[i], int.Parse(info[i + 1]));
                repairs.Add(repair);
            }

            Engineer engineer = new Engineer(firstName, lastName, id, salary, corps, repairs);
            soldiers.Add(engineer);
        }
    }
Пример #14
0
        public void Add(Engineer engineer)
        {
            string engineerString = engineer.BaseWorking.ToString();

            if (!queueTKey.Contains(engineer))
            {
                sortedDictTKey.Add(engineer.BaseWorking, engineer);
            }
            else
            {
                throw new MyException("Объект с данными фамилией и именем уже существует!", engineer.Firstname, engineer.Surname);
            }
            queueTKey        = new Queue <Working>(sortedDictTKey.Keys);
            queueString      = new Queue <string>();
            sortedDictString = new SortedDictionary <string, Engineer>();
            foreach (var obj in sortedDictTKey)
            {
                queueString.Enqueue(obj.Key.ToString());
                sortedDictString.Add(obj.Key.ToString(), obj.Value);
            }
        }
Пример #15
0
        /// <summary>
        /// 重载Dapper查询方法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="cnn"></param>
        /// <param name="sql"></param>
        /// <param name="author"></param>
        /// <param name="param"></param>
        /// <param name="transaction"></param>
        /// <param name="buffered"></param>
        /// <param name="commandTimeout"></param>
        /// <param name="commandType"></param>
        /// <returns></returns>
        public static IEnumerable <T> Query <T>(this IDbConnection cnn, string sql, Engineer author, object param = null, IDbTransaction transaction = null, bool buffered = true, int?commandTimeout = null, CommandType?commandType = null)
        {
            //是否开启查询监控
            if (Common.PubConstant.IsOpenQuerySqlMonitorLog)
            {
                #region 计算时间

                Stopwatch sw = new Stopwatch();
                sw.Start();
                var command = new CommandDefinition(sql, (object)param, transaction, commandTimeout, commandType, buffered ? CommandFlags.Buffered : CommandFlags.None);
                var data    = QueryImpl <T>(cnn, command, typeof(T));
                sw.Stop();
                #endregion

                #region 判断执行时间 是否大于1秒
                //if (sw.Elapsed.TotalSeconds >= GetTime())
                //{
                //    #region 异步发送消息
                //    string ProjectName = "主项目";
                //    string SqlHash = sql.GetHashCode().ToString();
                //    string Runtime = sw.Elapsed.TotalSeconds.ToString();
                //    string SqlMsg = sql.Replace("\r\n", "");
                //    string SqlParam = GetString(param);

                //    AddMessageEntity(Runtime, ProjectName, SqlHash, SqlMsg, SqlParam, author.ToString(), DateTime.Now.ToString());
                //    #endregion
                //}

                #endregion

                return(command.Buffered ? data.ToList() : data);
            }
            else
            {
                //没有开启监控
                var command = new CommandDefinition(sql, (object)param, transaction, commandTimeout, commandType, buffered ? CommandFlags.Buffered : CommandFlags.None);
                var data    = QueryImpl <T>(cnn, command, typeof(T));
                return(command.Buffered ? data.ToList() : data);
            }
        }
    public static void Main()
    {
        IDList <Engineer> plist = new IDList <Engineer>();

        plist.add(new Engineer("T", "1"));
        plist.add(new Engineer("G", "6"));
        plist.add(new Engineer("M", "9"));

        try
        {
            Engineer frnd = plist.findByName("G");
            Console.Write(frnd.Name + ": " + frnd.Number);
        }
        catch (NotFoundException)
        {
            Console.WriteLine("Not Found");
        }

        Console.WriteLine();

        IDList <Manager> plist2 = new IDList <Manager>();

        plist2.add(new Manager("H", "8"));
        plist2.add(new Manager("C", "2"));
        plist2.add(new Manager("N", "4"));

        try
        {
            Manager sp = plist2.findByNumber("4");
            Console.WriteLine(sp.Name + ": " + sp.Number);
        }
        catch (NotFoundException)
        {
            Console.WriteLine("Not Found");
        }

        // The following declaration is invalid
        // because Guest does NOT implement IUserID.
        // IDList<Guest> plist3 = new IDList<Guest>(); // Error!
    }
Пример #17
0
    public static ISoldier CreateSoldier(List <ISoldier> soldiers, string[] tokens, string soldierType, int id, string firstName, string lastName, decimal salary)
    {
        switch (soldierType)
        {
        case "Private":
            return(new Private(id, firstName, lastName, salary));

        case "LeutenantGeneral":
            var commandingSoldiers = tokens.Skip(5);
            var liutenant          = new LeutenantGeneral(id, firstName, lastName, salary);

            GetPrivates(soldiers, tokens, liutenant);

            return(liutenant);

        case "Commando":
            var commandoCorps = tokens[5];
            var commando      = new Commando(id, firstName, lastName, salary, commandoCorps);

            GetMissions(tokens, commando);

            return(commando);

        case "Engineer":
            var engineerCorps = tokens[5];
            var repairs       = tokens.Skip(5);
            var engineer      = new Engineer(id, firstName, lastName, salary, engineerCorps);
            GetRepairs(tokens, engineer);

            return(engineer);

        case "Spy":
            var codeNumber = (int)salary;

            return(new Spy(id, firstName, lastName, codeNumber));

        default:
            return(null);
        }
    }
Пример #18
0
        private ISoldier GetEngineer(int id, string firstName, string lastName, decimal salary,
                                     string[] splitted)
        {
            string corpsVal = splitted[5];

            if (!Enum.TryParse(corpsVal, out Corps corps))
            {
                return(null);
            }

            IEngineer engineer = new Engineer(id, firstName, lastName, salary, corps);

            for (int i = 6; i < splitted.Length; i += 2)
            {
                string  repairPart = splitted[i];
                int     repairHour = int.Parse(splitted[i + 1]);
                IRepair repair     = new Repair(repairPart, repairHour);
                engineer.Repairs.Add(repair);
            }

            return(engineer);
        }
Пример #19
0
        private ISoldier GetEngineer(int id, string firstName, string lastName, decimal salary, string[] args)
        {
            //In case of invalid corps the entire line should be skipped

            var isValidCorps = Enum.TryParse(args[5], out Corps corps);

            if (!isValidCorps)
            {
                return(null);
            }
            IEngineer engineer = new Engineer(id, firstName, lastName, salary, corps);

            for (int i = 6; i < args.Length; i += 2)
            {
                string  partName = args[i];
                int     hours    = int.Parse(args[i + 1]);
                IRepair repair   = new Repair(partName, hours);
                engineer.Repairs.Add(repair);
            }

            return(engineer);
        }
Пример #20
0
 /// <summary>
 ///     写入日志
 ///     baochen
 ///     2015年1月20日15:06:53
 /// </summary>
 /// <typeparam name="T">实体</typeparam>
 /// <param name="t">当前类</param>
 /// <param name="functionName">方法名称</param>
 /// <param name="author">作者</param>
 /// <param name="entity">参数实体</param>
 /// <param name="ex">错误信息</param>
 public static void WriteLog <T>(Type t, string functionName, Engineer author, T entity, Exception ex)
 {
     try
     {
         string str = string.Empty;
         if (entity != null)
         {
             str = JsonConvertTool.SerializeObject(entity);
         }
         var log     = LogManager.GetLogger(t);
         var strInfo = "Error:方法名:" + functionName + "--作者:" + author.ToString() + "\r\n传入参数:\r\n" + str + "\r\n错误信息:" +
                       ex.Message + "\r\n" + ex.StackTrace + "\r\n" + "客户端ip:" + ip + ",请求连接:" + rawUrl;
         log.Error(strInfo);
         //EmailDelegate dn = new EmailDelegate(new SendEmail().Send);
         //IAsyncResult ias = dn.BeginInvoke("屌丝你程序出错了", strInfo, author.ToString().Trim(), null, dn);
         //dn.EndInvoke(ias);
     }
     catch
     {
         //记录日志时有可能出现异常
     }
 }
Пример #21
0
 public ActionResult AddMachine(Engineer engineer, int MachineId, List <int> machines)
 {
     if (machines.Count != 0)
     {
         foreach (int machine in machines)
         {
             _db.EngineerMachine.Add(new EngineerMachine()
             {
                 MachineId = machine, EngineerId = engineer.EngineerId
             });
         }
     }
     if (MachineId != 0)
     {
         _db.EngineerMachine.Add(new EngineerMachine()
         {
             MachineId = MachineId, EngineerId = engineer.EngineerId
         });
     }
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Пример #22
0
 public static void clearAndReloadRoles()
 {
     Jester.clearAndReload();
     Mayor.clearAndReload();
     Engineer.clearAndReload();
     Sheriff.clearAndReload();
     Lighter.clearAndReload();
     Godfather.clearAndReload();
     Mafioso.clearAndReload();
     Janitor.clearAndReload();
     Detective.clearAndReload();
     TimeMaster.clearAndReload();
     Medic.clearAndReload();
     Shifter.clearAndReload();
     Swapper.clearAndReload();
     Lovers.clearAndReload();
     Seer.clearAndReload();
     Morphling.clearAndReload();
     Camouflager.clearAndReload();
     Spy.clearAndReload();
     Child.clearAndReload();
 }
Пример #23
0
        private ISoldier GetEngineer(int id, string firstName, string lastName, decimal salary, string[] input)
        {
            var corpsParse = input[5];

            if (!Enum.TryParse(corpsParse, out Corps corps))
            {
                return(null);
            }

            Engineer engineer = new Engineer(id, firstName, lastName, salary, corps);

            for (int i = 6; i < input.Length; i += 2)
            {
                var repairPart  = input[i];
                var repairHours = int.Parse(input[i + 1]);

                IRepair repair = new Repair(repairPart, repairHours);
                engineer.Repairs.Add(repair);
            }

            return(engineer);
        }
Пример #24
0
        private void AddEngineer(string id, string firstName, string lastName, string[] data)
        {
            decimal salary        = decimal.Parse(data[4]);
            string  corpsAsString = data[5];
            bool    isValidCorps  = Enum.TryParse(corpsAsString, out Corps corps);

            if (!isValidCorps)
            {
                return;
            }

            IEngineer engineer = new Engineer(id, firstName, lastName, salary, corps);

            for (int i = 6; i < data.Length; i += 2)
            {
                string partName    = data[i];
                int    hoursWorked = int.Parse(data[i + 1]);
                engineer.Repairs.Add(new Repair(partName, hoursWorked));
            }

            this.soldiers.Add(engineer);
        }
        public void GivenTwoCandidatesReturned_Schedule_ReturnsNewSchedule()
        {
            using (var autoMock = AutoMock.GetLoose())
            {
                var firstEngineer  = new Engineer(1, "1", "1");
                var secondEngineer = new Engineer(2, "2", "2");
                var engineers      = new[] { firstEngineer, secondEngineer };

                autoMock.Mock <ISupportCandidateSelector>()
                .Setup(selector => selector.Select(_specification))
                .Returns(engineers);

                autoMock.Mock <IRandomSelector>()
                .Setup(selector => selector.Select(It.IsAny <IEnumerable <Engineer> >()))
                .Returns(engineers);

                var sut    = autoMock.Create <SupportScheduler>();
                var result = sut.Schedule(_specification);

                Assert.Equal(_specification.Date, result.Date);
                Assert.Equal(engineers, result.Engineers);
            }
        }
Пример #26
0
        public IActionResult CreateEngineer([FromBody] Engineer engineer)
        {
            try
            {
                if (engineer.IsObjectNull())
                {
                    return(BadRequest("Engineer object is null"));
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid model object"));
                }

                _repository.Engineer.CreateEngineer(engineer);

                return(CreatedAtRoute("EngineerById", new { id = engineer.Id }, engineer));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error"));
            }
        }
        private void CreateEngineer(string[] tokens, string soldierType, int soldierId, string firstName, string lastName)
        {
            if (soldierType == typeof(Engineer).Name)
            {
                decimal         salary  = decimal.Parse(tokens[4]);
                List <IRepair>  repairs = new List <IRepair>();
                SoldierCropEnum crop;
                if (Enum.TryParse(tokens[5], out crop))
                {
                    for (int i = 6; i < tokens.Length - 1; i++)
                    {
                        string partName = tokens[i];
                        int    hours    = int.Parse(tokens[i + 1]);
                        var    repair   = new Repair(partName, hours);
                        repairs.Add(repair);
                        i++;
                    }

                    ISoldier currentSoldier = new Engineer(soldierId, firstName, lastName, salary, crop, repairs);
                    soldiers.Add(currentSoldier);
                }
            }
        }
Пример #28
0
        public override void add()
        {
            try
            {
                Engineer Engineer = new Engineer();
                //setting the default company
                Engineer.CompanyID = getDefaultCompany().Id;

                EngineerForm EngineerViewer = new EngineerForm();
                EngineerViewer.mainEntity = Engineer;
                EngineerViewer.controller = this;

                if (EngineerViewer.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    db.Engineer.Add(Engineer);
                    db.SaveChanges();
                }
            }
            catch (System.InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #29
0
        private ISoldier GetEngineerType(int id, string firstName, string lastName, decimal salary, string[] newArgs)
        {
            IEngineer engineer = null;

            Corp corp;
            bool isCastToCorp = Enum.TryParse <Corp>(newArgs[0], out corp);

            if (isCastToCorp)
            {
                engineer = new Engineer(id, firstName, lastName, salary, corp);
                string partName;
                int    hoursWorked;
                for (int i = 1; i < newArgs.Length; i += 2)
                {
                    partName    = newArgs[i];
                    hoursWorked = int.Parse(newArgs[i + 1]);
                    IRepair repair = new Repair(partName, hoursWorked);
                    engineer.AddRepairs(repair);
                }
            }

            return(engineer);
        }
Пример #30
0
        private async Task CheckIfWeAreRespectingRestDays(Engineer engineer, DateTime date, Team team)
        {
            var lastShiftBeforeDate = engineer.Shifts
                                      .Where(s => s.Date <= date)
                                      .OrderByDescending(s => s.Date)
                                      .FirstOrDefault();

            if (lastShiftBeforeDate == null)
            {
                return;
            }

            int restDays = (date - lastShiftBeforeDate.Date).Days;

            if (restDays > team.MinimumRestDaysAfterSupporting)
            {
                return;
            }

            // This may happen in real life, so instead of throwing an exception (because it's not),
            // we just notify someone (INotifierService is responsible for knowing who and how to notify)...
            await notifierService.MinimumRestDaysNotBeingRespected(engineer, lastShiftBeforeDate.Date, date).ConfigureAwait(false);
        }
        public void Should_Not_Allow_Vacation_When_Not_Available()
        {
            var engineer = new Engineer();
            var date     = DateTime.Now.AddMonths(1);

            engineer.Id        = Guid.NewGuid();
            engineer.JobTitle  = JobTitle.ProgrammerI;
            engineer.Firstname = "Taylor";

            engineer.TimeOffs.AddRange(new TimeOff[] {
                new TimeOff(DateTime.Now.AddMonths(-9), 20),
                new TimeOff(DateTime.Now.AddMonths(-7), 20),
                new TimeOff(DateTime.Now.AddMonths(-5), 20),
                new TimeOff(DateTime.Now.AddMonths(-3), 20),
                new TimeOff(DateTime.Now.AddMonths(-1), 20)
            });

            engineer.TakeVacation(10, date);

            //Assert.AreEqual(1, engineer.TimeOffs.Count);
            //Assert.AreEqual(8, engineer.TimeOffs.First().HoursTaken);
            //Assert.AreEqual(date.Date, engineer.TimeOffs.First().Date);
        }
Пример #32
0
        private ISoldier GetEngeneer(int id, string firstName, string lastName, decimal salary, string[] input)
        {
            var   corpsStr = input[5];
            Corps corps;

            if (Enum.TryParse(corpsStr, out corps) == false)
            {
                return(null);
            }

            IEngineer engineer = new Engineer(id, firstName, lastName, salary, corps);

            for (int i = 6; i < input.Length; i += 2)
            {
                var partName    = input[i];
                var workedHours = int.Parse(input[i + 1]);

                IRepair repair = new Repair(partName, workedHours);
                engineer.Repairs.Add(repair);
            }

            return(engineer);
        }
        public bool RemoveMember(Engineer gangMember)
        {
            DataAccess objADO = new DataAccess();
            ArrayList colParameters = new ArrayList();
            string strStoredProcedure = "delGangMember";
            int intRowsAffected = 0;

            colParameters.Add(new SqlParameter("@GangID", this.UserID));
            colParameters.Add(new SqlParameter("@MemberID", gangMember.UserID));

            intRowsAffected = objADO.ExecuteSQL(strStoredProcedure, (SqlParameter[])colParameters.ToArray(typeof(SqlParameter)));
            objADO = null;

            return (intRowsAffected > 0);
        }
Пример #34
0
 public List<Task> GetTaskList(Engineer e)
 {
     return new TaskListVisitor().GetAssignedTasks(e, this);
 }
Пример #35
0
 public void FromBin(NetSocket.ByteArray bin, twp.app.resource.AreaResourceType type)
 {
     switch (type) {
     case twp.app.resource.AreaResourceType.AREA_RESOURCE_TYPE_RESOURCE:
         goto case twp.app.resource.AreaResourceType.AREA_RESOURCE_TYPE_RESOURCE_MAX;
     case twp.app.resource.AreaResourceType.AREA_RESOURCE_TYPE_RESOURCE_MAX:
     {
         resouce = new Resouce();
         resouce.FromBin(bin);
     }
         break;
     case twp.app.resource.AreaResourceType.AREA_RESOURCE_TYPE_ENGINEER:
         goto case twp.app.resource.AreaResourceType.AREA_RESOURCE_TYPE_ENGINEER_MAX;
     case twp.app.resource.AreaResourceType.AREA_RESOURCE_TYPE_ENGINEER_MAX:
     {
         engineer = new Engineer();
         engineer.FromBin(bin);
     }
         break;
         default:
         break;
     }
 }
Пример #36
0
        public static WorkerCollection PopulateTyped(DataSet collectionMembers, string sortPropertyName)
        {
            WorkerCollection colMembers = new WorkerCollection();
            Worker objWorker = null;
            DataRow[] gangMembers = null;
            DataRow[] contractorDetails = null;
            DataRow drContractor = null;
            string filterExpression = string.Empty;

            collectionMembers.Tables[0].TableName = "Common";
            if (collectionMembers.Tables.Count > 1)
            {
                collectionMembers.Tables[1].TableName = "GangMembers";
                collectionMembers.Tables[2].TableName = "ContractorDetails";
            }

            foreach (DataRow drMember in collectionMembers.Tables["Common"].Rows)
            {
                if (drMember["MobileIdentityType"].ToString().ToUpper() == "GANG")
                {
                    objWorker = new Gang();
                }
                else if (drMember["MobileIdentityType"].ToString().ToUpper() == "CONTRACTOR")
                {
                    objWorker = new Contractor();
                }
                else
                {
                    objWorker = new Engineer();   //  Assume Engineer
                }
                objWorker.UserID = drMember["UserID"].ToString();
                objWorker.LoginName = drMember["ADLoginID"].ToString();
                objWorker.EmpNo = drMember["EmpNo"].ToString();
                if (drMember["EmpSurname"] != System.DBNull.Value)
                {
                    objWorker.Surname = drMember["EmpSurname"].ToString();
                }
                if (drMember["EmpForenames"] != System.DBNull.Value)
                {
                    objWorker.Forenames = drMember["EmpForenames"].ToString();
                }
                if (drMember["EmpPrefname"] != System.DBNull.Value)
                {
                    objWorker.EmpPrefname = drMember["EmpPrefname"].ToString();
                }
                else
                {
                    objWorker.EmpPrefname = objWorker.Forenames;
                }
                if (drMember["EmpAddress"] != System.DBNull.Value)
                {
                    objWorker.EmpAddress = drMember["EmpAddress"].ToString();
                }
                else
                {
                    objWorker.EmpAddress = string.Empty;
                }
                if (!drMember["EmailAddress"].Equals(DBNull.Value))
                {
                    objWorker.Email = drMember["EmailAddress"].ToString();
                }
                if (!drMember["EmpMobileTelNo"].Equals(DBNull.Value))
                {
                    objWorker.MobileNo = drMember["EmpMobileTelNo"].ToString();
                }
                objWorker.AreaDetails = new AreaDetails();
                objWorker.AreaDetails.PrimaryArea = new Area();
                objWorker.AreaDetails.PrimaryArea.Name = "UNKNOWN";
                objWorker.AreaDetails.SubArea = new Area();
                objWorker.AreaDetails.SubArea.Name = "UNKNOWN";

                if (!drMember["PrimaryArea"].Equals(DBNull.Value))
                {
                    objWorker.AreaDetails.PrimaryArea.Name = drMember["PrimaryArea"].ToString();
                }

                if (!drMember["SubArea"].Equals(DBNull.Value))
                {
                    objWorker.AreaDetails.SubArea.Name = drMember["SubArea"].ToString();
                }

                if (drMember["IsClickEngineer"] != System.DBNull.Value)
                {
                    objWorker.IsClickEngineer = (bool)drMember["IsClickEngineer"];
                }

                if (collectionMembers.Tables.Count > 1)
                {
                    if (objWorker is Gang)
                    {
                        try
                        {
                            int numericUserID = 0;
                            if (int.TryParse(objWorker.UserID, out numericUserID))
                            {
                                throw new Exception("Gang ID must start with a non-numeric character");
                                // NB: .Select(filterExpression) can't handle it otherwise
                            }
                            filterExpression = string.Format("GangID='{0}'", objWorker.UserID);
                            gangMembers = collectionMembers.Tables["GangMembers"].Select(filterExpression);
                            if (gangMembers != null && gangMembers.Length > 0)
                            {
                                string[] gangUserIDs = new string[gangMembers.Length];
                                for (int index = 0; index < gangMembers.Length; index++)
                                {
                                    gangUserIDs[index] = gangMembers[index]["MemberID"].ToString();
                                }
                                ((Gang)objWorker).Members = WorkerCollection.GetTypedWorkers(string.Empty, gangUserIDs);
                            }
                        }
                        catch (Exception excE)
                        {
                            throw new Exception("Error attemping to load GangMembers : " + excE.Message, excE);
                        }
                    }
                    if (objWorker is Contractor)
                    {
                        // 2 types of contractor so only add extra properties to sub contractor
                        if (objWorker.AreaDetails.SubArea.Name.ToUpper() == "CONTRACTOR")
                        {
                            try
                            {
                                filterExpression = string.Format("UserID='{0}'", objWorker.UserID);
                                contractorDetails = collectionMembers.Tables["ContractorDetails"].Select(filterExpression);
                                if (contractorDetails != null && contractorDetails.Length > 0)
                                {
                                    drContractor = contractorDetails[0];
                                    objWorker.Email = drContractor[1].ToString();//Email
                                    ((Contractor)objWorker).Telephone = drContractor[2].ToString(); //Telephone
                                    ((Contractor)objWorker).Mobile = drContractor[3].ToString();    //Mobile
                                    ((Contractor)objWorker).Password = drContractor[4].ToString();  //Password
                                }
                            }
                            catch (Exception excE)
                            {
                                throw new Exception("Error attemping to load Contractors : " + excE.Message, excE);
                            }
                        }
                    }
                }

                colMembers.Add(objWorker);
            }

            if (!string.IsNullOrEmpty(sortPropertyName))
            {
                string actualPropertyName = sortPropertyName;
                if (actualPropertyName.EndsWith(" DESC"))
                {
                    actualPropertyName = actualPropertyName.Replace(" DESC", "");
                    colMembers.Sort(actualPropertyName, System.ComponentModel.ListSortDirection.Descending);
                }
                else
                {
                    colMembers.Sort(actualPropertyName, System.ComponentModel.ListSortDirection.Ascending);
                }
            }
            return colMembers;
        }
Пример #37
0
public static void Main()
{
Engineer eng = new Engineer();
Console.WriteLine(eng.Name);
}
Пример #38
0
 partial void InsertEngineer(Engineer instance);
Пример #39
0
 partial void UpdateEngineer(Engineer instance);
Пример #40
0
 partial void DeleteEngineer(Engineer instance);