Changeset 3819


Ignore:
Timestamp:
Sep 3, 2009, 6:25:28 PM (15 years ago)
Author:
bayral
Message:

pwg.tags.add support

Location:
extensions/PiwigoLib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/PiwigoLib/PiwigoLib/Proxy/PwgTagsProxy.cs

    r3818 r3819  
    4848        }
    4949
     50        static public PwgTagsProxyResponse pwg_tag_add(string tagName)
     51        {
     52            PwgTagsProxyResponse response = null;
     53            try
     54            {
     55                StringBuilder data = new StringBuilder();
     56                data.Append("method=pwg.tags.add");
     57                data.Append("&name=" + HttpUtility.UrlEncode(tagName));
     58
     59                response = PwgGenericProxy<PwgTagsProxyResponse>.Post(
     60                    PwgConfigProxy.PwgServeurUriBuilder.Uri,
     61                    data.ToString());
     62            }
     63            catch (Exception ex)
     64            {
     65                throw new PwgProxyException("pwg_tag_add", ex);
     66            }
     67
     68            return response;
     69        }
     70
    5071    }
    5172
  • extensions/PiwigoLib/PiwigoLib/Service/PwgTagsService.cs

    r3818 r3819  
    9090
    9191
     92        static public Boolean AddTag(String tagName)
     93        {
     94            Boolean returnValue = false;
     95
     96            try
     97            {
     98                PwgTagsProxyResponse response = PwgTagsProxy.pwg_tag_add(tagName);
     99
     100                if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok)
     101                {
     102                    if (response.Erreur != null)
     103                    {
     104                        throw new PwgServiceException("AddTag, the server has return the error.",
     105                            response.Erreur.Code,
     106                            response.Erreur.Message);
     107                    }
     108                    else
     109                    {
     110                        throw new PwgServiceException("AddTag : a error occurs during server process.");
     111                    }
     112                }
     113                else
     114                {
     115                    returnValue = true;
     116                }
     117            }
     118            catch (PwgProxyException ex)
     119            {
     120                throw new PwgServiceException("AddTag : a error is raised by proxy.", ex);
     121            }
     122            return returnValue;
     123        }
     124
    92125        /// <summary>
    93126        /// private: convert response to dto object
  • extensions/PiwigoLib/TestPiwigoLib/Form1.Designer.cs

    r3816 r3819  
    2929        private void InitializeComponent()
    3030        {
     31            this.button1 = new System.Windows.Forms.Button();
     32            this.tbUser = new System.Windows.Forms.TextBox();
     33            this.tbPassword = new System.Windows.Forms.TextBox();
     34            this.label1 = new System.Windows.Forms.Label();
     35            this.label2 = new System.Windows.Forms.Label();
    3136            this.SuspendLayout();
     37            //
     38            // button1
     39            //
     40            this.button1.Location = new System.Drawing.Point(131, 89);
     41            this.button1.Name = "button1";
     42            this.button1.Size = new System.Drawing.Size(75, 23);
     43            this.button1.TabIndex = 0;
     44            this.button1.Text = "Tester";
     45            this.button1.UseVisualStyleBackColor = true;
     46            this.button1.Click += new System.EventHandler(this.button1_Click);
     47            //
     48            // tbUser
     49            //
     50            this.tbUser.Location = new System.Drawing.Point(68, 12);
     51            this.tbUser.Name = "tbUser";
     52            this.tbUser.Size = new System.Drawing.Size(138, 20);
     53            this.tbUser.TabIndex = 1;
     54            //
     55            // tbPassword
     56            //
     57            this.tbPassword.Location = new System.Drawing.Point(68, 38);
     58            this.tbPassword.Name = "tbPassword";
     59            this.tbPassword.PasswordChar = '*';
     60            this.tbPassword.Size = new System.Drawing.Size(138, 20);
     61            this.tbPassword.TabIndex = 2;
     62            this.tbPassword.UseSystemPasswordChar = true;
     63            //
     64            // label1
     65            //
     66            this.label1.AutoSize = true;
     67            this.label1.Location = new System.Drawing.Point(12, 15);
     68            this.label1.Name = "label1";
     69            this.label1.Size = new System.Drawing.Size(29, 13);
     70            this.label1.TabIndex = 3;
     71            this.label1.Text = "User";
     72            //
     73            // label2
     74            //
     75            this.label2.AutoSize = true;
     76            this.label2.Location = new System.Drawing.Point(12, 41);
     77            this.label2.Name = "label2";
     78            this.label2.Size = new System.Drawing.Size(53, 13);
     79            this.label2.TabIndex = 4;
     80            this.label2.Text = "Password";
    3281            //
    3382            // Form1
     
    3584            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    3685            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    37             this.ClientSize = new System.Drawing.Size(292, 266);
     86            this.ClientSize = new System.Drawing.Size(221, 143);
     87            this.Controls.Add(this.label2);
     88            this.Controls.Add(this.label1);
     89            this.Controls.Add(this.tbPassword);
     90            this.Controls.Add(this.tbUser);
     91            this.Controls.Add(this.button1);
    3892            this.Name = "Form1";
    3993            this.Text = "Form1";
    4094            this.Load += new System.EventHandler(this.Form1_Load);
    4195            this.ResumeLayout(false);
     96            this.PerformLayout();
    4297
    4398        }
    4499
    45100        #endregion
     101
     102        private System.Windows.Forms.Button button1;
     103        private System.Windows.Forms.TextBox tbUser;
     104        private System.Windows.Forms.TextBox tbPassword;
     105        private System.Windows.Forms.Label label1;
     106        private System.Windows.Forms.Label label2;
    46107    }
    47108}
  • extensions/PiwigoLib/TestPiwigoLib/Form1.cs

    r3818 r3819  
    2525        private void Form1_Load(object sender, EventArgs e)
    2626        {
     27        }
     28
     29        private void button1_Click(object sender, EventArgs e)
     30        {
    2731            PwgConfigProxy.PwgUserAgent = "TestPiwigoLib";
    2832            PwgConfigProxy.PwgServeurUriBuilder.Host = "bayral.free.fr";
     
    3640                PwgSession sess = null;
    3741                sess = PwgSessionService.GetPwgSession();
    38                 Console.WriteLine("user : " + sess.UserName + " "+ sess.Status);
     42                Console.WriteLine("user : " + sess.UserName + " " + sess.Status);
    3943
    40                 sess = PwgSessionService.Login("xxx", "xxx");
     44                sess = PwgSessionService.Login(tbUser.Text,tbPassword.Text);
    4145                Console.WriteLine("user : " + sess.UserName + " " + sess.Status);
     46
     47                Boolean rc = PwgTagsService.AddTag("Loic");
    4248
    4349                List<PwgTag> lstTag = PwgTagsService.GetAdminListOfTag();
     
    4652                Console.WriteLine("user : " + sess.UserName + " " + sess.Status);
    4753
    48                 sess = PwgSessionService.Login("xxx", "xxx");
     54                sess = PwgSessionService.Login(tbUser.Text, tbPassword.Text);
    4955                Console.WriteLine("user : " + sess.UserName + " " + sess.Status);
    5056            }
     
    5662           
    5763
     64
    5865        }
    5966    }
Note: See TracChangeset for help on using the changeset viewer.