Пример #1
0
        private void restore(int machineno = 1)
        {
            bool           stuts = CheckStatus(txt_ipaddress.Text);
            OpenFileDialog sf    = new OpenFileDialog();

            sf.DefaultExt = "*.csv";
            sf.FileName   = "backup.csv";
            if (sf.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string[] Lines = File.ReadAllLines(sf.FileName);


            Cursor = Cursors.WaitCursor;
            axCZKEM1.EnableDevice(machineno, false);

            //if (!axCZKEM1.BeginBatchUpdate(machineno, 1))
            //    return;

            int      iPrivilege  = 0;    //default previlege
            string   password    = "";
            bool     Enabled     = true; //Enabled by default
            int      FingerIndex = 0;
            DateTime start       = DateTime.Now;

            foreach (string usr in Lines)
            {
                string[] details = usr.Split(',');
                // SSR_SetUserInfo not working
                if (axCZKEM1.SSR_SetUserInfo(machineno, details[0], details[1], password, iPrivilege, Enabled))//upload user information to the memory
                {
                    axCZKEM1.SetUserTmpExStr(machineno, details[0], FingerIndex, 1, details[2].Trim());
                }
            }
            DateTime end  = DateTime.Now;
            TimeSpan span = (end - start);
            string   time = String.Format("it took {0} minutes, {1} seconds", span.Minutes, span.Seconds);


            //axCZKEM1.BatchUpdate(machineno);        //upload all the information in the memory
            //axCZKEM1.RefreshData(machineno);        //the data in the device should be refreshed
            //axCZKEM1.EnableDevice(machineno, true);
            Cursor = Cursors.Default;
            MessageBox.Show("Restore done!\n" + time);
        }