public void bindCommunities()
    {
        try
        {
            string whereCondition = "";
            // if (Filter != null)
            {
                Uri ServiceUri = new Uri(svcUri_Base);
                PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
                DataAccessLayer.IgnoreMissingProperties = true;
                DataAccessLayer.Credentials             = new NetworkCredential(svcLogin, svcPassword);

                ///bind data membership details
                var membershipDetails = DataAccessLayer.CustomerInfos.Where(p => p.CustomerClassCode == "CHAPTER" && p.RecordType == "T").Select(o => o).ToList().OrderBy(m => m.LabelName);
                if (membershipDetails != null)
                {
                    rptSub.DataSource = membershipDetails;
                    rptSub.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString() + "Executing Query<b> ");
        }
    }
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        drpCountry.SelectedIndexChanged += DrpCountry_SelectedIndexChanged;
        if (StopProcessing)
        {
            return;
        }
        else if (!this.IsPostBack)
        {
            // Init selector for countries
            var service = new PersonifyEntitiesBase(new Uri(svcUri_Base));
            service.IgnoreMissingProperties = true;
            service.Credentials             = new System.Net.NetworkCredential(svcLogin, svcPassword);
            var countries = service.Countries.Where(x => x.ActiveFlag == true).ToList().OrderBy(x => x.CountryCode == "USA" ? 0 : 1).ThenBy(x => x.CountryDescription).ToList();

            drpCountry.DataSource     = countries;
            drpCountry.DataTextField  = "CountryDescription";
            drpCountry.DataValueField = "CountryCode";
            drpCountry.DataBind();
            drpCountry.Items.Insert(0, new ListItem("-- Please Select --", String.Empty));
            drpCountry.SelectedValue = "USA";

            PopulateState(service);
        }
    }
Example #3
0
    public void bindCommunities()
    {
        try
        {
            string whereCondition = "";
            if (DivisionFilter != null)
            {
                litTitle.Text  = "Division Committees";
                whereCondition = "  where CustomerClassCode='" + DivisionFilter + "' ";
                string dataServiceUri      = ConfigurationManager.AppSettings["svcUri_Base"];
                string dataServiceUserName = ConfigurationManager.AppSettings["svcLogin"];
                string dataServicePassword = ConfigurationManager.AppSettings["svcPassword"];


                Uri ServiceUri = new Uri(dataServiceUri);
                PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
                DataAccessLayer.IgnoreMissingProperties = true;
                DataAccessLayer.Credentials             = new NetworkCredential(dataServiceUserName, dataServicePassword);
                var cusDemographics = DataAccessLayer.CusRelationships.Where(p => p.MasterCustomerId == DivisionFilter).Select(o => o).ToList();
                cusDemographics.Where(p => p.RelationshipType == "Committee").Select(o => o);
                cusDemographics.Where(p => p.RelationshipType == "Committee").Select(o => o);
                if (cusDemographics != null)
                {
                    rptSub.DataSource = cusDemographics;
                    rptSub.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            //Response.Write(ex.ToString() + "Executing Query<b> ");
        }
    }
    private void DrpCountry_SelectedIndexChanged(object sender, EventArgs e)
    {
        var service = new PersonifyEntitiesBase(new Uri(svcUri_Base));

        service.IgnoreMissingProperties = true;
        service.Credentials             = new System.Net.NetworkCredential(svcLogin, svcPassword);
        PopulateState(service);
    }
    private void BindStateDropdown(PersonifyEntitiesBase service)
    {
        var selectedCountry = drpCountry.SelectedValue;

        var state = service.States.Where(x => x.ActiveFlag == true && x.CountryCodeString == selectedCountry).ToList();

        drpState.DataTextField  = "StateDescription";
        drpState.DataValueField = "StateCode";
        drpState.SelectedIndex  = 0;
        drpState.DataBind();
    }
    /// <summary>
    /// Loads and selects control.
    /// </summary>
    /// <param name="forceReload">Indicates if items should be reloaded even if control contains some values</param>
    private void LoadAndSelectList(bool forceReload = false)
    {
        if (forceReload)
        {
            // Keep selected value
            mSelectedValue = dropDownList.SelectedValue;

            // Clears values if forced reload is requested
            dropDownList.Items.Clear();
        }

        if (dropDownList.Items.Count == 0)
        {
            try
            {
                if (string.IsNullOrEmpty(AppCode))
                {
                    throw new InvalidOperationException("AppCode must be set.");
                }
                else if (string.IsNullOrEmpty(Subsystem))
                {
                    throw new InvalidOperationException("Subsystem must be set.");
                }
                else if (string.IsNullOrEmpty(Type))
                {
                    throw new InvalidOperationException("Type must be set.");
                }
                else
                {
                    // Init selector for countries
                    var service = new PersonifyEntitiesBase(new Uri(svcUri_Base));
                    service.IgnoreMissingProperties = true;
                    service.Credentials             = new System.Net.NetworkCredential(svcLogin, svcPassword);
                    var appCode     = this.AppCode;
                    var subsystem   = this.Subsystem;
                    var type        = this.Type;
                    var appsubcodes = service.ApplicationSubcodes.Where(x => x.ActiveFlag == true && x.AvailableToWebFlag == true && x.Code == appCode && x.Subsystem == subsystem && x.Type == type).ToList().OrderBy(x => x.DisplayOrder).ToList();

                    dropDownList.DataSource     = appsubcodes;
                    dropDownList.DataTextField  = "Description";
                    dropDownList.DataValueField = "Subcode";
                    dropDownList.DataBind();
                    dropDownList.Items.Insert(0, new ListItem("-- Please Select --", String.Empty));
                    dropDownList.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                DisplayException(ex);
            }

            FormHelper.SelectSingleValue(mSelectedValue, dropDownList, true);
        }
    }
Example #7
0
    public bool CheckOrderRate()
    {
        UserInfo user       = MembershipContext.AuthenticatedUser;
        string   customerID = user.GetStringValue("PersonifyIdentifier", "");

        // check for empty customer id
        if (String.IsNullOrEmpty(customerID))
        {
            return(false);
        }

        if (customerID.Contains("|"))
        {
            customerID = customerID.Substring(0, (customerID.IndexOf('|')));
        }

        // look up orders with a rate code of MEAI
        // Build service call
        Uri ServiceUri = new Uri(SUri);
        PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);

        DataAccessLayer.Credentials = new NetworkCredential(UserName, Password);

        List <OrderDetailInfo> orderList = new List <OrderDetailInfo>();

        try
        {
            // Get all unpaid membership orders
            var orderInfo = DataAccessLayer.OrderDetailInfos.Where(o => o.ShipMasterCustomerId == customerID && o.RateCode == "MEAI");

            // No orders with MEAI rate code, let them continue
            if (orderInfo == null)
            {
                return(true);
            }

            if (orderInfo.ToList().Count == 0)
            {
                return(true);
            }
        }
        catch (Exception excp)
        {
            EventLogProvider.LogException("OneMine MEAI", "Lookup", excp, SiteContext.CurrentSiteID, "CustomerID : " + customerID);
        }


        return(false);
    }
    public void LoadCommunitiesfromDataservice()
    {
        try
        {
            string del = "delete dbo.Sme_Membershiplist";
            execute(del);
            //string customerClassCode = CustomerData.CustomerClassCode.Value;
            Uri ServiceUri = new Uri(SUri);
            PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
            DataAccessLayer.Credentials = new NetworkCredential(UserName, Password);
            string ProductId           = string.Empty;
            string ProductCode         = string.Empty;
            string OrganizationUnitId  = string.Empty;
            string ShortName           = string.Empty;
            string WebLongDescription  = string.Empty;
            string WebShortDescription = string.Empty;

            var CommuniteeList = DataAccessLayer.WebMembershipJoinProducts.ToList();//DataAccessLayer.CustomerInfos.Where(p => p.RecordType == "T").Select(o => o).ToList();

            if (CommuniteeList != null)
            {
                foreach (var community in CommuniteeList)
                {
                    ProductId           = community.ProductId.ToString();
                    ProductCode         = community.ProductCode;
                    OrganizationUnitId  = community.OrganizationUnitId;
                    ShortName           = community.ShortName;
                    WebLongDescription  = community.WebLongDescription.ToString();
                    WebShortDescription = community.WebShortDescription.ToString();
                    // Create new item for custom table with "Sme.CommiteesMaster" code name
                    var item = CustomTableItem.New("Sme.Membershiplist");
                    item.SetValue("ProductId", ProductId);
                    item.SetValue("ProductCode", ProductCode);
                    item.SetValue("OrganizationUnitId", OrganizationUnitId);
                    item.SetValue("ShortName", ShortName);
                    item.SetValue("WebLongDescription", WebLongDescription);
                    item.SetValue("WebShortDescription", WebShortDescription);
                    item.Insert();

                    Response.Write(" Committee : " + ProductCode + " in the commitee group : " + ShortName + " Product Id : " + ProductId + "<br/>");
                }
            }
        }
        catch (Exception Ex)
        {
            Response.Write(Ex.ToString());
        }
    }
    private void PopulateState(PersonifyEntitiesBase service)
    {
        var selectedCountryValue = drpCountry.SelectedValue;

        if (String.IsNullOrEmpty(selectedCountryValue))
        {
            divState.Visible = false;
            if (drpState.Items.Count > 0)
            {
                drpState.Items.Clear();
            }
            txtAddress1.Text      = String.Empty;
            divAddress1.Visible   = false;
            txtAddress2.Text      = String.Empty;
            divAddress2.Visible   = false;
            txtCity.Text          = String.Empty;
            divCity.Visible       = false;
            txtPostalCode.Text    = String.Empty;
            divPostalCode.Visible = false;
        }
        else
        {
            divState.Visible      = true;
            divAddress1.Visible   = true;
            divAddress2.Visible   = true;
            divCity.Visible       = true;
            divPostalCode.Visible = true;

            var state = service.States.Where(x => x.ActiveFlag == true && x.CountryCodeString == selectedCountryValue).ToList().OrderBy(x => x.CountryCodeString);

            drpState.DataSource     = state;
            drpState.DataTextField  = "StateDescription";
            drpState.DataValueField = "StateCode";
            drpState.DataBind();
            if (drpState.Items.Count > 0)
            {
                divState.Visible = true;
                drpState.Items.Insert(0, new ListItem("-- Please Select --", String.Empty));
                drpState.SelectedIndex = 0;
            }
            else
            {
                divState.Visible = false;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string svcUri_Base = ConfigurationManager.AppSettings["svcUri_Base"];
        string svcLogin    = ConfigurationManager.AppSettings["svcLogin"];
        string svcPassword = ConfigurationManager.AppSettings["svcPassword"];
        Uri    ServiceUri  = new Uri(svcUri_Base);
        PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);

        DataAccessLayer.Credentials = new NetworkCredential(svcLogin, svcPassword);

        ///bind data membership details
        var membershipDetails = DataAccessLayer.CustomerInfos.Where(o => o.CustomerClassCode == "CHAPTER");

        foreach (var member in membershipDetails)
        {
            Response.Write(member.CustomerClassCode);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        drpCountry.SelectedIndexChanged += DrpCountry_SelectedIndexChanged;
        if (!this.Page.IsPostBack)
        {
            Uri serviceUri = new Uri(svcUri_Base);

            var service = new PersonifyEntitiesBase(serviceUri);
            service.IgnoreMissingProperties = true;
            service.Credentials             = new System.Net.NetworkCredential(svcLogin, svcPassword);


            var countries = service.Countries.Where(x => x.ActiveFlag == true).ToList().OrderBy(x => x.CountryCode == "USA" ? 0 : 1).ThenBy(x => x.CountryDescription).ToList();

            drpCountry.DataSource     = countries;
            drpCountry.DataTextField  = "CountryDescription";
            drpCountry.DataValueField = "CountryCode";
            drpCountry.SelectedIndex  = 0;
            drpCountry.DataBind();

            BindStateDropdown(service);
        }
    }
Example #12
0
    public void bindCommunities()
    {
        try
        {
            string whereCondition = "";
            if (Filter != null)
            {
                Uri ServiceUri = new Uri(svcUri_Base);
                PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
                DataAccessLayer.IgnoreMissingProperties = true;
                DataAccessLayer.Credentials             = new NetworkCredential(svcLogin, svcPassword);

                ///bind data membership details

                var membershipDetails = DataAccessLayer.WebMembershipJoinProducts.Where(p => p.ProductId == Convert.ToInt64(Filter)).Select(o => o).ToList();

                if (membershipDetails != null)
                {
                    rptmain.DataSource = membershipDetails;
                    rptmain.DataBind();
                }

                ////bind price
                var cusDemographics = DataAccessLayer.ProductPricingInfos.Where(p => p.ProductId == Convert.ToInt64(Filter)).Select(o => o).ToList().OrderBy(m => m.SortOrder);

                if (cusDemographics != null)
                {
                    rptSub.DataSource = cusDemographics;
                    rptSub.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString() + "Executing Query<b> ");
        }
    }
Example #13
0
        public string Execute(TaskInfo ti)
        {
            try
            {
                string        eventName        = string.Empty;
                string        eventStartdate   = string.Empty;
                string        eventEnddate     = string.Empty;
                string        eventDescription = string.Empty;
                string        eventCategory    = string.Empty;
                long          eventProductId;
                StringBuilder documentsAddedStatus = new StringBuilder();//string eventLocation = string.Empty;
                string        eventWebsite         = string.Empty;
                string        eventContact         = string.Empty;
                string        eventFax             = string.Empty;
                string        eventFacilityID      = string.Empty;

                //Communicates with personify web service and gets the list of meetings

                string dataServiceUri      = ConfigurationManager.AppSettings["svcUri_Base"];
                string dataServiceUserName = ConfigurationManager.AppSettings["svcLogin"];
                string dataServicePassword = ConfigurationManager.AppSettings["svcPassword"];

                Uri ServiceUri = new Uri(dataServiceUri);
                PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
                DataAccessLayer.Credentials = new NetworkCredential(dataServiceUserName, dataServicePassword);
                var eventsListPersonify = DataAccessLayer.WebProductViews.Where(p => p.Subsystem == "MTG" && p.MeetingEndDate >= DateTime.Now.AddDays(-2)).ToList();

                DataSet eventsList = DocumentHelper.GetDocuments("SME.EVENT")
                                     .OnSite(SiteContext.CurrentSiteName)
                                     .Culture("en-us")
                                     .CombineWithDefaultCulture(false)
                                     .All();

                string un  = "smeadmin";
                string pwd = "533@dm1n";

                //authenticates user for publishing documents/pages/events
                AuthenticateUser(un, pwd);

                UserInfo ui = UserInfoProvider.GetUserInfo(un);


                // Create new instance of the Tree provider
                TreeProvider tree = new TreeProvider(ui);

                // Get parent node
                TreeNode parentNode = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/events-professional-development/events", "en-us");

                foreach (var events in eventsListPersonify)
                {
                    eventName        = events.ShortName;
                    eventProductId   = events.ProductId;
                    eventStartdate   = events.MeetingStartDate.ToString();
                    eventEnddate     = events.MeetingEndDate.ToString();
                    eventDescription = events.WebShortDescription;
                    eventCategory    = events.ProductClassCodeString;
                    eventFacilityID  = events.FacilityMasterCustomerId;

                    string[] addressDelimiter = new string[] { "\r\n" };
                    string[] address;
                    string   eventAddress        = string.Empty;
                    string   eventCity           = string.Empty;
                    string   eventCountry        = string.Empty;
                    string   eventStateProvince  = string.Empty;
                    string   eventZipPostalCode  = string.Empty;
                    string   eventLocation       = string.Empty;
                    string   eventEmail          = string.Empty;
                    string   eventPhone          = string.Empty;
                    bool     isAllowSocialEvents = events.ProductClassCodeString.ToLower() != "social_event";

                    if (eventFacilityID != "" && eventFacilityID != null)
                    {
                        var CommuniteeList = DataAccessLayer.AddressInfos.Where(p => p.MasterCustomerId == eventFacilityID).ToList();

                        foreach (var item in CommuniteeList)
                        {
                            address            = item.AddressLabel.Split(addressDelimiter, StringSplitOptions.None);
                            eventAddress       = address[0] + " " + address[1];
                            eventCity          = item.City;
                            eventCountry       = item.CountryCode;
                            eventStateProvince = item.State;
                            eventZipPostalCode = item.PostalCode;
                            eventLocation      = item.City + ", " + item.CountryCode;
                            eventEmail         = item.MailStop;
                            eventPhone         = item.PersonalLine;
                        }
                    }

                    if (parentNode != null)
                    {
                        if (!DocumentExists(events.ProductId, eventsList) && isAllowSocialEvents)
                        {
                            // Create documents

                            var newNode = CMS.DocumentEngine.TreeNode.New("SME.EVENT", tree);
                            newNode.DocumentName    = events.LongName;
                            newNode.NodeAlias       = eventName;
                            newNode.DocumentCulture = "en-us";
                            newNode.SetValue("EventName", eventName);
                            newNode.SetValue("ProductId", eventProductId);
                            newNode.SetValue("StartDate", eventStartdate);
                            newNode.SetValue("EndDate", eventEnddate);
                            newNode.SetValue("EventDetails", eventDescription);
                            newNode.SetValue("EventCategory", eventCategory);
                            newNode.SetValue("Location", eventLocation);
                            //newNode.SetValue("TargetUrl", eventWebsite);
                            //newNode.SetValue("Contact", eventContact);
                            newNode.SetValue("email", eventEmail);
                            newNode.SetValue("Address", eventAddress);
                            newNode.SetValue("City", eventCity);
                            newNode.SetValue("State_Province", eventStateProvince);
                            newNode.SetValue("Zip_PostalCode", eventZipPostalCode);
                            newNode.SetValue("Country", eventCountry);
                            newNode.SetValue("Phone", eventPhone);
                            newNode.SetValue("AllowPersonifyUpdate", true);
                            //newNode.SetValue("Fax", eventFax);
                            newNode.DocumentPageTemplateID = 24357;
                            newNode.Insert(parentNode);
                            //newNode.Publish();
                            documentsAddedStatus.Append("Meeting " + eventName + " added into kentico at " + DateTime.Now + Environment.NewLine);
                        }
                        else
                        {
                            // Update the Document
                            var updateNode = eventsList.Tables[0].AsEnumerable().Where(row => events.ProductId == row.Field <long?>("ProductId")).Select(row => new
                            {
                                ID = row.Field <int>("NodeId"),
                            }).ToList();
                            if (updateNode.Count == 1 && isAllowSocialEvents)
                            {
                                TreeNode node = tree.SelectSingleNode(updateNode[0].ID, "en-us", "SME.Event");

                                if (node.GetBooleanValue("AllowPersonifyUpdate", false))
                                {
                                    //node.DocumentName = events.LongName;
                                    //node.NodeAlias = eventName;
                                    node.DocumentCulture = "en-us";
                                    //node.SetValue("EventName", eventName);
                                    node.SetValue("ProductId", eventProductId);
                                    node.SetValue("StartDate", eventStartdate);
                                    node.SetValue("EndDate", eventEnddate);
                                    //this is the optional field which editors can update from CMS Desk.
                                    //node.SetValue("EventDetails", eventDescription);
                                    node.SetValue("EventCategory", eventCategory);
                                    node.SetValue("Location", eventLocation);
                                    //node.SetValue("TargetUrl", eventWebsite);
                                    //node.SetValue("Contact", eventContact);
                                    node.SetValue("email", eventEmail);
                                    node.SetValue("Address", eventAddress);
                                    node.SetValue("City", eventCity);
                                    node.SetValue("State_Province", eventStateProvince);
                                    node.SetValue("Zip_PostalCode", eventZipPostalCode);
                                    node.SetValue("Country", eventCountry);
                                    node.SetValue("Phone", eventPhone);
                                    //node.SetValue("Fax", eventFax);

                                    node.SetValue("LastUpdate", DateTime.Now);

                                    node.DocumentPageTemplateID = 24357;
                                    node.Update();
                                    DocumentHelper.UpdateDocument(node);
                                    //node.Publish();
                                    documentsAddedStatus.Append("Meeting " + eventName + " updated in kentico at " + DateTime.Now + Environment.NewLine);
                                }
                                else
                                {
                                    documentsAddedStatus.Append("Meeting " + eventName + " skipped due to document setting in document at " + DateTime.Now + Environment.NewLine);
                                }
                            }
                        }
                    }
                }



                EventLogProvider.LogInformation("PersonifyMeeting", "Import", documentsAddedStatus.ToString());
            }
            catch (Exception ex)
            {
                EventLogProvider.LogException("PersonifyMeeting", "Import", ex);
            }
            return(null);
        }
Example #14
0
    public void bindCommunities()
    {
        try
        {
            string id = "";
            if (Request.QueryString["ID"] != null)
            {
                id = Request.QueryString["ID"];

                /////cache it



                string parentQueryRepeater =
                    " select distinct CommitteeLabelName from Sme_CommiteesMembers where  committeeMasterCustomer ='"
                    + id + "'  ";
                DataSet dsParent = new DataSet();

                string dataServiceUri      = ConfigurationManager.AppSettings["svcUri_Base"];
                string dataServiceUserName = ConfigurationManager.AppSettings["svcLogin"];
                string dataServicePassword = ConfigurationManager.AppSettings["svcPassword"];


                /* Uri ServiceUri = new Uri("http://smemi.personifycloud.com/PersonifyDataServices/PersonifyDatasme.svc");
                 * Personify.WebControls.Base.PersonifyDataServicesBase.PersonifyEntitiesBase DataAccessLayer =
                 *   new Personify.WebControls.Base.PersonifyDataServicesBase.PersonifyEntitiesBase(ServiceUri);*/


                Uri ServiceUri = new Uri(dataServiceUri);
                PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
                DataAccessLayer.IgnoreMissingProperties = true;
                // DataAccessLayer.Credentials = new NetworkCredential("admin", "admin");
                //  DataAccessLayer.Credentials = new NetworkCredential("admin", "admin");

                DataAccessLayer.Credentials = new NetworkCredential(dataServiceUserName, dataServicePassword);
                var CommitteeList =
                    DataAccessLayer.CustomerInfos.Where(p => p.MasterCustomerId == id).Select(o => o).ToList();
                var CommitteeLabelName = CommitteeList.Select(p => p.LabelName).Distinct().ToList();
                try
                {
                    if (CommitteeLabelName != null)
                    {
                        if (CommitteeLabelName.Count > 0)
                        {
                            committeeName.Text = CommitteeLabelName[0].ToString();
                        }
                    }
                }
                catch (Exception ex2)
                {
                }

                /* cached Section */
                DataTable myTable = new DataTable();
                using (
                    var cs = new CachedSection <DataTable>(
                        ref myTable,
                        60000,
                        true,
                        null,
                        "PersonifyUsersfor|" + Request.QueryString["ID"]))
                {
                    if (cs.LoadData)
                    {
                        var CommuniteeList =
                            DataAccessLayer.CommitteeMembers.Where(p => p.CommitteeMasterCustomer == id)
                            .Select(o => o)
                            .ToList();
                        var current = CommuniteeList.Where(p => p.EndDate >= DateTime.Now).Select(o => o).ToList();
                        current = current.Where(p => p.BeginDate <= DateTime.Now).Select(o => o).ToList();
                        //.GroupBy(x => x.MemberAddressId, (key, group) => group.First());
                        var distinct =
                            current.GroupBy(x => x.CommitteeMemberLastFirstName, (key, group) => group.First()).ToList();
                        //current.Select(o => o.MemberAddressId).Distinct().Select(o => o).ToList();
                        if (distinct != null)
                        {
                            myTable =
                                ToDataTable <personifyDataservice.CommitteeMember>(
                                    current);
                            myTable.Columns.Add("SortOrder", typeof(System.Int32));

                            foreach (DataRow dr in myTable.Rows)
                            {
                                //need to set value to MyRow column
                                dr["SortOrder"] =
                                    Convert.ToInt16(
                                        returnDepartmentNumber(
                                            dr["PositionCodeDescriptionDisplay"].ToString().ToLower()));
                                // or set it to some other value
                            }
                        }
                        cs.Data = myTable;
                    }
                }

                /* cached Section */
                DataView dv = myTable.DefaultView;
                dv.Sort = "SortOrder asc";
                DataTable sortedDT = dv.ToTable();
                rptSub.DataSource = sortedDT;
                rptSub.DataBind();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString() + "Executing Query<b>  ");
        }
    }
Example #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Uri ServiceUri = new Uri(SUri);
        PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);

        DataAccessLayer.Credentials = new NetworkCredential(UserName, Password);
        _webControlParameters       = DataAccessLayer.WebControlParameters.ToList();


        if (_webControlParameters.Count > 0)
        {
            foreach (var x  in _webControlParameters)
            {
                //

                string customTableClassName = "Sme.personifyPages";
                string where = "ParameterName='" + x.ParameterName + "'";

                // Check if Custom table 'Sme.CommiteesMembers' exists
                DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);


                CustomTableItem item = CustomTableItem.New("Sme.personifyPages");
                item.SetValue("ParameterValue", x.ParameterValue);
                item.SetValue("ParameterName", x.ParameterName);
                item.Insert();
                //DataSet customTableRecord = CustomTableItemProvider.GetItems(customTableClassName, where);

                //int ItemID = 0;
                // if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                //    {
                //        // Get the custom table item ID
                //        ItemID = ValidationHelper.GetInteger(customTableRecord.Tables[0].Rows[0][0], 0);
                //    }

                //if (customTable != null)
                //{
                //    if (ItemID == 0)
                //    {
                //        CustomTableItem item = CustomTableItem.New("Sme.CommiteesMembers");
                //        item.SetValue("ParameterValue", x.ParameterValue);
                //        item.SetValue(" ParameterName", x.ParameterName);
                //        item.Insert();
                //    }

                //    else
                //    {

                //        if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                //        {
                //            CustomTableItem updateItem = CustomTableItemProvider.GetItem(ItemID, customTableClassName);
                //            if (updateItem != null)
                //            {
                //                updateItem.SetValue("ParameterValue", x.ParameterValue);
                //                updateItem.SetValue(" ParameterName", x.ParameterName);

                //                updateItem.Update();
                //            }
                //        }
                //    }
                //}

                ///
                Response.Write(x.ParameterValue + "---" + x.ParameterName + "<br/>");
            }
        }
    }
Example #16
0
    /// <summary>
    /// Verify User in Kentico
    /// </summary>
    /// <param name="customerToken">Decrypted Customer Token</param>
    /// <param name="userName">Username of Customer</param>
    private void VerifyKenticoUser(string customerToken, string userName)
    {
        // Get CustomerID
        var res = ssoClient.TIMSSCustomerIdentifierGet(_personifySsoVendorName, _personifySsoVendorPassword, customerToken);

        if (res != null && !String.IsNullOrEmpty(res.CustomerIdentifier))
        {
            var    aIdentifiers      = res.CustomerIdentifier.Split('|');
            string sMasterCustomerId = aIdentifiers[0];
            int    subCustomerId     = int.Parse(aIdentifiers[1]);

            Uri ServiceUri = new Uri(svcUri_Base);

            LoginUsertokentico.WriteError("AuthenticateCustomer ID ==>", sMasterCustomerId.ToString());

            // Get User details from Personify
            PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
            DataAccessLayer.Credentials = new NetworkCredential(svcLogin, svcPassword);

            var userdetails =
                DataAccessLayer.CusNameDemographics.Where(p => p.MasterCustomerId == sMasterCustomerId)
                .Select(o => o)
                .ToList()
                .FirstOrDefault();

            string pfirstname = null;
            string plastname  = null;

            if (userdetails == null)
            {
                pfirstname = @"&nbsp;";
                plastname  = @"&nbsp;";
            }
            if (userdetails != null && string.IsNullOrWhiteSpace(userdetails.FirstName))
            {
                pfirstname = @"&nbsp;";
            }
            else
            {
                if (userdetails != null)
                {
                    pfirstname = userdetails.FirstName;
                }
            }
            if (userdetails != null && string.IsNullOrWhiteSpace(userdetails.LastName))
            {
                plastname = @"&nbsp;";
            }
            else
            {
                if (userdetails != null)
                {
                    plastname = userdetails.LastName;
                }
            }
            //*******End Custom Dataservice code to get Firstname, Lastname***********//

            string[] memberGroups = GetImsroles(customerToken);

            string groupslist = String.Empty;

            if (memberGroups.Length > 0)
            {
                foreach (string s in memberGroups)
                {
                    if (s.Length > 0)
                    {
                        groupslist += s + ",";
                    }
                }
            }

            groupslist += "peronifyUser" + ",";



            string login = new LoginUsertokentico().CreateUpdateLoginUserinKentico(
                userName,
                pfirstname,
                plastname,
                userName,
                groupslist,
                true,
                false, res.CustomerIdentifier, customerToken);
            userinfo uInfo = new userinfo
            {
                ID         = sMasterCustomerId,
                Token      = Session[PersonifySessionKey].ToString(),
                email      = userName,
                firstname  = pfirstname,
                lastname   = plastname,
                username   = userName,
                groupNames = groupslist
            };

            // Add info to Session variable
            Session["userClass"] = uInfo;
        }
        else
        {
            EventLogProvider.LogException("SSOHandler", "Verify", new Exception("Unable to retrieve personify ID. Customer Token: " + Request.QueryString["ct"].ToString() + " <br />Decrypted Token: " + customerToken + "  <br />Username: " + userName));
            // should not get here
            URLHelper.Redirect(_loginErrorUrl);
        }
    }
    //This method uses the msterCustomerID (remoteID) and looks up the coresponding UserID value in the database for this user.
    //This is done because looking up user by UserName will not work when the username is updated in AMS (Personify).
    //This method returns the UserId in Ektron based on RemoteID/CustomerID from Personify.

    private string AuthenticateCustomer(string customerIdentifier, string email, string userName)
    {
        string sMasterCustomerId = "";
        string pfirstname        = "";
        string plastname         = "";
        int    subCustomerId     = 0;
        string groupslist        = "";

        try
        {
            if (customerIdentifier.Contains('|'))
            {
                var aIdentifiers = customerIdentifier.Split('|');
                sMasterCustomerId = aIdentifiers[0];
                subCustomerId     = int.Parse(aIdentifiers[1]);
            }
            else
            {
                sMasterCustomerId = customerIdentifier;
            }

            //*******Start Custom Dataservice code to get Firstname, Lastname***********//
            Uri ServiceUri = new Uri(svcUri_Base);
            LoginUsertokentico.WriteError("AuthenticateCustomer ID ==>", sMasterCustomerId.ToString());
            PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
            DataAccessLayer.IgnoreMissingProperties = true;
            DataAccessLayer.Credentials             = new NetworkCredential(svcLogin, svcPassword);

            var userdetails =
                DataAccessLayer.CusNameDemographics.Where(p => p.MasterCustomerId == sMasterCustomerId)
                .Select(o => o)
                .ToList()
                .FirstOrDefault();

            pfirstname = null;
            plastname  = null;
            if (userdetails == null)
            {
                pfirstname = @"&nbsp;";
                plastname  = @"&nbsp;";
            }
            if (userdetails != null && string.IsNullOrWhiteSpace(userdetails.FirstName))
            {
                pfirstname = @"&nbsp;";
            }
            else
            {
                if (userdetails != null)
                {
                    pfirstname = userdetails.FirstName;
                }
            }
            if (userdetails != null && string.IsNullOrWhiteSpace(userdetails.LastName))
            {
                plastname = @"&nbsp;";
            }
            else
            {
                if (userdetails != null)
                {
                    plastname = userdetails.LastName;
                }
            }
            //*******End Custom Dataservice code to get Firstname, Lastname***********//

            string[] memberGroups = GetImsroles(sMasterCustomerId, subCustomerId);

            if (memberGroups.Length > 0)
            {
                foreach (string s in memberGroups)
                {
                    if (s.Length > 0)
                    {
                        groupslist += s + ",";
                    }
                }
            }

            groupslist += "peronifyUser" + ",";



            string login = objKenticoService.CreateUpdateLoginUserinKentico(
                userName,
                pfirstname,
                plastname,
                email,
                groupslist,
                true,
                false);
            userinfo uInfo = new userinfo
            {
                ID         = sMasterCustomerId,
                Token      = Session["PersonifyToken"].ToString(),
                email      = email,
                firstname  = pfirstname,
                lastname   = plastname,
                username   = userName,
                groupNames = groupslist
            };


            Session["userClass"] = uInfo;
            return(login);
        }
        catch (Exception exception)
        {
            EventLogProvider.LogException("AuthenticateCustomer", "Get", exception);
            LoginUsertokentico.WriteError("AuthenticateCustomer", exception.ToString());
            return(null);
        }
    }
Example #18
0
        public void runRoles()
        {
            try
            {
                string del = "delete dbo.Sme_Membershiplist";
                execute(del);
                //string customerClassCode = CustomerData.CustomerClassCode.Value;
                Uri ServiceUri = new Uri(SUri);
                PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
                DataAccessLayer.Credentials = new NetworkCredential(UserName, Password);
                string ProductId           = string.Empty;
                string ProductCode         = string.Empty;
                string OrganizationUnitId  = string.Empty;
                string ShortName           = string.Empty;
                string WebLongDescription  = string.Empty;
                string WebShortDescription = string.Empty;

                var CommuniteeList = DataAccessLayer.WebMembershipJoinProducts.ToList();//DataAccessLayer.CustomerInfos.Where(p => p.RecordType == "T").Select(o => o).ToList();

                if (CommuniteeList != null)
                {
                    foreach (var community in CommuniteeList)
                    {
                        ProductId           = community.ProductId.ToString();
                        ProductCode         = community.ProductCode;
                        OrganizationUnitId  = community.OrganizationUnitId;
                        ShortName           = community.ShortName;
                        WebLongDescription  = community.WebLongDescription.ToString();
                        WebShortDescription = community.WebShortDescription.ToString();
                        // Create new item for custom table with "Sme.CommiteesMaster" code name
                        var item = CustomTableItem.New("Sme.Membershiplist");
                        item.SetValue("ProductId", ProductId);
                        item.SetValue("ProductCode", ProductCode);
                        item.SetValue("OrganizationUnitId", OrganizationUnitId);
                        item.SetValue("ShortName", ShortName);
                        item.SetValue("WebLongDescription", WebLongDescription);
                        item.SetValue("WebShortDescription", WebShortDescription);
                        item.Insert();

                        StringBuilder documentsAddedStatus = new StringBuilder();
                        //string eventLocation = string.Empty;
                        string rootFolder = "error";
                        string folderName = "task";
                        string fileName   = "DocumentsStatusLogged.txt";
                        string filePath   = Path.Combine(
                            AppDomain.CurrentDomain.BaseDirectory,
                            rootFolder,
                            folderName,
                            fileName);
                        documentsAddedStatus.Append(
                            "role Added" + ProductCode + ShortName.Trim()
                            + Environment.NewLine);
                        using (StreamWriter writer = new StreamWriter(filePath, true))
                        {
                            writer.WriteLine(documentsAddedStatus);
                            writer.WriteLine(
                                Environment.NewLine
                                + "-----------------------------------------------------------------------------"
                                + Environment.NewLine);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string folderName = "error";
                string fileName   = "ExceptionLogged.txt";
                string filePath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, folderName, fileName);

                File.Delete(filePath);

                using (StreamWriter writer = new StreamWriter(filePath, true))
                {
                    writer.WriteLine(
                        "Message :" + ex.Message + Environment.NewLine + "StackTrace :" + ex.StackTrace + ""
                        + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                    writer.WriteLine(
                        Environment.NewLine
                        + "-----------------------------------------------------------------------------"
                        + Environment.NewLine);
                }
            }
        }
Example #19
0
    public void LoadIndividualData(int pageFrom, int pageTo)
    {
        StringBuilder documentsAddedStatus = new StringBuilder();

        string Query = "select * from (select distinct MasterCustomerId,LabelName,ROW_NUMBER() over (ORDER BY MasterCustomerId) AS Number from dbo.Sme_CommiteesMaster) as com where Number>=" + pageFrom + "AND Number<=" + pageTo;

        var      queryToGetCommittees = new QueryParameters(Query, null, CMS.DataEngine.QueryTypeEnum.SQLQuery, false);
        DataSet  ds = ConnectionHelper.ExecuteQuery(queryToGetCommittees);  //ExecQuery(Query); //("pb.account_types.select_accounts", null, where, null);
        string   CommitteeMemberId            = string.Empty;
        DateTime BeginDate                    = new DateTime();
        string   CommitteeMasterCustomer      = string.Empty;
        string   CommitteeMemberLastFirstName = string.Empty;
        string   CommitteeSubCustomer         = string.Empty;
        DateTime EndDate                        = new DateTime();
        string   MemberAddressId                = string.Empty;
        string   MemberAddressTypeCodeString    = string.Empty;
        string   MemberMasterCustomer           = string.Empty;
        string   ParticipationStatusCodeString  = string.Empty;
        string   PositionCodeDescriptionDisplay = string.Empty;
        string   PositionCodeString             = string.Empty;
        string   VotingStatusCodeString         = string.Empty;
        string   CommitteeLabelName             = string.Empty;

        if (ds.Tables[0].Rows.Count > 0)
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Uri ServiceUri =
                    new Uri("http://smemitst.personifycloud.com/PersonifyDataServices/PersonifyDatasme.svc");
                PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
                DataAccessLayer.Credentials = new NetworkCredential("admin", "admin");
                var CommiteeMembers =
                    DataAccessLayer.CommitteeMembers.Where(p => p.CommitteeMasterCustomer == dr["MasterCustomerId"])
                    .Select(o => o)
                    .ToList();
                if (CommiteeMembers != null)
                {
                    foreach (var member in CommiteeMembers)
                    {
                        CommitteeMemberId            = member.CommitteeMemberId.ToString();
                        BeginDate                    = Convert.ToDateTime(member.BeginDate);
                        CommitteeMasterCustomer      = member.CommitteeMasterCustomer;
                        CommitteeMemberLastFirstName = member.CommitteeMemberLastFirstName;
                        CommitteeSubCustomer         = member.CommitteeSubCustomer.ToString();
                        MemberAddressId              = member.MemberAddressId.ToString();

                        MemberAddressTypeCodeString    = member.MemberAddressTypeCodeString;
                        MemberMasterCustomer           = member.MemberMasterCustomer;
                        ParticipationStatusCodeString  = member.ParticipationStatusCodeString;
                        PositionCodeDescriptionDisplay = member.PositionCodeDescriptionDisplay.ToString();


                        PositionCodeString     = member.PositionCodeString;
                        VotingStatusCodeString = member.VotingStatusCodeString.ToString();
                        CommitteeLabelName     = member.CommitteeLabelName;
                        EndDate = Convert.ToDateTime(member.EndDate);

                        string customTableClassName = "Sme.CommiteesMembers";
                        string where = "CommitteeMemberId='" + CommitteeMemberId + "' AND CommitteeMemberLastFirstName='" + CommitteeMemberLastFirstName.Replace("'", "''") + "'";

                        // Check if Custom table 'Sme.CommiteesMembers' exists
                        DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);

                        DataSet customTableRecord = CustomTableItemProvider.GetItems(customTableClassName, where);

                        int memberID = 0;

                        if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                        {
                            // Get the custom table item ID
                            memberID = ValidationHelper.GetInteger(customTableRecord.Tables[0].Rows[0][0], 0);
                        }


                        if (customTable != null)
                        {
                            if (memberID == 0)
                            {
                                if (EndDate >= DateTime.Now ||
                                    PositionCodeDescriptionDisplay.ToLower().Contains("president"))
                                {
                                    // Create new item for custom table with "Sme.CommiteesMembers" code name
                                    CustomTableItem item = CustomTableItem.New("Sme.CommiteesMembers");
                                    item.SetValue("CommitteeMemberId", CommitteeMemberId);
                                    item.SetValue("BeginDate", BeginDate);
                                    item.SetValue("CommitteeMasterCustomer", CommitteeMasterCustomer);
                                    item.SetValue("CommitteeMemberLastFirstName", CommitteeMemberLastFirstName.Replace("'", "''"));
                                    item.SetValue("CommitteeSubCustomer", CommitteeSubCustomer);

                                    item.SetValue("MemberAddressId", MemberAddressId);
                                    item.SetValue("MemberAddressTypeCodeString", MemberAddressTypeCodeString);
                                    item.SetValue("MemberMasterCustomer", MemberMasterCustomer);
                                    item.SetValue("ParticipationStatusCodeString", ParticipationStatusCodeString);
                                    item.SetValue("PositionCodeDescriptionDisplay", PositionCodeDescriptionDisplay);
                                    item.SetValue("PositionCodeString", PositionCodeString);

                                    item.SetValue("VotingStatusCodeString", VotingStatusCodeString);
                                    item.SetValue("CommitteeLabelName", CommitteeLabelName);
                                    item.SetValue("EndDate", EndDate);
                                    item.Insert();
                                }

                                /*documentsAddedStatus.Append(
                                 *  "Added CommitteeLabelName : " + CommitteeLabelName + " in the CommitteeMemberId: "
                                 + CommitteeMemberId + "at" + DateTime.Now + Environment.NewLine);*/
                            }
                            else
                            {
                                if (!DataHelper.DataSourceIsEmpty(customTableRecord))
                                {
                                    // Get the custom table item
                                    CustomTableItem updateItem = CustomTableItemProvider.GetItem(memberID, customTableClassName);

                                    if (updateItem != null)
                                    {
                                        if (EndDate >= DateTime.Now ||
                                            PositionCodeDescriptionDisplay.ToLower().Contains("president"))
                                        {
                                            //updateItem.SetValue("CommitteeMemberId", CommitteeMemberId);
                                            updateItem.SetValue("BeginDate", BeginDate);
                                            updateItem.SetValue("CommitteeMasterCustomer", CommitteeMasterCustomer);
                                            updateItem.SetValue("CommitteeMemberLastFirstName", CommitteeMemberLastFirstName.Replace("'", "''"));
                                            updateItem.SetValue("CommitteeSubCustomer", CommitteeSubCustomer);

                                            updateItem.SetValue("MemberAddressId", MemberAddressId);
                                            updateItem.SetValue(
                                                "MemberAddressTypeCodeString",
                                                MemberAddressTypeCodeString);
                                            updateItem.SetValue("MemberMasterCustomer", MemberMasterCustomer);
                                            updateItem.SetValue(
                                                "ParticipationStatusCodeString",
                                                ParticipationStatusCodeString);
                                            updateItem.SetValue(
                                                "PositionCodeDescriptionDisplay",
                                                PositionCodeDescriptionDisplay);
                                            updateItem.SetValue("PositionCodeString", PositionCodeString);

                                            updateItem.SetValue("VotingStatusCodeString", VotingStatusCodeString);
                                            updateItem.SetValue("CommitteeLabelName", CommitteeLabelName);
                                            updateItem.SetValue("EndDate", EndDate);
                                            updateItem.Update();

                                            /*documentsAddedStatus.Append(
                                             * "Updated CommitteeLabelName : " + CommitteeLabelName + " in the CommitteeMemberId: "
                                             + CommitteeMemberId + "at" + DateTime.Now + Environment.NewLine);*/
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                /*string rootFolder = "CMSWebParts";
                 * string folderName = "SME";
                 * string fileName = "CommitteeMembersStatusLogged.txt";
                 * string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, rootFolder, folderName, fileName);
                 *
                 * using (StreamWriter writer = new StreamWriter(filePath, true))
                 * {
                 *  writer.WriteLine(documentsAddedStatus);
                 *  writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
                 *  writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
                 * }*/
            }
        }
    }
Example #20
0
    private static String LookupRenewalStatus(CacheSettings cs, String CustomerID)
    {
        // Build service call
        Uri ServiceUri = new Uri(SUri);
        PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);

        DataAccessLayer.Credentials = new NetworkCredential(UserName, Password);

        List <OrderDetailInfo> orderList = new List <OrderDetailInfo>();

        try
        {
            DataAccessLayer.RenewalNationalMemberships.Where(rm => rm.ShipMasterCustomerId == CustomerID);


            // Get all unpaid or canceled membership orders
            var orderInfo = DataAccessLayer.OrderDetailInfos.Where(o => o.ShipMasterCustomerId == CustomerID && o.ProductCode == "PROF1YR");
            //

            if (orderInfo == null)
            {
                return("current");
            }

            orderList = orderInfo.ToList();
            orderList = orderList.OrderByDescending(o => o.OrderNumber).Take(2).ToList(); // get 2 most recent orders
        }
        catch (Exception excp)
        {
            EventLogProvider.LogException("RenewalStatus", "Lookup", excp, SiteContext.CurrentSiteID, "CustomerID : " + CustomerID);
            return("join");
        }

        if (cs.Cached)
        {
            // Sets a cache dependency for the data
            // The data is removed from the cache if the objects represented by the dummy key are modified (all user objects in this case)
            cs.CacheDependency = CacheHelper.GetCacheDependency("cms.user|all");
        }

        /*
         * // No orders, then re
         * if (orderList == null)
         *  return "join";
         * else if (orderList.Count == 0)
         *  return "current";
         * // 1 open order, then renew or join if last order was canceled
         * else if (orderList.Count == 1)
         * {
         *  if (orderList[0].LineStatusCode == "C")  // last order was unpaid, they're no longer an active member
         *      return "join";
         *  else // Line Status Code = P
         *      return "renew";
         * }
         *
         * // more than 1 open order, then they need to join
         * else
         *  return "join";
         */

        if (orderList.Count == 0)
        {
            return("join");
        }
        else if (orderList.Count == 1)
        {
            if (orderList[0].LineStatusCode == "A") // 1 order that's been approved
            {
                return("current");
            }
            else
            {
                return("join");
            }
        }
        else
        {
            //EventLogProvider.LogInformation("Renewal", "Lookup", "Order #1: " + orderList[0].LineStatusCode + " " + orderList[0].OrderDate + " " + orderList[0].FulfillStatusCodeString + "<br />Order #2" + orderList[1].LineStatusCode + " " + orderList[1].OrderDate + " " + orderList[1].FulfillStatusCodeString);

            if (orderList[0].LineStatusCode == "A") // Latest membership was paid
            {
                return("current");
            }

            if (orderList[0].LineStatusCode == "C" && orderList[1].LineStatusCode == "C")  // all orders canceled
            {
                return("join");
            }

            // previous order was processed - Active
            if (orderList[1].LineStatusCode == "A")
            {
                if (orderList[0].LineStatusCode == "P") // open renewal - Pending
                {
                    return("renew");
                }
                else if (orderList[0].LineStatusCode == "C") // Most recent order canceled
                {
                    return("join");
                }
            }

            return("current");
        }
    }
    //This method uses the msterCustomerID (remoteID) and looks up the coresponding UserID value in the database for this user.
    //This is done because looking up user by UserName will not work when the username is updated in AMS (Personify).
    //This method returns the UserId in Ektron based on RemoteID/CustomerID from Personify.

    private string AuthenticateCustomer(string customerIdentifier, string email, string userName)
    {
        string sMasterCustomerId = "";
        string pfirstname        = "";
        string plastname         = "";
        int    subCustomerId     = 0;
        string groupslist        = "";

        try
        {
            var aIdentifiers = customerIdentifier.Split('|');
            sMasterCustomerId = aIdentifiers[0];
            subCustomerId     = int.Parse(aIdentifiers[1]);

            //*******Custom Dataservice code to get Firstname, Lastname*****//
            var personifyuser = new Personify.WebControls.Base.Business.PersonifyIdentity
            {
                ContainerName    = "Kentico",
                CurrencyCode     = "USD",
                MasterCustomerId =
                    sMasterCustomerId,
                SubCustomerId =
                    subCustomerId
            };
            //  var userdetails = new DemographicProvider().GetCusNameDemographic(personifyuser);
            // Uri ServiceUri = new Uri("http://smemi.personifycloud.com/PersonifyDataServices/PersonifyDatasme.svc");
            Uri ServiceUri = new Uri(svcUri_Base);

            LoginUsertokentico.WriteError("AuthenticateCustomer ID ==>", sMasterCustomerId.ToString());

            PersonifyEntitiesBase DataAccessLayer = new PersonifyEntitiesBase(ServiceUri);
            //  DataAccessLayer.Credentials = new NetworkCredential("admin", "admin123");
            DataAccessLayer.Credentials = new NetworkCredential(svcLogin, svcPassword);
            // var userdetails = DataAccessLayer.CusNameDemographics.Where(p => p.MasterCustomerId == sMasterCustomerId).Select(o => o).ToList().FirstOrDefault();
            var userdetails =
                DataAccessLayer.CusNameDemographics.Where(p => p.MasterCustomerId == sMasterCustomerId)
                .Select(o => o)
                .ToList()
                .FirstOrDefault();
            // var userdetails = new DemographicProvider().GetCusNameDemographic(personifyuser);
            pfirstname = null;
            plastname  = null;

            if (userdetails == null)
            {
                pfirstname = @"&nbsp;";
                plastname  = @"&nbsp;";
            }
            if (userdetails != null && string.IsNullOrWhiteSpace(userdetails.FirstName))
            {
                pfirstname = @"&nbsp;";
            }
            else
            {
                if (userdetails != null)
                {
                    pfirstname = userdetails.FirstName;
                }
            }
            if (userdetails != null && string.IsNullOrWhiteSpace(userdetails.LastName))
            {
                plastname = @"&nbsp;";
            }
            else
            {
                if (userdetails != null)
                {
                    plastname = userdetails.LastName;
                }
            }
            //*******End Custom Dataservice code to get Firstname, Lastname***********//

            string[] memberGroups = GetImsroles(sMasterCustomerId, subCustomerId);

            if (memberGroups.Length > 0)
            {
                foreach (string s in memberGroups)
                {
                    if (s.Length > 0)
                    {
                        groupslist += s + ",";
                    }
                }
            }

            groupslist += "peronifyUser" + ",";



            string login = objKenticoService.CreateUpdateLoginUserinKentico(
                userName,
                pfirstname,
                plastname,
                email,
                groupslist,
                true,
                false);
            userinfo uInfo = new userinfo
            {
                ID         = sMasterCustomerId,
                Token      = Session["PersonifyToken"].ToString(),
                email      = email,
                firstname  = pfirstname,
                lastname   = plastname,
                username   = userName,
                groupNames = groupslist
            };


            Session["userClass"] = uInfo;
            return(login);
        }
        catch (Exception exception)
        {
            EventLogProvider.LogException("AuthenticateCustomer", "Get", exception);
            LoginUsertokentico.WriteError("AuthenticateCustomer", exception.ToString());
            return(null);
            // evp.LogEvent("Source", "EventCode", exception,1);
            //evp.LogEvent("AuthenticateCustomer", "Get", exception.ToString(),"","",0,"",0,"","",0,"","","",DateTime.Now);
        }
    }