Exemplo n.º 1
0
        /// <summary>
        /// 获取数据
        /// </summary>
        public InterfaceOutPut GetObjectData(String InputString)
        {
            InterfaceOutPut output = new InterfaceOutPut();

            output.Success = 0;
            try
            {
                InGetObjectData  inParams  = (InGetObjectData)Newtonsoft.Json.JsonConvert.DeserializeObject <InGetObjectData>(InputString);
                OutGetObjectData OutParams = new OutGetObjectData();

                TF.YA.Soft.DBSyncObject uStore = new TF.YA.Soft.DBSyncObject(GetDBConn());
                OutParams.IsExist      = 0;
                OutParams.Data.Json    = "";
                OutParams.Data.Key     = "";
                OutParams.Data.Version = "";
                if (uStore.GetObjectData(inParams.ObjectName, inParams.Key, OutParams.Data))
                {
                    OutParams.IsExist = 1;
                    byte[] buffer = System.Text.Encoding.UTF8.GetBytes(OutParams.Data.Json);

                    OutParams.Data.Json = Convert.ToBase64String(buffer);
                }

                output.Data    = OutParams;
                output.Success = 1;
            }
            catch (Exception ex)
            {
                output.ResultText = ex.Message;
                throw ex;
            }
            return(output);
        }
Exemplo n.º 2
0
        private void btnGetUpdate_Click(object sender, EventArgs e)
        {
            TF.YA.Soft.DBSyncObject     uStore      = new TF.YA.Soft.DBSyncObject(strStoreConn);
            List <TF.YA.Soft.UserIndex> userIndexes = new List <TF.YA.Soft.UserIndex>();

            if (!uStore.GetUserIndex(tbUserID.Text, tb_UserObjectName.Text, userIndexes))
            {
                MessageBox.Show("当前客户端未注册此更新对象");
                return;
            }
            tbUpdateLog.Text = "";

            tbUpdateLog.AppendText(string.Format("本次共获得{0}条更新" + "\r\n", userIndexes.Count));
            progressBar1.Maximum = userIndexes.Count;
            progressBar1.Value   = 0;//设置当前值
            foreach (var item in userIndexes)
            {
                tbUpdateLog.AppendText(string.Format("开始下载{0}" + "\r\n", item.Key));
                TF.YA.Soft.SyncData d = new TF.YA.Soft.SyncData();
                uStore.GetObjectData(tb_UserObjectName.Text, item.Key, d);
                tbUpdateLog.AppendText(string.Format("成功获取{0}的值:{1}" + "\r\n", item.Key, d.Json));

                uStore.CommitUserIndex(tbUserID.Text, tb_UserObjectName.Text, item.Key);
                tbUpdateLog.AppendText(string.Format("成功提交{0}" + "\r\n", item.Key));
                progressBar1.Value += 1;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取差异更新数据索引
        /// </summary>
        public InterfaceOutPut GetUserIndex(String InputString)
        {
            InterfaceOutPut output = new InterfaceOutPut();

            output.Success = 0;
            try
            {
                InGetUserIndex  inParams  = (InGetUserIndex)Newtonsoft.Json.JsonConvert.DeserializeObject <InGetUserIndex>(InputString);
                OutGetUserIndex OutParams = new OutGetUserIndex();

                TF.YA.Soft.DBSyncObject     uStore      = new TF.YA.Soft.DBSyncObject(GetDBConn());
                List <TF.YA.Soft.UserIndex> userIndexes = new List <TF.YA.Soft.UserIndex>();

                OutParams.IsReg = 1;
                if (!uStore.GetUserIndex(inParams.UserID, inParams.ObjectName, userIndexes))
                {
                    OutParams.IsReg = 0;
                }
                OutParams.UserIndexes = userIndexes;

                output.Data    = OutParams;
                output.Success = 1;
            }
            catch (Exception ex)
            {
                output.ResultText = ex.Message;
                throw ex;
            }
            return(output);
        }
Exemplo n.º 4
0
        public void Execute(IJobExecutionContext context)
        {
            ILog logger = Common.Logging.LogManager.GetLogger(context.JobDetail.Key.Name);


            string strSourceConn = context.JobDetail.JobDataMap.GetString("SourceConn");
            string strStoreConn  = context.JobDetail.JobDataMap.GetString("StoreConn");
            string ObjectName    = context.JobDetail.JobDataMap.GetString("ObjectName");

            logger.Info(string.Format("获取参数【数据源地址:SourceConn={0}】", strSourceConn));
            logger.Info(string.Format("获取参数【本地存储地址:StoreConn={0}】", strStoreConn));
            logger.Info(string.Format("获取参数【对象名称:ObjectName={0}】", ObjectName));
            TF.YA.Soft.DBSyncUser   uSource = new TF.YA.Soft.DBSyncUser(strSourceConn);
            TF.YA.Soft.DBSyncObject uStore  = new TF.YA.Soft.DBSyncObject(strStoreConn);
            logger.Info("开始执行更新");
            try
            {
                TF.YA.Soft.SyncUtils.Update(ObjectName, uSource, uStore);
                logger.Info("更新完毕");
            }
            catch (Exception e)
            {
                logger.Error("更新错误:" + e.Message);
            }
        }
Exemplo n.º 5
0
        private void btnStartSync_Click(object sender, EventArgs e)
        {
            btnStartSync.Enabled = false;

            TF.YA.Soft.DBSyncUser   uSource = new TF.YA.Soft.DBSyncUser(strSourceConn);
            TF.YA.Soft.DBSyncObject uStore  = new TF.YA.Soft.DBSyncObject(strStoreConn);
            TF.YA.Soft.SyncUtils.Update((comboBox1.SelectedItem as ComboboxItem).Value.ToString(), uSource, uStore);
            MessageBox.Show("更新完毕");
            btnStartSync.Enabled = true;
        }
Exemplo n.º 6
0
        private void btnViewSum_Click(object sender, EventArgs e)
        {
            TF.YA.Soft.DBSyncObject         uStore   = new TF.YA.Soft.DBSyncObject(strStoreConn);
            List <TF.YA.Soft.SyncObject>    objs     = new List <TF.YA.Soft.SyncObject>();
            List <TF.YA.Soft.SyncObjectSum> objsSum  = new List <TF.YA.Soft.SyncObjectSum>();
            List <TF.YA.Soft.SyncUser>      users    = new List <TF.YA.Soft.SyncUser>();
            List <TF.YA.Soft.SyncUserSum>   usersSum = new List <TF.YA.Soft.SyncUserSum>();

            uStore.GetObjects(objs);
            uStore.GetObjectsSum(objsSum);
            uStore.GetUsers(users);
            uStore.GetUsersSum(usersSum);

            lstObject.Items.Clear();
            for (int i = 0; i < objs.Count; i++)
            {
                ListViewItem item = lstObject.Items.Add("");
                item.Text = objs[i].ObjectName;
                item.SubItems.Add(objs[i].ObjectVersion);
                TF.YA.Soft.SyncObjectSum sum = objsSum.Find((TF.YA.Soft.SyncObjectSum s) => s.ObjectName == objs[i].ObjectName);
                if (sum != null)
                {
                    item.SubItems.Add(sum.Count.ToString());
                }
                else
                {
                    item.SubItems.Add("0");
                }
            }
            lstUser.Items.Clear();
            for (int i = 0; i < users.Count; i++)
            {
                ListViewItem item = lstUser.Items.Add("");
                item.Text = users[i].UserID;
                item.SubItems.Add(users[i].UserName);
                item.SubItems.Add(users[i].ObjectName);
                TF.YA.Soft.SyncUserSum sum = usersSum.Find((TF.YA.Soft.SyncUserSum s) => (s.ObjectName == users[i].ObjectName) && (s.UserID == users[i].UserID));
                if (sum != null)
                {
                    item.SubItems.Add(sum.Count.ToString());
                }
                else
                {
                    item.SubItems.Add("0");
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 注销客户端关注
        /// </summary>
        public InterfaceOutPut UnRegUser(String InputString)
        {
            InterfaceOutPut output = new InterfaceOutPut();

            output.Success = 0;
            try
            {
                InUnRegUser             inParams = (InUnRegUser)Newtonsoft.Json.JsonConvert.DeserializeObject <InUnRegUser>(InputString);
                TF.YA.Soft.DBSyncObject uStore   = new TF.YA.Soft.DBSyncObject(GetDBConn());
                uStore.UnRegUser(inParams.UserID, inParams.ObjectName);
                output.Success = 1;
            }
            catch (Exception ex)
            {
                output.ResultText = ex.Message;
                throw ex;
            }
            return(output);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 清除客户端的所有更新
        /// </summary>
        public InterfaceOutPut ClearUserIndex(String InputString)
        {
            InterfaceOutPut output = new InterfaceOutPut();

            output.Success = 0;
            try
            {
                InClearUserIndex        inParams  = (InClearUserIndex)Newtonsoft.Json.JsonConvert.DeserializeObject <InClearUserIndex>(InputString);
                OutGetObjectDatas       OutParams = new OutGetObjectDatas();
                TF.YA.Soft.DBSyncObject uStore    = new TF.YA.Soft.DBSyncObject(GetDBConn());
                uStore.ClearUserIndex(inParams.UserID, inParams.ObjectName);
                output.Data = OutParams;

                output.Success = 1;
            }
            catch (Exception ex)
            {
                output.ResultText = ex.Message;
                throw ex;
            }
            return(output);
        }
Exemplo n.º 9
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            TF.YA.Soft.DBSyncObject      uStore      = new TF.YA.Soft.DBSyncObject(strStoreConn);
            List <TF.YA.Soft.SyncDataOP> userIndexes = new List <TF.YA.Soft.SyncDataOP>();

            uStore.GetObjectDatas(tb_UserObjectName.Text, userIndexes);

            tbUpdateLog.Text = "";

            tbUpdateLog.AppendText(string.Format("本次共获得{0}条更新" + "\r\n", userIndexes.Count));
            progressBar1.Maximum = userIndexes.Count;
            progressBar1.Value   = 0;//设置当前值
            foreach (var item in userIndexes)
            {
                tbUpdateLog.AppendText(string.Format("开始下载{0}" + "\r\n", item.Key));
                TF.YA.Soft.SyncData d = new TF.YA.Soft.SyncData();
                uStore.GetObjectData(tb_UserObjectName.Text, item.Key, d);
                tbUpdateLog.AppendText(string.Format("成功获取{0}的值:{1}" + "\r\n", item.Key, d.Json));

                uStore.CommitUserIndex(tbUserID.Text, tb_UserObjectName.Text, item.Key);
                tbUpdateLog.AppendText(string.Format("成功提交{0}" + "\r\n", item.Key));
                progressBar1.Value += 1;
            }
        }
Exemplo n.º 10
0
 private void button2_Click(object sender, EventArgs e)
 {
     TF.YA.Soft.DBSyncObject uStore = new TF.YA.Soft.DBSyncObject(strStoreConn);
     uStore.UnRegUser(tbUserID.Text, tb_UserObjectName.Text);
     MessageBox.Show("注消成功");
 }