Ejemplo n.º 1
0
        private void butSendCode_Click(object sender, EventArgs e)
        {
            if (textEmailAddress.Text.Trim() == "")
            {
                MsgBox.Show(this, "Email Address is blank.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = ("    ");
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, settings)) {
                writer.WriteStartElement("RequestEmailVeritificationCode");
                writer.WriteElementString("RegistrationKey", PrefC.GetString(PrefName.RegistrationKey));
                writer.WriteElementString("EmailAddress", textEmailAddress.Text);
                writer.WriteEndElement();
            }
#if DEBUG
            OpenDental.localhost.Service1 updateService = new OpenDental.localhost.Service1();
#else
            OpenDental.customerUpdates.Service1 updateService = new OpenDental.customerUpdates.Service1();
            updateService.Url = PrefC.GetString(PrefName.UpdateServerAddress);
#endif
            if (PrefC.GetString(PrefName.UpdateWebProxyAddress) != "")
            {
                IWebProxy    proxy = new WebProxy(PrefC.GetString(PrefName.UpdateWebProxyAddress));
                ICredentials cred  = new NetworkCredential(PrefC.GetString(PrefName.UpdateWebProxyUserName), PrefC.GetString(PrefName.UpdateWebProxyPassword));
                proxy.Credentials   = cred;
                updateService.Proxy = proxy;
            }
            string xmlResponse = "";
            try {
                xmlResponse = updateService.RequestEmailVerificationCode(strbuild.ToString());
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show(Lan.g(this, "Error.") + "  " + ex.Message);
                return;
            }
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xmlResponse);
            string strError = WebServiceRequest.CheckForErrors(doc);
            if (!string.IsNullOrEmpty(strError))
            {
                Cursor = Cursors.Default;
                MessageBox.Show(Lan.g(this, "Error.") + "  " + Lan.g(this, "Verification code was not sent.") + "  " + strError);
                return;
            }
            Cursor = Cursors.Default;
            textVerificationCode.Text = "";          //Clear the old verification code if there was one.
            MessageBox.Show(Lan.g(this, "Done.") + "  " + Lan.g(this, "The verification code has been sent to") + " " + textEmailAddress.Text);
        }
Ejemplo n.º 2
0
 ///<summary>Only called when user clicks Delete or OK.  Not called repeatedly when adding discussions.</summary>
 private bool SaveChangesToDb(bool doDelete)
 {
     #region validation
     //validate---------------------------------------------------------------------------------------------------------
     int    difficulty = 0;
     int    myPoints   = 0;
     double myPledge   = 0;
     double bounty     = 0;
     if (!doDelete)
     {
         if (textDescription.Text == "")
         {
             MsgBox.Show(this, "Description cannot be blank.");
             return(false);
         }
         try{
             difficulty = int.Parse(textDifficulty.Text);
         }
         catch {
             MsgBox.Show(this, "Difficulty is invalid.");
             return(false);
         }
         if (difficulty < 0 || difficulty > 10)
         {
             MsgBox.Show(this, "Difficulty is invalid.");
             return(false);
         }
         if (IsAdminMode)
         {
             try {
                 bounty = PIn.Int(textBounty.Text);
             }
             catch {
                 MsgBox.Show(this, "Bounty is invalid.");
                 return(false);
             }
         }
         if (!IsAdminMode)
         {
             try{
                 myPoints = PIn.Int(textMyPoints.Text);                      //handles "" gracefully
             }
             catch {
                 MsgBox.Show(this, "Points is invalid.");
                 return(false);
             }
             if (difficulty < 0 || difficulty > 100)
             {
                 MsgBox.Show(this, "Points is invalid.");
                 return(false);
             }
             //still need to validate that they have enough points.
             if (textMyPledge.Text == "")
             {
                 myPledge = 0;
             }
             else
             {
                 try{
                     myPledge = double.Parse(textMyPledge.Text);
                 }
                 catch {
                     MsgBox.Show(this, "Pledge is invalid.");
                     return(false);
                 }
             }
             if (myPledge < 0)
             {
                 MsgBox.Show(this, "Pledge is invalid.");
                 return(false);
             }
         }
         double myPointsRemain = PIn.Double(textMyPointsRemain.Text);
         if (myPointsRemain < 0)
         {
             MsgBox.Show(this, "You have gone over your allotted points.");
             return(false);
         }
     }
     //end of validation------------------------------------------------------------------------------------------------
     #endregion validation
     //if user has made no changes, then exit out-------------------------------------------------------------------------
     bool changesMade = false;
     if (doDelete)
     {
         changesMade = true;
     }
     if (tableObj == null || tableObj.Rows.Count == 0)        //new
     {
         changesMade = true;
     }
     else
     {
         ODDataRow row = tableObj.Rows[0];
         if (textDescription.Text != row["Description"])
         {
             changesMade = true;
         }
         if (textDetail.Text != row["Detail"])
         {
             changesMade = true;
         }
         if (textDifficulty.Text != row["Difficulty"])
         {
             changesMade = true;
         }
         int approval = PIn.Int(row["Approval"]);
         if (comboApproval.SelectedIndex != approval)
         {
             changesMade = true;
         }
         if (groupMyVotes.Visible)
         {
             if (textMyPoints.Text != row["myPoints"] ||
                 checkIsCritical.Checked != PIn.Bool(row["IsCritical"]) ||
                 textMyPledge.Text != row["myPledge"])
             {
                 changesMade = true;
             }
         }
         try {
             if (textBounty.Text != row["Bounty"])
             {
                 changesMade = true;
             }
         }
         catch { }
     }
     if (!changesMade)
     {
         //temporarily show me which ones shortcutted out
         //MessageBox.Show("no changes made");
         return(true);
     }
     Cursor = Cursors.WaitCursor;
     //prepare the xml document to send--------------------------------------------------------------------------------------
     XmlWriterSettings settings = new XmlWriterSettings();
     settings.Indent      = true;
     settings.IndentChars = ("    ");
     StringBuilder strbuild = new StringBuilder();
     using (XmlWriter writer = XmlWriter.Create(strbuild, settings)){
         writer.WriteStartElement("FeatureRequestSubmitChanges");
         //regkey
         writer.WriteStartElement("RegistrationKey");
         writer.WriteString(PrefC.GetString(PrefName.RegistrationKey));
         writer.WriteEndElement();
         //requestId
         writer.WriteStartElement("RequestId");
         writer.WriteString(RequestId.ToString());                //this will be zero for a new request.
         writer.WriteEndElement();
         if (doDelete)
         {
             //delete
             writer.WriteStartElement("Delete");
             writer.WriteString("true");                    //all the other elements will be ignored.
             writer.WriteEndElement();
         }
         else
         {
             if (!textDescription.ReadOnly)
             {
                 //description
                 writer.WriteStartElement("Description");
                 writer.WriteString(textDescription.Text);
                 writer.WriteEndElement();
             }
             if (!textDetail.ReadOnly)
             {
                 //detail
                 writer.WriteStartElement("Detail");
                 writer.WriteString(textDetail.Text);
                 writer.WriteEndElement();
             }
             if (IsAdminMode ||
                 RequestId == 0)                         //This allows the initial difficulty of 5 to get saved.
             {
                 //difficulty
                 writer.WriteStartElement("Difficulty");
                 writer.WriteString(difficulty.ToString());
                 writer.WriteEndElement();
             }
             if (IsAdminMode)
             {
                 //Bounty
                 writer.WriteStartElement("Bounty");
                 writer.WriteString(bounty.ToString());
                 writer.WriteEndElement();
             }
             //approval
             writer.WriteStartElement("Approval");
             writer.WriteString(comboApproval.SelectedIndex.ToString());
             writer.WriteEndElement();
             if (!IsAdminMode)
             {
                 //mypoints
                 writer.WriteStartElement("MyPoints");
                 writer.WriteString(myPoints.ToString());
                 writer.WriteEndElement();
                 //iscritical
                 writer.WriteStartElement("IsCritical");
                 if (checkIsCritical.Checked)
                 {
                     writer.WriteString("1");
                 }
                 else
                 {
                     writer.WriteString("0");
                 }
                 writer.WriteEndElement();
                 //mypledge
                 writer.WriteStartElement("MyPledge");
                 writer.WriteString(myPledge.ToString("f2"));
                 writer.WriteEndElement();
             }
         }
         writer.WriteEndElement();
     }
                 #if DEBUG
     OpenDental.localhost.Service1 updateService = new OpenDental.localhost.Service1();
                 #else
     OpenDental.customerUpdates.Service1 updateService = new OpenDental.customerUpdates.Service1();
     updateService.Url = PrefC.GetString(PrefName.UpdateServerAddress);
                 #endif
     //Send the message and get the result-------------------------------------------------------------------------------------
     string result = "";
     try {
         result = updateService.FeatureRequestSubmitChanges(strbuild.ToString());
     }
     catch (Exception ex) {
         Cursor = Cursors.Default;
         MessageBox.Show("Error: " + ex.Message);
         return(false);
     }
     //textConnectionMessage.Text=Lan.g(this,"Connection successful.");
     //Application.DoEvents();
     Cursor = Cursors.Default;
     //MessageBox.Show(result);
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(result);
     //Process errors------------------------------------------------------------------------------------------------------------
     string strError = WebServiceRequest.CheckForErrors(doc);
     if (!string.IsNullOrEmpty(strError))
     {
         MessageBox.Show(strError, "Error");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
        ///<summary></summary>
        private bool SaveDiscuss()         //bool doDelete) {
        //prepare the xml document to send--------------------------------------------------------------------------------------
        {
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = ("    ");
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, settings)){
                writer.WriteStartElement("FeatureRequestDiscussSubmit");
                //regkey
                writer.WriteStartElement("RegistrationKey");
                writer.WriteString(PrefC.GetString(PrefName.RegistrationKey));
                writer.WriteEndElement();
                //DiscussId
                //writer.WriteStartElement("DiscussId");
                //writer.WriteString(DiscussIdCur.ToString());//this will be zero for a new entry. We currently only support new entries
                //writer.WriteEndElement();
                //RequestId
                writer.WriteStartElement("RequestId");
                writer.WriteString(RequestId.ToString());
                writer.WriteEndElement();
                //can't pass patnum.  Determined on the server side.
                //date will also be figured on the server side.
                //Note
                writer.WriteStartElement("Note");
                writer.WriteString(textNote.Text);
                writer.WriteEndElement();

                /*if(doDelete){
                 *      //delete
                 *      writer.WriteStartElement("Delete");
                 *      writer.WriteString("true");
                 *      writer.WriteEndElement();
                 * }*/
            }
            Cursor = Cursors.WaitCursor;
                        #if DEBUG
            OpenDental.localhost.Service1 updateService = new OpenDental.localhost.Service1();
                        #else
            OpenDental.customerUpdates.Service1 updateService = new OpenDental.customerUpdates.Service1();
            updateService.Url = PrefC.GetString(PrefName.UpdateServerAddress);
                        #endif
            //Send the message and get the result-------------------------------------------------------------------------------------
            string result = "";
            try {
                result = updateService.FeatureRequestDiscussSubmit(strbuild.ToString());
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show("Error: " + ex.Message);
                return(false);
            }
            //textConnectionMessage.Text=Lan.g(this,"Connection successful.");
            //Application.DoEvents();
            Cursor = Cursors.Default;
            //MessageBox.Show(result);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(result);
            //Process errors------------------------------------------------------------------------------------------------------------
            string strError = WebServiceRequest.CheckForErrors(doc);
            if (!string.IsNullOrEmpty(strError))
            {
                MessageBox.Show(strError, "Error");
                return(false);
            }
            return(true);
        }
Ejemplo n.º 4
0
        private void GetOneFromServer()
        {
            //get a table with data
            Cursor = Cursors.WaitCursor;
            //prepare the xml document to send--------------------------------------------------------------------------------------
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = ("    ");
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, settings)){
                writer.WriteStartElement("FeatureRequestGetOne");
                writer.WriteStartElement("RegistrationKey");
                writer.WriteString(PrefC.GetString(PrefName.RegistrationKey));
                writer.WriteEndElement();
                writer.WriteStartElement("RequestId");
                writer.WriteString(RequestId.ToString());
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
                        #if DEBUG
            OpenDental.localhost.Service1 updateService = new OpenDental.localhost.Service1();
                        #else
            OpenDental.customerUpdates.Service1 updateService = new OpenDental.customerUpdates.Service1();
            updateService.Url = PrefC.GetString(PrefName.UpdateServerAddress);
                        #endif
            //Send the message and get the result-------------------------------------------------------------------------------------
            string result = "";
            try {
                result = updateService.FeatureRequestGetOne(strbuild.ToString());
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show("Error: " + ex.Message);
                return;
            }
            //textConnectionMessage.Text=Lan.g(this,"Connection successful.");
            //Application.DoEvents();
            Cursor = Cursors.Default;
            //MessageBox.Show(result);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(result);
            //Process errors------------------------------------------------------------------------------------------------------------
            string strError = WebServiceRequest.CheckForErrors(doc);
            if (!string.IsNullOrEmpty(strError))
            {
                MessageBox.Show(strError, "Error");
                DialogResult = DialogResult.Cancel;
                Close();
                return;
            }
            //Process a valid return value------------------------------------------------------------------------------------------------
            XmlNode node = doc.SelectSingleNode("//ResultTable");
            tableObj = new ODDataTable(node.InnerXml);
            ODDataRow row = tableObj.Rows[0];
            node = doc.SelectSingleNode("//MaxPoints");
            int maxPoints = PIn.Int(node.InnerText);
            node = doc.SelectSingleNode("//MaxCrit");
            int maxCritical = PIn.Int(node.InnerText);
            node = doc.SelectSingleNode("//MaxPledged");
            double maxPledged = PIn.Double(node.InnerText);
            textDescription.Text = row["Description"];
            string detail = row["Detail"];
            detail              = detail.Replace("\n", "\r\n");
            textDetail.Text     = detail;
            checkIsMine.Checked = PIn.Bool(row["isMine"]);
            textDifficulty.Text = row["Difficulty"];
            int approval = PIn.Int(row["Approval"]);
            if (IsAdminMode)
            {
                textSubmitter.Text = row["submitter"];
            }
            comboApproval.SelectedIndex = approval;
            //textApproval gets set automatically due to comboApproval_SelectedIndexChanged.
            if (!IsAdminMode && PIn.Bool(row["isMine"]))            //user editing their own request
            {
                if ((ApprovalEnum)approval == ApprovalEnum.New ||
                    (ApprovalEnum)approval == ApprovalEnum.NeedsClarification ||
                    (ApprovalEnum)approval == ApprovalEnum.NotARequest ||
                    (ApprovalEnum)approval == ApprovalEnum.Redundant ||
                    (ApprovalEnum)approval == ApprovalEnum.TooBroad)
                {
                    //users not allowed to edit
                    if ((ApprovalEnum)approval != ApprovalEnum.New)
                    {
                        _canResubmit = true;
                        butOK.Text   = Lan.g(this, "Resubmit");
                    }
                    butDelete.Visible = true;
                }
            }
            if ((ApprovalEnum)approval != ApprovalEnum.Approved)
            {
                //only allowed to vote on Approved features.
                //All others should always have zero votes, except InProgress and Complete
                groupMyVotes.Visible = false;
            }
            if ((ApprovalEnum)approval == ApprovalEnum.Approved ||
                (ApprovalEnum)approval == ApprovalEnum.InProgress ||
                (ApprovalEnum)approval == ApprovalEnum.Complete)
            {            //even administrators should not be able to change things at this point
                textDescription.BackColor = colorDisabled;
                textDescription.ReadOnly  = true;
                textDetail.BackColor      = colorDisabled;
                textDetail.ReadOnly       = true;
            }
            //Note: If the RegKey is in "Admin mode" the points allotted will always be 100 even though some may be used on other feature requests.
            myPointsUsed = PIn.Int(row["myPointsUsed"]);
            try {
                myPointsAllotted = PIn.Int(row["myPointsAllotted"]);
            }
            catch {
                myPointsAllotted = 100;
            }
            //textMyPointsRemain.Text=;this will be filled automatically when myPoints changes
            textMyPoints.Text = row["myPoints"];
            RecalcMyPoints();
            checkIsCritical.Checked = PIn.Bool(row["IsCritical"]);
            textMyPledge.Text       = row["myPledge"];
            textTotalPoints.Text    = row["totalPoints"];
            textTotalCritical.Text  = row["totalCritical"];
            textTotalPledged.Text   = row["totalPledged"];
            textWeight.Text         = row["Weight"];
            try {
                textBounty.Text = row["Bounty"];
            }
            catch { }
        }