Example #1
0
        static void UpdateSource(Source src)
        {
            if (src.error != null){
            Console.WriteLine("Source has error: " + src.error);
            return;
              }

              PrintTrackingSource(src);

              string oldname     = src.name;
              int?   oldposition = src.position;
              bool   oldonline   = src.online;

              string oldref_pattern = src.referring_url;
              string oldref_exclude = src.not_referrer_url;
              string oldurl_pattern = src.landing_url;
              string oldurl_exclude = src.not_landing_url;

              src.name     = "Changed the name!";
              src.position = 23;
              src.online   = false;

              src.referring_url    = "Referring URL Regex";
              src.not_referrer_url = "Referring URL Exclude";
              src.landing_url      = "Landing URL Regex";
              src.not_landing_url  = "Landing URL Exclude";

              if (!src.save()){
            Console.WriteLine("Error saving source: " + src.error);
            src.reload();
            return;
              }else{
            src.reload();
              }

              PrintTrackingSource(src);

              src.name     = oldname;
              src.position = oldposition;
              src.online   = oldonline;

              src.referring_url    = oldref_pattern;
              src.not_referrer_url = oldref_exclude;
              src.landing_url      = oldurl_pattern;
              src.not_landing_url  = oldurl_exclude;

              if (!src.save()){
            Console.WriteLine("Error saving source: " + src.error);
            src.reload();
            return;
              }else{
            src.reload();
              }

              PrintTrackingSource(src);
        }