示例#1
0
 private void sPasswordChange()
 {
     if (User.CurrentUserType == UserType.utLocal)
     {
         User.IsPasswordChanged = true;
         frmUserChange frmUC = new frmUserChange();
         if (frmUC.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             if (User.IsUserChanged == false)
             {
                 frmPasswordChange frmPC = new frmPasswordChange();
                 frmPC.ShowDialog();
                 return;
             }
         }
     }
 }
示例#2
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.txtUserId.Text.Trim() == "")
                {
                    InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Enter User Id.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    frmMessageBox.ShowDialog();

                    this.txtUserId.Focus();
                }
                else
                {
                    if (this.txtPassword.Text.Trim() == "")
                    {
                        InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Enter Password.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        frmMessageBox.ShowDialog();

                        this.txtPassword.Focus();
                    }
                    else
                    {
                        this.Cursor = Cursors.AppStarting;

                        this.txtUserId.Enabled   = false;
                        this.txtPassword.Enabled = false;
                        this.btnOK.Enabled       = false;

                        string strUserInformation = this.txtUserId.Text.Trim().ToUpper() + "|" + this.txtPassword.Text.Trim().ToUpper();

                        object[] objParm = new object[1];
                        objParm[0] = strUserInformation;

                        byte[] bytCompress = null;

                        if (this.rbnLocal.Checked == true)
                        {
                            pvtblnLocalWebService = true;
                            bytCompress           = (byte[])clsISClientUtilities.DynamicFunction("Logon_User", objParm, false);
                        }
                        else
                        {
                            pvtblnLocalWebService = false;
                            bytCompress           = (byte[])clsISUtilities.DynamicFunction("Logon_Client_User", objParm, false);
                        }

                        pvtDataSet = clsISClientUtilities.DeCompress_Array_To_DataSet(bytCompress);

                        this.Cursor = Cursors.Default;

                        this.txtUserId.Enabled   = true;
                        this.txtPassword.Enabled = true;
                        this.btnOK.Enabled       = true;

                        if (this.rbnLocal.Checked == true)
                        {
                            if (pvtDataSet.Tables["ReturnValues"].Rows[0]["DB_CREATE_FOR_ENGINE"].ToString() == "")
                            {
                                InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("There is Currently NO Database for SQL Server.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                frmMessageBox.ShowDialog();

                                this.Close();

                                return;
                            }
                        }

                        //From Local Machine
                        if (pvtDataSet.Tables["ReturnValues"].Rows[0]["NO_USERS_IND"].ToString() == "Y")
                        {
                            //Not Found
                            InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("There are Currently NO Users on Local Machine.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            frmMessageBox.ShowDialog();
                        }
                        else
                        {
                            if (pvtDataSet.Tables["ReturnValues"].Rows[0]["DOWNLOAD_IND"].ToString() != "")
                            {
                                //CRC Error
                                if (pvtDataSet.Tables["ReturnValues"].Rows[0]["DOWNLOAD_IND"].ToString() == "C")
                                {
                                    //Not Found
                                    InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Server CRC File Error\n\nTry Re-Login\n\nIf Problem Persists, Speak to Administrator.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    frmMessageBox.ShowDialog();
                                }
                                else
                                {
                                    //Not Found
                                    InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Server Download Error\n\nTry Re-Login\n\nIf Problem Persists, Speak to Administrator.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    frmMessageBox.ShowDialog();
                                }

                                this.Close();

                                return;
                            }
                            else
                            {
                                if (pvtDataSet.Tables["ReturnValues"].Rows[0]["USER_NO"].ToString() == "-1")
                                {
                                    //Not Found
                                    InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("User Id / Password NOT Found.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    frmMessageBox.ShowDialog();
                                }
                                else
                                {
btnOK_Click_Continue:

                                    if (pvtDataSet.Tables["ReturnValues"].Rows[0]["RESET"].ToString() == "Y")
                                    {
                                        if (this.rbnLocal.Checked == true)
                                        {
                                            InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("User Needs To Login To Internet Site to Change Password.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            frmMessageBox.ShowDialog();
                                        }
                                        else
                                        {
                                            AppDomain.CurrentDomain.SetData("UserNo", pvtDataSet.Tables["ReturnValues"].Rows[0]["USER_NO"].ToString());

                                            frmPasswordChange = null;
                                            frmPasswordChange = new frmPasswordChange();
                                            frmPasswordChange.ShowDialog();

                                            if (AppDomain.CurrentDomain.GetData("PasswordChanged").ToString() != "Y")
                                            {
                                                //Set so That Lower Down in Program it Closes in exe
                                                AppDomain.CurrentDomain.SetData("UserNo", -1);
                                            }
                                            else
                                            {
                                                pvtDataSet.Tables["ReturnValues"].Rows[0]["RESET"] = "N";
                                                goto btnOK_Click_Continue;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        pvtint64UserNo = Convert.ToInt64(pvtDataSet.Tables["ReturnValues"].Rows[0]["USER_NO"]);

                                        pvtstrAccessInd = pvtDataSet.Tables["ReturnValues"].Rows[0]["ACCESS_IND"].ToString();

                                        if (this.rbnLocal.Checked == true)
                                        {
                                            string strApplicationPath = AppDomain.CurrentDomain.BaseDirectory;
#if (DEBUG)
                                            strApplicationPath = AppDomain.CurrentDomain.BaseDirectory + "bin\\";
#endif
                                            FileInfo     fiFileInfo;
                                            BinaryReader brBinaryReader;
                                            FileStream   fsFileStream;
                                            BinaryWriter bwBinaryWriter;

                                            long   lngFileStartOffset = 0;
                                            byte[] bytFileBytes;
                                            byte[] bytFileChunkBytes;
                                            byte[] bytDecompressedBytes;
                                            byte[] bytTempBytes;
                                            string strDownLoadFileName = "";
                                            bool   blnRestartProgram   = false;
#if (DEBUG)
                                            //pvtDataSet.Tables["Files"].Rows.Clear();
#endif
                                            if (pvtDataSet.Tables["Files"].Rows.Count > 0)
                                            {
                                                for (int intRow = 0; intRow < pvtDataSet.Tables["Files"].Rows.Count; intRow++)
                                                {
                                                    fiFileInfo = new FileInfo(strApplicationPath + pvtDataSet.Tables["Files"].Rows[intRow]["FILE_NAME"].ToString());

                                                    if (fiFileInfo.Exists == true)
                                                    {
                                                        if (fiFileInfo.LastWriteTime >= Convert.ToDateTime(pvtDataSet.Tables["Files"].Rows[intRow]["FILE_LAST_UPDATED_DATE"]).AddSeconds(-3)
                                                            & fiFileInfo.LastWriteTime <= Convert.ToDateTime(pvtDataSet.Tables["Files"].Rows[intRow]["FILE_LAST_UPDATED_DATE"]).AddSeconds(3))
                                                        {
                                                            continue;
                                                        }
                                                    }

                                                    if (pvtDataSet.Tables["Files"].Rows[intRow]["FILE_NAME"].ToString() == "TimeAttendanceClient.exe")
                                                    {
                                                        //Check If TimeAttendanceClient.exe_ Exists (Can only be Replaced Via Fix or Manual Process)

                                                        FileInfo fiFileInfoTemp = new FileInfo(strApplicationPath + pvtDataSet.Tables["Files"].Rows[intRow]["FILE_NAME"].ToString() + "_");

                                                        if (fiFileInfoTemp.Exists == true)
                                                        {
                                                            if (fiFileInfoTemp.LastWriteTime >= Convert.ToDateTime(pvtDataSet.Tables["Files"].Rows[intRow]["FILE_LAST_UPDATED_DATE"]).AddSeconds(-3)
                                                                & fiFileInfoTemp.LastWriteTime <= Convert.ToDateTime(pvtDataSet.Tables["Files"].Rows[intRow]["FILE_LAST_UPDATED_DATE"]).AddSeconds(3))
                                                            {
                                                                continue;
                                                            }
                                                        }
                                                    }

                                                    pvtDataSet.Tables["Files"].Rows[intRow]["DOWNLOAD_IND"] = "Y";
                                                }

                                                DataView FilesDataView = new DataView(pvtDataSet.Tables["Files"],
                                                                                      "DOWNLOAD_IND = 'Y'",
                                                                                      "",
                                                                                      DataViewRowState.CurrentRows);

                                                if (FilesDataView.Count > 0)
                                                {
                                                    int intProgressBarCombinedMaxValue = 0;
                                                    int intProgressBarMaxValue         = 0;

                                                    for (int intRow = 0; intRow < FilesDataView.Count; intRow++)
                                                    {
                                                        //strFileName = parDataTable.Rows[intRow]["FILE_NAME"].ToString();
                                                        intProgressBarCombinedMaxValue += Convert.ToInt32(FilesDataView[intRow]["MAX_FILE_CHUNK_NO"]);
                                                    }

                                                    frmReadWriteFile = new frmReadWriteFile();
                                                    frmReadWriteFile.Show();
                                                    frmReadWriteFile.Refresh();


                                                    frmReadWriteFile.prbAllFileProgress.Maximum = intProgressBarCombinedMaxValue;
                                                    frmReadWriteFile.prbAllFileProgress.Value   = 0;

                                                    //This Must Be Fixed
                                                    for (int intRow = 0; intRow < FilesDataView.Count; intRow++)
                                                    {
                                                        DateTime dtMinLoopTime = DateTime.Now.AddSeconds(1);

                                                        strDownLoadFileName = FilesDataView[intRow]["FILE_NAME"].ToString();

                                                        if (strDownLoadFileName == "URLConfig.dll"
                                                            | strDownLoadFileName == "clsISUtilities.dll"
                                                            | strDownLoadFileName == "PasswordChange.dll"
                                                            | strDownLoadFileName == "DownloadFiles.dll"
                                                            | strDownLoadFileName == "clsISClientUtilities.dll"
                                                            | strDownLoadFileName == "TimeAttendanceLogon.dll"
                                                            | strDownLoadFileName == "TimeAttendanceClient.exe"
                                                            | strDownLoadFileName == "TimeAttendanceClientIS.exe")
                                                        {
                                                            if (strDownLoadFileName == "TimeAttendanceClient.exe")
                                                            {
                                                                //Fix Will have to Be done Manually or via Fix
                                                            }
                                                            else
                                                            {
                                                                blnRestartProgram = true;
                                                            }

                                                            strDownLoadFileName += "_";
                                                        }

                                                        intProgressBarMaxValue = Convert.ToInt32(FilesDataView[intRow]["MAX_FILE_CHUNK_NO"]);

                                                        frmReadWriteFile.prbFileProgress.Maximum = intProgressBarMaxValue;
                                                        frmReadWriteFile.prbFileProgress.Value   = 0;
                                                        frmReadWriteFile.lblFileName.Text        = strDownLoadFileName;

                                                        bytFileBytes       = new byte[Convert.ToInt32(FilesDataView[intRow]["FILE_SIZE_COMPRESSED"])];
                                                        lngFileStartOffset = 0;

                                                        for (int intChunkRow = 1; intChunkRow <= Convert.ToInt32(FilesDataView[intRow]["MAX_FILE_CHUNK_NO"]); intChunkRow++)
                                                        {
                                                            objParm    = new object[2];
                                                            objParm[0] = FilesDataView[intRow]["FILE_NAME"].ToString();
                                                            objParm[1] = intChunkRow;

                                                            pvtblnLocalWebService = true;
                                                            bytTempBytes          = (byte[])clsISClientUtilities.DynamicFunction("Get_File_Chunk", objParm, false);

                                                            this.pvtTempDataSet = clsISClientUtilities.DeCompress_Array_To_DataSet(bytTempBytes);

                                                            bytFileChunkBytes = (byte[])pvtTempDataSet.Tables["FileChunk"].Rows[0]["FILE_CHUNK"];

                                                            Array.Copy(bytFileChunkBytes, 0, bytFileBytes, lngFileStartOffset, bytFileChunkBytes.Length);
                                                            lngFileStartOffset += bytFileChunkBytes.Length;

                                                            frmReadWriteFile.prbAllFileProgress.Value += 1;
                                                            frmReadWriteFile.prbFileProgress.Value    += 1;
                                                            this.Refresh();
                                                            Application.DoEvents();
                                                        }

                                                        bytDecompressedBytes = null;
                                                        bytDecompressedBytes = new byte[Convert.ToInt32(FilesDataView[intRow]["FILE_SIZE"])];

                                                        //Open Memory Stream with Compressed Data
                                                        MemoryStream msMemoryStream = new MemoryStream(bytFileBytes);

                                                        System.IO.Compression.GZipStream GZipStreamDecompress = new GZipStream(msMemoryStream, CompressionMode.Decompress);

                                                        //Decompress Bytes
                                                        brBinaryReader       = new BinaryReader(GZipStreamDecompress);
                                                        bytDecompressedBytes = brBinaryReader.ReadBytes(Convert.ToInt32(FilesDataView[intRow]["FILE_SIZE"]));

                                                        if (FilesDataView[intRow]["FILE_CRC_VALUE"].ToString() != "")
                                                        {
                                                            //CRC32 Value
                                                            string strCRC32Value = "";

                                                            foreach (byte b in clsCrc32.ComputeHash(bytDecompressedBytes))
                                                            {
                                                                strCRC32Value += b.ToString("x2").ToLower();
                                                            }

                                                            if (strCRC32Value != FilesDataView[intRow]["FILE_CRC_VALUE"].ToString())
                                                            {
                                                                InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Client CRC File Error\n\nTry Re-Login\n\nIf Problem Persists, Speak to Administrator.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                                frmMessageBox.ShowDialog();

                                                                this.Close();

                                                                return;
                                                            }
                                                        }

                                                        fsFileStream   = null;
                                                        bwBinaryWriter = null;

                                                        fsFileStream   = new FileStream(strApplicationPath + strDownLoadFileName, FileMode.Create);
                                                        bwBinaryWriter = new BinaryWriter(fsFileStream);

                                                        bwBinaryWriter.Write(bytDecompressedBytes);

                                                        //Write Memory Portion To Disk
                                                        bwBinaryWriter.Close();

                                                        File.SetLastWriteTime(strApplicationPath + strDownLoadFileName, Convert.ToDateTime(FilesDataView[intRow]["FILE_LAST_UPDATED_DATE"]));

                                                        while (dtMinLoopTime > DateTime.Now)
                                                        {
                                                            this.Refresh();
                                                            Application.DoEvents();
                                                        }

                                                        this.Refresh();
                                                        Application.DoEvents();
                                                    }

                                                    frmReadWriteFile.Close();
                                                    frmReadWriteFile.Dispose();
                                                }
                                            }

                                            pvtDataSet.Tables.Remove(pvtDataSet.Tables["Files"]);

                                            if (blnRestartProgram == true
                                                | pvtDataSet.Tables["ReturnValues"].Rows[0]["REBOOT_IND"].ToString() == "Y")
                                            {
                                                bool blnCloseProgram = true;

                                                if (pvtDataSet.Tables["ReturnValues"].Rows[0]["REBOOT_IND"].ToString() == "Y")
                                                {
                                                    frmRestartService frmRestartService = new frmRestartService(pvtDataSet.Tables["ReturnValues"].Rows[0]["MACHINE_NAME"].ToString(), pvtDataSet.Tables["ReturnValues"].Rows[0]["MACHINE_IP"].ToString());

                                                    frmRestartService.Show();

                                                    try
                                                    {
                                                        clsRestartFingerPrintClockTimeAttendanceService clsRestartFingerPrintClockTimeAttendanceService;

                                                        if (AppDomain.CurrentDomain.GetData("URLClientPath").ToString() != "")
                                                        {
                                                            //Calls Web Service Internally
                                                            clsRestartFingerPrintClockTimeAttendanceService = new clsRestartFingerPrintClockTimeAttendanceService("");

                                                            InteractPayrollClient.Restart Restart = (InteractPayrollClient.Restart)clsRestartFingerPrintClockTimeAttendanceService.DynamicFunction("RestartFingerPrintClockTimeAttendanceService", null);

                                                            if (Restart.OK == "Y")
                                                            {
                                                                if (blnRestartProgram == false)
                                                                {
                                                                    blnCloseProgram = false;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Failed to Restart 'FingerPrintClockTimeAttendanceService' Service.\n\nSpeak to System Administrator.\n\nReboot of Machine '" + pvtDataSet.Tables["ReturnValues"].Rows[0]["MACHINE_NAME"].ToString() + "' (IP = " + pvtDataSet.Tables["ReturnValues"].Rows[0]["MACHINE_IP"].ToString() + ")\n will Allow you to Continue.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                                frmMessageBox.ShowDialog();
                                                            }
                                                        }
                                                        else
                                                        {
                                                            clsRestartFingerPrintClockTimeAttendanceService = new clsRestartFingerPrintClockTimeAttendanceService("FingerPrintClockServiceStartStop");

                                                            object Restart = clsRestartFingerPrintClockTimeAttendanceService.DynamicFunction("RestartFingerPrintClockTimeAttendanceService", null);

                                                            string strRestart = Restart.ToString();

                                                            if (strRestart.IndexOf("FingerPrintClockServer.Restart") > -1)
                                                            {
                                                                //Not Really True
                                                                if (blnRestartProgram == false)
                                                                {
                                                                    blnCloseProgram = false;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Failed to Restart 'FingerPrintClockTimeAttendanceService' Service.\n\nSpeak to System Administrator.\n\nReboot of Machine '" + pvtDataSet.Tables["ReturnValues"].Rows[0]["MACHINE_NAME"].ToString() + "' (IP = " + pvtDataSet.Tables["ReturnValues"].Rows[0]["MACHINE_IP"].ToString() + ")\n will Allow you to Continue.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                                frmMessageBox.ShowDialog();
                                                            }
                                                        }
                                                    }
                                                    catch
                                                    {
                                                        InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Failed to Restart 'FingerPrintClockTimeAttendanceService' Service.\n\nSpeak to System Administrator.\n\nReboot of Machine '" + pvtDataSet.Tables["ReturnValues"].Rows[0]["MACHINE_NAME"].ToString() + "' (IP = " + pvtDataSet.Tables["ReturnValues"].Rows[0]["MACHINE_IP"].ToString() + ")\n will Allow you to Continue.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                        frmMessageBox.ShowDialog();
                                                    }

                                                    frmRestartService.Close();
                                                }

                                                if (blnRestartProgram == true)
                                                {
                                                    InteractPayrollClient.CustomClientMessageBox frmMessageBox = new CustomClientMessageBox("Changes Have been Made to the Main Program.\nYou need to Restart the Program.", "Program Changes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                                    frmMessageBox.ShowDialog();
                                                }

                                                if (blnCloseProgram == true)
                                                {
                                                    this.Close();

                                                    return;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            //2013-11-01
                                            objParm    = new object[5];
                                            objParm[0] = Convert.ToInt64(pvtDataSet.Tables["ReturnValues"].Rows[0]["USER_NO"]);

                                            objParm[1] = this.txtUserId.Text.Trim().ToUpper();

                                            if (AppDomain.CurrentDomain.GetData("NewPassword") != null)
                                            {
                                                objParm[2] = AppDomain.CurrentDomain.GetData("NewPassword");
                                            }
                                            else
                                            {
                                                objParm[2] = this.txtPassword.Text.Trim().ToUpper();
                                            }

                                            //Access Ind
                                            objParm[3] = pvtDataSet.Tables["ReturnValues"].Rows[0]["ACCESS_IND"].ToString();

                                            string strCompanies = "";

                                            if (pvtDataSet.Tables["ReturnValues"].Rows[0]["ACCESS_IND"].ToString() != "S")
                                            {
                                                for (int intRow = 0; intRow < pvtDataSet.Tables["CompanyAccess"].Rows.Count; intRow++)
                                                {
                                                    if (intRow == 0)
                                                    {
                                                        strCompanies = pvtDataSet.Tables["CompanyAccess"].Rows[intRow]["COMPANY_NO"].ToString();
                                                    }
                                                    else
                                                    {
                                                        strCompanies += "#" + pvtDataSet.Tables["CompanyAccess"].Rows[intRow]["COMPANY_NO"].ToString();
                                                    }
                                                }
                                            }

                                            objParm[4] = strCompanies;

                                            clsISClientUtilities.DynamicFunction("Update_New_User_Details_From_Internet", objParm, false);
                                        }

                                        Close_SplasScreen_And_Show_Main();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception eException)
            {
                this.Cursor = Cursors.Default;

                this.txtUserId.Enabled   = true;
                this.txtPassword.Enabled = true;
                this.btnOK.Enabled       = true;

                if (pvtblnLocalWebService == true)
                {
                    clsISClientUtilities.ErrorHandler(eException);
                }
                else
                {
                    clsISUtilities.ErrorHandler(eException);
                }

                //this.Close();
            }
        }
        private void tsmibtnChangePassword_Click(object sender, EventArgs e)
        {
            frmPasswordChange frm = new frmPasswordChange();

            frm.ShowDialog();
        }