Exemplo n.º 1
0
 // Returns the first page of root level assignments for the employee specified
 public static string GetAssignments(CDovicoID idEmployee, ref APIRequestResult aRequestResult)
 {
     // Build up the URI for a request of assignments for the specified employee and then call our overloaded function to do the rest of
     // the work.
     aRequestResult.SetRequestURI(("Assignments/Employee/" + idEmployee.ToString() + "/"), "");
     return GetAssignments("", ref aRequestResult);
 }
Exemplo n.º 2
0
        // Returns the first page of root level assignments for the employee specified
        public static string GetAssignments(CDovicoID idEmployee, ref APIRequestResult aRequestResult)
        {
            // Build up the URI for a request of assignments for the specified employee and then call our overloaded function to do the rest of
            // the work.
            aRequestResult.SetRequestURI(("Assignments/Employee/" + idEmployee.ToString() + "/"), "ForTimeEntry=T");

            return(GetAssignments("", ref aRequestResult));
        }
Exemplo n.º 3
0
        // Returns the assignments for the URI requested (if there are multiple pages of data, pass in the NextPageURI. If you are trying to get
        // the child assignment items, pass in the GetAssignmentsURI value of the item you wish to drill down on)
        public static string GetAssignments(string sAssignmentsURI, ref APIRequestResult aRequestResult)
        {
            // Set the URI if one was specified
            if (sAssignmentsURI != "") { aRequestResult.SetRequestURI(sAssignmentsURI); }

            // Request the list of child assignments
            CRestApiHelper.MakeAPIRequest(aRequestResult);
            return (aRequestResult.HadRequestError ? aRequestResult.GetRequestErrorMessage() : aRequestResult.RequestResult);
        }
Exemplo n.º 4
0
        // Method used to insert a time entry via the API.
        //
        // NOTE: StartTime, StopTime, and Description are optional and can be left out by passing in 'null'
        //
        // If successful, returns the inserted time entry data from the API.
        // If there is an error, the return value will be null.
        public static CTimeEntry DoInsert(CDovicoID idProject, CDovicoID idTask, CDovicoID idEmployee, DateTime dtDate, string sStartTimeHHMM,
                                          string sStopTimeHHMM, double dTotalHours, string sDescription, ref APIRequestResult aRequestResult)
        {
            // Start off the XML needed for the POST call to the API
            CStringBuilderXML sbXML = new CStringBuilderXML(false);

            sbXML.AppendStartTag("TimeEntries");
            sbXML.AppendStartTag("TimeEntry");
            sbXML.AppendTagsWithValue("ProjectID", idProject);
            sbXML.AppendTagsWithValue("TaskID", idTask);
            sbXML.AppendTagsWithValue("EmployeeID", idEmployee);
            sbXML.AppendTagsWithValue("Date", dtDate);

            // If the StartTime has been provided then...(it's optional)
            if (sStartTimeHHMM != null)
            {
                sbXML.AppendTagsWithValue("StartTime", sStartTimeHHMM);
            }

            // If the StopTime has been provided then...(it's optional)
            if (sStopTimeHHMM != null)
            {
                sbXML.AppendTagsWithValue("StopTime", sStopTimeHHMM);
            }

            sbXML.AppendTagsWithValue("TotalHours", dTotalHours);

            // If the Description has been provided then...(it's optional)
            if (sDescription != null)
            {
                sbXML.AppendTagsWithValue("Description", sDescription);
            }

            // Close off the XML needed for the POST call
            sbXML.AppendEndTag("TimeEntry");
            sbXML.AppendEndTag("TimeEntries");



            // Configure our request object with the necessary data for the POST
            aRequestResult.SetRequestURI("TimeEntries/", "");
            aRequestResult.RequestHttpMethod  = "POST";
            aRequestResult.RequestPostPutData = sbXML;

            // Execute the request and get the list of time entries back. If we have a list then return the first item in the list (there should
            // only be the one item)
            List <CTimeEntry> lstTimeEntries = ProcessRequest(ref aRequestResult);

            if (lstTimeEntries != null)
            {
                return(lstTimeEntries[0]);
            }

            // An error happened so just return null.
            return(null);
        }
Exemplo n.º 5
0
        // A request for the logged in Employee's info (this information is quite limited but may be the only employee information you can obtain
        // if the logged in user has no employee access permissions. this will return the employee's ID, Last Name, and First Name - with the ID,
        // you can call getInfo and 'try' to get the rest of the info if desired)
        //
        // If there was an error the return value will be null
        public static CEmployee GetInfoMe(APIRequestResult aRequestResult)
        {
            // Set the URI for the Employee/Me/ request. Process the request and if the returned list is not null (no errors) then return the first item in the list (there
            // should only ever be the one item)
            aRequestResult.SetRequestURI("Employees/Me/", "");
            List<CEmployee> lstEmployees = ProcessRequest(aRequestResult);
            if (lstEmployees != null) { return lstEmployees[0]; }

            // An error happened so just return null.
            return null;
        }
Exemplo n.º 6
0
        //=====================================================================
        // STATIC METHODS: For use when interacting with the DOVICO Hosted API
        //---------------------------------------------------------------------
        // A request for a specific employee by ID (If there was an error the return value will be null)
        public static CEmployee GetInfo(CDovicoID idEmployee, APIRequestResult aRequestResult)
        {
            // Set the URI for the Employee/{ID}/ request. Process the request and if the returned list is not null (no errors) then return the
            // first item in the list (there should only ever be the one item)
            aRequestResult.SetRequestURI(("Employees/" + idEmployee.ToString() + "/"), "");
            List<CEmployee> lstEmployees = ProcessRequest(aRequestResult);
            if (lstEmployees != null) { return lstEmployees[0]; }

            // An error happened so just return null.
            return null;
        }
Exemplo n.º 7
0
        //=====================================================================
        // STATIC METHODS: For use when interacting with the DOVICO Hosted API
        //---------------------------------------------------------------------

        //get list options are:
        // - all time (no filters)
        // - all time (filtered by date range)
        // - all time by employee

        //-------------------------------------------------
        // ALL TIME by EMPLOYEE (filtered by date range)
        //-------------------------------------------------
        public static List <CTimeEntry> GetListForEmployee(CDovicoID idEmployeeID, DateTime dtDateRangeStart, DateTime dtDateRangeEnd,
                                                           ref APIRequestResult aRequestResult)
        {
            // If the Request URI has not been set then set it to return the first page of time entries (if it's already set we may have been called to get a next/previous
            // page)
            if (aRequestResult.GetRequestURI() == "")
            {
                aRequestResult.SetRequestURI(("TimeEntries/Employee/" + idEmployeeID + "/"), BuildDateRangeQueryString(dtDateRangeStart, dtDateRangeEnd));
            }
            return(ProcessRequest(ref aRequestResult));
        }
Exemplo n.º 8
0
        // Returns the assignments for the URI requested (if there are multiple pages of data, pass in the NextPageURI. If you are trying to get
        // the child assignment items, pass in the GetAssignmentsURI value of the item you wish to drill down on)
        public static string GetAssignments(string sAssignmentsURI, ref APIRequestResult aRequestResult)
        {
            // Set the URI if one was specified
            if (sAssignmentsURI != "")
            {
                aRequestResult.SetRequestURI(sAssignmentsURI);
            }

            // Request the list of child assignments
            CRestApiHelper.MakeAPIRequest(aRequestResult);
            return(aRequestResult.HadRequestError ? aRequestResult.GetRequestErrorMessage() : aRequestResult.RequestResult);
        }
Exemplo n.º 9
0
        public static string GetInfoMeOptions(ref APIRequestResult aRequestResult)
        {
            // Set the URI for the Employee/Me/ request. Process the request and if the returned list is not null (no errors) then return the first item in the list (there
            // should only ever be the one item)
            aRequestResult.SetRequestURI("Employees/Me/Options/", "");
            aRequestResult.ContentType = "text/xml";
            CRestApiHelper.MakeAPIRequest(aRequestResult);

            XmlDocument xdDoc = new XmlDocument();

            xdDoc.LoadXml(aRequestResult.RequestResult);
            string ShowBillable = CXMLHelper.GetChildNodeValue(xdDoc.DocumentElement, "ShowBillable");

            return(ShowBillable);
        }
Exemplo n.º 10
0
        // A request for the logged in Employee's info (this information is quite limited but may be the only employee information you can obtain
        // if the logged in user has no employee access permissions. this will return the employee's ID, Last Name, and First Name - with the ID,
        // you can call getInfo and 'try' to get the rest of the info if desired)
        //
        // If there was an error the return value will be null
        public static CEmployee GetInfoMe(APIRequestResult aRequestResult)
        {
            // Set the URI for the Employee/Me/ request. Process the request and if the returned list is not null (no errors) then return the first item in the list (there
            // should only ever be the one item)
            aRequestResult.SetRequestURI("Employees/Me/", "");
            List <CEmployee> lstEmployees = ProcessRequest(aRequestResult);

            if (lstEmployees != null)
            {
                return(lstEmployees[0]);
            }

            // An error happened so just return null.
            return(null);
        }
Exemplo n.º 11
0
        //=====================================================================
        // STATIC METHODS: For use when interacting with the DOVICO Hosted API
        //---------------------------------------------------------------------

        // A request for a specific employee by ID (If there was an error the return value will be null)
        public static CEmployee GetInfo(CDovicoID idEmployee, APIRequestResult aRequestResult)
        {
            // Set the URI for the Employee/{ID}/ request. Process the request and if the returned list is not null (no errors) then return the
            // first item in the list (there should only ever be the one item)
            aRequestResult.SetRequestURI(("Employees/" + idEmployee.ToString() + "/"), "");
            List <CEmployee> lstEmployees = ProcessRequest(aRequestResult);

            if (lstEmployees != null)
            {
                return(lstEmployees[0]);
            }

            // An error happened so just return null.
            return(null);
        }
Exemplo n.º 12
0
 //=====================================================================
 // STATIC METHODS: For use when interacting with the DOVICO Hosted API
 //---------------------------------------------------------------------
 //get list options are:
 // - all time (no filters)
 // - all time (filtered by date range)
 // - all time by employee
 //-------------------------------------------------
 // ALL TIME by EMPLOYEE (filtered by date range)
 //-------------------------------------------------
 public static List<CTimeEntry> GetListForEmployee(CDovicoID idEmployeeID, DateTime dtDateRangeStart, DateTime dtDateRangeEnd,
     ref APIRequestResult aRequestResult)
 {
     // If the Request URI has not been set then set it to return the first page of time entries (if it's already set we may have been called to get a next/previous
     // page)
     if (aRequestResult.GetRequestURI() == "") { aRequestResult.SetRequestURI(("TimeEntries/Employee/" + idEmployeeID + "/"), BuildDateRangeQueryString(dtDateRangeStart, dtDateRangeEnd)); }
     return ProcessRequest(ref aRequestResult);
 }
Exemplo n.º 13
0
        // Method used to insert a time entry via the API.
        //
        // NOTE: StartTime, StopTime, and Description are optional and can be left out by passing in 'null'
        //
        // If successful, returns the inserted time entry data from the API.
        // If there is an error, the return value will be null.
        public static CTimeEntry DoInsert(CDovicoID idProject, CDovicoID idTask, CDovicoID idEmployee, DateTime dtDate, string sStartTimeHHMM,
            string sStopTimeHHMM, double dTotalHours, string sDescription, ref APIRequestResult aRequestResult)
        {
            // Start off the XML needed for the POST call to the API
            CStringBuilderXML sbXML = new CStringBuilderXML(false);
            sbXML.AppendStartTag("TimeEntries");
            sbXML.AppendStartTag("TimeEntry");
            sbXML.AppendTagsWithValue("ProjectID", idProject);
            sbXML.AppendTagsWithValue("TaskID", idTask);
            sbXML.AppendTagsWithValue("EmployeeID", idEmployee);
            sbXML.AppendTagsWithValue("Date", dtDate);

            // If the StartTime has been provided then...(it's optional)
            if (sStartTimeHHMM != null) { sbXML.AppendTagsWithValue("StartTime", sStartTimeHHMM); }

            // If the StopTime has been provided then...(it's optional)
            if (sStopTimeHHMM != null) { sbXML.AppendTagsWithValue("StopTime", sStopTimeHHMM); }

            sbXML.AppendTagsWithValue("TotalHours", dTotalHours);

            // If the Description has been provided then...(it's optional)
            if (sDescription != null) { sbXML.AppendTagsWithValue("Description", sDescription); }

            // Close off the XML needed for the POST call
            sbXML.AppendEndTag("TimeEntry");
            sbXML.AppendEndTag("TimeEntries");

            // Configure our request object with the necessary data for the POST
            aRequestResult.SetRequestURI("TimeEntries/", "");
            aRequestResult.RequestHttpMethod = "POST";
            aRequestResult.RequestPostPutData = sbXML;

            // Execute the request and get the list of time entries back. If we have a list then return the first item in the list (there should
            // only be the one item)
            List<CTimeEntry> lstTimeEntries = ProcessRequest(ref aRequestResult);
            if (lstTimeEntries != null) { return lstTimeEntries[0]; }

            // An error happened so just return null.
            return null;
        }