Exemple #1
0
        public void  LoadContact(int ContactID)
        {
            DataSet ds  = DBTask.ExecuteDataset(ConfigurationSettings.AppSettings[Web.Global.CfgKeyConnString], "ContactInfo_GetContact", ContactID);
            DataRow row = ds.Tables[0].Rows[0];

            _ContactID   = Convert.ToInt32(row["ContactID"].ToString());
            _Title       = row["Title"].ToString();
            _FirstName   = row["FirstName"].ToString();
            _MiddleName  = row["MiddleName"].ToString();
            _LastName    = row["LastName"].ToString();
            _JobTitle    = row["JobTitle"].ToString();
            _Company     = row["Company"].ToString();
            _Website     = row["Website"].ToString();
            _OfficePhone = row["OfficePhone"].ToString();
            _HomePhone   = row["HomePhone"].ToString();
            _Mobile      = row["Mobile"].ToString();
            _Fax         = row["Fax"].ToString();
            _OEmail      = row["OfficialEmail"].ToString();
            _PEmail      = row["PersonalEmail"].ToString();
            _OAStreet    = row["OAStreet"].ToString();
            _OACity      = row["OACity"].ToString();
            _OAState     = row["OAState"].ToString();
            _OACountry   = row["OACountry"].ToString();
            _OAZipCode   = row["OAZip"].ToString();
            _PAStreet    = row["PAStreet"].ToString();
            _PACity      = row["PACity"].ToString();
            _PAState     = row["PAState"].ToString();
            _PACountry   = row["PACountry"].ToString();
            _PAZipCode   = row["PAZip"].ToString();
        }
Exemple #2
0
    public DBTask GetDBTask(int id)
    {
        DBTask db = null;

        DictTask.TryGetValue(id, out db);
        return(db);
    }
        public async Task DeleteTaskAsync(object sender)
        {
            var listBoxItem = sender as System.Windows.Controls.ListBoxItem; //Get sender

            itemIndex = int.Parse(listBoxItem.Tag.ToString());               //Convert  listBoxItem.Tag to int (TaskID)
            TaskModel task = Tasks.Where(n => n.TaskID == itemIndex).First();


            await Task.Delay(300); //A short delay to make more smooth animation of removing

            Tasks.Remove(task);    //Get and remove selected task

            /*if (Tasks.Count == 0)
             * {
             *  itemCount = 0;
             * }*/

            //Usuniecie z bazy
            using (var context = new StudentAppContext())
            {
                DBTask DBTask = context.DBTasks.Where(x => x.DBTaskId == itemIndex).FirstOrDefault();
                context.DBTasks.Remove(DBTask);

                context.SaveChanges();
            }
        }
        public void EditTask(object sender)
        {
            var listBoxItem = sender as System.Windows.Controls.ListBoxItem; //Get sender

            itemIndex = int.Parse(listBoxItem.Tag.ToString());               //Convert  listBoxItem.Tag to int (TaskID)
            int       itemindex = itemIndex;
            TaskModel task      = Tasks.Where(n => n.TaskID == itemIndex).First();

            itemIndex = Tasks.IndexOf(task);

            IsDialogOpen = true;
            isEditing    = true;

            TaskName        = Tasks[itemIndex].TaskName;
            TaskExplanation = Tasks[itemIndex].TaskExplanation;

            //Modyfikacja w bazie
            using (var context = new StudentAppContext())
            {
                DBTask DBTask = context.DBTasks.Where(x => x.DBTaskId == itemindex).FirstOrDefault(); //Do poprawy idIndex
                DBTask.TaskHeadline = TaskName;
                DBTask.TaskText     = TaskExplanation;

                context.SaveChanges();
            }
        }
Exemple #5
0
        /// <summary>
        /// Runs the tasks.
        /// </summary>
        private void RunTasks()
        {
            // need refactoring

            LogSectionHeader("Database Installation");
            DBTask dbTask = new DBTask();

            if (dbTask.Validate())
            {
                dbTask.Execute();
            }

            LogSectionHeader("Reports Installation");
            PublishTask publishTask = new PublishTask();

            if (publishTask.Validate())
            {
                publishTask.Execute();
            }

            LogSectionHeader("BinaryFiles Installation");
            PublishBinaryFilesTask publishBinaryFilesTask = new PublishBinaryFilesTask();

            if (publishBinaryFilesTask.Validate())
            {
                publishBinaryFilesTask.Execute();
            }
        }
 public TaskStruct GetTask(int id)
 {
     DBTask dbTask = new DBTask(dataProvider);
     dbTask.Connection = connection;
     dbTask.Load(id);
     return dbTask.BusinessObject;
 }
Exemple #7
0
        public static long GetAllCount(SqlBaseItemXml basemodel, ref long sqlnum)
        {
            sqlnum = 0;
            long rownum = 0;
            List <TaskDataParam> taskdataparam = new List <TaskDataParam>();
            var databaselist = DBConfig.GetDatabaseXmlConfig(basemodel).SqlDatabaseList.Where(m => m.IsUse == true).ToList();

            foreach (var item in databaselist)
            {
                var servermodel = DBConfig.GetServerItemXmlConfig(basemodel, item.ServerNumber);
                if (servermodel != null)
                {
                    TaskDataParam tempparam = new TaskDataParam();
                    tempparam.servername = servermodel.ServerName;
                    tempparam.dbtype     = servermodel.DBType;
                    tempparam.connstr    = GetConnStr(basemodel, servermodel, item);
                    tempparam.sqlstr     = "select  sum(b.rows) as 记录条数 from sysobjects a,sysindexes b where a.id=b.id and a.xtype='u' and b.indid=1 ";
                    taskdataparam.Add(tempparam);
                }
            }
            DBTask servicetask = new DBTask();

            rownum = servicetask.SyncThreadPoolManagerSum(taskdataparam, 100, false);
            sqlnum = servicetask.runnumcurrent;
            return(rownum);
        }
Exemple #8
0
 /// <summary>
 /// Loads a quest from the databaseobject and assigns it to a player
 /// </summary>
 /// <param name="targetPlayer">Player to assign the loaded quest</param>
 /// <param name="dbTask">Quest to load</param>
 /// <returns>The created quest</returns>
 public static AbstractTask LoadFromDatabase(GamePlayer targetPlayer, DBTask dbTask)
 {
     // if we have a active task load it, else the taksdone will be updated on creation of first task instance in AbstractTask(GamePlayer) constructor
     if (dbTask.TaskType != null && dbTask.TaskType != "")
     {
         Type taskType = null;
         foreach (Assembly asm in ScriptMgr.Scripts)
         {
             taskType = asm.GetType(dbTask.TaskType);
             if (taskType != null)
             {
                 break;
             }
         }
         if (taskType == null)
         {
             taskType = Assembly.GetAssembly(typeof(GameServer)).GetType(dbTask.TaskType);
         }
         if (taskType == null)
         {
             if (log.IsErrorEnabled)
             {
                 log.Error("Could not find task: " + dbTask.TaskType + "!!!");
             }
             return(null);
         }
         return((AbstractTask)Activator.CreateInstance(taskType, new object[] { targetPlayer, dbTask }));
     }
     else
     {
         return(null);
     }
 }
 /// <summary>
 /// Constructs a new Quest from a database Object
 /// </summary>
 /// <param name="taskPlayer">The player doing the quest</param>
 /// <param name="dbTask">The database object</param>
 public AbstractTask(GamePlayer taskPlayer, DBTask dbTask)
 {
     m_taskPlayer = taskPlayer;
     _dbTask      = dbTask;
     ParseCustomProperties();
     SaveIntoDatabase();
 }
Exemple #10
0
        //方法:实现“注册”功能的业务逻辑
        public void registerUser(User user)
        {
            //通过DBTask间接地将用户信息写入数据库
            DBTask dBTask = new DBTask();//建立DBTask的实例

            dBTask.registerUser(user);
        }
Exemple #11
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    private void EndCurTask()
    {
        if (m_task != null)
        {
            m_task.End();

            m_task = null;
        }
    }
Exemple #12
0
        /// <summary>
        /// 执行task
        /// </summary>
        /// <param name="taskID">任务编号</param>
        public Result ExecuteTask(string taskID)
        {
            Result result   = null;
            DBTask taskInfo = null;

            try
            {
                taskInfo = this.GetTaskByID(taskID);
                if (string.IsNullOrWhiteSpace(taskInfo?.KeyID))
                {
                    throw new Exception($"任务编号:{taskID}获取任务失败");
                }

                if (this.StartTask(taskID) == false)
                {
                    throw new Exception($"任务编号:{taskID} 开始任务失败");
                }

                ITaskDeal deal = new TaskDeal(taskInfo);

                switch (taskInfo.BusinessType)
                {
                case BusinessType.初始化: result = deal.InitDatabaseInfo(); break;

                case BusinessType.整库建表: result = deal.ExecuteConCreateTables(); break;

                case BusinessType.整库表分析: result = deal.ExecuteConAnalysisTables(); break;

                case BusinessType.表建表: result = deal.ExecuteTableCreateTables(); break;

                case BusinessType.表分析: result = deal.ExecuteTableAnalysisTables(); break;

                default: result = new Result()
                {
                        Msg = "未定义的处理方式"
                }; break;
                }
            }
            catch (Exception e)
            {
                result = new Result()
                {
                    Msg = e.Message
                };
                NLog.LogManager.GetCurrentClassLogger().Error($"执行任务出错:{e}");
            }
            finally
            {
                this.BuildTaskResult(taskInfo, result);
                this.UpdateTask(taskInfo, result);
                ////每次执行都要增加任务执行次数
                this.AddTaskRunTimes(taskID, result);
            }

            return(result);
        }
Exemple #13
0
        /// <summary>
        /// 添加db任务
        /// </summary>
        /// <param name="paramIn">入参</param>
        /// <returns>结果</returns>
        public Result AddDBTask(DBTask paramIn)
        {
            var con = ConnectionHelper.GetSqlSugarClient();
            //paramIn.KeyID = KeyIDHelper.Generator();
            var rt = con.Insertable <DBTask>(paramIn).ExecuteCommand();

            return(new Result()
            {
                Success = rt > 0
            });
        }
Exemple #14
0
 private bool Update()
 {
     try
     {
         DBTask.ExecuteNonQuery(ConfigurationSettings.AppSettings[Web.Global.CfgKeyConnString], "ContactInfo_Update", _ContactID, _Title, _FirstName, _MiddleName, _LastName, _JobTitle, _Company, _Website, _OfficePhone, _HomePhone, _Mobile, _Fax, _OEmail, _PEmail, _OAStreet, _OACity, _OAState, _OACountry, _OAZipCode, _PAStreet, _PACity, _PAState, _PACountry, _PAZipCode);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public bool CreateTask(TaskStruct taskStruct, ref int newTaskID)
        {
            DBTask dbTask = new DBTask(dataProvider);
            dbTask.Connection = connection;

            if (dbTask.Save(taskStruct))
            {
                newTaskID = (int)dbTask.LastID;
                return true;
            }
            return false;
        }
Exemple #16
0
            public void DeleteTest()
            {
                //Arrange
                DBTask task = new DBTask();
                int    id   = 5; //OPS - Sæt ny værdi inden test køres eller bliver intet slettet

                //Act
                var succes = task.Delete(id);

                //Assert
                Assert.AreNotEqual(succes, false);
            }
Exemple #17
0
 /// <summary>
 /// 构建任务执行结果
 /// </summary>
 /// <param name="model">任务model</param>
 /// <param name="result">结果</param>
 private void BuildTaskResult(DBTask model, Result result)
 {
     try
     {
         model.ExecuteStatus = result.Success ? 3 : 1;
         model.ExecuteMsg    = result.Success ? string.Empty : result.Msg;
         model.ModifyTime    = DateTime.Now;
     }
     catch (Exception e)
     {
         NLog.LogManager.GetCurrentClassLogger().Error(e);
     }
 }
Exemple #18
0
 /// <summary>
 /// 更新任务
 /// </summary>
 /// <param name="model">入参</param>
 /// <returns>结果</returns>
 public bool UpdateTask(DBTask model, Result result)
 {
     try
     {
         var con = ConnectionHelper.GetSqlSugarClient();
         return(con.Updateable <DBTask>(model).ExecuteCommand() > 0);
     }
     catch (Exception e)
     {
         NLog.LogManager.GetCurrentClassLogger().Error(e);
         return(false);
     }
 }
Exemple #19
0
        /// <summary>
        /// Deletes this quest from the database
        /// </summary>
        public virtual void DeleteFromDatabase()
        {
            if (!m_dbTask.IsPersisted)
            {
                return;
            }

            DBTask dbTask = (DBTask)GameServer.Database.FindObjectByKey <DBTask>(m_dbTask.ObjectId);

            if (dbTask != null)
            {
                GameServer.Database.DeleteObject(dbTask);
            }
        }
 public void AddDBTaskTest()
 {
     try
     {
         var task = new DBTask()
         {
             BusinessKeyID = "202102071129559905157225",
             BusinessType  = BusinessType.表建表,
         };
         var res = new BTask().AddDBTask(task);
     }
     catch (Exception)
     {
     }
 }
Exemple #21
0
            public void CreateTest()
            {
                //Arrange
                DBTask TaskDB = new DBTask();
                var    create = new Task();

                create.description = "lille";
                create.name        = "snerydning";
                create.isComplete  = true;

                //Act
                var sucess = TaskDB.Create(create);

                //Assert
                Assert.IsTrue(sucess);
            }
Exemple #22
0
            public void UpdateTest()
            {
                //Arrange
                DBTask TaskDB = new DBTask();
                var    update = new Task();

                update.id          = 3;
                update.name        = "Håndvask";
                update.description = "En hvid en";
                update.isComplete  = true;

                //Act
                var sucess = TaskDB.Update(update);

                //Assert
                Assert.IsTrue(sucess);
            }
        public void AddNewTask()
        {
            if (isEditing)
            {
                Tasks[itemIndex].TaskName        = TaskName;
                Tasks[itemIndex].TaskExplanation = TaskExplanation;
                Tasks.Refresh(); //Raises a change notification indicating that all bindings should be refreshed.

                //Modyfikacja w bazie

                /*
                 * using (var context = new StudentAppContext())
                 * {
                 *  DBTask DBTask = context.DBTasks.Where(x => x.DBTaskId == 4).FirstOrDefault(); //Do poprawy idIndex
                 *  DBTask.TaskHeadline = TaskName;
                 *  DBTask.TaskText = TaskExplanation;
                 *
                 *  context.SaveChanges();
                 * }*/
            }
            else
            {
                //Dodawanie do bazy
                var dbtask = new DBTask {
                    TaskHeadline = taskName, TaskText = taskExplanation
                };
                int itemId;
                using (var context = new StudentAppContext())
                {
                    context.DBTasks.Add(dbtask);
                    context.SaveChanges();
                    var obiektChwilowy = context.DBTasks.OrderByDescending(x => x.DBTaskId).FirstOrDefault();
                    itemId = obiektChwilowy.DBTaskId;
                }

                tasks.Add(new TaskModel {
                    TaskName = taskName, TaskExplanation = taskExplanation, TaskID = itemId
                });
            }

            TaskExplanation = "";
            TaskName        = "";
            IsDialogOpen    = false;
            isEditing       = false;
        }
Exemple #24
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public void Update()
    {
        if ((m_task == null) && (m_tasks.Count > 0))
        {
            m_task = m_tasks.Dequeue();

            m_task.Start();
        }

        if (m_task != null)
        {
            m_task.Monitor();

            if (m_task.status == DBTask.STATUS.FINISHED)
            {
                m_task = null;
            }
        }
    }
Exemple #25
0
            public void GetTest()
            {
                //Arrange
                DBTask TaskDB   = new DBTask();
                int    id       = 1;
                var    expected = new Task();

                expected.id         = 1;
                expected.name       = "Hans";
                expected.isComplete = false;

                //Act
                var sucess = TaskDB.Get(id);

                //Assert
                Assert.AreEqual(expected.id, sucess.id);
                Assert.AreEqual(expected.name, sucess.name);
                Assert.AreEqual(expected.isComplete, sucess.isComplete);
            }
Exemple #26
0
        public static AddressBookCollection GetEntries(string BLetter)
        {
            DataSet dsData = DBTask.ExecuteDataset(ConfigurationSettings.AppSettings[Web.Global.CfgKeyConnString]
                                                   , "ContactInfo_GetContactList", BLetter);
            AddressBookCollection entryList = new AddressBookCollection();

            foreach (DataRow row in dsData.Tables[0].Rows)
            {
                Address AB = new Address();
                AB.ContactID     = Convert.ToInt32(row["ContactID"]);
                AB.FullName      = row["FullName"].ToString();
                AB.OfficialEmail = row["OfficialEmail"].ToString();
                AB.PersonalEmail = row["PersonalEmail"].ToString();
                AB.OfficePhone   = row["OfficePhone"].ToString();
                AB.HomePhone     = row["HomePhone"].ToString();
                entryList.Add(AB);
            }
            return(entryList);
        }
Exemple #27
0
        internal static void UpdateConfigurationInfo(int taskId, int activationTypeId, int completionTypeId, bool mustBeConfirmed, bool checkAccess)
        {
            if (checkAccess)
            {
                VerifyCanUpdate(taskId);
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                if (0 < DbTask2.UpdateConfigurationInfo(taskId, activationTypeId, completionTypeId, mustBeConfirmed))
                {
                    SystemEvents.AddSystemEvents(SystemEventTypes.Task_Updated_ConfigurationInfo, taskId);

                    Task.RecalculateAllStates(DBTask.GetProject(taskId));
                }

                tran.Commit();
            }
        }
Exemple #28
0
        /// <summary>
        /// Constructs a new Quest
        /// </summary>
        /// <param name="taskPlayer">The player doing this task</param>
        public AbstractTask(GamePlayer taskPlayer)
        {
            m_taskPlayer = taskPlayer;

            DBTask dbTask = null;

            // Check if player already has a task
            // if yes reuse dbtask object to keep TasksDone from old dbtask object.
            if (taskPlayer.Task != null)
            {
                dbTask = taskPlayer.Task.m_dbTask;
            }
            else             // if player has no active task, load dbtask an use tasksdone
            {
                // Load Task object of player ...
                var tasks = GameServer.Database.SelectObjects <DBTask>("Character_ID ='" + GameServer.Database.Escape(taskPlayer.QuestPlayerID) + "'");
                if (tasks.Count == 1)
                {
                    dbTask = tasks[0];
                }
                else if (tasks.Count > 1)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("More than one DBTask Object found for player " + taskPlayer.Name);
                    }
                }
            }

            // this should happen only if player never did a task and has no entry in DBTask.
            if (dbTask == null)
            {
                dbTask = new DBTask();
                dbTask.Character_ID = taskPlayer.QuestPlayerID;
            }

            dbTask.TaskType = GetType().FullName;

            m_dbTask = dbTask;

            ParseCustomProperties();
            SaveIntoDatabase();
        }
Exemple #29
0
        public string loginBookstore(User user)
        {
            DBTask dbTask  = new DBTask();
            User   regUser = dbTask.getRegUser(user);

            if (regUser != null)
            {
                if (user.Password == regUser.Password)
                {
                    return("信息正确");
                }
                else
                {
                    return("密码错!登录失败");
                }
            }
            else
            {
                return("用户不存在!登录失败");
            }
        }
Exemple #30
0
        public IEnumerable <EmployeeModel> getAllEmployee()
        {
            List <EmployeeModel> empList = new List <EmployeeModel>();
            SqlDataReader        sdr     = DBTask.ExecuteReader(Startup.ConnectionStringTS, "spGetEmployee", "GetAll", "", "", "", "", "");

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    var emp = new EmployeeModel
                    {
                        empID     = Convert.ToString(sdr["empID"]),
                        empName   = Convert.ToString(sdr["empName"]),
                        empSalary = Convert.ToString(sdr["empSalary"]),
                        DeptName  = Convert.ToString(sdr["DeptName"]),
                        DesigName = Convert.ToString(sdr["DesigName"])
                    };
                    empList.Add(emp);
                }
            }
            return(empList);
        }
        /// <summary>
        /// Constructs a new Quest
        /// </summary>
        /// <param name="taskPlayer">The player doing this task</param>
        public AbstractTask(GamePlayer taskPlayer)
        {
            m_taskPlayer = taskPlayer;

            DBTask dbTask = null;

            // Check if player already has a task
            // if yes reuse dbtask object to keep TasksDone from old dbtask object.
            if (taskPlayer.Task != null)
            {
                dbTask = taskPlayer.Task._dbTask;
            }
            else // if player has no active task, load dbtask an use tasksdone
            {
                // Load Task object of player ...
                var tasks = GameServer.Database.FindObjectByKey <DBTask>(taskPlayer.QuestPlayerID);
                if (tasks != null)
                {
                    dbTask = tasks;
                }
            }

            // this should happen only if player never did a task and has no entry in DBTask.
            if (dbTask == null)
            {
                dbTask = new DBTask
                {
                    Character_ID = taskPlayer.QuestPlayerID
                };
            }

            dbTask.TaskType = GetType().FullName;

            _dbTask = dbTask;

            ParseCustomProperties();
            SaveIntoDatabase();
        }
Exemple #32
0
        public static int GetSharingLevel(ObjectTypes ObjectType, int ObjectId)
        {
            int UserId = Security.CurrentUser.UserID;

            int RetVal = -1;

            switch (ObjectType)
            {
            case ObjectTypes.ToDo:
                RetVal = DBToDo.GetSharingLevel(UserId, ObjectId);
                break;

            case ObjectTypes.Task:
                RetVal = DBTask.GetSharingLevel(UserId, ObjectId);
                break;

            case ObjectTypes.CalendarEntry:
                RetVal = DBEvent.GetSharingLevel(UserId, ObjectId);
                break;

            case ObjectTypes.Issue:
                RetVal = DBIncident.GetSharingLevel(UserId, ObjectId);
                break;

            case ObjectTypes.Project:
                RetVal = DBProject.GetSharingLevel(UserId, ObjectId);
                break;

            case ObjectTypes.Document:
                RetVal = DBDocument.GetSharingLevel(UserId, ObjectId);
                break;

            default:
                RetVal = -1;
                break;
            }
            return(RetVal);
        }
 public bool DeleteTask(int TaskID)
 {
     DBTask dbTask = new DBTask(dataProvider);
     dbTask.Connection = connection;
     return dbTask.Delete(TaskID);
 }
 public bool UpdateTask(TaskStruct task)
 {
     DBTask dbTask = new DBTask(dataProvider);
     dbTask.Connection = connection;
     dbTask.BusinessObject = task;
     dbTask.ID = task.ID;
     return dbTask.Save();
 }