Exemplo n.º 1
0
 private void RaiseFinishedEvent(RegexLib.Services.RegexResult result)
 {
     if (Finished != null)
     {
         Finished(result);
     }
 }
Exemplo n.º 2
0
        public RegexLib.Services.RegexResult Submit(RegexLib.Services.PatternInfo info)
        {
            try
            {
                ShowStatus("Getting ready to submit...");
                RegexLib.Services.Webservices ws = new RegexLib.Services.Webservices();
                ws.Proxy = ProxyFactory.Create(AppContext.Instance.Settings.ProxySettings, ws.Url);

                //Apply user authorication settings if exist in settings
                //the ticket allows us to update patterns as well
                if (info.UserInfo.Ticket == null ||
                    info.UserInfo.Ticket == "")
                {
                    if (UserDetailsInfo != null &&
                        UserDetailsInfo.Ticket != "")
                    {
                        info.UserInfo = UserDetailsInfo;
                    }
                }


                ShowStatus("Submitting...");

                RegexLib.Services.RegexResult result = ws.Save(info);


                ShowStatus(result.Message);
                if (result.Status == RegexLib.Services.RegexActionStatus.Inserted)
                {
                    //we have gotten a ticket!
                    UserDetailsInfo = result.PatternInformation.UserInfo;
                    ShowStatus("Your expression was posted successfully!");
                }
                if (result.Status == RegexLib.Services.RegexActionStatus.Updated)
                {
                    //we have gotten a ticket!
                    UserDetailsInfo = result.PatternInformation.UserInfo;
                    ShowStatus("Your expression was updated successfully!");
                }

                RaiseFinishedEvent(result);
                return(result);
            }
            catch (Exception e)
            {
                RaiseFinishedEvent(null);
                throw new Exception("There was a problem submitting to Regexlib.com\n" + e.Message, e);
            }
        }