/// <summary>
        /// 获取用户名和密码和区局配置
        /// </summary>
        /// <param name="GcId"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="qjpz"></param>
        public static void GetUserNamePwd(string GcId, ref string username, ref string password, ref string qjpz)
        {
            CDBManger dbm = null;

            try
            {
                dbm = new CDBManger();
                string    sql           = "select GCUSERNAME from cadgis.ticketship where GCTICKET_ID='" + GcId + "'";
                DataTable dt_ticketship = dbm.ExecuteTable(sql);



                if (dt_ticketship != null && dt_ticketship.Rows.Count > 0)
                {
                    username = dt_ticketship.Rows[0]["GCUSERNAME"].ToString();
                }
                else
                {
                    username = null;
                    password = null;
                    qjpz     = null;
                }
                if (!string.IsNullOrEmpty(username))
                {
                    sql = "SELECT password_out(QX_YH_MM) FROM GG_XT_QX_YH where QX_YH_MC='" + username + "'";
                    DataTable dt_ticketship2 = dbm.ExecuteTable(sql);
                    if (dt_ticketship2 != null && dt_ticketship2.Rows.Count > 0)
                    {
                        password = dt_ticketship2.Rows[0][0].ToString();
                    }
                }
                if (!string.IsNullOrEmpty(username))
                {
                    StringBuilder sb = new StringBuilder("");
                    sb.Append("select m.XT_BM_CONFIGURAN from gg_xt_bm_dzhyj  m");
                    sb.Append(" where  m.XT_BM_MC in (");
                    sb.Append(" SELECT  b.qx_zzjg_mc ");
                    sb.Append(" FROM GG_XT_QX_YH a,GG_XT_QX_ZZJG b  ");
                    sb.Append(" where a.qx_yh_ejdw=b.qx_zzjg_ejdw ");
                    sb.Append(" and  upper(a.qx_yh_mc)='" + username + "' and b.qx_zzjg_mc  in (select x.xt_bm_mc from gg_xt_bm_dzhyj x ))");
                    DataTable dt_ticketship3 = dbm.ExecuteTable(sb.ToString());
                    if (dt_ticketship3 != null && dt_ticketship3.Rows.Count > 0)
                    {
                        qjpz = dt_ticketship3.Rows[0]["XT_BM_CONFIGURAN"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (dbm != null)
                {
                    dbm.close();
                }
            }
        }
        public string DisableAllTicket()
        {
            string    ss  = "";
            CDBManger dbm = null;

            try
            {
                dbm = new CDBManger();
                DataTable dt = dbm.ExecuteTable("select distinct t.gcticket_id from cadgis.ticketship t");

                if (dt != null)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string GC_ID = dt.Rows[i][0].ToString();
                        CYZLog.writeLog("DisableTicket1(" + GC_ID + ")");
                        if (TickHelper.qxtick1(GC_ID))
                        {
                            ss = "TRUE";
                        }

                        Thread.Sleep(1000);
                    }
                }
            }
            catch (Exception ex)
            {
                CYZLog.writeLog(ex.ToString(), "");
                ss = "ERROR:" + ex;
            }
            finally
            {
                if (dbm != null)
                {
                    dbm.close();
                }
            }

            CYZLog.writeLog("End DisableTicket; return " + ss);
            return(ss);
        }
        public string UpLoadAppend(string AppendFile, string GC_ID)
        {
            string    ss        = "TRUE";
            int       SjBVerion = 0;
            string    smzq      = "";
            bool      bbreval   = false;
            string    UserName  = "";
            string    PassWord  = "";
            string    QjPz      = "";
            CDBManger cdm       = null;

            try
            {
                DateTime appenshiptime = DateTime.Now;

                CYZLog.writeLog("UpLoadAppend(" + AppendFile + "," + GC_ID + ")");



                string gistick = "";
                smzq = Smzq(GC_ID, ref gistick);

                if (smzq == "")
                {
                    return("工单不存在。");
                }
                bbreval = false;

                var xmldb = new XmlDBManager();
                xmldb.FileName = Application["dataappendpath"] + GC_ID + "\\" + AppendFile.Substring(AppendFile.LastIndexOf("/") + 1, AppendFile.Length - AppendFile.LastIndexOf("/") - 1);
                xmldb.Initialize();

                if (xmldb.Count() <= 0)
                {
                    CYZLog.writeLog("数据格式不正确");
                    return("数据格式不正确请重新导出");
                }

                int ZlVerion = -1;
                var CadV     = xmldb.GetEntity <CadVersion>(o => o.G3E_FID == 1); //这个版本号是从增量文件得到的

                ZlVerion = CadV.Version;

                //对比tickship里面的版本号
                cdm = new CDBManger();
                GetUserNamePwd(GC_ID, ref UserName, ref PassWord, ref QjPz);
                if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(PassWord) || string.IsNullOrEmpty(QjPz))
                {
                    CYZLog.writeLog("账号或密码不存在");
                    return("账号或密码不存在");
                }

                var oracledb = new OracleDBManager {
                    UserName = UserName, Password = PassWord
                };
                //var oracledb = new OracleDBManager();

                string    str = "select VERSION from cadgis.appendship t  where t.gcticket_id='" + GC_ID + "'";
                DataTable tab = cdm.ExecuteTable(str);
                if (tab != null && tab.Rows.Count > 0)
                {
                    SjBVerion = int.Parse(tab.Rows[0][0].ToString());
                    if (ZlVerion == 1 || SjBVerion == 1)//数据库的版本等于1是说明这个数据从来没有到过直接按原来的导入即使是导过一次版本都等于1也是要撤销重新导入的
                    {
                        if (!TickHelper.qxtick1(GC_ID, UserName, PassWord, QjPz))
                        {
                            return("FALSE");
                        }
                        OnceImport(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                    }
                    else
                    {
                        if (ZlVerion <= SjBVerion)
                        {
                            if (!TickHelper.qxtick1(GC_ID, UserName, PassWord, QjPz))
                            {
                                return("FALSE");
                            }                                                                            //发现增量文件版本低与tickship里面的版本号,就撤销工单.
                            OnceImport(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                        }
                        else//如果要导入的版本高于数据库的版本执行下面的导入
                        {
                            TwoImport(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                        }
                    }
                }
                else
                {
                    if (!TickHelper.qxtick1(GC_ID, UserName, PassWord, QjPz))
                    {
                        return("FALSE");
                    }
                    OnceImport(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                }
                if (cdm != null)
                {
                    cdm.close();
                }
                //增量的增删改

                //更新公共属性表里面的从属关系
                UploadEventHandler.COMMON_N(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                CYZLog.writeLog("End 更新公共属性表里面的从属关系");
                UploadEventHandler.GG_PD_GNWZMC_N(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                CYZLog.writeLog("End 更新功能位置表");
                //更新计量表坐标的
                UploadEventHandler.UploadGg_jx_jlb_pt_sdogeom(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                CYZLog.writeLog("End 更新计量表坐标的");
                //更新户表坐标的
                UploadEventHandler.UploadGg_jx_shbd_pt_sdogeom(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                CYZLog.writeLog("End 更新户表坐标的");
                // UploadEventHandler.UploadGg_gl_zxbz_n(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                CYZLog.writeLog("End 更新杂项标注");
                UploadEventHandler.UpLoadGg_gz_tj_n(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                CYZLog.writeLog("End 更新杂项标注");
                UploadEventHandler.UpLoadGg_pd_cbx_n(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                CYZLog.writeLog("End 更新集抄所属变压器");
                UploadEventHandler.UpGg_pd_dykg_n(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                CYZLog.writeLog("End 更新低压开关所属变压器");
                UploadEventHandler.UpGg_jc_pwy_n(oracledb, xmldb, GC_ID, smzq, appenshiptime, QjPz);
                CYZLog.writeLog("End 更新配网仪所属变压器");
                //修改所有新增修改删除数据的版本
                cdm = new CDBManger();
                string strSql  = "update cadgis.ticketship set version=" + ZlVerion + " where gcticket_id='" + GC_ID + "'";
                string strSql2 = "update cadgis.appendship  set version=" + ZlVerion + " where gcticket_id='" + GC_ID + "'";
                string StrSql3 = "update cadgis.appendfidship  set version=" + ZlVerion + " where gcticket_id='" + GC_ID + "'";

                cdm.ExecuteNonQuery(strSql);
                cdm.ExecuteNonQuery(strSql2);
                cdm.ExecuteNonQuery(StrSql3);

                TickHelper.SxSj(smzq, QjPz, UserName, PassWord);
                string tzdz     = Application["dataappendpath"] + GC_ID;
                string filename = null;
                GetAllDbFiles(tzdz, ref filename);
                //上传生产的增量
                TZInterface.UpLoadTZData(gistick.ToString(),
                                         System.Web.HttpUtility.UrlEncode(Application["dataftppath"].ToString().Replace("export", "import") + GC_ID + "/" + filename, Encoding.UTF8).Replace("%", "<M>")
                                         );
            }
            catch (Exception ex)
            {
                bbreval = false;
                ss      = ex.ToString();
                CYZLog.writeLog(ex.ToString());
            }
            finally
            {
                if (cdm != null)
                {
                    cdm.close();
                }
            }

            CYZLog.writeLog("End UpLoadAppend");
            return(ss);
        }