Пример #1
0
        /// <summary>
        /// 更新单据表(发起时)
        /// </summary>
        /// <param name="billTableName"></param>
        /// <param name="billId"></param>
        internal void UpdateBillDataWhenStartup(string billTableName, string billId)
        {
            FapTable table = DbSession.QueryFirstOrDefault <FapTable>($"select * from FapTable where TableName='{billTableName}'");

            if (table == null || string.IsNullOrWhiteSpace(table.TableFeature))
            {
                return;
            }

            if (("," + table.TableFeature + ",").IndexOf(",BillFeature,") >= 0)
            {
                //单据数据
                dynamic billData = DbSession.Get(billTableName, billId);
                if (billData == null)
                {
                    return;
                }
                WfProcessInstance process    = DbSession.Get <WfProcessInstance>(ProcessId);
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("ProcessId", ProcessId);
                IEnumerable <WfTask> tasks = DbSession.QueryWhere <WfTask>("ProcessId=@ProcessId", parameters);
                if (tasks != null && tasks.Count() > 0)
                {
                    billData.CurrApprover = tasks.First().ExecutorEmpUid;
                }
                //更新单据的字段数据
                billData.SubmitTime = PublicUtils.GetSysDateTimeStr();
                billData.BillStatus = BillStatus.PROCESSING;

                DbSession.UpdateDynamicData(billData);
            }
        }
Пример #2
0
        /// <summary>
        /// 获取随机消息
        /// </summary>
        /// <param name="SendParam"></param>
        /// <returns></returns>
        private string GetRandomMessage(SendParamModel SendParam)
        {
            string tempMessage = "";

            //固定消息,只会传一条消息模板过来
            if (SendParam.TemplateRule == 0)
            {
                tempMessage = SendParam.Message[0];
            }
            //随机消息,随机获取
            else if (SendParam.TemplateRule == 1)
            {
                int messageIndex = PublicUtils.GetRandom(0, SendParam.Message.Count);
                tempMessage = SendParam.Message[messageIndex];
            }

            //替换时间变量
            tempMessage = tempMessage.Replace("[时间]", "[Time]");
            //替换昵称变量
            tempMessage = tempMessage.Replace("[昵称]", "[ObjName]");
            //替换时段
            tempMessage = tempMessage.Replace("[时段]", "[TimePer]");
            //替换分段
            //自己进行分段
            //tempMessage = tempMessage.Replace("[分段]", "[Next]");

            //替换随机表情
            //tempMessage = tempMessage.Replace("[随机表情]", "[RFace]");
            return(FaceHelper.ReplaceRandomFace(tempMessage));
        }
Пример #3
0
        /// <summary>
        /// 发送文本消息,主要处理框架分段发送会缺失以及顺序会乱的问题,自己分段并且加上延时
        /// </summary>
        /// <param name="RobotQQ"></param>
        /// <param name="MsgType"></param>
        /// <param name="MsgTo"></param>
        /// <param name="ObjQQ"></param>
        /// <param name="Msg"></param>
        /// <param name="ABID"></param>
        /// <param name="SendParam"></param>
        private void SendTextMsg(string MsgTo, string ObjQQ, string Msg, int ABID, SendParamModel SendParam)
        {
            string pattern = "\\[分段\\]";

            string[] msessages = Regex.Split(Msg, pattern);
            for (int i = 0; i < msessages.Length; i++)
            {
                if (!string.IsNullOrEmpty(msessages[i]))
                {
                    IRQQApi.Api_SendMsg(SendParam.RobotQQ, SendParam.SendObject, MsgTo, ObjQQ, msessages[i], 1);
                    //如果不是最后一次,则进入文本分段休眠
                    if (i != msessages.Length - 1)
                    {
                        int interval = PublicUtils.GetRandom(SendParam.NextIntervalDown, SendParam.NextIntervalUp + 1);
                        OnOutStatus?.Invoke(string.Format("机器人[{0}]进入文本分段休眠{1}秒!", new object[] { SendParam.RobotQQ, interval }));
                        Thread.Sleep(interval * 1000);
                    }
                }
            }
        }
Пример #4
0
        public void Github()
        {
            const string url = "https://github.com/dotnetcore/osharp";

            PublicUtils.OpenUrl2(url);
        }
Пример #5
0
        public void Gitee()
        {
            const string url = "https://gitee.com/i66soft/OSharp.CodeGenerator";

            PublicUtils.OpenUrl2(url);
        }
Пример #6
0
        public void ThreadProc()
        {
            DateTime beginTime = DateTime.Now;
            //发送总数
            int    sendCount   = 0;
            string objectText  = SendParam.SendObject == 1 ? "好友" : (SendParam.SendObject == 2 ? "群" : (SendParam.SendObject == 4 ? "群成员" : ""));
            int    friendCount = 0;

            try
            {
                int?commandExce = 1;
                commandExce = OnGetCommand?.Invoke();
                //如果收到停止指令,则直接退出
                if (commandExce == 4)
                {
                    throw new Exception("收到停止指令,任务自动取消!");
                }
                //获取好友或者群数据
                DataTable dataTable = null;
                if (SendParam.SendObject == 1)
                {
                    OnOutStatus?.Invoke(string.Format("准备获取机器人[{0}]的好友数据!", new object[] { SendParam.RobotQQ }));
                    dataTable = DataHelper.GetFriends(SendParam.RobotQQ);
                    OnOutStatus?.Invoke(string.Format("获取机器人[{0}]的好友数据成功!", new object[] { SendParam.RobotQQ }));
                }
                else if (SendParam.SendObject == 2)
                {
                    OnOutStatus?.Invoke(string.Format("准备获取机器人[{0}]的群组数据!", new object[] { SendParam.RobotQQ }));
                    dataTable = DataHelper.GetGroups(SendParam.RobotQQ);
                    OnOutStatus?.Invoke(string.Format("获取机器人[{0}]的群组数据成功!", new object[] { SendParam.RobotQQ }));
                }
                else if (SendParam.SendObject == 4)
                {
                }
                if (dataTable == null)
                {
                    OnOutStatus?.Invoke(string.Format("机器人[{0}]获取数据失败!", new object[] { SendParam.RobotQQ }));
                    return;
                }

                //待输出界面的消息列表
                List <string> infos = new List <string>();
                friendCount = dataTable.Rows.Count;
                OnOutStatus?.Invoke(string.Format("机器人[{0}]开始发送数据,{1}总数:{2}", new object[] { SendParam.RobotQQ, objectText, friendCount }));

                //从第二行开始遍历
                for (int i = 0; i <= friendCount; i++)
                {
                    bool outCommandInfo = true;

                    //获取命令,判断当前是否执行
labelCommand:
                    int?command = 1;
                    command     = OnGetCommand?.Invoke();
                    switch (command)
                    {
                    case 1:
                        break;

                    case 2:
                        if (outCommandInfo)
                        {
                            OnOutStatus?.Invoke(string.Format("机器人[{0}]收到暂停指令,当前任务已暂停!", new object[] { SendParam.RobotQQ }));
                        }
                        outCommandInfo = false;
                        break;

                    case 3:
                        OnOutStatus?.Invoke(string.Format("机器人[{0}]收到恢复指令,当前任务已恢复!", new object[] { SendParam.RobotQQ }));
                        break;

                    case 4:
                        OnOutStatus?.Invoke(string.Format("机器人[{0}]收到停止指令,当前任务已取消!", new object[] { SendParam.RobotQQ }));
                        break;
                    }
                    //如果是暂停指令,则不停检测是否收到恢复指令或者停止指令
                    if (command == 2)
                    {
                        Thread.Sleep(1000);
                        goto labelCommand;
                    }
                    //如果是停止执行,则停止当前处理
                    else if (command == 4)
                    {
                        break;
                    }

                    string uin  = Convert.ToString(dataTable.Rows[i]["uin"]);
                    string name = Convert.ToString(dataTable.Rows[i]["name"]);
                    //发送消息
                    SendMsg(uin, uin, name, sendCount, objectText, SendParam);
                    sendCount++;

                    //回传当前状态
                    OnOutStatus?.Invoke(string.Format("机器人[{0}]成功给第{1}个{2}[{3}-{4}]发送消息!", new object[] { SendParam.RobotQQ, sendCount, objectText, uin, name }));

                    //如果当前已发送完,则停止
                    if (sendCount == dataTable.Rows.Count)
                    {
                        break;
                    }

                    //当到达每组发送总数时进行暂停
                    if (sendCount % SendParam.GroupNum == 0)
                    {
                        int groupSleep = PublicUtils.GetRandom(SendParam.GroupSleepDown, SendParam.GroupSleepUp + 1);
                        OnOutStatus?.Invoke(string.Format("机器人[{0}]进入组休眠{1}秒!", new object[] { SendParam.RobotQQ, groupSleep }));
                        Thread.Sleep(groupSleep * 1000);
                    }
                    else
                    {
                        //算出每个休眠时间
                        int interval = PublicUtils.GetRandom(SendParam.FriendIntervalDown, SendParam.FriendIntervalUp + 1);
                        OnOutStatus?.Invoke(string.Format("机器人[{0}]进入好友休眠{1}秒!", new object[] { SendParam.RobotQQ, interval }));
                        Thread.Sleep(interval * 1000);
                    }
                }
            }
            catch (Exception ex)
            {
                OnOutStatus?.Invoke(string.Format("机器人[{0}]执行任务出错了,任务自动取消!成功发送{1},未发送{2},错误详情:{3}", new object[] { SendParam.RobotQQ, sendCount, friendCount - sendCount, ex.Message }));
            }
            finally
            {
                OnTaskCompleted?.Invoke(string.Format("机器人[{0}]任务已完成!用时:{1:F}秒,共发送{2}个{3}", new object[] { SendParam.RobotQQ, (DateTime.Now - beginTime).TotalSeconds, sendCount, objectText }));
            }
        }
Пример #7
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="RobotQQ"></param>
        /// <param name="MsgType"></param>
        /// <param name="MsgTo"></param>
        /// <param name="ObjQQ"></param>
        /// <param name="Msg"></param>
        /// <param name="ABID"></param>
        /// <param name="SendParam"></param>
        private void SendMsg(string MsgTo, string ObjQQ, string name, int sendCount, string objectText, SendParamModel SendParam)
        {
            //每发一次消息获取一个随机消息
            string tempMessage = GetRandomMessage(SendParam);
            //如果有语音,则拆分发送
            string pattern = "\\[IR:Voi=(.)*?\\]";

            //当前模板存在语音
            if (Regex.Match(tempMessage, pattern).Length > 0)
            {
                MatchCollection matchCollection = Regex.Matches(tempMessage, pattern);
                string[]        messages        = Regex.Split(tempMessage, pattern);
                for (int j = 0; j < messages.Length; j++)
                {
                    if (!string.IsNullOrEmpty(messages[j]))
                    {
                        if (messages[j] == "r")
                        {
                            //发送语音
                            //获取当前文本
                            //0 1 2 3 4 5 6 7  x   x - 1 / 2
                            //0 1 2 3 y
                            //如果语音数据列表存在,则发送,否则提示不存在
                            //获取语音标签
                            string voiceKey = matchCollection[(j - 1) / 2].Value;
                            if (SendParam.Voices.ContainsKey(voiceKey))
                            {
                                if (SendParam.SendObject == 1)
                                {
                                    IRQQApi.Api_SendVoice(SendParam.RobotQQ, ObjQQ, SendParam.Voices[voiceKey]);
                                }
                                else
                                {
                                    string guid = IRQQApi.Api_UpLoadVoice(SendParam.RobotQQ, 2, ObjQQ, SendParam.Voices[voiceKey]);
                                    OnOutStatus?.Invoke(string.Format("获取到的GUID:{0}", new string[] { guid }));
                                    IRQQApi.Api_SendMsg(SendParam.RobotQQ, 2, MsgTo, ObjQQ, guid, 0);
                                }
                                OnOutStatus?.Invoke(string.Format("机器人[{0}]发送语音给第{1}个{2}[{3}-{4}]发送语音成功:{5}", new object[] { SendParam.RobotQQ, sendCount + 1, objectText, ObjQQ, name, voiceKey }));
                            }
                            else
                            {
                                OnOutStatus?.Invoke(string.Format("机器人[{0}]发送语音给第{1}个{2}[{3}-{4}]失败,找不到语音文件{5}", new object[] { SendParam.RobotQQ, sendCount + 1, objectText, ObjQQ, name, voiceKey }));
                            }
                        }
                        else
                        {
                            //直接发当前文本
                            SendTextMsg(MsgTo, ObjQQ, messages[j], 1, SendParam);
                            OnOutStatus?.Invoke(string.Format("机器人[{0}]发送语音给第{1}个{2}[{3}-{4}]发送拆分文本成功:{5}", new object[] { SendParam.RobotQQ, sendCount + 1, objectText, ObjQQ, name, messages[j] }));
                        }
                        //算出分段间隔时间
                        int interval = PublicUtils.GetRandom(SendParam.NextIntervalDown, SendParam.NextIntervalUp + 1);
                        OnOutStatus?.Invoke(string.Format("机器人[{0}]进入语音分段休眠{1}秒!", new object[] { SendParam.RobotQQ, interval }));
                        Thread.Sleep(interval * 1000);
                    }
                }
            }
            else
            {
                SendTextMsg(MsgTo, ObjQQ, tempMessage, 1, SendParam);
            }
        }
Пример #8
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="logid"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public int SetPassWord(string logid, string password)
        {
            int iret = 0;

            try
            {
                //统一身份认证启用的情况下,同步修改统一身份认证服务器的用户密码
                if (IsUseUia())
                {
                    //旧密码
                    string oldpassword = NG.NGEncode.DecodePassword(HttpContext.Current.Session["uiapwd"].ToString(), 128);

                    string tokenIdentity = string.Empty;
                    //统一身份认证
                    string ssoPath     = HttpContext.Current.Request.PhysicalApplicationPath + "\\sso.config";
                    string serverUrl   = string.Format("http://{0}/v1.0/Router.ashx", SSOService.GetSTSLoginWebSiteName());
                    var    client      = new DefaultNGClient(serverUrl, MainCommonUIP.GetConfigSetion(ssoPath, "WebSiteIdentity"), MainCommonUIP.GetConfigSetion(ssoPath, "MD5key"), NG.SDK10.Enums.EnumDataFormat.Xml);
                    string newpassword = NG.NGEncode.DecodePassword(password, 128);

                    var reqCPW = new UserChangePWRequest()
                    {
                        //tokenkey
                        TokenIdentity = HttpContext.Current.Session["ssotoken"].ToString(),
                        //userkey
                        ChangeUserKey = HttpContext.Current.Session["ssouserkey"].ToString(),
                        NewPassword   = newpassword,
                        OldPassword   = oldpassword
                    };

                    UserResponse user = client.Execute(reqCPW);

                    if (!string.IsNullOrEmpty(user.UserKey))
                    {
                        iret = 1;
                    }

                    iret = dac.SetPassWord(AppSessionConfig.GetPubDBConnStr(), logid, password);

                    string loginACCount       = AppSessionConfig.GetLoginACCount();//登录帐套
                    bool   netcallIsAvailable = PublicUtils.GetNetcallIsAvailableEx(loginACCount);
                    if (netcallIsAvailable)
                    {
                        IFactory             facatory = new NetCallFactory();
                        IInstantMessageRules rules    = facatory.Create();
                        string msg = string.Empty;
                        rules.SetUserPassWord(logid, password, ref msg);
                    }

                    System.Diagnostics.Trace.WriteLine("修改用户Password成功! 用户标识:" + user.UserKey);
                }
                else
                {
                    //string file = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + @"\DMC\TimerService\PortalMaptoNetcallConfig.dat";
                    string loginACCount       = AppSessionConfig.GetLoginACCount();//登录帐套
                    bool   netcallIsAvailable = PublicUtils.GetNetcallIsAvailableEx(loginACCount);
                    if (netcallIsAvailable)
                    {
                        IFactory             facatory = new NetCallFactory();
                        IInstantMessageRules rules    = facatory.Create();
                        string msg = string.Empty;
                        rules.SetUserPassWord(logid, password, ref msg);
                    }

                    iret = dac.SetPassWord(AppSessionConfig.GetPubDBConnStr(), logid, password);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine(e.Message + e.StackTrace);
                iret = 0;
                //throw e;  netcall密码有时候修改失败,异常不抛出
            }
            return(iret);
        }