Exemplo n.º 1
0
def taskHold(dict):
    taskid, days, startdate, count = None, 0, None, 0
    msg = dict.get("text")
    manager = dict.get("user")
    channel = dict.get("channel")
    array = msg.split(" ")
    if UserManager.checkUserRole(manager):
        for split in array:
            if split != None and split != " ":
                if split[0] == "-":
                    if split == "-taskid":
                        taskid = array[count + 1]
                    if split == "-startdate":
                        startdate = array[count + 1]
                    if split == "-days":
                        days = int(array[count + 1])
            count = count + 1
        Task.taskforecast(taskid, startdate, days, channel)
    else:
        text = "Only project manager can perform this command"
        SlackCommunication.postMessege(channel, text)
Exemplo n.º 2
0
def registration(dict):
    user = dict.get("user")
    channel = dict.get("channel")
    count = 0
    location, email, fullname = None, None, None
    msg = dict.get("text")
    array = msg.split(" ")
    for split in array:
        if split != None:
            if split[0] == "-":
                if split == "-location":
                    location = array[count + 1]
                if split == "-email":
                    email = array[count + 1]
                    try:
                        email = email.split("|")[1]
                        email = email[:-1]
                    except:
                        email = ""
                        text = "Please check email domain"
                        SlackCommunication.postMessege(channel, text)
                if split == "-fullname":
                    fullname = array[count + 1]
        count = count + 1
    records = db.get_collection("user")
    if user != None and fullname != None and email != None and location != None:
        if rightEmail(email):
            if Task.duplicateChecker("userid", user, "user"):
                mydict = {
                    "userid": user,
                    "fullname": fullname,
                    "email": email,
                    "location": location
                }
                ischecked = records.insert_one(mydict).acknowledged
                if ischecked:
                    text = "<@" + user + "> registered to system."
                    SlackCommunication.postMessege(channel, text)
                else:
                    text = "Registration failed."
                    SlackCommunication.postMessege(channel, text)
            else:
                text = "Alreqady registered."
                SlackCommunication.postMessege(channel, text)
        else:
            text = "Please check email again."
            SlackCommunication.postMessege(channel, text)
    else:
        text = "You should set input parameters with values."
        SlackCommunication.postMessege(channel, text)
Exemplo n.º 3
0
def workassigner(dict):
    id, userid = None, None
    count = 0
    taskids = ""
    taskvalidate, isvalidate = False, True
    user = dict.get("user")
    records = db.get_collection("user")
    channel = dict.get("channel")
    msg = dict.get("text")
    array = msg.split(" ")
    for split in array:
        if split != None:
            if split == "-userid":
                userid = array[count + 1]
            if split == "-tasksid":
                for countnumber in range(count + 1, len(array)):
                    taskids = taskids + " " + str(array[countnumber])
        count = count + 1

    if taskids != "":
        checktaskid = taskids.split(" ")
        for checks in checktaskid:
            if checks != "" and checks != " " and checks != None:
                isvalidtask = Task.rightTask(checks)
                if isvalidtask == False:
                    isvalidate = False
                    break
        if isvalidate and checkUserRole(user):
            if records.find_one_and_update(
                {"userid": userid}, {'$set': {
                    "allocatedtasks": taskids
                }}):
                text = "<@" + user + "> asssigned to do " + taskids + "."
                SlackCommunication.postMessege(channel, text)
        else:
            text = "Assigning failed"
            SlackCommunication.postMessege(channel, text)
Exemplo n.º 4
0
def statusUpdater(dict):
    text = None
    projectdocuments = db.get_collection("project")
    taskdocument = db.get_collection("task")
    managerid = dict.get("user")
    channels = dict.get("channel")
    projectids = projectdocuments.find({
        "managerid": managerid
    }, {
        "roleid": "2"
    }).distinct("projectid")
    if projectids != [] and projectids != None:
        projectids = projectids[0]
        taskdetailarray = taskdocument.find({
            "projectid": projectids
        }).distinct("taskid")
        if taskdetailarray != []:
            for taskids in taskdetailarray:
                tasktime = taskdocument.find({
                    "taskid": taskids
                }).distinct("endtime")[0]
                taskstarttime = taskdocument.find({
                    "taskid": taskids
                }).distinct("starttime")[0]
                nows = str(datetime.datetime.now().date())
                checkdate = nows.replace("-", "/", 2)
                currentremain = Task.periodCalculator(checkdate, tasktime)
                tasktimes = Task.periodCalculator(taskstarttime, tasktime)
                ratio = currentremain / tasktimes
                taskprogress = int(
                    float(
                        taskdocument.find({
                            "taskid": taskids
                        }).distinct("taskprogress")[0]))
                tasktype = taskdocument.find({
                    "taskid": taskids
                }).distinct("type")[0]
                if (taskprogress > 90 and taskprogress < 100):
                    if ratio < 1 and ratio > 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "is almost done but keep work on. " + tasktype + " task"
                    elif ratio < 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "is almost done but keep work on. " + tasktype + " task"
                            taskdocument.find_one_and_update(
                                {"taskid": taskids},
                                {'$set': {
                                    "status": "working"
                                }})

                elif (taskprogress > 50 and taskprogress < 90):
                    if ratio < 1 and ratio > 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "need full attention because " + tasktype + " task"

                    elif ratio < 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "need full attention because " + tasktype + " task"
                            taskdocument.find_one_and_update(
                                {"taskid": taskids},
                                {'$set': {
                                    "status": "critical"
                                }})
                elif (taskprogress < 50):
                    if ratio < 1 and ratio > 0.5:
                        if tasktype == "critical" or tasktype == "important":
                            text = taskids + "is almost done but keep work on. " + tasktype + " task"
                            taskdocument.find_one_and_update(
                                {"taskid": taskids},
                                {'$set': {
                                    "status": "working"
                                }})
                    elif ratio < 0.5:
                        text = taskids + "is in reallly bad stage. its " + tasktype + " task"
                        taskdocument.find_one_and_update(
                            {"taskid": taskids},
                            {'$set': {
                                "status": "critical"
                            }})

                SlackCommunication.postMessege(channels, text)
Exemplo n.º 5
0
def checkTaskStatus(taskid):
    return Task.taskstatus(taskid)
Exemplo n.º 6
0
def register_Project(dict):
    count = 0
    user = dict.get("user")
    msg = dict.get("text")
    channels = dict.get("channel")
    if UserManager.checkUserRole(user):
        projectid, projectname, startdate, enddate, totalslack = None, None, None, None, None
        array = msg.split(" ")
        for split in array:
            if split[0] != None and split[0] != " ":
                if split[0] == "-":
                    if split == "-projectid":
                        projectid = array[count + 1]
                    if split == "-projectname":
                        projectname = array[count + 1]
                    if split == "-startdate":
                        startdate = array[count + 1]
                    if split == "-enddate":
                        enddate = array[count + 1]
                    if split == "-totalslack":
                        totalslack = array[count + 1]
            count = count + 1
        records = db.get_collection("project")
        if periodValidation(
                startdate, enddate, channels
        ) and projectid != None and projectname != None and startdate != None and enddate != None and totalslack != None and Task.duplicateChecker(
                "projectid", projectid, "project"):
            mydict = {
                "projectid": projectid,
                "projectname": projectname,
                "startdate": startdate,
                "enddate": enddate,
                "totalslack": totalslack,
                "managerid": user
            }
            ischecked = records.insert_one(mydict).acknowledged
            if ischecked:
                text = "Project  " + projectname + " is connected"
                SlackCommunication.postMessege(channels, text)
            else:
                text = "Process terminated. Try again"
                SlackCommunication.postMessege(channels, text)
        else:
            text = "Check input again"
            SlackCommunication.postMessege(channels, text)
    else:
        text = "Only project manager can perform this project"
        SlackCommunication.postMessege(channels, text)
Exemplo n.º 7
0
def create_Task(dict):
    manager = dict.get("user")
    channel = dict.get("channel")
    count = 0
    if UserManager.checkUserRole(manager):
        taskname = None
        taskid = None
        projectid = None
        starttime = None
        endtime = None
        type = None
        taskcontent = None
        msg = dict.get("text")
        array = msg.split(" ")

        for split in array:
            if split != None and split != " ":
                if split[0] == "-":
                    if split == "-taskname":
                        taskname = array[count + 1]
                    if split == "-taskid":
                        taskid = array[count + 1]
                    if split == "-projectid":
                        projectid = array[count + 1]
                    if split == "-freeslack":
                        freeslack = array[count + 1]
                    if split == "-startdate":
                        starttime = array[count + 1]
                    if split == "-enddate":
                        endtime = array[count + 1]
                    if split == "-taskcontent":
                        taskcontent = array[count + 1]
                    if split == "-type":
                        if array[count + 1] == "important" or array[
                                count +
                                1] == "normal" or array[count +
                                                        1] == "critical":
                            type = array[count + 1]
            count = count + 1
        if dateValidation(
                manager, projectid, starttime, endtime) and periodValidation(
                    starttime, endtime, channel) and Task.duplicateChecker(
                        "taskid", taskid, "task"):
            records = db.get_collection("task")
            mydict = {
                "taskname": taskname,
                "taskid": taskid,
                "projectid": projectid,
                "taskprogress": "0",
                "freeslack": freeslack,
                "starttime": starttime,
                "endtime": endtime,
                "type": type,
                "status": "fine",
                "taskcontent": taskcontent
            }
            ischeck = records.insert_one(mydict).acknowledged
            if ischeck:
                text = "Task created"
                SlackCommunication.postMessege(channel, text)
        else:
            text = "Process terminated. Check input again"
            SlackCommunication.postMessege(channel, text)
    else:
        text = "Only project manager can perform this project"
        SlackCommunication.postMessege(channel, text)