Example #1
0
        public static async Task <DomainInfoReturnValue> GetInfo(string domainName)
        {
            var requestModel = DDnsSharpRuntime.NewRequestModel <DomainInfoRequestModel>();

            requestModel.DomainName = domainName;
            return(await ServiceHelper.AccessAPI <DomainInfoReturnValue>(SERVICE_NAME, "Info", requestModel));
        }
Example #2
0
        public static async Task <DomainLogReturnValue> GetLog(int domainID)
        {
            var requestModel = DDnsSharpRuntime.NewRequestModel <DomainInfoRequestModel>();

            requestModel.DomainID = domainID;
            return(await ServiceHelper.AccessAPI <DomainLogReturnValue>(SERVICE_NAME, "Log", requestModel));
        }
Example #3
0
        public static async Task <ReturnValueBase> GetAPIVersion()
        {
            var requestModel = DDnsSharpRuntime.NewRequestModel <RequestModelBase>();
            var url          = ServiceHelper.BuildAPIUrl("Info", "Version");

            return(await ServiceHelper.AccessAPI <ReturnValueBase>(url, requestModel));
        }
Example #4
0
        public static async Task <UserInfoReturnValue> GetUserInfo()
        {
            var requestModel = DDnsSharpRuntime.NewRequestModel <RequestModelBase>();
            var url          = ServiceHelper.BuildAPIUrl("User", "Detail");

            return(await ServiceHelper.AccessAPI <UserInfoReturnValue>(url, requestModel));
        }
Example #5
0
        public static async Task <DomainListRetrunValue> GetList(string domainType = "all", string groupID = null)
        {
            var requestModel = DDnsSharpRuntime.NewRequestModel <DomainListRequestModel>();

            requestModel.Type    = domainType;
            requestModel.GroupID = groupID;
            return(await ServiceHelper.AccessAPI <DomainListRetrunValue>(SERVICE_NAME, "List", requestModel));
        }
Example #6
0
        public static async Task <RecordListReturnValue> GetList(int domainID, string subDomain = null)
        {
            var m = DDnsSharpRuntime.NewRequestModel <RecordListRequestModel>();

            m.DomainID  = domainID;
            m.SubDomain = subDomain;
            return(await ServiceHelper.Current.AccessAPI <RecordListReturnValue>(SERVICE_NAME, "List", m));
        }
        private async void UserLogin()
        {
            UserInfoReturnValue userInfo;

            try
            {
                userInfo = await CommonService.GetUserInfo();
            }
            catch (WebException)
            {
                MessageBox.Show("无法连接至服务器.");
                return;
            }
            if (userInfo.Status.Code == 1)
            {
                _runtime.UserInfo = userInfo.Info;
                DDnsSharpRuntime.SaveAppConfig();

                var mwin = new DDNSMonitorWindow();
                mwin.Show();
                foreach (Window win in App.Current.Windows)
                {
                    if (win != mwin)
                    {
                        win.Close();
                    }
                }
            }
            else
            {
                _loginFailedCount++;
                if (_loginFailedCount == 10)
                {
                    ErrorMessage = "登陆次数超过已达10次,请5分钟后再试.";
                    if (_loginTimer == null)
                    {
                        _loginTimer = new Timer();
                    }
                    _loginTimer.Interval = 300000;
                    _loginTimer.Start();
                    _loginTimer.Elapsed += (o, e) =>
                    {
                        _ableToLogin = true;
                        LoginCommand.RaiseCanExecuteChanged();
                        _loginTimer.Stop();
                        _loginTimer.Dispose();
                        _loginTimer = null;
                    };
                    _ableToLogin = false;
                    LoginCommand.RaiseCanExecuteChanged();
                }
                else
                {
                    ErrorMessage = userInfo.Status.Message;
                }
            }
        }
Example #8
0
        public static async Task <RecordChangedReturnValue> UpdateDDNS(int domainID, int recordID, string subDomain, string line)
        {
            var model = DDnsSharpRuntime.NewRequestModel <UpdateDDNSRequestModel>();

            model.DomainID  = domainID;
            model.RecordID  = recordID;
            model.SubDomain = subDomain;
            model.LineName  = line;
            return(await ServiceHelper.Current.AccessAPI <RecordChangedReturnValue>(SERVICE_NAME, "Ddns", model));
        }
        private void OnRecordManaged(UpdateModelWrapper obj)
        {
            if (Runtime.UpdateList.Count(m => m == obj) <= 0)
            {
                Runtime.UpdateList.Add(obj);
            }

            DDnsSharpRuntime.AppConfig.UpdateList = (from w in Runtime.UpdateList
                                                     select w.UnWrap()).ToList();
            DDnsSharpRuntime.SaveAppConfig();
        }
Example #10
0
        protected override void OnStart(string[] args)
        {
            logger = LogManager.GetCurrentClassLogger();

            DDnsSharpRuntime.MakeBackup();

            timer          = new Timer(REGULAR_INTERVAL);
            timer.Elapsed += timer_Elapsed;
            timer.Start();

            OnJob();
        }
        private void DeleteRecrod(UpdateModelWrapper um)
        {
            var mbr = MessageBox.Show("请确认操作.", "注意", MessageBoxButton.YesNo);

            if (mbr == MessageBoxResult.Yes)
            {
                Runtime.UpdateList.Remove(um);

                DDnsSharpRuntime.AppConfig.UpdateList = (from w in Runtime.UpdateList
                                                         select w.UnWrap()).ToList();
                DDnsSharpRuntime.SaveAppConfig();
            }
        }
        private async void OnForceUpdate()
        {
            UpdateCurrentIP();
            var updateModels = from u in Runtime.UpdateList select u.UnWrap();

            try
            {
                await DDNS.Start(updateModels, true);
            }
            catch (WebException)
            {
                MessageBox.Show("无法连接至服务器.");
            }
            Runtime.SetUpdateList(updateModels);
            DDnsSharpRuntime.AppConfig.UpdateList = updateModels.ToList();
            DDnsSharpRuntime.SaveAppConfig();
        }
Example #13
0
        public static async Task <RecordChangedReturnValue> CreateRecord(int domainID, string subDomain, string recordType,
                                                                         string line, string value, int mx, int ttl)
        {
            if (ttl < 1 || ttl > 604800)
            {
                ttl = 600;
            }
            var m = DDnsSharpRuntime.NewRequestModel <CreateRecordRequestModel>();

            m.DomainID   = domainID;
            m.SubDomain  = subDomain;
            m.RecordType = recordType;
            m.LineName   = line;
            m.Value      = value;
            m.MX         = mx;
            m.TTL        = ttl;
            return(await ServiceHelper.Current.AccessAPI <RecordChangedReturnValue>(SERVICE_NAME, "Create", m));
        }
Example #14
0
        public MainWindow()
        {
            mconfig = MonitorIoc.Current.Get <MonitorConfig>();
            ViewModelLocator.Setup();
            DDnsSharpRuntime.LoadAppConfig();
            var config = DDnsSharpRuntime.AppConfig;

            if (String.IsNullOrWhiteSpace(config.Email) ||
                String.IsNullOrWhiteSpace(config.Password))
            {
                ShowLoginWindow();
            }
            else
            {
                InitializeComponent();
                Login();
            }
        }
Example #15
0
        private async void OnJob()
        {
            try
            {
                DDnsSharpRuntime.LoadAppConfig();
                await DDNS.Start(DDnsSharpRuntime.AppConfig.UpdateList);

                DDnsSharpRuntime.SaveAppConfig();
                if (timer.Interval > 30000)
                {
                    timer.Interval = 30000;
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException("更新记录时出现意外错误", ex);
                timer.Interval = 300000;
            }
        }
 private void RefreshUpdateList()
 {
     DDnsSharpRuntime.LoadAppConfig();
     Runtime.SetUpdateList(DDnsSharpRuntime.AppConfig.UpdateList);
 }