Esempio n. 1
0
        protected async void getLogins_Click(object sender, EventArgs e)
        {
            List <TWP_Login> logins = await TWPSDK.getLogins(siteId, returnAuthToken);

            foreach (TWP_Login login in logins)
            {
                createButton(login.LoginName, login.LoginName);
            }
        }
Esempio n. 2
0
        protected async void getPayrollFormats_Click(object sender, EventArgs e)
        {
            List <string> formats = await TWPSDK.getPayrollFormats(siteId, returnAuthToken);

            var formatLabel = new Label()
            {
            };

            resultsPanel.Controls.Add(resultsLabel);
        }
Esempio n. 3
0
        public static async Task AuthorizeAPI()
        {
            if (partnerAPIToken == null)
            {
                partnerAPIToken = await TWPSDK.GetJWTToken(apiSecret, accountantId, siteId, APIProduct.TWP_Partner);

                if (!String.IsNullOrEmpty(partnerAPIToken))
                {
                    Console.WriteLine($"Partner Authorization succeeded.");
                }
            }
        }
Esempio n. 4
0
        protected async void getSchemaTimeOffRequests_Click(object sender, EventArgs e)
        {
            List <JObject> TORs = await TWPSDK.getTORCats(siteId, returnAuthToken);

            foreach (JObject Cat in TORs)
            {
                string category = Cat.ToString();
                var    label    = new Label
                {
                    ID   = category,
                    Text = category
                };
                resultsPanel.Controls.Add(label);
            }
        }
Esempio n. 5
0
        protected async void getAccrualBalance_Click(object sender, EventArgs e)
        {
            try
            {
                List <TWP_Accruals> accBalances = await TWPSDK.getAccruals(siteId, returnAuthToken);

                foreach (TWP_Accruals results in accBalances)
                {
                    foreach (TWP_AccrualValues balances in results.Balances)
                    {
                        string name = $"{results.FirstName} {results.LastName} {balances.Category}";
                        string text = $"{results.FirstName} {results.LastName} {balances.Category} {balances.Value}";
                        createButton(name, text);
                    }
                }
            }
            catch
            {
            }
        }
Esempio n. 6
0
        protected async void getPayrollActivitiesPerPayPeriod_Click(object sender, EventArgs e)
        {
            var response = await TWPSDK.GetPayrollActivities(siteId, returnAuthToken, null, null, "sum3");

            if (string.IsNullOrEmpty(response.Error))
            {
                if (!string.IsNullOrEmpty(response.FormatString))
                {
                    string   file          = response.FormatString.Replace("\"", "");
                    string[] strSeparators = new string[] { "\r\n" };
                    string[] result;
                    result = file.Split(strSeparators, StringSplitOptions.None);
                    StringBuilder sb = new StringBuilder();
                    foreach (string line in result)
                    {
                        sb.AppendLine(line);
                    }
                    downloadFile("payroll", sb);
                }
            }
        }
Esempio n. 7
0
 protected async void getRules_Click(object sender, EventArgs e)
 {
     List <TWP_Rules> rules = await TWPSDK.getRules(siteId, returnAuthToken);
 }
Esempio n. 8
0
        protected async void bulkUpsertEmployees_Click(object sender, EventArgs e)
        {
            List <TWP_EE_Upsert> updatedEE = new List <TWP_EE_Upsert>();


            if (EEImport.HasFile)
            {
                StreamReader csvreader = new StreamReader(EEImport.FileContent);
                while (!csvreader.EndOfStream)
                {
                    var line   = csvreader.ReadLine();
                    var values = line.Split(',');

                    List <Variable>             varsList = new List <Variable>();
                    Dictionary <string, string> varsDic  = new Dictionary <string, string>();
                    TWP_upsert_State            vars     = new TWP_upsert_State();
                    List <TWP_Employee_Schema>  eeSchema = await TWPSDK.listEESchema(siteId, returnAuthToken);

                    List <TWP_upsert_State> states = new List <TWP_upsert_State>();

                    IList <string> varValue = new List <string>();


                    int valCount = 15;


                    foreach (string key in eeSchema[0].States[0].Variables.Keys)
                    {
                        string currkey = key;
                        if (!varsDic.ContainsKey(key))
                        {
                            varsDic.Add(key, valCount.ToString());
                        }
                        valCount++;
                    }

                    if (values[0] != "RecordNumber")
                    {
                        List <TWP_Identifier> idList = new List <TWP_Identifier>();
                        List <string>         testid = new List <string>();

                        if (values.Length > 13)
                        {
                            for (int i = 12; i <= 14; i++)
                            {
                                TWP_Identifier id = new TWP_Identifier();
                                id.Id = !string.IsNullOrEmpty(values[i]) ? values[i].ToString() : "";
                                idList.Add(id);
                                testid.Add(id.Id);
                            }
                        }


                        for (var i = 0; i < eeSchema[0].States[0].Variables.Keys.Count; i++)
                        {
                            int    keyInd = i + 15;
                            string value  = values[keyInd];

                            string key = varsDic.FirstOrDefault(x => x.Value == keyInd.ToString()).Key;
                            varsDic[key] = value;
                            if (value == "" && key != "EmployeeType")
                            {
                                varsDic.Remove(key);
                            }
                        }

                        vars.EffectiveDate = DateTime.Now.ToString("yyyy-MM-dd");
                        vars.Variables     = varsDic;
                        states.Add(vars);

                        TWP_EE_Upsert ee = new TWP_EE_Upsert()
                        {
                            FirstName       = values[1],
                            MiddleName      = values[2],
                            LastName        = values[3],
                            EmployeeCode    = values[4],
                            Designation     = values[5],
                            Phone           = values[6],
                            Email           = values[7],
                            StartDate       = values[8],
                            EndDate         = values[9],
                            ExportBlock     = Convert.ToBoolean(values[10]),
                            WebClockEnabled = Convert.ToBoolean(values[11]),
                            //Identifiers = idList,
                            States = states
                        };

                        try
                        {
                            await TWPSDK.UpsertEmployee(siteId, returnAuthToken, values[0], ee);

                            createButton(ee.EmployeeCode, $"{ee.FirstName} {ee.LastName}");
                        }
                        catch
                        {
                            createButton(ee.EmployeeCode, $"{ee.FirstName} {ee.LastName}", false);
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        protected async void downloadEmployees_Click(object sender, EventArgs e)
        {
            List <TWP_Employee_Schema> eeSchema = await TWPSDK.listEESchema(siteId, returnAuthToken);

            IList <string> schemaState = eeSchema[0].States[0].Variables.Keys.ToList();

            List <TWP_Employee> employees = await TWPSDK.ListEmployees(siteId, returnAuthToken);

            StringBuilder sb = new StringBuilder();

            int idCount     = 3;
            int statesCount = 0;

            string header = "RecordNumber,First Name,Middle Name,Last Name,Code,Designation,Phone,Email,Start Date,Separation Date," +
                            "Export Block,WebClock Enabled,login1,login2,login3,";

            foreach (TWP_Employee_Schema results in eeSchema)
            {
                foreach (TWP_State_Schema state in results.States)
                {
                    foreach (KeyValuePair <string, string> kvp in state.Variables)
                    {
                        ++statesCount;
                        header += $"{kvp.Key.ToString()},";
                    }
                }
            }

            sb.AppendLine(header);
            string body = "";

            foreach (TWP_Employee emp in employees)
            {
                body = $"{emp.RecordNumber},{emp.FirstName},{emp.MiddleName},{emp.LastName},{emp.EmployeeCode},{emp.Designation},{emp.Phone},{emp.Email},{emp.StartDate},{emp.EndDate},{emp.ExportBlock},{emp.WebClockEnabled},";

                try
                {
                    foreach (TWP_Identifier id in emp.Identifiers)
                    {
                        if (!string.IsNullOrEmpty(id.Id))
                        {
                            body += $"{id.Id},";
                        }
                    }
                    if (emp.Identifiers.Count < idCount)
                    {
                        body += string.Concat(Enumerable.Repeat(",", idCount - emp.Identifiers.Count));
                    }
                }
                catch
                {
                    body += $",,,";
                }



                try
                {
                    foreach (TWP_State state in emp.States)
                    {
                        foreach (string varName in schemaState)
                        {
                            foreach (KeyValuePair <string, string> kvp in state.Variables)
                            {
                                if (kvp.Key == varName)
                                {
                                    body += $"{kvp.Value}";
                                }
                            }
                            body += ",";
                        }
                    }
                }
                catch
                {
                    body += string.Concat(Enumerable.Repeat(",", statesCount));
                }
                sb.AppendLine(body);
            }

            downloadFile("EmployeeDetail", sb);
        }
Esempio n. 10
0
 protected async void getEmployeesSchema_Click(object sender, EventArgs e)
 {
     List <TWP_Employee> eeSchema = await TWPSDK.ListEmployees(siteId, returnAuthToken);
 }
Esempio n. 11
0
 protected async void getAccrualActivity_Click(object sender, EventArgs e)
 {
     List <TWP_AccrualActivities> accrualActivity = await TWPSDK.getAccrualActivity(siteId, returnAuthToken);
 }