本文整理汇总了C#中System.App.Auth方法的典型用法代码示例。如果您正苦于以下问题:C# App.Auth方法的具体用法?C# App.Auth怎么用?C# App.Auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.App
的用法示例。
在下文中一共展示了App.Auth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanSync
public const string DescriptionHeaderName = "# CrossSync: "; // Don't modify this.
#endregion Fields
#region Methods
public static bool CanSync(out CybozuException ex)
{
ex = null;
Properties.Settings settings = Properties.Settings.Default;
if (!IsConfigured(settings)) return false;
App firstApp, secondApp;
Schedule firstSchedule, secondSchedule;
try
{
firstApp = new App(settings.FirstUrl);
firstApp.Auth(settings.FirstUsername, settings.FirstPassword);
firstSchedule = new Schedule(firstApp);
secondApp = new App(settings.SecondUrl);
secondApp.Auth(settings.SecondUsername, settings.SecondPassword);
secondSchedule = new Schedule(secondApp);
}
catch (CybozuException e)
{
// fail to auth
ex = e;
return false;
}
catch (Exception)
{
return false;
}
return true;
}
示例2: Apply
private bool Apply()
{
if (string.IsNullOrEmpty(this.firstUrl.Text) && string.IsNullOrEmpty(this.secondUrl.Text))
{
this.syncButton.Enabled = false;
Properties.Settings.Default.Save();
return true;
}
string url1 = TrimUrl(this.firstUrl.Text);
if (string.IsNullOrEmpty(url1))
{
MessageBox.Show(string.Format(Resources.Account1Error, Resources.URLIsInvalid), Resources.ProductName);
return false;
}
string url2 = TrimUrl(this.secondUrl.Text);
if (string.IsNullOrEmpty(url2))
{
MessageBox.Show(string.Format(Resources.Account2Error, Resources.URLIsInvalid), Resources.ProductName);
return false;
}
App app;
try
{
app = new App(url1);
app.Auth(this.firstUsername.Text, this.firstPassword.Text);
}
catch (CybozuException ex)
{
if (!ShowMessageIfLicenseError(ex))
{
MessageBox.Show(string.Format(Resources.Account1Error, ex.Message), Resources.ProductName);
}
return false;
}
catch (UriFormatException ex)
{
MessageBox.Show(ex.Message);
return false;
}
catch (WebException ex)
{
MessageBox.Show(ex.Message);
return false;
}
if (string.IsNullOrEmpty(this.firstPostfix.Text))
{
MessageBox.Show(string.Format(Resources.Account1Error, Resources.PostfixIsNecessary), Resources.ProductName);
return false;
}
try
{
app = new App(url2);
app.Auth(this.secondUsername.Text, this.secondPassword.Text);
}
catch (CybozuException ex)
{
if (!ShowMessageIfLicenseError(ex))
{
MessageBox.Show(string.Format(Resources.Account2Error, ex.Message), Resources.ProductName);
}
return false;
}
catch (UriFormatException ex)
{
MessageBox.Show(ex.Message);
return false;
}
catch (WebException ex)
{
MessageBox.Show(ex.Message);
return false;
}
if (string.IsNullOrEmpty(this.secondPostfix.Text))
{
MessageBox.Show(string.Format(Resources.Account2Error, Resources.PostfixIsNecessary), Resources.ProductName);
return false;
}
this.firstUrl.Text = url1;
this.secondUrl.Text = url2;
Properties.Settings settings = Properties.Settings.Default;
int intervalIndex = this.syncInterval.SelectedIndex;
if (intervalIndex >= 0)
{
int nextInterval = (int)(double.Parse(intervals[intervalIndex]) * 60);
if (settings.SyncInterval != nextInterval)
{
settings.SyncInterval = nextInterval;
SetTimerInterval(settings);
}
}
this.syncButton.Enabled = true;
//.........这里部分代码省略.........
示例3: Sync
public static bool Sync()
{
Properties.Settings settings = Properties.Settings.Default;
if (!IsConfigured(settings)) return false;
App firstApp = new App(settings.FirstUrl);
firstApp.Auth(settings.FirstUsername, settings.FirstPassword);
Schedule firstSchedule = new Schedule(firstApp);
App secondApp = new App(settings.SecondUrl);
secondApp.Auth(settings.SecondUsername, settings.SecondPassword);
Schedule secondSchedule = new Schedule(secondApp);
// sync span
DateTime start = DateTime.Now.Date;
DateTime end = start.AddMonths(1);
// current events in first
ScheduleEventCollection event1to2 = new ScheduleEventCollection();
ScheduleEventCollection event1from2 = new ScheduleEventCollection();
GetEvents(firstApp, firstSchedule, settings.SecondPostfix, start, end, event1to2, event1from2);
// current events in second
ScheduleEventCollection event2to1 = new ScheduleEventCollection();
ScheduleEventCollection event2from1 = new ScheduleEventCollection();
GetEvents(secondApp, secondSchedule, settings.FirstPostfix, start, end, event2to1, event2from1);
// remove not modified
UnsetNotModified(event1to2, event2to1, event2from1, settings.FirstPostfix);
UnsetNotModified(event2to1, event1to2, event1from2, settings.SecondPostfix);
// remove old copied events
RemoveInvalidCopiedEvents(secondSchedule, event2from1);
RemoveInvalidCopiedEvents(firstSchedule, event1from2);
// add new copied events
CopyValidEvents(secondSchedule, event1to2, settings.FirstPostfix);
CopyValidEvents(firstSchedule, event2to1, settings.SecondPostfix);
settings.LastSynchronized = DateTime.Now.ToString("o");
settings.Save();
return true;
}