Exemplo n.º 1
0
 static CustomClassCache()
 {
     if (Program.EnableRemoting)
     {
         mDataTableProxy = DataTableServerProxy.GetDataTableProxy();
     }
 }
Exemplo n.º 2
0
 static Helper()
 {
     if (Program.EnableRemoting)
     {
         mDataTableProxy = DataTableServerProxy.GetDataTableProxy();
     }
     mCommands = new Dictionary <int, SqlCommand>();
 }
Exemplo n.º 3
0
        private int GetUnusedID(string strFieldName, object oDeafult)
        {
            if (m_keyvalue == null)
            {
                return(-1);
            }
            DBCustomClass subdbclass = m_dbclass;
            //string sql = string.Format("SELECT * FROM {0}", subdbclass.MainTable);
            //DataTable tbl = Helper.GetDataTable(sql, MainForm.conn);
            DataTable tbl         = Helper.GetDataTableProxy(subdbclass.MainTable, MainForm.conn);
            int       nFieldIndex = -1;

            for (int i = 0; i < subdbclass.DBPrimaryKey.Length; i++)
            {
                m_findkeyvalues[i] = null;// GetNextID(subdbclass.DBPrimaryKey[i]);
                if (subdbclass.DBPrimaryKey[i].ToString().ToLower() == strFieldName.ToLower())
                {
                    nFieldIndex = i;
                }
                else if (m_keyvalue.Contains(subdbclass.DBPrimaryKey[i]))
                {
                    m_findkeyvalues[i] = m_keyvalue[subdbclass.DBPrimaryKey[i]];
                }
            }
            if (oDeafult != null && oDeafult != DBNull.Value)
            {
                m_findkeyvalues[nFieldIndex] = oDeafult;
            }
            else
            {
                m_findkeyvalues[nFieldIndex] = GetNextID(strFieldName);
            }
            if (Program.EnableRemoting && subdbclass.MainTable.Length > 7 && subdbclass.MainTable.Substring(0, 7) == "RTTEST_")
            {
                m_findkeyvalues[nFieldIndex] = Convert.ToInt32(m_findkeyvalues[nFieldIndex]);
                DataTableProxy proxy = DataTableServerProxy.GetDataTableProxy();
                m_findkeyvalues = proxy.UTGetTableID(subdbclass.MainTable, m_findkeyvalues);
            }
            else
            {
                bool bFirstTry = true;
                while (tbl.Rows.Find(m_findkeyvalues) != null)
                {
                    m_findkeyvalues[nFieldIndex] = Convert.ToInt32(m_findkeyvalues[nFieldIndex]) + (bFirstTry == true ? 1 : 1 /*1000*/); // 现在的id太大了
                    bFirstTry = false;
                }
            }
            m_keyvalue[strFieldName] = m_findkeyvalues[nFieldIndex];
            if (oDeafult == DBNull.Value || Convert.ToInt32(m_findkeyvalues[nFieldIndex]) != Convert.ToInt32(oDeafult))
            {
                SetLastID(strFieldName, Convert.ToInt32(m_findkeyvalues[nFieldIndex]));
            }
            return(Convert.ToInt32(m_findkeyvalues[nFieldIndex]));
        }
Exemplo n.º 4
0
        public UniteModel(string mdlname)
        {
            InitializeComponent();
            bool bRet = false;

            if (Program.EnableRemoting)
            {
                mDataTableProxy = DataTableServerProxy.GetDataTableProxy();
                bRet            = mDataTableProxy.UTExistDatabase(Program.Database);
            }
            if (!bRet)
            {
                MessageBox.Show("本库不是主干或分技或没有连接远程数据服务");
                RunUnite = false;
                return;
            }

            mModelName = mdlname;
            InitTables();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            DataTableServerProxy.InitServerProxy(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, "monitor");
            IMonitorRemoting monitor = DataTableServerProxy.GetMonitorRemoting();

            mMonitor = monitor;
            BroadcastSystem broadcast = DataTableServerProxy.GetBroadcastSystem();

            broadcast.AddConnectEventHandler(OnConnect);
            broadcast.AddLogToMonitorHandler(OnLogToMonitor);
            Console.BufferHeight    = 8000;
            Console.BufferWidth     = 300;
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("Server connect success.");
            mTime = DateTime.Now;
            PrintInfo();
            while (ReadCommand())
            {
                ;
            }
            DataTableServerProxy.DisconnectServer();
        }
Exemplo n.º 6
0
 static public void InitConn()
 {
     if (Program.EnableRemoting)
     {
         if (!DataTableServerProxy.IsInit)
         {
             DataTableServerProxy.InitServerProxy(Application.ExecutablePath + ".config", Program.Database);
         }
         m_strconn = DataTableServerProxy.GetDBSourceString();
         Program.ConnetionString = m_strconn;
         conn = new SqlConnection(m_strconn);
         DataTableServerProxy.GetDataTableProxy().InitRemoting(conn);
     }
     else
     {
         m_strconn = Program.ConnetionString;
         conn      = new SqlConnection(m_strconn);
     }
     CustomClassCache.Conn = conn;
     CustomClassCache.DelAllCaches();
     //add by cuiwei 07.10.16
     DBProcess.SetConnection(conn);
     //add end
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (ConfigurationManager.AppSettings["remoting"] == "true")
            {
                EnableRemoting = true;
            }

            if (args.Length < 1)
            {
                MessageBox.Show(string.Format("启动失败,请使用 UpdatePrograme.exe 启动本程序。"), "错误",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


#if (!_DEBUG)
            if (ProgramAlreadyRunning() && args[0] != "-Debug")
            {
                MessageBox.Show("此工具不能双开。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
#endif

            //add by cuiwei 07.8.21
            EV ev = new EV();
            ev.evPath(Path.GetDirectoryName(Application.ExecutablePath));
            //add end

            // ftp init
            m_ftp = new FTPclient(m_ftp_hostName, m_ftp_user, m_ftp_psw);
            //m_ftp.Upload("c:/path.txt", m_ftp_basedir + "xxxx");

            // 数据库选择
            if (!m_bSkillBranch)
            {
                if (forPublic)
                {
                    m_bLoadBackupDB = false;
                }
                else
                {
                    //DialogResult dr = MessageBox.Show("要读Head策划库,点<是>;\r\n要读分支库(1-0-8-1380,2009.03.25),点<否>。", "选择策划库", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    //if (dr == DialogResult.Yes)
                    //    m_bLoadBackupDB = false;
                    //else
                    //    m_bLoadBackupDB = true;

                    DialogResult dr = MessageBox.Show("要读Head策划库,点<是>;\r\n要退出程序,点<否>。", "是否继续", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        m_bLoadBackupDB = false;
                    }
                    else
                    {
                        return;
                    }
                }
            }

            TimeLog log = null;

            do
            {
                try
                {
                    if (!InitSettings())
                    {
                        return;
                    }

                    if (m_bRestart)
                    {
                        m_bRestart = false;
                    }
                    m_MainForm = new MainForm();

                    try
                    {
                        log = new TimeLog();
                        ClearRecordLocks(MainForm.conn);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    if (RightsSettings.AllowSave)
                    {
                        log.Log(TimeLog.enumLogType.ltstart, "主窗口", "应用程序启动", "主版本=" + Helper.GetVersionInfo());
                    }
                    else
                    {
                        log.Log(TimeLog.enumLogType.ltstart, "主窗口", "应用程序启动", "主版本=" + Helper.GetVersionInfo() + " [只读版本]");
                    }

                    m_MainForm.Text += "(" + Helper.GetVersionInfo() + ")";

                    Application.Run(m_MainForm);

                    m_rightmgr.Uninit();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("{0}", ex.Message), "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                finally
                {
                    if (log != null)
                    {
                        log.Log(TimeLog.enumLogType.ltend, null, null, null);
                        log.Clear();
                    }
                }
            }while(m_bRestart); // 检查是否需要重新启动主窗口

            if (EnableRemoting)
            {
                DataTableServerProxy.DisconnectServer();
            }
        }