static void Main(string[] args) { Console.WriteLine("** PRESS ENTER TO AUTHORIZE THIS APP **"); Console.ReadKey(); // app validation string apiKey = ConfigurationManager.AppSettings["api-key"]; if (!string.IsNullOrEmpty(apiKey)) { AppAuth.AuthenticateAppAsync(apiKey); } Console.WriteLine("*** AUTHORIZED ***"); Console.ReadKey(); #region Getting list of Plans/Services Console.WriteLine("Getting List of Plans"); IEnumerable <Plan> plans = null; plans = GetPlansList().Result; #endregion Console.ReadKey(); #region CreateOffer Sample Console.WriteLine("Creating an Offer"); Offer offer = new Offer(); //offer.MerchantId = *merchantId*; // substitute with Merchant's Id //offer.AppId = *appId*; // substitute with App's Id //offer.Type = OfferType.PercentageOff; //offer.Reward = "10"; // offer amount // set this property if OfferType is BOGO // merchant.IsRewardBased = true; offer.Name = "5% Off anything in Opero Store."; //offer.Description = *description*; //offer.TermsConditions = *termsAndConditions*; //offer.Tags = *tags*; //offer.StartDate = *startDate*; //offer.EndDate = *endDate*; //offer.ExpiryDate = *expiryDate*; //offer.Limited = true; // set true if redemption is limited //offer.RedemptionLimit = 10; //offer.Share = false; //offer.OfferImage = *offerImage*; // save var result = SaveOffer(offer).Result; #endregion Console.ReadKey(); Console.Clear(); }
public async Task TestReflashTokenFailedAsync() { string testResultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApiResults", "GetTokenFailedResult.json"); string json = File.ReadAllText(testResultPath); Guid clientId = Guid.NewGuid(); var mocks = Utils.CreateDefaultGraphApiMock(json); await Utils.SetOneValueDbContextAsync(clientId); BotDbContext db = Utils.CreateMemoryDbContext(); AppAuth appAuth = await db.AppAuths.Include(appAuth => appAuth.AzureApp).FirstAsync(); DefaultGraphApi defaultGraphApi = new DefaultGraphApi(db, mocks.Item1, mocks.Item2); (string, string)_ = await defaultGraphApi.ReflashTokenAsync(appAuth); }
public async Task TestReflashTokenSuccessAsync() { string testResultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApiResults", "GetTokenSuccessResult.json"); string json = File.ReadAllText(testResultPath); Guid clientId = Guid.NewGuid(); var mocks = Utils.CreateDefaultGraphApiMock(json); await Utils.SetOneValueDbContextAsync(clientId); BotDbContext db = Utils.CreateMemoryDbContext(); AppAuth appAuth = await db.AppAuths.Include(appAuth => appAuth.AzureApp).FirstAsync(); DefaultGraphApi defaultGraphApi = new DefaultGraphApi(db, mocks.Item1, mocks.Item2); (string, string)tokens = await defaultGraphApi.ReflashTokenAsync(appAuth); JObject jObject = JObject.Parse(json); Assert.AreEqual(jObject["access_token"].ToString(), tokens.Item1); Assert.AreEqual(appAuth.Name, tokens.Item2); Assert.AreEqual(jObject["refresh_token"].ToString(), appAuth.RefreshToken); }
/// <summary> /// 查詢使用者的所有 o365 授權 /// /// 列出 o365 授權的詳細訊息 /// </summary> /// <param name="callbackQuery"> Telegram callbackQuery object </param> /// <returns></returns> private async Task QueryUserAuthCallback(CallbackQuery callbackQuery) { AppAuth auth = await telegramHandler.GetAuthInfoAsync(callbackQuery.Data); string text = "查無此授權"; if (auth != null) { string[] infos = new string[] { $"授權識別碼: {auth.Id}", $"授權別名: {auth.Name}", $"Refresh token: {auth.RefreshToken}", $"Scope: {auth.Scope}", $"綁定時間: {auth.BindTime}", $"Token 更新的時間: {auth.UpdateTime}" }; text = string.Join('\n', infos); } await botClient.SendTextMessageAsync( chatId : callbackQuery.From.Id, text : text); }
public static Ice.DispatchStatus reset_cellphone___(AppAuth obj__, IceInternal.Incoming inS__, Ice.Current current__) { Ice.ObjectImpl.checkMode__(Ice.OperationMode.Normal, current__.mode); IceInternal.BasicStream is__ = inS__.startReadParams(); string newCellphone; string verifyCode0; string verifyCode1; newCellphone = is__.readString(); verifyCode0 = is__.readString(); verifyCode1 = is__.readString(); inS__.endReadParams(); try { int ret__ = obj__.reset_cellphone(newCellphone, verifyCode0, verifyCode1, current__); IceInternal.BasicStream os__ = inS__.startWriteParams__(Ice.FormatType.DefaultFormat); os__.writeInt(ret__); inS__.endWriteParams__(true); return Ice.DispatchStatus.DispatchOK; } catch(minie.irpc.VerificationError ex__) { inS__.writeUserException__(ex__, Ice.FormatType.DefaultFormat); return Ice.DispatchStatus.DispatchUserException; } }
public static Ice.DispatchStatus send_verification_sms___(AppAuth obj__, IceInternal.Incoming inS__, Ice.Current current__) { Ice.ObjectImpl.checkMode__(Ice.OperationMode.Normal, current__.mode); IceInternal.BasicStream is__ = inS__.startReadParams(); string cellphone; cellphone = is__.readString(); inS__.endReadParams(); bool ret__ = obj__.send_verification_sms(cellphone, current__); IceInternal.BasicStream os__ = inS__.startWriteParams__(Ice.FormatType.DefaultFormat); os__.writeBool(ret__); inS__.endWriteParams__(true); return Ice.DispatchStatus.DispatchOK; }
public static Ice.DispatchStatus register_user___(AppAuth obj__, IceInternal.Incoming inS__, Ice.Current current__) { Ice.ObjectImpl.checkMode__(Ice.OperationMode.Normal, current__.mode); IceInternal.BasicStream is__ = inS__.startReadParams(); string cellphone; string verificationCode; cellphone = is__.readString(); verificationCode = is__.readString(); inS__.endReadParams(); minie.irpc.AppServicePrx ret__ = obj__.register_user(cellphone, verificationCode, current__); IceInternal.BasicStream os__ = inS__.startWriteParams__(Ice.FormatType.DefaultFormat); minie.irpc.AppServicePrxHelper.write__(os__, ret__); inS__.endWriteParams__(true); return Ice.DispatchStatus.DispatchOK; }
public static void write(Ice.OutputStream outS__, AppAuth v__) { outS__.writeObject(v__); }
public static Ice.DispatchStatus login_app_by_token___(AppAuth obj__, IceInternal.Incoming inS__, Ice.Current current__) { Ice.ObjectImpl.checkMode__(Ice.OperationMode.Normal, current__.mode); IceInternal.BasicStream is__ = inS__.startReadParams(); string token; token = is__.readString(); inS__.endReadParams(); try { minie.irpc.AppServicePrx ret__ = obj__.login_app_by_token(token, current__); IceInternal.BasicStream os__ = inS__.startWriteParams__(Ice.FormatType.DefaultFormat); minie.irpc.AppServicePrxHelper.write__(os__, ret__); inS__.endWriteParams__(true); return Ice.DispatchStatus.DispatchOK; } catch(minie.irpc.AuthError ex__) { inS__.writeUserException__(ex__, Ice.FormatType.DefaultFormat); return Ice.DispatchStatus.DispatchUserException; } }
private static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(true); if (!CEmbeddedApplication.IsEmbeddedApplication(args)) { RsViewEngine.InitializeCore(); RsViewEngine.InitializeApplication(); string lRpt = ""; // Argument processing: for (int i = 0; i < args.Length; i++) { if (args[i] == "-o" || args[i] == "--open") { lRpt = args.Length > i + 1 ? args[i + 1] : ""; } } #if DEBUG #warning RS View: DEBUG build ReportSmart.Controls.CRSMessageBox.ShowBox("ReportSmart View now running in DEBUG mode.", "Debug"); #elif (DEMO) #warning RS View: DEMO build #else #warning RS View: RELEASE build #endif #if DEMO try { string lProjID = RsViewEngine.GetProjectID(); long lVal = AppAuth.chkshwauthfrw(AppAuth.crdtstamp(RsViewEngine.ReferenceTime, _YM, _MM, _DM), _YM, _MM, _DM, _PERIOD); long lChkval = AppAuth.gnchkval(_YM, _MM, _DM, _PERIOD); CdlgDemoAlert.ShowDemoAlert(lVal, lChkval, _PERIOD); if ((lVal - lChkval) <= 0) { RsViewEngine.KillApplication(); } Math.Sqrt((lVal - lChkval)); } catch { RsViewEngine.KillApplication(); } #endif if (lRpt != "") { RsViewEngine.MainForm.OpenReport(FileSystem.NameOf(lRpt), lRpt); } System.Windows.Forms.Application.Run(RsViewEngine.MainForm); } else { CEmbeddedApplication lEmbApp = new CEmbeddedApplication(args[1]); RsViewEngine.InitializeCore(); RsViewEngine.InitializeEmbedded(lEmbApp); CRSReportViewerEmbedded lViewer = new CRSReportViewerEmbedded(); lViewer.EmbeddedApplication = lEmbApp; lViewer.ReportFile = args[2]; lViewer.ReportTitle = args[3]; lViewer.Location = new System.Drawing.Point(0, 0); lViewer.Size = new System.Drawing.Size(640, 480); lViewer.Anchor = (AnchorStyles)(AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom); lViewer.EmbeddedApplication.IntegrateControl(lViewer); Messaging.SendMessage(lViewer.EmbeddedApplication.Handle, Messaging.WM_REGISTERME, (uint)lViewer.Handle, 0); lViewer.OpenReport(); System.Windows.Forms.Application.ApplicationExit += new EventHandler(RsViewEngine.EH_ApplicationExit); System.Windows.Forms.Application.Run(); } }