Summary description for StaffBrokerFunctions
Esempio n. 1
0
        static public int AuthenticateAdv(int UserId, int AdvanceId, int PortalId)
        {
            StaffRmbDataContext d = new StaffRmbDataContext();
            var adv = from c in d.AP_Staff_AdvanceRequests where c.AdvanceId == AdvanceId && c.PortalId == PortalId select c;

            if (adv.Count() > 0)
            {
                if (adv.First().UserId == UserId)
                {
                    return(RmbAccess.Owner);
                }
                else if (adv.First().ApproverId == UserId)
                {
                    return(RmbAccess.Approver);
                }
                else
                {
                    var spouseId = StaffBrokerFunctions.GetSpouseId(UserId);
                    if (adv.First().UserId == spouseId)
                    {
                        return(RmbAccess.Spouse);
                    }
                    else
                    {
                        var team = from c in StaffBrokerFunctions.GetTeam(UserId) select c.UserID;

                        if (team.Contains((int)(adv.First().UserId)))
                        {
                            return(RmbAccess.Approver);
                        }
                    }
                }
            }
            return(RmbAccess.Denied);
        }
Esempio n. 2
0
        static public int GetNewAdvId(int PortalId)
        {
            string NextAdvID = StaffBrokerFunctions.GetSetting("NextAdvID", PortalId);

            if (NextAdvID == "")
            {
                StaffRmbDataContext d = new StaffRmbDataContext();
                var MaxAdvID          = (from c in d.AP_Staff_AdvanceRequests  where c.PortalId == PortalId select c.LocalAdvanceId);
                if (MaxAdvID.Count() == 0)
                {
                    StaffBrokerFunctions.SetSetting("NextAdvID", "2", PortalId);
                    return(1);
                }
                else
                {
                    StaffBrokerFunctions.SetSetting("NextAdvID", (MaxAdvID.Max() + 1).ToString(), PortalId);
                    return((int)MaxAdvID.First());
                }
            }
            else
            {
                StaffBrokerFunctions.SetSetting("NextAdvID", (Convert.ToInt32(NextAdvID) + 1).ToString(), PortalId);
                return(Convert.ToInt32(NextAdvID));
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _startDate = FirstDayOfMonthFromDateTime(DateTime.Today.AddMonths(-12));
            _endDate   = LastDayOfMonthFromDateTime(DateTime.Today);
            if (!Page.IsPostBack)
            {
                //First Load Countries From Thads Search

                DSPortalsService.DSPortalsSoapClient dsw = new DSPortalsService.DSPortalsSoapClient();
                var ssoGUID      = UserInfo.Profile.GetPropertyValue("ssoGUID");
                var resp         = dsw.GetPortalsForUserJson(ssoGUID).Distinct();
                var thisInstance = StaffBrokerFunctions.GetSetting("DataserverURL", PortalId);
                if (String.IsNullOrEmpty(thisInstance))
                {
                    thisInstance = "-unknownLocation";
                }


                //    MyCountries.Items.Add(new ListItem("South Africa", "https://tntdataserver.com/dataserver/rsa/dataquery/dataqueryservice.asmx"));


                foreach (DSPortalsService.DataserverPortal p in resp.OrderByDescending(x => x.InstanceUri.Contains(thisInstance)).ThenBy(y => y.InstanceName))
                {
                    MyCountries.Items.Add(new ListItem(p.InstanceName, p.InstanceUri));
                }


                //MyCountries.Items.Add(new ListItem("devtest","https://tntdataserver.eu/dataserver/devtest/dataquery/dataqueryservice.asmx"));
                //MyCountries.Items.Add(new ListItem("AgapeAOA","https://tntdataserver.eu/dataserver/AgapeAOA/dataquery/dataqueryservice.asmx"));



                ////

                if (MyCountries.Items.Count > 0)
                {
                    MyCountries_SelectedIndexChanged(this, null);
                    lblMessage.Visible = false;
                }
                else
                {
                    lblMessage.Text = "We cannot find an tntDataserver account for you in any country. Please contact the countries in which you receive donations, as ask them to add your TheKey account to their dataserver.";
                    string Message = "No DataServer accounts for: " + UserInfo.DisplayName + "(" + UserId.ToString() + ") " + ssoGUID + "CountryCount:" + MyCountries.Items.Count.ToString() + ";" + (resp.Count()).ToString();
                    DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();

                    objEventLog.AddLog("Accounts", Message, PortalSettings, UserId, Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT);

                    lblMessage.Visible = true;
                }
            }



            //   InitializeValues();
        }
Esempio n. 4
0
        static public int Authenticate(int UserId, int RmbNo, int PortalId)
        {
            StaffRmbDataContext d = new StaffRmbDataContext();
            var rmb = from c in d.AP_Staff_Rmbs where c.RMBNo == RmbNo && c.PortalId == PortalId select c;

            if (rmb.Count() > 0)
            {
                if (rmb.First().UserId == UserId)
                {
                    return(RmbAccess.Owner);
                }
                else if (rmb.First().ApprUserId == UserId)
                {
                    return(RmbAccess.Approver);
                }
                else
                {
                    var spouseId = StaffBrokerFunctions.GetSpouseId(UserId);
                    if (rmb.First().UserId == spouseId)
                    {
                        return(RmbAccess.Spouse);
                    }
                    else
                    {
                        var    team = from c in StaffBrokerFunctions.GetTeam(UserId) select c.UserID;
                        string pcc  = StaffBrokerFunctions.GetStaffMember(UserId).CostCenter;
                        if (rmb.First().CostCenter == pcc)
                        {
                            if (team.Contains(rmb.First().UserId))
                            {
                                return(RmbAccess.Approver);
                            }
                        }
                        else
                        {
                            var depts = from c in StaffBrokerFunctions.GetDepartments(UserId) select c.CostCentre;

                            if (depts.Contains(rmb.First().CostCenter))
                            {
                                return(RmbAccess.Approver);
                            }
                            else if (team.Contains(rmb.First().UserId))
                            {
                                return(RmbAccess.Leader);
                            }
                        }
                    }
                }
            }
            return(RmbAccess.Denied);
        }
Esempio n. 5
0
        private void PopulateDropdowns()
        {
            if (_myAccounts != null)
            {
                MyCountries.Visible        = true;
                MyCountries.DataSource     = _myAccounts.Countries;
                MyCountries.DataTextField  = "Name";
                MyCountries.DataValueField = "URL";
                MyCountries.DataBind();


                MyCountries.SelectedValue = StaffBrokerFunctions.GetSetting("https://tntdataserver.eu/dataserver/devtest/dataquery/dataqueryservice.asmx", PortalId);

                MyCountries_SelectedIndexChanged(this, null);
            }
        }
Esempio n. 6
0
        static public Approvers getAdvApprovers(AP_Staff_AdvanceRequest adv, double LargeTransaction, DotNetNuke.Entities.Users.UserInfo authUser, DotNetNuke.Entities.Users.UserInfo authAuthUser)
        {
            StaffBroker.StaffBrokerDataContext dStaff = new StaffBroker.StaffBrokerDataContext();
            Approvers rtn = new Approvers();

            var st = StaffBrokerFunctions.GetStaffMember((int)adv.UserId);

            rtn.Name = st.DisplayName;
            int SpouseId = StaffBrokerFunctions.GetSpouseId((int)adv.UserId);

            rtn.AmountSpecial = ((double)adv.RequestAmount) > LargeTransaction;

            rtn.SpouseSpecial = false;
            rtn.UserIds       = new List <DotNetNuke.Entities.Users.UserInfo>();

            var app2 = StaffBrokerFunctions.GetLeaders((int)adv.UserId, true);

            rtn.SpouseSpecial = (app2.Count() == 1 && ((app2.First() == SpouseId) || (app2.First() == (int)adv.UserId)));
            if (rtn.AmountSpecial || rtn.SpouseSpecial || app2.Count() == 0)
            {
                rtn.UserIds.Add(authUser.UserID == adv.UserId ? authAuthUser : authUser);

                if (app2.Contains((authUser.UserID == adv.UserId ? (authAuthUser.UserID) : authUser.UserID)))
                {
                    rtn.AmountSpecial = false;
                }
            }
            else
            {
                foreach (int i in (from c in app2 where c != adv.UserId && c != SpouseId select c))
                {
                    rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(adv.PortalId, i));
                }
            }



            return(rtn);
        }
Esempio n. 7
0
        static public Approvers getApprovers(AP_Staff_Rmb rmb, DotNetNuke.Entities.Users.UserInfo authUser, DotNetNuke.Entities.Users.UserInfo authAuthUser)
        {
            StaffBroker.StaffBrokerDataContext dStaff = new StaffBroker.StaffBrokerDataContext();
            Approvers rtn = new Approvers();

            var st = StaffBrokerFunctions.GetStaffMember(rmb.UserId);

            rtn.Name = st.DisplayName;
            int SpouseId = StaffBrokerFunctions.GetSpouseId(rmb.UserId);

            rtn.AmountSpecial = (from c in rmb.AP_Staff_RmbLines where c.LargeTransaction == true select c).Count() > 0;
            rtn.isDept        = (rmb.CostCenter != st.CostCenter);
            rtn.SpouseSpecial = false;
            rtn.UserIds       = new List <DotNetNuke.Entities.Users.UserInfo>();
            if (rtn.isDept)
            {
                var cc = from c in dStaff.AP_StaffBroker_Departments where (c.CostCentre == rmb.CostCenter) && c.PortalId == rmb.PortalId select c;
                rtn.CCMSpecial = (from c in cc
                                  where ((c.CostCentreManager == null && c.CostCentreDelegate == null) == false) &&
                                  (
                                      ((c.CostCentreManager != rmb.UserId) && (c.CostCentreManager != SpouseId)) ||
                                      ((c.CostCentreDelegate != rmb.UserId) && (c.CostCentreDelegate != SpouseId))

                                  )
                                  select c.CostCenterId).Count() == 0;

                if (rtn.CCMSpecial || rtn.AmountSpecial || rtn.SpouseSpecial)
                {
                    rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser);

                    if (cc.First().CostCentreManager == rtn.UserIds.First().UserID || cc.First().CostCentreDelegate == rtn.UserIds.First().UserID)
                    {
                        rtn.AmountSpecial = false;
                        rtn.CCMSpecial    = false;
                    }
                }
                else
                {
                    if (cc.First().CostCentreManager != rmb.UserId && cc.First().CostCentreManager != SpouseId && cc.First().CostCentreManager != null)
                    {
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, (int)cc.First().CostCentreManager));
                    }
                    if (cc.First().CostCentreDelegate != rmb.UserId && cc.First().CostCentreDelegate != SpouseId && cc.First().CostCentreDelegate != null)
                    {
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, (int)cc.First().CostCentreDelegate));
                    }
                }
                if (cc.Count() > 0)
                {
                    rtn.Name = cc.First().Name;
                }
            }
            else
            {
                rtn.CCMSpecial = false;
                var app2 = StaffBrokerFunctions.GetLeaders(rmb.UserId, true);
                rtn.SpouseSpecial = (app2.Count() == 1 && ((app2.First() == SpouseId) || (app2.First() == rmb.UserId)));
                if (rtn.AmountSpecial || rtn.SpouseSpecial || app2.Count() == 0)
                {
                    rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser);

                    if (app2.Contains(rtn.UserIds.First().UserID))
                    {
                        rtn.AmountSpecial = false;
                    }
                }
                else
                {
                    foreach (int i in (from c in app2 where c != rmb.UserId && c != SpouseId select c))
                    {
                        rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, i));
                    }
                }
            }

            if (rtn.UserIds.Count() == 0)
            {
                rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser);
            }



            return(rtn);
        }
    public static List <Donation> getDonations(string Username, string Password, string serviceURL, string Action, DateTime DateFrom, DateTime DateTo)
    {
        List <Donation> donations = new List <Donation>();
        HttpWebRequest  request   = (HttpWebRequest)WebRequest.Create(serviceURL);

        request.Method      = "POST";
        request.ContentType = "application/x-www-form-urlencoded";
        StringBuilder data = new StringBuilder();

        data.Append("Username="******"&Password="******"&Action=" + HttpUtility.UrlEncode(Action));
        data.Append("&DateFrom=" + HttpUtility.UrlEncode(DateFrom.ToString("M/d/yyyy")));
        data.Append("&DateTo=" + HttpUtility.UrlEncode(DateTo.ToString("M/d/yyyy")));
        data.Append("&Order=Date");
        request.ContentLength = data.Length;

        StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);

        requestWriter.Write(data);
        requestWriter.Close();

        try
        {
            WebResponse webResponse = request.GetResponse();
            if (!webResponse.ContentType.Contains("csv"))
            {
                Donation rtn = new Donation();
                rtn.DonorName = "Authentication/Connection Error. <a href=\"javascript: $('#divAddCountry').dialog('open');\">Click here</a> to reauthenticate.";

                rtn.PeopleId = -1;
                StaffBrokerFunctions.EventLog("MPD-ServiceError downloading Transaction for " + Username, rtn.DonorName, 1);
                donations.Add(rtn);
                return(donations);
            }

            Stream       webStream      = webResponse.GetResponseStream();
            StreamReader responseReader = new StreamReader(webStream);
            string       response       = responseReader.ReadToEnd();



            //Console.Out.WriteLine(response);
            responseReader.Close();



            CSVHelper csv   = new CSVHelper(response, ",");
            bool      first = true;
            foreach (string[] line in csv)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    try
                    {
                        Donation don = new Donation();
                        don.account   = int.Parse(line[0]);
                        don.PeopleId  = int.Parse(line[1]);
                        don.DonorName = line[2].Replace("\"", "");
                        IFormatProvider culture = new System.Globalization.CultureInfo("en-US");

                        don.DonationDate   = DateTime.Parse(line[3], culture);
                        don.DonationId     = line[4];
                        don.Payment_Method = line[6];
                        try
                        {
                            don.Amount = double.Parse(line[10], new System.Globalization.CultureInfo(""));
                        }
                        catch (Exception)
                        {
                            don.Amount = double.Parse(line[9], new System.Globalization.CultureInfo(""));
                        }



                        don.FiscalPeriod = don.DonationDate.ToString("yyyyMM");
                        don.MonthName    = don.DonationDate.ToString("MMM yy");
                        donations.Add(don);
                    }
                    catch (Exception e)
                    {
                        Donation rtn = new Donation();
                        StaffBrokerFunctions.EventLog("MPD-Service Error downloading a donation for " + Username, e.Message, 1);

                        rtn.DonorName = "There was an error downloading one or more of your donations: this list may not be complete.";
                        rtn.PeopleId  = -3;
                        donations.Add(rtn);
                    }
                }
            }



            return(donations);
        }
        catch (Exception e)
        {
            Donation rtn = new Donation();
            StaffBrokerFunctions.EventLog("MPD-Service Error Downloading Donations for " + Username, e.Message, 1);

            rtn.DonorName = "There was an error downloading your transations from the remote server.";
            rtn.PeopleId  = -2;
            donations.Add(rtn);
            return(donations);
        }
    }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            openAddCountry.ToolTip = Translate("btnAddCountryTooltip");
            lblNew.Text            = Translate("lblNew");
            _startDate             = FirstDayOfMonthFromDateTime(DateTime.Today.AddMonths(-12));
            _endDate = LastDayOfMonthFromDateTime(DateTime.Today);


            if (!Page.IsPostBack)
            {
                //First Load Countries From Thads Search

                DSPU.DSPortalUsers dspus = new DSPU.DSPortalUsers();
                ssoGUID = UserInfo.Profile.GetPropertyValue("ssoGUID");
                var resp = dspus.GetPortalsForUser("CASAUTH", "thecatsaysmeow3", ssoGUID);



                //DSPortalsService.DSPortalsSoapClient dsw = new DSPortalsService.DSPortalsSoapClient();

                //var resp = dsw.GetPortalsForUserJson(ssoGUID).Distinct();
                var thisInstance = StaffBrokerFunctions.GetSetting("DataserverURL", PortalId);
                if (String.IsNullOrEmpty(thisInstance))
                {
                    thisInstance = "-unknownLocation";
                }


                //    MyCountries.Items.Add(new ListItem("South Africa", "https://tntdataserver.com/dataserver/rsa/dataquery/dataqueryservice.asmx"));

                ////MyCountries.Items.Add(new ListItem("Bulgaria Test", "https://tntdataserver.eu/dataserver/bgr/dataquery/dataqueryservice.asmx"));

                foreach (var p in resp.OrderByDescending(x => x.PortalUri.Contains(thisInstance)).ThenBy(y => y.PortalName))
                {
                    MyCountries.Items.Add(new ListItem(p.PortalName, p.PortalUri));
                }

                MinistryView.MinistryViewDataContext dm = new MinistryView.MinistryViewDataContext();

                var addCountries = from c in dm.MinistryView_UserCountryProfiles where c.GUID == ssoGUID select new { c.UserCountryProfileId, c.MinistryView_AdditionalCountry.CountryName };
                foreach (var row in addCountries)
                {
                    MyCountries.Items.Add(new ListItem(row.CountryName, "ADD" + row.UserCountryProfileId));
                }



                //MyCountries.Items.Add(new ListItem("devtest","https://tntdataserver.eu/dataserver/devtest/dataquery/dataqueryservice.asmx"));
                //MyCountries.Items.Add(new ListItem("AgapeAOA","https://tntdataserver.eu/dataserver/AgapeAOA/dataquery/dataqueryservice.asmx"));



                ////

                if (MyCountries.Items.Count > 0)
                {
                    MyCountries_SelectedIndexChanged(this, null);
                    lblMessage.Visible = false;
                }
                else
                {
                    lblMessage.Text = Translate("lblMessage");
                    string Message = "No DataServer accounts for: " + UserInfo.DisplayName + "(" + UserId.ToString() + ") " + ssoGUID + "CountryCount:" + MyCountries.Items.Count.ToString() + ";" + (resp.Count()).ToString();
                    DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();

                    objEventLog.AddLog("Accounts", Message, PortalSettings, UserId, Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT);

                    lblMessage.Visible  = true;
                    accordion.Visible   = false;
                    divBalance.Visible  = false;
                    IncExpGraph.Visible = false;
                }
            }



            //   InitializeValues();
        }