Ejemplo n.º 1
0
        public JsonResult SyncAllToWechatFromH3()
        {
            //设置本次的同步时间
            AppUtility.Engine.SettingManager.SetCustomSetting(LastWechatSyncTime, DateTime.Now.ToString());
            //开始同步
            var        wechat = new WeChatAdapter(OThinker.H3.Controllers.AppUtility.Engine);
            SyncResult result = wechat.SyncOrgToWeChat(DateTime.MinValue);

            //保存本次的同步结果
            AppUtility.Engine.SettingManager.SetCustomSetting(LastWechatSyncResult, result.ToString());
            AppUtility.Engine.LogWriter.Write("微信同步结束:" + result.ToString());
            return(Json(new { Success = result.Success, Message = result.ToString() }));
        }
Ejemplo n.º 2
0
        public JsonResult SyncToWechatFromH3()
        {
            //获取上次的同步时间
            var lastWechatSyncTime = AppUtility.Engine.SettingManager.GetCustomSetting(LastWechatSyncTime);

            lastWechatSyncTime = string.IsNullOrEmpty(lastWechatSyncTime) ? DateTime.MinValue.ToString() : lastWechatSyncTime;

            //设置本次的同步时间
            AppUtility.Engine.SettingManager.SetCustomSetting(LastWechatSyncTime, DateTime.Now.ToString());
            //开始同步
            var        wechat = new WeChatAdapter(OThinker.H3.Controllers.AppUtility.Engine);
            SyncResult result = wechat.SyncOrgToWeChat(Convert.ToDateTime(lastWechatSyncTime));

            //保存本次的同步结果
            AppUtility.Engine.SettingManager.SetCustomSetting(LastWechatSyncResult, result.ToString());
            AppUtility.Engine.LogWriter.Write("微信同步结束:" + result.ToString());
            return(Json(new { Success = result.Success, Message = result.ToString() }));
        }
Ejemplo n.º 3
0
        public JsonResult AllSync()
        {
            try
            {
                #region CAP
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("CAP开始");
                //获取上次的同步时间
                var lastCAPSyncTime = AppUtility.Engine.SettingManager.GetCustomSetting(LastCAPSyncTime);
                lastCAPSyncTime = string.IsNullOrEmpty(lastCAPSyncTime) ? DateTime.MinValue.ToString() : lastCAPSyncTime;
                //执行
                string CAPMsg = CAP.CAPClass.SetCAPUser(true);
                //设置本次的同步时间
                AppUtility.Engine.SettingManager.SetCustomSetting(LastCAPSyncTime, DateTime.Now.ToString());
                AppUtility.Engine.SettingManager.SetCustomSetting(LastCAPSyncResult, CAPMsg);
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write(CAPMsg);
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("CAP结束");
                #endregion

                #region 263
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("263开始");
                //获取上次的同步时间
                var last263SyncTime = AppUtility.Engine.SettingManager.GetCustomSetting(Last263SyncTime);
                last263SyncTime = string.IsNullOrEmpty(last263SyncTime) ? DateTime.MinValue.ToString() : last263SyncTime;
                //执行时间
                DateTime dt = DateTime.Now;
                //执行
                string Msg = DongZheng.H3.WebApi.Common._263.YXTClass.SetYXTUser(true, dt);
                //设置本次的同步时间
                AppUtility.Engine.SettingManager.SetCustomSetting(Last263SyncTime, DateTime.Now.ToString());
                AppUtility.Engine.SettingManager.SetCustomSetting(Last263SyncResult, Msg);
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write(Msg);
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("263结束");
                #endregion

                #region 微信
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("WX开始");
                //设置本次的同步时间
                AppUtility.Engine.SettingManager.SetCustomSetting(LastWechatSyncTime, DateTime.Now.ToString());
                //开始同步
                var        wechat = new WeChatAdapter(OThinker.H3.Controllers.AppUtility.Engine);
                SyncResult result = wechat.SyncOrgToWeChat(DateTime.MinValue);
                //保存本次的同步结果
                AppUtility.Engine.SettingManager.SetCustomSetting(LastWechatSyncResult, result.ToString());
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write(result.ToString());
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("WX结束");
                #endregion
            }
            catch (Exception E)
            {
                return(Json(new { Success = false, Message = E.ToString() }));
            }

            return(Json(new { Success = true, Message = "成功" }));
        }
        /// <summary>
        /// Syncs local database
        /// </summary>
        public static async Task<string> SyncAsync(IProgress<ProgressArgs> progress)
        {
            // Create serverprovider and sync agent
            LogManager.log("Creating server provider and synchronization provider for synchronization", LogCategory.info, LogTopic.Database);
            MySqlSyncProvider serverProvider = new MySqlSyncProvider(Settings.Settings.MYSQLConnectionString);
            SyncAgent agent = new SyncAgent(clientProvider, serverProvider, tables);
            SyncResult result = null;

            // Synchronize
            LogManager.log("Synchronizing data with sync agent", LogCategory.info, LogTopic.Database);
            if (progress != null)
            {
                result = await agent.SynchronizeAsync(progress);
            }
            else
            {
                result = await agent.SynchronizeAsync();
            }

            LogManager.log("Sync-Result: " + result.ToString());
            return result.ToString();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 263
        /// </summary>
        /// <param name="isAll">是否完全同步</param>
        /// <param name="ExecutionTime">执行时间</param>
        /// <returns></returns>
        public static string SetYXTUser(bool isAll, DateTime ExecutionTime)
        {
            var    msg     = "";
            string domain  = "dongzhengafc.com";
            string account = "dongzhengafc.com";
            string sign1   = "cf6436ec710286f08292d48e36034012";
            string sign2   = "d7e7089f86df015c74fdadcc244ce4fb";

            xmapi.XmapiImplProxyService api = new xmapi.XmapiImplProxyService();
            var ou            = api.getDepartment("chenghuashan", domain, account, sign2);   //全部ou
            var user          = api.getDomainUserlist_New(domain, account, sign1);           //全部用户
            var userDismissed = api.getDomainUserlistByStatus(domain, 1, 0, account, sign1); //禁止用户

            if (ou == null || user == null || userDismissed == null)
            {
                return("263接口取数出错!");
            }
            OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("ou开始");
            DataTable dt = XmlToTablebyOU(ou);

            OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("ou结束");
            OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("user开始");
            DataTable dtUser = XmlToTablebyUser(user);

            OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("user结束");
            OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("dis开始");
            DataTable dtUserDismissed = XmlToTablebyUser(userDismissed);

            OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("dis结束");
            SyncResult syn = new SyncResult();

            if (dt.Rows.Count > 0)
            {
                if (!YXTOU(dt, "0", isAll, syn))
                {
                    msg = "OU更新失败!请联系管理员查看日志";
                }
                else
                {
                    var      dateuser = DateTime.Now;
                    TimeSpan ts       = dateuser.Subtract(DateTime.Now);
                    string   timespan = "相差:" + ts.Days.ToString() + "天" + ts.Hours.ToString() + "小时"
                                        + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒";
                    OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("ou结束修改" + timespan);
                    if (!YXTUser(dtUser, isAll, false, syn, ExecutionTime))
                    {
                        msg = "263USER更新失败!请联系管理员查看日志";
                    }
                    else
                    {
                        OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("user结束修改");
                        if (!YXTUser(dtUserDismissed, isAll, true, syn, ExecutionTime))
                        {
                            msg = "263禁止用户更新失败!请联系管理员查看日志";
                        }
                        OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("dis结束修改");
                    }
                }
            }
            //H3组织架构推送CRM
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("dep", "市场销售部");
            try
            {
                BizService.ExecuteBizNonQuery("CRMService", "postUser", dic);
            }
            catch (Exception ex)
            {
                OThinker.H3.Controllers.AppUtility.Engine.LogWriter.Write("CRM市场部组织架构推送异常:message:" + ex.Message);
            }
            return(msg + syn.ToString());
        }