Esempio n. 1
0
        //*************************************************************************
        //Name:SrverSecurityToolsInsert;
        //Description:create application info table and insert online server datetime in local sql server
        //************************************************************************
        private void SrverSecurityToolsInsert()
        {
            List <string> lstQuery = new List <string>();
            string        mEncryptStartDate = "", mEncryptEndDate = "", mEncryptCurrentDate = "";

            if (rbtnServer.Checked)
            {
                string query = "IF  EXISTS(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ApplicationInfo]') AND type in (N'U'))  " +
                               "DROP TABLE[dbo].[ApplicationInfo] " +
                               "SET ANSI_NULLS ON  " +
                               "SET QUOTED_IDENTIFIER ON  " +
                               "SET ANSI_PADDING ON  " +
                               "CREATE TABLE[dbo].[ApplicationInfo](  " +
                               "[Id][int] IDENTITY(1, 1) NOT NULL,  " +
                               " [ApplicationId] [varchar](200) NULL,  " +
                               "[StartDate]    [varchar](200)  NOT NULL,  [EndDate] [varchar](200)  " +
                               "   NOT NULL,  [ApplicationKey] [varchar](200) NULL,  " +
                               "[CurrentDate]  [varchar](200)    NULL,[STATUS] [varchar](50) NULL ) ON[PRIMARY]  " +
                               "SET ANSI_PADDING OFF";
                lstQuery.Add(query);

                string CurrentDate = DateTime.Now.ToString();
                string StartDate   = "";
                string EndDate     = "";
                //*******************IF VALID KEY THEN  DATE TIME INSERT ONLIE SERVER TO OFFLINE SERVER*********************
                if (mKey.Length == 19)
                {
                    //*******************GET ONLINE DATABASE <START DATE> AND <END DATE> PERIOD*********************
                    OnlineActivationTools.OutOlnActivationDate(mKey, out StartDate, out EndDate);
                }
                else
                {
                    //*******************TRAIL PERIOD*********************
                    StartDate = CurrentDate;
                    EndDate   = ((DateTime.Now).AddDays(7d)).ToString();
                }
                //*******************ENCRIPT DATE *********************
                mEncryptStartDate   = CryptorEngine.Encrypt(StartDate, true);
                mEncryptEndDate     = CryptorEngine.Encrypt(EndDate, true);
                mEncryptCurrentDate = CryptorEngine.Encrypt(CurrentDate, true);

                query = "Insert into ApplicationInfo(ApplicationId,StartDate,EndDate,ApplicationKey,CurrentDate,STATUS) values('" + mApplicationGuid + "','" + mEncryptStartDate + "','" + mEncryptEndDate + "','','" + mEncryptCurrentDate + "','')";
                lstQuery.Add(query);
                if (SQLHelper.GetInstance().ExecuteTransection(lstQuery, out msg))
                {
                    isConnectionSuccess = true;
                    DesktopNotify("Database Connected.", ToolTipIcon.Info);
                }
                else
                {
                    isConnectionSuccess = false;
                    //********Desktop notification*********
                    DesktopNotify("Database connection failed.", ToolTipIcon.Error);
                    //this.Close();
                }
            }
        }
Esempio n. 2
0
        private static void DateUpdateFromOnlineServer()
        {
            //******************Check Internet connection*********************************************************
            if (CheckInternetconnection.CheckForInternetConnection())
            {
                //******************online date and system date same or not check*********************************************************
                DateTime?onlineDate = OnlineServerDateTimeTools.GetOnlineServerDate();
                if (onlineDate != null)
                {
                    if (DateTime.Now.Date == onlineDate.Value.Date)
                    {
                        #region Update datetime from online to offline server
                        //***********************Update datetime from online to offline server**************************************
                        string Activation_Key = "", StartDate = "", EndDate = "", msg = "";
                        string mEncryptStartDate = "", mEncryptEndDate = "", mEncryptCurrentDate = "";
                        if (OnlineActivationTools.IsValidLicenseDate(out Activation_Key))
                        {
                            //*******************GET ONLINE DATABASE <START DATE> AND <END DATE> PERIOD*********************
                            OnlineActivationTools.OutOlnActivationDate(Activation_Key, out StartDate, out EndDate);

                            //*******************ENCRIPT DATE ****************************************************************
                            string CurrentDate = DateTime.Now.ToString();
                            mEncryptStartDate   = CryptorEngine.Encrypt(StartDate, true);
                            mEncryptEndDate     = CryptorEngine.Encrypt(EndDate, true);
                            mEncryptCurrentDate = CryptorEngine.Encrypt(CurrentDate, true);


                            string qry = "update ApplicationInfo set StartDate='" + mEncryptStartDate + "',EndDate='" + mEncryptEndDate + "',CurrentDate='" + mEncryptCurrentDate + "'";
                            if (SQLHelper.GetInstance().ExcuteQuery(qry, out msg))
                            {
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        if (MessageBox.Show("Your system Date and Time is not currect \n you can chang the Date and Time in now ? ", "Invalid Date", MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.Yes)
                        {
                            //*******************Set System Date ****************************************************************
                            onlineDate.SetSystemDate();
                            DesktopNotify("System Date Changing Successfull", ToolTipIcon.Info);
                        }
                        else
                        {
                            DesktopNotify("Please Set Current Date and Time in Your system", ToolTipIcon.Warning);
                            Application.Exit();
                        }
                    }
                }
            }
        }