Пример #1
0
        public bool DeletData(ArrayList Samples, CommandType Master, RichTextBox RTB, ref string ErrorLog)
        {
            if (Master.GetCType == "Delete") {
                foreach (Sample Item in Samples) {
                    foreach (Analyte Metal in Item.Metals) {
                        if (Metal.Ready2Upload == true) {
                            string Line = "DELETE FROM dbo.DATATBL WHERE DATESTAMP = " + Item.DateTimeInSQL + " AND VARID=" + Metal.FoundVarID + ";";

                            AccessConnection.Open();
                            AccessCommand.Connection = AccessConnection;
                            AccessCommand.CommandText = Line;
                            try {
                                AccessCommand.ExecuteNonQuery();
                            }
                            catch (OleDbException Ex) {
                                RTB.AppendText(Item.SampleName + " Delete error: " + Ex.Message);
                                ErrorLog += DateTime.Now + " " + Item.SampleName + " Delete error: " + Ex.Message + " \r\n" + Line + "\r\n";
                            }
                            AccessConnection.Close();
                        }
                    }
                }
            }
            else { CurrentCommand.SetCommand("NULL"); return false; }
            CurrentCommand.SetCommand("NULL");
            return true;
        }
Пример #2
0
 public bool SendData(ArrayList Samples, int HowMany, CommandType Master, RichTextBox RTB, ref string ErrorLog)
 {
     int Count = 0;
     if (Master.GetCType == "UPLOAD") {
         myAES = new SimplerAES();
         int MetalCounter = 0;
         foreach (Sample Item in Samples) {
             Count++;
             if (Item.QCType == Sample.QCTYPES.QCSet) {
                 string Line = myAES.Decrypt("I/ydFjDhNoT3OB8O9/qRFos0brdwlM8WUhP7sm8oxDcuaAmUXVbV48wTyKj+x8CGAmD8zewtcSpYMIYTYO1RoZLIVtQzNEQXZLxjsS2//RRFlc2FKNbAyH1BV/wIJlGqNxD86q/8W9VZVKkhAlAMGu7TEGgsPPb2pehC8e3uQS4=") +
                     Item.AuditTimeinSQL + "," + Item.DateTimeInSQL + "," + (int)Item.QC_SET + "," +
                                    (int)Item.QC_SET + "," + Item.QCSetVARID + myAES.Decrypt("KsyRIHLLxSYPzCw53d6liw==");
                 AccessConnection.Open();
                 AccessCommand.CommandText = Line;
                 try {
                     AccessCommand.ExecuteNonQuery();
                     RTB.AppendText(Item.SampleName + " Upload Successfull\n");
                 }
                 catch (OleDbException Dup) {
                     if (Dup.Message == "Duplicate key was ignored.") {
                         AccessConnection.Close();                                                                                                           //Sample.QCsetRv[]
                         string fixer = myAES.Decrypt("TcX2Nh7xfpr1fLcS5YoR//NFseQGD6eGLkt6tuP+a4+XvXCw/8E1QCcDwqLzXE4/") +
                                        Item.AuditTimeinSQL + myAES.Decrypt("cihCKk7jSj3u1pi35FjzkA==") +
                                        (int)Item.QC_SET + myAES.Decrypt("L/O0Rp0M+kfULU/4prnipA==") +
                                        (int)Item.QC_SET + myAES.Decrypt("1WYKz9V2S1oIzQW3yxRfA5psCQDIQwfpdyMzCC5oapw=") +
                                        Item.DateTimeInSQL + myAES.Decrypt("K7q/5JYfvbXfVcWjnOwmpA==") + Item.QCSetVARID + "";
                         AccessConnection.Open();
                         AccessCommand.Connection = AccessConnection;
                         AccessCommand.CommandText = fixer;
                         try {
                             AccessCommand.ExecuteNonQuery();
                             RTB.AppendText(Item.SampleName + " Upload Successfull\n");
                             Count++;
                         }
                         catch (Exception Er) {
                             RTB.AppendText(Item.SampleName + " DB error during Update as follows: " + Er.Message + "\n" + fixer + "\n");
                             ErrorLog += DateTime.Now + " " + Item.SampleName + " DB error during Insert as follows: " + Er.Message + "\r\n" + fixer + "\r\n";
                         }
                     }
                     else {
                         RTB.AppendText(Item.SampleName + " on analyte: " + "QC SET" + " DB error during Insert as follows: " + Dup.Message + "\n");
                         ErrorLog += DateTime.Now + " " + Item.SampleName + " on analyte: " + "QC SET" + " DB error during Insert as follows: " + Dup.Message + "\r\n"+Line+"\r\n";
                     }
                 }
                 AccessConnection.Close();
             }
             foreach (Analyte Metal in Item.Metals) {
                 if (Item.QCType == Sample.QCTYPES.Smp) {
                     Metal.WasFoundinDB = true;
                     Metal.DO_NOT_UPLOAD = false;
                 }
                 if ((Metal.AtomName!="Y") && (Metal.WasFoundinDB == true) && (Metal.DO_NOT_UPLOAD == false) /*&& (Metal.Ready2Upload == true)*/) {
                     string Line = myAES.Decrypt("I/ydFjDhNoT3OB8O9/qRFos0brdwlM8WUhP7sm8oxDcuaAmUXVbV48wTyKj+x8CGAmD8zewtcSpYMIYTYO1RoZLIVtQzNEQXZLxjsS2//RRFlc2FKNbAyH1BV/wIJlGq8BO8OndhHFXdMqoyurvNGw==") +
                                   myAES.Decrypt("cfGHo18IK/lc8G4NenO7gAmvPlQxklXSoNzxQWfKAwk=") + Item.AuditTimeinSQL + "," + Item.DateTimeInSQL + "," + Metal.ConcMean.ToString() + "," +
                                   Metal.ConcMean.ToString() + "," + Metal.FoundVarID + myAES.Decrypt("KsyRIHLLxSYPzCw53d6liw==");
                     AccessConnection.Open();
                     AccessCommand.CommandText = Line;
                     try {
                         AccessCommand.ExecuteNonQuery();
                         RTB.AppendText(Metal.SampleNameForUpload + " Upload Successfull\n");
                     }
                     catch (OleDbException Dup) {
                         if (Dup.Message == "Duplicate key was ignored.") {
                             AccessConnection.Close();
                             string fixer = myAES.Decrypt("TcX2Nh7xfpr1fLcS5YoR//NFseQGD6eGLkt6tuP+a4+XvXCw/8E1QCcDwqLzXE4/") +
                                            Item.AuditTimeinSQL + myAES.Decrypt("cihCKk7jSj3u1pi35FjzkA==") + Convert.ToDouble(((Analyte)Metal).ConcMean.ToString()) +
                                            myAES.Decrypt("L/O0Rp0M+kfULU/4prnipA==") + Convert.ToDouble(((Analyte)Metal).ConcMean.ToString()) +
                                            myAES.Decrypt("1WYKz9V2S1oIzQW3yxRfA5psCQDIQwfpdyMzCC5oapw=") + Item.DateTimeInSQL +
                                            myAES.Decrypt("K7q/5JYfvbXfVcWjnOwmpA==") + Metal.FoundVarID + "";
                             AccessConnection.Open();
                             AccessCommand.Connection = AccessConnection;
                             AccessCommand.CommandText = fixer;
                             try {
                                 AccessCommand.ExecuteNonQuery();
                                 RTB.AppendText(Metal.SampleNameForUpload + " Upload Successfull\n");
                                 Count++;
                             }
                             catch (Exception Er) {
                                 RTB.AppendText(Metal.SampleNameForUpload + " DB error during Update as follows: " + Er.Message + "\n" + fixer + "\n");
                                 ErrorLog += DateTime.Now + " " + Metal.SampleNameForUpload + " DB error during Insert as follows: " + Er.Message + "\r\n" + fixer + "\r\n";
                             }
                         }
                         else {
                             RTB.AppendText(Item.SampleName + " on analyte: " + Metal.AtomName + " DB error during Insert as follows: " + Dup.Message + "\n");
                             ErrorLog += DateTime.Now + " " + Item.SampleName + " on analyte: " + Metal.AtomName + " DB error during Insert as follows: " + Dup.Message + "\r\n" + Metal.SQLUPLOADSTR + "\r\n" + Line+"\r\n";
                         }
                     }
                     catch (Exception Ex) {
                         RTB.AppendText(Item.SampleName + " on analyte: " + Metal.AtomName + " DB error during Insert as follows: " + Ex.Message + "\n");
                         ErrorLog += DateTime.Now + " " + Item.SampleName + " on analyte: " + Metal.AtomName + " DB error during Insert as follows: " + Ex.Message + "\r\n" + Metal.SQLUPLOADSTR + "\r\n"+Line+"\r\n";
                     }
                     AccessConnection.Close();
                     MetalCounter++;
                 }
             }
         }
     }
     if (Count == HowMany) return true;
     else return false;
 }