Ejemplo n.º 1
0
        private void SendNotifys(WF_WORKFLOW_INST mainRow, IUnitOfData source)
        {
            try
            {
                INotifyAction notifyAction;
                if (!NotifyActions.IsNotEmpty())
                {
                    NotifyActions.Add("DefaultNotifyAction");
                }
                //if (NotifyActions.IndexOf("NotifyAction") < 0 )
                //{
                //    NotifyActions.Add("NotifyAction");
                //}

                foreach (var notify in NotifyActions)
                {
                    notifyAction = notify.CodePlugIn <INotifyAction>();
                    notifyAction.DoPush(QuoteIdList.LoadFromString(mainRow.WI_RECEIVE_LIST), null, mainRow, source);
                    //DoActionDelegate doActionDelegate = new DoActionDelegate(notifyAction.DoAction);
                    foreach (var userID in QuoteIdList.LoadFromString(mainRow.WI_RECEIVE_LIST))
                    {
                        notifyAction.DoAction(userID, mainRow, null, source);
                        //doActionDelegate.BeginInvoke(userID, mainRow, WorkflowInstUtil.CreateContent(mainRow), source, null, null);
                    }
                }

                //----------
            }
            catch (Exception ex)
            {
                string str = "工作流触发异常:" + ex.Message;
                AtawAppContext.Current.Logger.Debug(str);
                AtawTrace.WriteFile(LogType.Error, str);
            }
        }
Ejemplo n.º 2
0
        public void Send()
        {
            StringBuilder _log = new StringBuilder();

            ToUsers.ToList().ForEach((u) => {
                SmtpClient client            = new SmtpClient(Host);
                client.UseDefaultCredentials = false;
                client.Credentials           = new System.Net.NetworkCredential(FromUser, Password);
                client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                MailMessage message          = new MailMessage(FromUser, u, StrSubject, StrBody);
                message.BodyEncoding         = System.Text.Encoding.GetEncoding("GB2312");
                message.IsBodyHtml           = true;

                try
                {
                    client.SendCompleted += client_SendCompleted;
                    client.Send(message);
                    _log.AppendLine();
                    _log.AppendLine("form:{1}{0}to:{2}{0}title:{3}{0}content:{4}{0}".AkFormat(Environment.NewLine, FromUser, u, StrSubject, StrBody));
                }
                catch (Exception ex)
                {
                    AtawTrace.WriteFile(LogType.EmailLog, JSON.Instance.ToJSON(this) + ex.ExcepString());
                    // AtawDebug.ThrowAtawException(JSON.Instance.ToJSON(this) + ex.ExcepString(), this);
                }
            });
            if (!_log.ToString().IsEmpty())
            {
                string fileName = "AtawLogs\\{0}.txt".AkFormat("EmailSendLog");
                AtawTrace.WriteStringFile(fileName, _log.ToString());
            }
        }
Ejemplo n.º 3
0
        private void RecoredException(Exception exception)
        {
            StringBuilder sb = new StringBuilder();

            AtawTrace.WriteFile(LogType.Error, SetException(exception, sb, true).ToString());
            //SetException(exception, sb, AtawAppContext.Current.ApplicationXml.ExceptionStack);
            AtawAppContext.Current.Logger.Debug(string.Format(ObjectUtil.SysCulture, "{0}/r/n{1}", exception.Message, exception.StackTrace));
        }
Ejemplo n.º 4
0
 private void TryThowIgro(Action a)
 {
     try
     {
         a();
     }
     catch (Exception ex)
     {
         AtawTrace.WriteFile(LogType.Desk,
                             "{0}{1}{2}".AkFormat(ex.Message, Environment.NewLine, ex.StackTrace)
                             );
         //---------------异常处理继续往下执行,以后这里需要记录日志
     }
 }
Ejemplo n.º 5
0
        public T Get <T>(string name)
        {
            string regName = GetRegName <T>(name);

            if (PageItems.Contains(regName))
            {
                if (PageItems[regName] is T)
                {
                    AtawTrace.WriteFile(LogType.PageCacheHit,
                                        "命中注册 : {0} {1} 类型 : {2} {1}".AkFormat(regName, Environment.NewLine, typeof(T).Name));
                    return((T)PageItems[regName]);
                }
            }
            return(default(T));
        }
Ejemplo n.º 6
0
        protected void SetPostDataSet(string ds)
        {
            string str = string.Format(ObjectUtil.SysCulture, "{0}{1}{2}", Environment.NewLine, ds, Environment.NewLine);

            // GlobalVariable.AppContext.Logger.Debug(str, "post数据");
            AtawTrace.WriteFile(LogType.Post, str);
            if (!ds.IsEmpty())
            {
                PostDataSet = JsonConvert.DeserializeObject <DataSet>(ds);
            }
            else
            {
                PostDataSet = new DataSet();
            }
        }
Ejemplo n.º 7
0
 public override void Prepare(WF_WORKFLOW_INST workflowRow, IUnitOfData source)
 {
     try
     {
         INotifyAction notifyAction;
         foreach (var notify in NotifyActions)
         {
             notifyAction = AtawIocContext.Current.FetchInstance <INotifyAction>(notify);
             notifyAction.DoAction(workflowRow.WI_CREATE_USER, workflowRow, null, source);
         }
     }
     catch (Exception ex)
     {
         string str = "工作流触发异常:" + ex.Message;
         AtawAppContext.Current.Logger.Debug(str);
         AtawTrace.WriteFile(LogType.Error, str);
     }
 }
Ejemplo n.º 8
0
        protected string ReturnJsonObject <T>(T res)
        {
            JsResponseResult <T> ree = new JsResponseResult <T>()
            {
                ActionType = JsActionType.JsonObject,
                Obj        = res
            };
            //  ree.SaveString(System.Xml.Formatting.Indented);
            // string str = JsonConvert.SerializeObject(ree);
            string str = FastJson(ree);

            AtawTrace.WriteFile(LogType.JsonData, str);
            HttpContext.Response.HeaderEncoding = Encoding.UTF8;

            ree.EndTimer  = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.ffff");
            ree.BeginTime = AtawAppContext.Current.GetItem("__beginTime").Value <DateTime>().ToString("yyyy/MM/dd HH:mm:ss.ffff");
            //HttpContext.Response.
            return(str);
        }
Ejemplo n.º 9
0
        protected override void OnException(ExceptionContext filterContext)
        {
            var exception = filterContext.Exception;

            filterContext.ExceptionHandled = true;
            JsResponseResult <object> ree = null;

            if (exception is AtawLegalException)
            {
                ree = new JsResponseResult <object>()
                {
                    ActionType = JsActionType.Object,
                    Obj        = new LegalPageView()
                    {
                        Error = exception.Message
                    }
                    // Content =
                };
            }
            else
            {
                ree = new JsResponseResult <object>()
                {
                    ActionType = JsActionType.Alert
                                 // Content =
                };
            }
            StringBuilder sb = new StringBuilder();

            SetException(exception, sb, AtawAppContext.Current.ApplicationXml.ExceptionStack);
            ree.Content = sb.ToString();

            AtawTrace.WriteFile(LogType.Error, SetException(exception, new StringBuilder(), true).ToString());
            // this.ControllerContext.Controller.Co
            filterContext.Result = new ContentResult()
            {
                Content = FastJson(ree)
            };
            // AtawAppContext.Current.Logger.Debug(string.Format(ObjectUtil.SysCulture, "{0}/r/n{1}", exception.Message, exception.StackTrace));

            base.OnException(filterContext);
        }
Ejemplo n.º 10
0
        public void Run()
        {
            bool continueRun;

            do
            {
                try
                {
                    if (!IsFinish)
                    {
                        continueRun = CurrentState.Execute(this);
                    }
                    else
                    {
                        continueRun = false;
                    }
                }
                catch (WorkflowException ex)
                {
                    SaveError(ex);
                    continueRun = SetWorkflowException(ex);
                    throw new AtawException("工作流异常", ex, this);
                }
                catch (Exception ex)
                {
                    string mesg = string.Format(ObjectUtil.SysCulture,
                                                "程序出现异常,异常信息是:{0}{1}{0}堆栈信息是:{0}{2}",
                                                Environment.NewLine, ex.Message, ex.StackTrace);
                    AtawTrace.WriteFile(LogType.WorkFlowError, mesg);;
                    // throw ex;

                    //SaveError(ex);
                    continueRun = false;
                    IsFinish    = true;
                    StepUtil.ErrorAbort(Source, WorkflowRow);
                    //StepUtil.ErrorAbort(this, FinishType.Error);
                    //  throw new AtawException("工作流异常", ex, this);
                    throw ex;
                }
            } while (continueRun);
        }
Ejemplo n.º 11
0
        private void SaveError(Exception ex)
        {
            string mesg = string.Format(ObjectUtil.SysCulture,
                                        "程序出现异常,异常信息是:{0}{1}{0}堆栈信息是:{0}{2}",
                                        Environment.NewLine, ex.Message, ex.StackTrace);

            AtawTrace.WriteFile(LogType.WorkFlowError, mesg);;
            //int errorId;
            //WorkflowException wfException = ex as WorkflowException;
            //if (wfException == null || wfException != null && wfException.InnerException != null)
            //    errorId = GetSaveError(ex);
            //else
            //    errorId = 0;
            //WorkflowRow.BeginEdit();
            //SetWorkflowRowByState();
            //if (errorId > 0)
            //{
            //    WorkflowRow["WI_WE_ID"] = errorId;
            //}
            //WorkflowRow.EndEdit();
        }
Ejemplo n.º 12
0
        public string ToSisenMess(string userId, string mesg)
        {
            //Thread th = new Thread(() =>
            //{
            try
            {
                //  string mesg = CreateSisenMess("zyk", DateTime.Now.ToString());
                string path = AtawAppContext.Current.ApplicationXml.AppSettings["SisenMessNotifyPath"].Value;

                FileUtil.VerifySaveFile(Path.Combine(path, "wf.sisenmsg"), mesg, Encoding.Unicode);
            }
            catch (Exception ex)
            {
                string str = "触发到布谷鸟异常: {0} {1} ".AkFormat(Environment.NewLine, ex.Message);
                //string str = "工作流触发到布谷鸟异常:" + path + ex.Message;
                AtawAppContext.Current.Logger.Debug(str);
                AtawTrace.WriteFile(LogType.IoError, str);
            }

            //});
            //// th.
            //th.Start();
            return("ok");
        }
Ejemplo n.º 13
0
 void client_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     //throw new NotImplementedException();
     AtawTrace.WriteFile(LogType.EmailLog, JSON.Instance.ToJSON(sender));
 }
Ejemplo n.º 14
0
        protected override bool Execute()
        {
            WorkflowDbContext dbContext = Source as WorkflowDbContext;
            EndStepConfig     config    = Config as EndStepConfig;
            AutoProcessor     processor = null;
            WorkflowContent   content   = WorkflowInstUtil.CreateContent(WorkflowRow);

            if (!string.IsNullOrEmpty(config.PlugRegName))
            {
                try
                {
                    processor         = AtawIocContext.Current.FetchInstance <AutoProcessor>(config.PlugRegName);
                    processor.Config  = config;
                    processor.Source  = Source;
                    processor.Content = content;
                    processor.Execute(WorkflowRow);
                }
                catch (Exception ex)
                {
                    string mesg = string.Format(ObjectUtil.SysCulture,
                                                "程序出现异常,异常信息是:{0}{1}{0}堆栈信息是:{0}{2}",
                                                Environment.NewLine, ex.Message, ex.StackTrace);
                    AtawTrace.WriteFile(LogType.WorkFlowError, mesg);;

                    // AtawTrace.WriteFile();
                    throw new PlugInException(config, config.Error, ex);
                }
            }
            FinishType finishType = FinishType.Normal;

            if (config.EnableModify)
            {
                finishType = FinishType.ModifiedNormal;
            }
            //-----
            ////新增实例历史
            // "WI_ID",
            //"WI_WD_NAME", "WI_CONTENT_XML", "WI_NAME", "WI_CREATE_DATE", "WI_CREATE_USER",
            //"WI_REF_LIST", "WI_IS_TIMEOUT","WI_TIMEOUT_DATE", "WI_NEXT_EXE_DATE", "WI_PRIORITY" ,
            //"WI_STATUS", "WI_ERROR_TYPE","WI_RETRY_TIMES","WI_MAX_RETRY_TIMES","WI_WE_ID",
            //"WI_PARENT_ID","WI_PC_FLAG"
            WF_WORKFLOW_INST_HIS wfi_His = new WF_WORKFLOW_INST_HIS();

            //copy
            wfi_His.WI_ID              = WorkflowRow.WI_ID;
            wfi_His.WI_WD_NAME         = WorkflowRow.WI_WD_NAME;
            wfi_His.WI_CONTENT_XML     = WorkflowRow.WI_CONTENT_XML;
            wfi_His.WI_NAME            = WorkflowRow.WI_NAME;
            wfi_His.WI_CREATE_DATE     = WorkflowRow.WI_CREATE_DATE;
            wfi_His.WI_CREATE_USER     = WorkflowRow.WI_CREATE_USER;
            wfi_His.WI_REF_LIST        = WorkflowRow.WI_REF_LIST;
            wfi_His.WI_IS_TIMEOUT      = WorkflowRow.WI_IS_TIMEOUT;
            wfi_His.WI_TIMEOUT_DATE    = WorkflowRow.WI_TIMEOUT_DATE;
            wfi_His.WI_NEXT_EXE_DATE   = WorkflowRow.WI_NEXT_EXE_DATE;
            wfi_His.WI_PRIORITY        = WorkflowRow.WI_PRIORITY;
            wfi_His.WI_STATUS          = WorkflowRow.WI_STATUS;
            wfi_His.WI_ERROR_TYPE      = WorkflowRow.WI_ERROR_TYPE;
            wfi_His.WI_RETRY_TIMES     = WorkflowRow.WI_RETRY_TIMES;
            wfi_His.WI_MAX_RETRY_TIMES = WorkflowRow.WI_MAX_RETRY_TIMES;
            wfi_His.WI_WE_ID           = WorkflowRow.WI_WE_ID;
            wfi_His.WI_PARENT_ID       = WorkflowRow.WI_PARENT_ID;
            wfi_His.WI_PC_FLAG         = WorkflowRow.WI_PC_FLAG;
            //赋值
            wfi_His.WI_END_DATE  = dbContext.Now;
            wfi_His.WI_END_STATE = (int)finishType;
            if (!string.IsNullOrEmpty(WorkflowRow.WI_PROCESS_ID))
            {
                wfi_His.WI_END_USER = WorkflowRow.WI_PROCESS_ID;
            }
            else
            {
                wfi_His.WI_END_USER = GlobalVariable.UserId.ToString();
            }
            //附加
            dbContext.WF_WORKFLOW_INST_HIS.Add(wfi_His);
            ////copy步骤历史
            string wiId = WorkflowRow.WI_ID;
            List <WF_STEP_INST>     stepList    = dbContext.WF_STEP_INST.Where(a => a.SI_WI_ID == wiId).ToList();
            List <WF_STEP_INST_HIS> stepListHis = new List <WF_STEP_INST_HIS>();

            foreach (var step in stepList)
            {
                //------------
                WF_STEP_INST_HIS his = new WF_STEP_INST_HIS();
                his.SI_WI_ID             = step.SI_WI_ID;
                his.SI_CURRENT_STEP      = step.SI_CURRENT_STEP;
                his.SI_CURRENT_STEP_NAME = step.SI_CURRENT_STEP_NAME;
                his.SI_END_DATE          = step.SI_END_DATE;

                his.SI_FLOW_TYPE        = step.SI_FLOW_TYPE;
                his.SI_ID               = step.SI_ID;
                his.SI_INDEX            = step.SI_INDEX;
                his.SI_IS_TIMEOUT       = step.SI_IS_TIMEOUT;
                his.SI_LAST_MANUAL      = step.SI_LAST_MANUAL;
                his.SI_LAST_MANUAL_NAME = step.SI_LAST_MANUAL_NAME;
                his.SI_LAST_STEP        = step.SI_LAST_STEP;
                his.SI_LAST_STEP_NAME   = step.SI_LAST_STEP_NAME;
                his.SI_NOTE             = step.SI_NOTE;
                his.SI_PRIORITY         = step.SI_PRIORITY;
                his.SI_PROCESS_DATE     = step.SI_PROCESS_DATE;
                his.SI_PROCESS_ID       = step.SI_PROCESS_ID;
                his.SI_RECEIVE_DATE     = step.SI_RECEIVE_DATE;
                his.SI_RECEIVE_ID       = step.SI_RECEIVE_ID;
                his.SI_SEND_DATE        = step.SI_SEND_DATE;
                his.SI_SEND_ID          = step.SI_SEND_ID;
                his.SI_START_DATE       = step.SI_START_DATE;
                his.SI_STATUS           = step.SI_STATUS;
                his.SI_STEP_TYPE        = step.SI_STEP_TYPE;
                his.SI_TIME_SPAN        = step.SI_TIME_SPAN;
                his.SI_TIMEOUT_DATE     = step.SI_TIMEOUT_DATE;

                dbContext.WF_STEP_INST.Remove(step);
                dbContext.WF_STEP_INST_HIS.Add(his);
            }
            //新增最后一个步骤到历史
            WF_STEP_INST_HIS his_step = new WF_STEP_INST_HIS();

            // dbContext.WF_STEP_INST_HIS.Add(his_step);
            StepUtil.CopyWorkflowToStepHis(dbContext, WorkflowRow, his_step, FlowAction.Flow);
            dbContext.WF_STEP_INST_HIS.Add(his_step);
            ////更新主表信息
            //删除视力表

            content.EndMainRowStatus(Source as WorkflowDbContext, finishType);
            ////主表转移先不做
            ////--提交
            dbContext.WF_WORKFLOW_INST.Remove(WorkflowRow);
            Source.Submit();
            return(false);
        }
Ejemplo n.º 15
0
        public virtual string ModuleMerge(string ds, string xml, string pageStyle)
        {
            DateTime d1 = DateTime.Now;

            //try
            //{
            xml = Xml(xml);
            IPageViewTool tool = null;
            List <Func <SubmitData, SubmitData> > resultFunList = new List <Func <SubmitData, SubmitData> >();

            Merge(ds, xml, pageStyle, out tool, resultFunList);
            int      res       = 0;
            var      dbContext = AtawAppContext.Current.UnitOfData;
            DateTime d0        = DateTime.Now;

            if (dbContext != null)
            {
                res = AtawAppContext.Current.UnitOfData.Submit();
            }



            int objRes = (AtawAppContext.Current.PageFlyweight.PageItems["ATAW_DATASOURCE_RETURN"] ?? "0").Value <int>();

            if (objRes > 0)
            {
                res = objRes;
            }
            var insertKeys = AtawAppContext.Current.PageFlyweight.PageItems["InsertKeys"] as List <string>;
            //DateTime d2 = DateTime.Now;
            //string dd = (d2 - d0).TotalMilliseconds.ToString();
            //if (insertKeys != null)
            //{
            //    return ReturnJsonObject("{\"res\":" + res + ",\"keys\":\"" + String.Join(",", insertKeys) + "\"}");
            //}
            SubmitData data = new SubmitData()
            {
                DataSourceInt = objRes,
                SubmitInt     = res,
                InsertKeys    = insertKeys,
                Result        = null
            };

            foreach (Func <SubmitData, SubmitData> fun in resultFunList)
            {
                data = fun(data);
            }

            if (data.Result != null)
            {
                string str = FastJson(data.Result);
                AtawTrace.WriteFile(LogType.JsonData, str);
                HttpContext.Response.HeaderEncoding = Encoding.UTF8;
                return(str);
            }
            else
            {
                //return ReturnJsonObject("{\"res\":" + res + ",\"keys\":\"\"}");
                return(tool.EndModuleMergeInterceptor(res, objRes, insertKeys));
            }

            // }
            //catch (AtawLegalException ex)
            //{
            //    JsResponseResult<object> ree = new JsResponseResult<object>()
            //        {
            //            ActionType = JsActionType.Alert,
            //            Content = ex.Message
            //        };
            //    return FastJson(ree);
            //}
            //return FastJson(source.Result);
            //foreach(Da)
        }
Ejemplo n.º 16
0
        public string Module(string ds, string xml, string pageStyle, string keyValue)
        {
            try
            {
                xml = Xml(xml);
                AtawDebug.AssertNotNullOrEmpty(xml, "亲 ,modulexml 注册名不可以为空的", this);
                ModuleConfig mc = xml.SingletonByPage <ModuleConfig>();
                if (mc.Mode == ModuleMode.None)
                {
                    throw new AtawException("ModuleXml的Mode节点不能为空", this);
                }

                var tool = GetPageViewTool(mc);
                tool.BeginModuleInterceptor(ref ds, ref xml, ref pageStyle, ref keyValue, ref mc);

                //if (!AtawAppContext.Current.IsAuthenticated)
                //{
                //    JsResponseResult<object> ree = new JsResponseResult<object>()
                //    {
                //        ActionType = JsActionType.Alert,
                //        Content = "请登录,匿名暂不开放...."
                //    };
                //    return FastJson(ree);
                //}
                mc = xml.SingletonByPage <ModuleConfig>();
                if (!AtawBasePageViewCreator.IsSupportPage(mc.SupportPage, pageStyle.Value <PageStyle>()))
                {
                    JsResponseResult <object> ree = new JsResponseResult <object>()
                    {
                        ActionType = JsActionType.Alert,
                        Content    = "无权访问该页面"
                    };
                    return(FastJson(ree));
                }
                bool isXml2Db = AtawAppContext.Current.ApplicationXml.IsMigration && !mc.IsNoDb;
                if (isXml2Db && mc.DataBase == null)
                {
                    mc.Forms.Cast <FormConfig>().ToList().ForEach(a =>
                    {
                        var dataForm = a.File.XmlConfig <DataFormConfig>();
                        AtawAppContext.Current.Xml2Db.Migrations(dataForm);
                    }
                                                                  );
                }

                if (isXml2Db)
                {
                    AtawTrace.WriteFile(LogType.DatabaseStructure, AtawAppContext.Current.Xml2Db.GetLogMessage());
                    var dbContext = AtawAppContext.Current.UnitOfData;
                    if (dbContext != null)
                    {
                        AtawAppContext.Current.UnitOfData.Submit();
                        AtawAppContext.Current.UnitOfData = null;
                    }
                }

                AtawBasePageViewCreator pageCreator = (pageStyle + "PageView").SingletonByPage <AtawBasePageViewCreator>();
                pageCreator.Initialize(mc, JsonConvert.DeserializeObject <DataSet>(ds ?? ""), keyValue, "", false);
                var apcv = pageCreator.Create();
                apcv.RegName = xml;


                return(tool.EndModuleInterceptor(apcv));
            }
            catch (Exception ex)
            {
                RecoredException(ex);
                AtawPageConfigView apcv = new AtawPageConfigView();
                apcv.Header         = new PageHeader();
                apcv.Header.IsValid = false;
                apcv.Header.Message = "<h2>系统出现异常,请跟管理员联系!</h2><p>异常信息是:{0}</p>".AkFormat(ex.Message);
                return(ReturnJson(apcv));
            }
            //return ReturnJson(apcv);
        }