示例#1
0
      } // end Start

      #endregion

      #region ImportVariables

      private bool ImportVariables()
      {
         DataTable tblDataDrop;
         NiceApp niceLabelApp;
         NiceLabel5WR.NiceLabel niceLabel;
         WRVar variable;
         bool bReturn = true;
         int iProgressStep;

         if (System.IO.File.Exists(_sDataDropFilePath))
         {
            if (System.IO.File.Exists(_sLabelFormatPath))
            {
               tblDataDrop = LoadDropData();
               niceLabelApp = new NiceApp();
               niceLabel = niceLabelApp.LabelOpenEx(_sLabelFormatPath);
               iProgressStep = 100 / (tblDataDrop.Columns.Count + 2);
               for (int i = 0; i < tblDataDrop.Columns.Count; i++)
               {
                  RaiseUpdateProgressEvent("Attempting to add variable " +
                                              tblDataDrop.Columns[i].ColumnName + "...",
                                           iProgressStep * (i + 1));
                  if (niceLabel.Variables.FindByName(tblDataDrop.Columns[i].ColumnName) == null)
                  {
                     variable = niceLabel.Variables.Create(tblDataDrop.Columns[i].ColumnName);
                  } // end if
               } // end for

               RaiseUpdateProgressEvent("Saving the label format...", tblDataDrop.Columns.Count + 1);
               bReturn = niceLabel.Save();
               niceLabel.Free();

               niceLabelApp.Quit();
               niceLabelApp.Free();

               return (bReturn);
            } // end if
            else
            {
               throw (new System.IO.FileNotFoundException(null, _sLabelFormatPath));
            } // end else
         } // end if
         else
         {
            throw (new System.IO.FileNotFoundException(null, _sDataDropFilePath));
         } // end else
      } // end ImportVariables