Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //EASBusinessApi.DispatchService.DispatchServiceClient client=new DispatchServiceClient("127.0.0.1",8079);
            BusinessServiceClient.InitializeDefault("127.0.0.1", 8079);
            EASBusinessApi.DispatchService.BusinessServiceClient client = BusinessServiceClient.Default;

            Stopwatch stopwatch = new Stopwatch();


            stopwatch.Start();
            for (int i = 0; i < 1000; i++)
            {
                client.DispatchCreate(new DispatchRequest()
                {
                    ProcessKey = new BusinessProcessKey()
                    {
                        DataAreaId = "rp", StoreId = "1231312", TerminalId = "1234.00", OperationId = Guid.NewGuid().ToString()
                    },

                    DispatchId = $"00{i}", TransactionId = $"00000000{i}", BeginTime = DateTime.Now.ToBinary()
                });
            }

            stopwatch.Stop();



            Console.WriteLine($"Time watch {stopwatch.Elapsed}");

            /*stopwatch.Reset();
             * stopwatch.Start();
             * for (int i = 0; i < 1000; i++)
             *  client.ComDispatchUpdate(new ComDispatchRequest() { DispatchId = $"00{i}", DataAreaId = "rp", StoreId = "1231312", TerminalId = "1234.00", TransactionId = $"00000000{i}",CashVoucher = $"{i}",EndTime = DateTime.Now.ToBinary()});
             * stopwatch.Stop();
             *
             * Console.WriteLine($"Time watch {stopwatch.Elapsed}");
             */
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
 protected void Page_Init(object sender, EventArgs e)
 {
     _service = new BusinessServiceClient();
 }
Exemplo n.º 3
0
        public void Get(string uwmAccountID)
        {
            System.Console.WriteLine(uwmAccountID);

            // The first thing you need to do is make sure that your user is logged in. It is likely that you use some
            // sort of cookie for that.
            var currentUser = this.GetCurrentUser();

            if (currentUser == null)
            {
                this.redirectToLogin();
            }

            // Once you have the current user on your end, you need to know which account on the Vendasta end that the
            // user is supposed to access.

            // In the Vendasta system, users have access to accounts. Accounts are a "business" - a physical location,
            // and can have one or more users.

            // In UWM's case, I believe that the users are "brokers" - we need to figure out whether a broker matches
            // up to an account in the Vendasta system, or whether a broker matches up to a user, and there is some
            // other business that the broker would have access to.

            // For this example, let's assume a few things here:
            // 1. Accounts in the Vendasta system have a "customer identifier" field pre-populated that matches up to
            //    a UWM "account".
            // 2. The customer identifier is passed in via the URL (the {id} portion).
            // 3. The user may not have access to the specified account so you will want to run an access check,
            //    if applicable.

            // First, you should check that your user has access to the ID that is being requested on your end:
            if (!this.canUserAccessID(currentUser, uwmAccountID))
            {
                throw new System.UnauthorizedAccessException(); // or some kind of appropriate HTTP 403 error code.
            }

            // Once we know that the user has access to the specific account, we need to convert your account ID into
            // the Vendasta account ID (also known as a Business ID), in order to call the SSO API.
            //
            // We do so by searching for the business by customer ID:
            var req = new Business.V1.SearchRequest
            {
                Filters = new Business.V1.SearchRequest.Types.Filters
                {
                    PartnerId          = "USFS", // This is UWM's Partner ID.
                    CustomerIdentifier = uwmAccountID
                }
            };

            // In your actual code, you should store this client and reuse it, since it opens a new connection for each
            // instance.
            var _client = new BusinessServiceClient(Vendasta.Vax.Environment.Prod);
            var resp    = _client.Search(req);

            // You might want to make sure that you only get one business back here, and you will definitely want to
            // check that you get at least one business back.
            var vendastaAccountID = resp.Businesses[0].BusinessId;

            // Finally, we can call the Vendasta SSO service to get the authenticated URL:

            var _ssoClient = new IdentityProviderClient(Vendasta.Vax.Environment.Prod);

            // "SM" is Social Marketing's service provider ID
            // sessionID is a unique identifier from your system indicating your user's unique session.
            //     - It is recommended that you hash this value, Vendasta does not need the actual session ID from your
            //       end, just something unique that you can reference on your end.
            //     - For this example, I'm just using a new GUID
            //
            var urlBeforeAuthentication = string.Format("https://united-shore-financial-services-llc.socialsmbs.com/embed/account/{0}/compose", vendastaAccountID);
            var accountCtx = new Sso.V1.ServiceContext.Types.Account {
                AccountId = vendastaAccountID
            };
            var serviceContext = new Sso.V1.ServiceContext {
                Account = accountCtx
            };
            var ssoReq = new Sso.V1.GetEntryURLWithCodeRequest
            {
                Email             = currentUser.email,
                SessionId         = Guid.NewGuid().ToString(),
                ServiceProviderId = "SM",
                NextUrl           = urlBeforeAuthentication,
                UserId            = currentUser.userId,
                Context           = serviceContext
            };
            var ssoResp          = _ssoClient.GetEntryURLWithCode(ssoReq);
            var authenticatedUrl = ssoResp.EntryUrl;

            Response.Redirect(authenticatedUrl);
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblStatusSubmissionFailed.Visible = false;
            lblStatusSubmitted.Visible = false;
            lblZurichAdvFailed.Visible = false;
            lblZurichAdvSuccess.Visible = false;

            activity = activityStatusDao.getActivity(13);
            ViewState["activity"] = activity;

            ZPlanResponseDataContract zPlanResponse = null;
            string clonedFrom = "";

            if (!IsPostBack)
            {

                /*string nextCaseId = Request.Form["caseid"];
                string menuCaseId = Request.QueryString["caseid"];

                if (nextCaseId != null && nextCaseId != "")
                {
                    caseid = nextCaseId;
                }

                if (menuCaseId != null && menuCaseId != "")
                {
                    caseid = menuCaseId;
                }*/

                string activityID = string.Empty;

                string country = string.Empty;
                if (Request.Form["Country"] != null)
                {
                    country = Request.Form["Country"].ToString();
                }

                string salesChannel = string.Empty;
                if (Request.Form["SalesChannel"] != null)
                {
                    salesChannel = Request.Form["SalesChannel"].ToString();
                }

                if (Request.Form["ActivityID"] != null)
                {
                    activityID = Request.Form["ActivityID"].ToString();
                    //activityID = "1500";

                    ZPlanDataContract zPlanContract = new ZPlanDataContract();
                    zPlanContract.ActivityId = activityID;
                    zPlanContract.Activity = ActivityTypeEnum.ZPlan;
                    zPlanContract.Action = ActionEnumContracts.View;
                    UserInfoEntity ufo = new UserInfoEntity();
                    ufo.Country = country;
                    ufo.RoleType = salesChannel;
                    zPlanContract.UserInfo = ufo;
                    zPlanResponse = new ZPlanResponseDataContract();

                    try
                    {
                        BusinessServiceClient client = new BusinessServiceClient();
                        client.ClientCredentials.Windows.AllowedImpersonationLevel =
                            System.Security.Principal.TokenImpersonationLevel.Impersonation;
                        zPlanResponse = client.ManageZPlan(zPlanContract);

                        if (zPlanResponse != null)
                        {
                            salesportalinfo salesPortalDto = new salesportalinfo();
                            salesPortalDto.activityid = activityID;
                            salesPortalDto.activitytype = zPlanResponse.ActivityType;
                            salesPortalDto.caseid = zPlanResponse.CaseId;
                            salesPortalDto.redirecturl = zPlanResponse.RedirectUrl;
                            salesPortalDto.roletype = zPlanResponse.RoleType;
                            salesPortalDto.salesportalurl = zPlanResponse.SalesPortalUrl;
                            salesPortalDto.userfirstname = zPlanResponse.UserFirstName;
                            salesPortalDto.userid = zPlanResponse.UserId;
                            salesPortalDto.userlastname = zPlanResponse.UserLastName;
                            salesPortalDto.usertype = zPlanResponse.UserType;
                            salesPortalDto.casestatus = zPlanResponse.CaseStatus;
                            salesPortalDto.country = country;
                            salesPortalDto.saleschannel = salesChannel;
                            activityStatusDao.saveSalesPortalInfo(activityID, salesPortalDto);

                            caseid = zPlanResponse.ActivityId;

                            //check if ClonedFrom is sent from portal
                            if (zPlanResponse.ClonedFrom != null && zPlanResponse.ClonedFrom != "")
                            {
                                clonedFrom = zPlanResponse.ClonedFrom;

                                //check if case has been cloned earlier
                                clonemappingid clonemapping = activityStatusDao.getCloneMappingForCaseid(clonedFrom, zPlanResponse.ActivityId);

                                if (clonemapping == null)
                                {
                                    //if the case is not cloned, add entry in the clone mapping table and clone the case
                                    clonemapping = new clonemappingid();
                                    clonemapping.clonedfrom = clonedFrom;
                                    clonemapping.newid = zPlanResponse.ActivityId;
                                    activityStatusDao.saveClonemapping(clonemapping);

                                    activityStatusDao.cloneCase(clonedFrom, zPlanResponse.ActivityId);
                                }

                            }

                        }
                    }
                    catch (Exception ex)
                    {
                        //log exception to db
                        exceptionlog exLog = new exceptionlog();
                        exLog.message = ex.Message + " class: MyZurichAdviser Method: Page_Load";
                        exLog.source = ex.Source;

                        string strtmp = ex.StackTrace;
                        strtmp = strtmp.Replace('\r', ' ');
                        strtmp = strtmp.Replace('\n', ' ');
                        exLog.stacktrace = strtmp;

                        exLog.targetsitename = ex.TargetSite.Name;

                        activityStatusDao.logException(exLog);
                    }

                }
                else
                {
                    string backCaseId = Request.Form["caseid"];
                    string menuCaseId = Request.QueryString["caseid"];

                    if (backCaseId != null && backCaseId != "")
                    {
                        caseid = backCaseId;
                    }
                    else if (menuCaseId != null && menuCaseId != "")
                    {
                        caseid = menuCaseId;
                    }
                    else if (Session["fnacaseid"] != null)
                    {
                        caseid = Session["fnacaseid"].ToString();
                    }
                    else
                    {
                        caseid = "2040";
                    }

                }

                activityId.Value = caseid;
                PersonalDetailsDAO dao = new PersonalDetailsDAO();
                personaldetail detail = dao.getPersonalDetail(caseid);

                if (detail != null)
                {
                    if (zPlanResponse != null)
                    {
                        detail.datepicker = zPlanResponse.Dob;
                        detail.gender = zPlanResponse.Gender;
                        //detail.maritalstatus = zPlanResponse.MaritalStatus;
                        detail.name = zPlanResponse.UserFirstName;
                        detail.surname = zPlanResponse.UserLastName;
                        detail.nationality = zPlanResponse.Nationality;
                        detail.nric = zPlanResponse.NricOrPassport;
                        detail.occupation = zPlanResponse.Occupation;
                        if (zPlanResponse.Smoker)
                        {
                            detail.issmoker = "Yes";
                        }
                        else
                        {
                            detail.issmoker = "No";
                        }
                        detail.title = zPlanResponse.Title;
                    }

                    dao.updatePersonalDetails(detail);
                }
                else
                {
                    detail = new personaldetail();
                    detail.caseid = caseid;

                    if (zPlanResponse != null)
                    {
                        detail.datepicker = zPlanResponse.Dob;
                        detail.gender = zPlanResponse.Gender;
                        //detail.maritalstatus = zPlanResponse.MaritalStatus;
                        detail.name = zPlanResponse.UserFirstName;
                        detail.surname = zPlanResponse.UserLastName;
                        detail.nationality = zPlanResponse.Nationality;
                        detail.nric = zPlanResponse.NricOrPassport;
                        detail.occupation = zPlanResponse.Occupation;
                        if (zPlanResponse.Smoker)
                        {
                            detail.issmoker = "Yes";
                        }
                        else
                        {
                            detail.issmoker = "No";
                        }
                        detail.title = zPlanResponse.Title;
                    }
                    dao.savePersonalDetails(detail);
                }

                if (caseid != "")
                {
                    ViewState["caseid"] = caseid;

                    List<myzurichadviser> savedMzaoptions = mzaDao.getMza(caseid);

                    if (savedMzaoptions != null && savedMzaoptions.Count>0)
                    {
                        ViewState["casetype"] = "update";
                    }
                    else
                    {
                        ViewState["casetype"] = "new";
                        savedMzaoptions = new List<myzurichadviser>();
                        myzurichadviser mzadv = new myzurichadviser();
                        mzadv.caseid = caseid;
                        mzadv.selectedoptionid = 1;
                        savedMzaoptions.Add(mzadv);

                        mzadv = new myzurichadviser();
                        mzadv.caseid = caseid;
                        mzadv.selectedoptionid = 2;
                        savedMzaoptions.Add(mzadv);
                    }

                    populateMzaoptions(savedMzaoptions, caseid);

                }

            }
            markStatusOnTab(caseid);
        }