/// <summary>
        /// 执行同步客户操作
        /// </summary>
        /// <param name="sourceDatas"></param>
        /// <param name="logs"></param>
        /// <param name="operationType"></param>
        /// <returns></returns>
        public override HttpResponseResult ExecuteSynchro(IEnumerable <AbsSynchroDataInfo> sourceDatas, List <SynchroLog> logs, SynOperationType operationType)
        {
            HttpResponseResult result = null;
            KDTransactionScope trans  = null;

            List <K3CustomerInfo> custs = ConvertAbsSynchroObject(sourceDatas);
            JObject bizData             = BuildSynchroDataJsons(sourceDatas, operationType);

            List <string> numbers = null;
            List <int>    pkIds   = null;

            try
            {
                if (operationType == SynOperationType.SAVE)
                {
                    #region
                    try
                    {
                        #region
                        using (trans = new KDTransactionScope(System.Transactions.TransactionScopeOption.Required))
                        {
                            //单据保存
                            result = ExecuteOperate(SynOperationType.SAVE, null, null, bizData.ToString());

                            if (result != null && result.Success == true)
                            {
                                //保存操作成功后返回单据的编码集合
                                if (result.GetNeedReturnValues("FNumber").ConvertAll(obj => string.Format("{0}", obj)) != null)
                                {
                                    numbers = result.GetNeedReturnValues("FNumber").ConvertAll(obj => string.Format("{0}", obj));
                                }
                                //保存操作成功后返回的单据内码集合
                                if (result.GetNeedReturnValues("FCUSTID").Select(obj => Convert.ToInt32(obj)).ToList() != null)
                                {
                                    pkIds = result.GetNeedReturnValues("FCUSTID").Select(obj => Convert.ToInt32(obj)).ToList();
                                }
                            }
                            ////单据提交
                            //result = InvokeWebApi.InvokeBatchSubmit(this.K3CloudContext, this.DataType, FormKey, numbers);
                            ////单据审核
                            //result = InvokeWebApi.InvokeBatchAudit(this.K3CloudContext, this.DataType, FormKey, numbers);
                            ////单据分配
                            //result = InvokeWebApi.InvokeBatchAllot(this.K3CloudContext, this.DataType, FormKey, pkIds);
                            ////分配后更新提交审核
                            //result = AfterAllot(this.K3CloudContext, custs);
                            ////提交事务
                            trans.Complete();
                        }
                    }

                    #endregion

                    #region
                    ////单据保存
                    //result = InvokeWebApi.InvokeBatchSave(this.K3CloudContext, this.DataType, FormKey, bizData.ToString());

                    //if (result != null && result.Success == true)
                    //{
                    //    //保存操作成功后返回单据的编码集合
                    //    if (result.ReturnValues("FNumber").ConvertAll(obj => string.Format("{0}", obj)) != null)
                    //    {
                    //        numbers = result.ReturnValues("FNumber").ConvertAll(obj => string.Format("{0}", obj));
                    //    }
                    //    //保存操作成功后返回的单据内码集合
                    //    if (result.ReturnValues("FCUSTID").Select(obj => Convert.ToInt32(obj)).ToList() != null)
                    //    {
                    //        pkIds = result.ReturnValues("FCUSTID").Select(obj => Convert.ToInt32(obj)).ToList();
                    //    }
                    //}
                    ////单据提交
                    //result = InvokeWebApi.InvokeBatchSumbit(this.K3CloudContext, this.DataType, FormKey, numbers);

                    ////单据审核
                    //result = InvokeWebApi.InvokeBatchAudit(this.K3CloudContext, this.DataType, FormKey, numbers);


                    ////单据分配
                    ////result = InvokeWebApi.InvokeBatchAllot(this.K3CloudContext, this.DataType, FormKey, pkIds);

                    ////分配后更新提交审核
                    ////result = AfterAllot(this.K3CloudContext, custs);

                    //trans.Complete();

                    #endregion

                    catch (Exception ex)
                    {
                        LogUtils.WriteSynchroLog(this.K3CloudContext, this.DataType, "提交事务出现异常,异常信息:" + ex.Message + System.Environment.NewLine + ex.StackTrace);
                    }
                    finally
                    {
                        if (trans != null)
                        {
                            trans.Dispose();
                        }
                    }

                    #endregion
                }
                else if (operationType == SynOperationType.ALLOT)
                {
                    //单据分配
                    try
                    {
                        if (custs != null && custs.Count > 0)
                        {
                            AfterAllot(this.K3CloudContext, custs);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogUtils.WriteSynchroLog(this.K3CloudContext, this.DataType, "分配操作出现异常,异常信息:" + ex.Message + System.Environment.NewLine + ex.StackTrace);
                    }
                }

                else if (operationType == SynOperationType.UPDATE)
                {
                    //单据更新
                    //result = InvokeWebApi.InvokeBatchSave(this.K3CloudContext, this.DataType, FormKey, bizData.ToString());
                }
                return(result);
            }
            catch (Exception ex)
            {
                if (logs != null && logs.Count > 0)
                {
                    foreach (var log in logs)
                    {
                        log.IsSuccess = 0;
                        log.ErrInfor  = ex.Message + System.Environment.NewLine + ex.StackTrace;
                    }
                }
            }

            if (result == null)
            {
                return(null);
            }

            if (result.Success == false && result.FailedResult == null && result.Result == null)
            {
                //同步出现错误之类:如令牌错误,url错误之类的
                if (logs != null && logs.Count > 0)
                {
                    foreach (var log in logs)
                    {
                        log.IsSuccess = 0;
                        log.ErrInfor  = "数据同步失败:" + result.Message == null ? "" : result.Message;
                    }
                }

                return(result);
            }

            return(result);
        }
示例#2
0
        public static ContentInfo Calculate(int sequence, ContentInfo contentInfo, List <ContentColumn> columns, Dictionary <string, Dictionary <string, Func <IContentContext, string> > > pluginColumns)
        {
            if (contentInfo == null)
            {
                return(null);
            }

            var retVal = new ContentInfo(contentInfo.ToDictionary());

            foreach (var column in columns)
            {
                //添加审核人的名称转换
                //if (column.AttributeName == "CheckUserName")
                //{
                //    column.IsCalculate = true;
                //}

                if (!column.IsCalculate)
                {
                    continue;
                }

                if (StringUtils.EqualsIgnoreCase(column.AttributeName, ContentAttribute.Sequence))
                {
                    retVal.Set(ContentAttribute.Sequence, sequence);
                }
                else if (StringUtils.EqualsIgnoreCase(column.AttributeName, ContentAttribute.AdminId))
                {
                    var value = string.Empty;
                    if (contentInfo.AdminId > 0)
                    {
                        var adminInfo = AdminManager.GetAdminInfoByUserId(contentInfo.AdminId);
                        if (adminInfo != null)
                        {
                            value = string.IsNullOrEmpty(adminInfo.DisplayName) ? adminInfo.UserName : adminInfo.DisplayName;
                        }
                    }
                    retVal.Set(ContentAttribute.AdminId, value);
                }
                else if (StringUtils.EqualsIgnoreCase(column.AttributeName, ContentAttribute.UserId))
                {
                    var value = string.Empty;
                    if (contentInfo.UserId > 0)
                    {
                        var userInfo = UserManager.GetUserInfoByUserId(contentInfo.UserId);
                        if (userInfo != null)
                        {
                            value = string.IsNullOrEmpty(userInfo.DisplayName) ? userInfo.UserName : userInfo.DisplayName;
                        }
                    }
                    retVal.Set(ContentAttribute.UserId, value);
                }
                else if (StringUtils.EqualsIgnoreCase(column.AttributeName, ContentAttribute.SourceId))
                {
                    retVal.Set(ContentAttribute.SourceId, SourceManager.GetSourceName(contentInfo.SourceId));
                }
                else if (StringUtils.EqualsIgnoreCase(column.AttributeName, ContentAttribute.AddUserName))
                {
                    var value = string.Empty;
                    if (!string.IsNullOrEmpty(contentInfo.AddUserName))
                    {
                        var adminInfo = AdminManager.GetAdminInfoByUserName(contentInfo.AddUserName);
                        if (adminInfo != null)
                        {
                            value = string.IsNullOrEmpty(adminInfo.DisplayName) ? adminInfo.UserName : adminInfo.DisplayName;
                        }
                    }
                    retVal.Set(ContentAttribute.AddUserName, value);
                }
                else if (StringUtils.EqualsIgnoreCase(column.AttributeName, ContentAttribute.LastEditUserName))
                {
                    var value = string.Empty;
                    if (!string.IsNullOrEmpty(contentInfo.LastEditUserName))
                    {
                        var adminInfo = AdminManager.GetAdminInfoByUserName(contentInfo.LastEditUserName);
                        if (adminInfo != null)
                        {
                            value = string.IsNullOrEmpty(adminInfo.DisplayName) ? adminInfo.UserName : adminInfo.DisplayName;
                        }
                    }
                    retVal.Set(ContentAttribute.LastEditUserName, value);
                }
                //else if (StringUtils.EqualsIgnoreCase(column.AttributeName, ContentAttribute.CheckUserName))
                //{
                //    var value = string.Empty;
                //    if (!string.IsNullOrEmpty(contentInfo.))
                //    {
                //        var adminInfo = AdminManager.GetAdminInfoByUserName(contentInfo.CheckUserName);
                //        if (adminInfo != null)
                //        {
                //            value = string.IsNullOrEmpty(adminInfo.DisplayName) ? adminInfo.UserName : adminInfo.DisplayName;
                //        }
                //    }
                //    retVal.Set(ContentAttribute.CheckUserName, value);
                //}
            }

            if (pluginColumns != null)
            {
                foreach (var pluginId in pluginColumns.Keys)
                {
                    var contentColumns = pluginColumns[pluginId];
                    if (contentColumns == null || contentColumns.Count == 0)
                    {
                        continue;
                    }

                    foreach (var columnName in contentColumns.Keys)
                    {
                        var attributeName = $"{pluginId}:{columnName}";
                        if (columns.All(x => x.AttributeName != attributeName))
                        {
                            continue;
                        }

                        try
                        {
                            var func  = contentColumns[columnName];
                            var value = func(new ContentContextImpl
                            {
                                SiteId    = contentInfo.SiteId,
                                ChannelId = contentInfo.ChannelId,
                                ContentId = contentInfo.Id
                            });

                            retVal.Set(attributeName, value);
                        }
                        catch (Exception ex)
                        {
                            LogUtils.AddErrorLog(pluginId, ex);
                        }
                    }
                }
            }

            return(retVal);
        }
示例#3
0
 public void AddSiteLog(int siteId, int channelId, int contentId, string action, string summary)
 {
     LogUtils.AddSiteLog(siteId, channelId, contentId, AdminName, action, summary);
 }
示例#4
0
        public static void TestRFID(object sender, ElapsedEventArgs elapsed)
        {
            GClient clientConn = new GClient();

            //COM1  主柜rfid串口
            //COM4  副柜rfid串口
            if (clientConn.OpenSerial("COM1:115200", 3000, out eConnectionAttemptEventStatusType status))
            //if (clientConn.OpenTcp("192.168.1.168:8160", 3000, out status))
            {
                // 订阅标签上报事件
                clientConn.OnEncapedTagEpcLog  += new delegateEncapedTagEpcLog(OnEncapedTagEpcLog);
                clientConn.OnEncapedTagEpcOver += new delegateEncapedTagEpcOver(OnEncapedTagEpcOver);

                // 停止指令,空闲态
                MsgBaseStop msgBaseStop = new MsgBaseStop();
                clientConn.SendSynMsg(msgBaseStop);
                if (0 == msgBaseStop.RtCode)
                {
                    LogUtils.Debug("Stop successful.");
                }
                else
                {
                    LogUtils.Debug("Stop error.");
                }

                // 功率配置, 将4个天线功率都设置为30dBm.
                MsgBaseSetPower msgBaseSetPower = new MsgBaseSetPower
                {
                    DicPower = new Dictionary <byte, byte>()
                    {
                        { 1, 30 },
                        { 2, 30 },
                        { 3, 30 },
                        { 4, 30 }
                    }
                };
                clientConn.SendSynMsg(msgBaseSetPower);
                if (0 == msgBaseSetPower.RtCode)
                {
                    LogUtils.Debug("Power configuration successful.");
                }
                else
                {
                    LogUtils.Debug("Power configuration error.");
                }
                LogUtils.Debug("Enter any character to start reading the tag.");
                Console.ReadKey();

                // 4个天线读卡, 读取EPC数据区以及TID数据区
                MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc
                {
                    AntennaEnable = (uint)(eAntennaNo._1 | eAntennaNo._2 | eAntennaNo._3 | eAntennaNo._4),
                    InventoryMode = (byte)eInventoryMode.Inventory,
                    // tid参数
                    ReadTid = new ParamEpcReadTid()
                };
                msgBaseInventoryEpc.ReadTid.Mode = (byte)eParamTidMode.Auto;
                msgBaseInventoryEpc.ReadTid.Len  = 6;
                clientConn.SendSynMsg(msgBaseInventoryEpc);
                if (0 == msgBaseInventoryEpc.RtCode)
                {
                    LogUtils.Debug("Inventory epc successful.");
                }
                else
                {
                    LogUtils.Debug("Inventory epc error.");
                }
                Console.ReadKey();

                // 停止读卡,空闲态
                clientConn.SendSynMsg(msgBaseStop);
                if (0 == msgBaseStop.RtCode)
                {
                    LogUtils.Debug("Stop successful.");
                }
                else
                {
                    LogUtils.Debug("Stop error.");
                }
            }
            else
            {
                LogUtils.Debug("Connect failure.");
            }
            Console.ReadKey();
            clientConn.Close();
        }
示例#5
0
 public void Awake()
 {
     Instance = this;
     LogUtils.DoLog("Loading Depot Hooks!");
     RedirectorInstance.AddRedirect(typeof(DepotAI).GetMethod("StartTransfer", allFlags), typeof(TLMDepotAIOverrides).GetMethod("StartTransfer", allFlags));
 }
示例#6
0
        public string Parse(int totalNum, int currentPageIndex, int pageCount, bool isStatic)
        {
            if (isStatic)
            {
                var maxPage = ListInfo.MaxPage;
                if (maxPage == 0)
                {
                    maxPage = _pageInfo.SiteInfo.Additional.CreateStaticMaxPage;
                }
                if (maxPage > 0 && currentPageIndex + 1 > maxPage)
                {
                    return(ParseDynamic(totalNum, currentPageIndex, pageCount));
                }
            }

            var parsedContent = string.Empty;

            _contextInfo.PageItemIndex = currentPageIndex * ListInfo.PageNum;

            try
            {
                if (!string.IsNullOrEmpty(SqlString))
                {
                    //var pageSqlString = DataProvider.DatabaseDao.GetPageSqlString(SqlString, ListInfo.OrderByString, totalNum, ListInfo.PageNum, currentPageIndex);
                    var pageSqlString = StlDatabaseCache.GetStlPageSqlString(SqlString, ListInfo.OrderByString, totalNum, ListInfo.PageNum, currentPageIndex);

                    var datasource = DataProvider.DatabaseDao.GetDataSource(pageSqlString);

                    if (ListInfo.Layout == ELayout.None)
                    {
                        var rptContents = new Repeater();

                        if (!string.IsNullOrEmpty(ListInfo.HeaderTemplate))
                        {
                            rptContents.HeaderTemplate = new SeparatorTemplate(ListInfo.HeaderTemplate);
                        }
                        if (!string.IsNullOrEmpty(ListInfo.FooterTemplate))
                        {
                            rptContents.FooterTemplate = new SeparatorTemplate(ListInfo.FooterTemplate);
                        }
                        if (!string.IsNullOrEmpty(ListInfo.SeparatorTemplate))
                        {
                            rptContents.SeparatorTemplate = new SeparatorTemplate(ListInfo.SeparatorTemplate);
                        }
                        if (!string.IsNullOrEmpty(ListInfo.AlternatingItemTemplate))
                        {
                            rptContents.AlternatingItemTemplate = new RepeaterTemplate(ListInfo.AlternatingItemTemplate, ListInfo.SelectedItems, ListInfo.SelectedValues, ListInfo.SeparatorRepeatTemplate, ListInfo.SeparatorRepeat, _pageInfo, EContextType.Content, _contextInfo);
                        }

                        rptContents.ItemTemplate = new RepeaterTemplate(ListInfo.ItemTemplate, ListInfo.SelectedItems, ListInfo.SelectedValues, ListInfo.SeparatorRepeatTemplate, ListInfo.SeparatorRepeat, _pageInfo, EContextType.Content, _contextInfo);

                        rptContents.DataSource = datasource;
                        rptContents.DataBind();

                        if (rptContents.Items.Count > 0)
                        {
                            parsedContent = ControlUtils.GetControlRenderHtml(rptContents);
                        }
                    }
                    else
                    {
                        var pdlContents = new ParsedDataList();

                        //设置显示属性
                        TemplateUtility.PutListInfoToMyDataList(pdlContents, ListInfo);

                        pdlContents.ItemTemplate = new DataListTemplate(ListInfo.ItemTemplate, ListInfo.SelectedItems, ListInfo.SelectedValues, ListInfo.SeparatorRepeatTemplate, ListInfo.SeparatorRepeat, _pageInfo, EContextType.Content, _contextInfo);
                        if (!string.IsNullOrEmpty(ListInfo.HeaderTemplate))
                        {
                            pdlContents.HeaderTemplate = new SeparatorTemplate(ListInfo.HeaderTemplate);
                        }
                        if (!string.IsNullOrEmpty(ListInfo.FooterTemplate))
                        {
                            pdlContents.FooterTemplate = new SeparatorTemplate(ListInfo.FooterTemplate);
                        }
                        if (!string.IsNullOrEmpty(ListInfo.SeparatorTemplate))
                        {
                            pdlContents.SeparatorTemplate = new SeparatorTemplate(ListInfo.SeparatorTemplate);
                        }
                        if (!string.IsNullOrEmpty(ListInfo.AlternatingItemTemplate))
                        {
                            pdlContents.AlternatingItemTemplate = new DataListTemplate(ListInfo.AlternatingItemTemplate, ListInfo.SelectedItems, ListInfo.SelectedValues, ListInfo.SeparatorRepeatTemplate, ListInfo.SeparatorRepeat, _pageInfo, EContextType.Content, _contextInfo);
                        }

                        pdlContents.DataSource   = datasource;
                        pdlContents.DataKeyField = ContentAttribute.Id;
                        pdlContents.DataBind();

                        if (pdlContents.Items.Count > 0)
                        {
                            parsedContent = ControlUtils.GetControlRenderHtml(pdlContents);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                parsedContent = LogUtils.AddStlErrorLog(_pageInfo, ElementName, _stlPageContentsElement, ex);
            }

            //还原翻页为0,使得其他列表能够正确解析ItemIndex
            _contextInfo.PageItemIndex = 0;
            return(parsedContent);
        }
示例#7
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                var targetNodeID = int.Parse(NodeIDTo.SelectedValue);

                var targetPublishmentSystemID   = int.Parse(PublishmentSystemIDDropDownList.SelectedValue);
                var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetPublishmentSystemID);
                var isChecked    = false;
                var checkedLevel = 0;
                if (targetPublishmentSystemInfo.CheckContentLevel == 0 || AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentAdd, AppManager.Cms.Permission.Channel.ContentCheck))
                {
                    isChecked    = true;
                    checkedLevel = 0;
                }
                else
                {
                    var UserCheckLevel  = 0;
                    var OwnHighestLevel = false;

                    if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel1))
                    {
                        UserCheckLevel = 1;
                        if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel2))
                        {
                            UserCheckLevel = 2;
                            if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel3))
                            {
                                UserCheckLevel = 3;
                                if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel4))
                                {
                                    UserCheckLevel = 4;
                                    if (AdminUtility.HasChannelPermissions(Body.AdministratorName, targetPublishmentSystemID, targetNodeID, AppManager.Cms.Permission.Channel.ContentCheckLevel5))
                                    {
                                        UserCheckLevel = 5;
                                    }
                                }
                            }
                        }
                    }

                    if (UserCheckLevel >= targetPublishmentSystemInfo.CheckContentLevel)
                    {
                        OwnHighestLevel = true;
                    }
                    if (OwnHighestLevel)
                    {
                        isChecked    = true;
                        checkedLevel = 0;
                    }
                    else
                    {
                        isChecked    = false;
                        checkedLevel = UserCheckLevel;
                    }
                }

                try
                {
                    var translateType = ETranslateTypeUtils.GetEnumType(TranslateType.SelectedValue);

                    var nodeIDStrArrayList = ControlUtils.GetSelectedListControlValueArrayList(NodeIDFrom);

                    var nodeIDArrayList = new ArrayList();//需要转移的栏目ID
                    foreach (string nodeIDStr in nodeIDStrArrayList)
                    {
                        var nodeID = int.Parse(nodeIDStr);
                        if (translateType != ETranslateType.Content)//需要转移栏目
                        {
                            if (!NodeManager.IsAncestorOrSelf(PublishmentSystemId, nodeID, targetNodeID))
                            {
                                nodeIDArrayList.Add(nodeID);
                            }
                        }

                        if (translateType == ETranslateType.Content)//转移内容
                        {
                            TranslateContent(targetPublishmentSystemInfo, nodeID, targetNodeID, isChecked, checkedLevel);
                        }
                    }

                    if (translateType != ETranslateType.Content)//需要转移栏目
                    {
                        var nodeIDArrayListToTranslate = new ArrayList(nodeIDArrayList);
                        foreach (int nodeID in nodeIDArrayList)
                        {
                            var subNodeIDArrayList = DataProvider.NodeDao.GetNodeIdListForDescendant(nodeID);
                            if (subNodeIDArrayList != null && subNodeIDArrayList.Count > 0)
                            {
                                foreach (int nodeIDToDelete in subNodeIDArrayList)
                                {
                                    if (nodeIDArrayListToTranslate.Contains(nodeIDToDelete))
                                    {
                                        nodeIDArrayListToTranslate.Remove(nodeIDToDelete);
                                    }
                                }
                            }
                        }

                        var nodeInfoList = new List <NodeInfo>();
                        foreach (int nodeID in nodeIDArrayListToTranslate)
                        {
                            var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeID);
                            nodeInfoList.Add(nodeInfo);
                        }

                        TranslateChannelAndContent(nodeInfoList, targetPublishmentSystemID, targetNodeID, translateType, isChecked, checkedLevel, null, null);

                        if (IsDeleteAfterTranslate.Visible && EBooleanUtils.Equals(IsDeleteAfterTranslate.SelectedValue, EBoolean.True))
                        {
                            foreach (int nodeID in nodeIDArrayListToTranslate)
                            {
                                try
                                {
                                    DataProvider.NodeDao.Delete(nodeID);
                                }
                                catch { }
                            }
                        }
                    }
                    Submit.Enabled = false;

                    var builder = new StringBuilder();
                    foreach (ListItem listItem in NodeIDFrom.Items)
                    {
                        if (listItem.Selected)
                        {
                            builder.Append(listItem.Text).Append(",");
                        }
                    }
                    if (builder.Length > 0)
                    {
                        builder.Length = builder.Length - 1;
                    }
                    Body.AddSiteLog(PublishmentSystemId, "批量转移", $"栏目:{builder},转移后删除:{IsDeleteAfterTranslate.SelectedValue}");

                    SuccessMessage("批量转移成功!");
                    if (Body.IsQueryExists("ChannelIDCollection"))
                    {
                        PageUtils.Redirect(returnUrl);
                    }
                    else
                    {
                        PageUtils.Redirect(GetRedirectUrl(PublishmentSystemId));
                    }
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "批量转移失败!");
                    LogUtils.AddErrorLog(ex);
                }
            }
        }
 private void OnAuthSuccess(object sender, EventArgs e)
 {
     LogUtils.LogMessage(Enums.LogSeverity.INFO, $"Successfully authenticated and verified user. Navigation to {nameof(QuestionnairePageActivity)}");
     GoToQuestionnairePage();
 }
 private void LogInWithIDPortenButton_Click(object sender, EventArgs e)
 {
     LogUtils.LogMessage(Enums.LogSeverity.INFO, "Startet login with ID porten");
     Intent browserIntent = AuthenticationState.Authenticator.GetUI(this);
     StartActivity(browserIntent);
 }
 public override void ViewWillAppear(bool animated)
 {
     base.ViewWillAppear(animated);
     LogUtils.LogMessage(Enums.LogSeverity.INFO, "The user is seeing General Error", null, GetCorrelationId());
 }
示例#11
0
        public bool Refresh()
        {
            this.DictColumnInfo      = new IgCaseDictionary <ColumnInfo>(KeyCase.Upper);
            this.TableInfoDict       = new IgCaseDictionary <TableInfo>(KeyCase.Upper);
            this.TableColumnNameDict = new IgCaseDictionary <List <string> >(KeyCase.Upper);
            this.TableColumnInfoDict = new IgCaseDictionary <List <ColumnInfo> >(KeyCase.Upper);
            this.TableColumnComments = new IgCaseDictionary <NameValueCollection>(KeyCase.Upper);

            string sequence_Sql = string.Format("SELECT SEQUENCE_NAME FROM ALL_SEQUENCES WHERE SEQUENCE_OWNER = '{0}' ORDER BY SEQUENCE_NAME", User);

            string strSql = string.Format("SELECT T.TABLE_NAME as Name, TC.COMMENTS  as Value FROM SYS.ALL_ALL_TABLES T, SYS.ALL_TAB_COMMENTS TC WHERE T.IOT_NAME IS NULL  AND T.NESTED = 'NO'  AND T.SECONDARY = 'N'  AND NOT EXISTS ( SELECT 1 FROM SYS.ALL_MVIEWS MV WHERE MV.OWNER = T.OWNER AND MV.MVIEW_NAME = T.TABLE_NAME ) AND TC.OWNER ( + ) = T.OWNER  AND TC.TABLE_NAME ( + ) = T.TABLE_NAME  AND T.OWNER = '{0}' ORDER BY T.TABLE_NAME ASC", User);

            string viewSql = string.Format("select view_name,text from ALL_VIEWS WHERE OWNER = '{0}' order by view_name asc", User);

            //Oracle 11g 推出 LISTAGG 函数,有可能会报:ora-01489 字符串连接的结果过长
            string procSql = string.Format("select * from (SELECT name,LISTAGG(text,' ') WITHIN  group (order by line asc) text FROM all_source where OWNER = '{0}'  group by name ) order by name asc", User);

            //https://blog.csdn.net/rczrj/article/details/74977010
            procSql = string.Format("select * from (SELECT name,xmlagg(xmlparse(content text||' ' wellformed) order by line asc).getclobval() text FROM all_source where OWNER = '{0}' group by name ) order by name asc", User);

            try
            {
                //查询Oracle的所有序列
                this.Sequences = Db.ReadList <string>(sequence_Sql);

                this.TableComments = Db.ReadNameValues(strSql);

                this.Version = Db.Scalar("select * from v$version where ROWNUM = 1", string.Empty);

                this.Views = Db.ReadNameValues(viewSql);

                try
                {
                    this.Procs = Db.ReadNameValues(procSql);
                }
                catch (Exception e)
                {
                    LogUtils.LogError("查询存储过程报错", Developer.SysDefault, e, this.Version, procSql);
                    this.Procs = new NameValueCollection();
                }

                if (this.TableComments != null && this.TableComments.Count > 0)
                {
                    this.TableNames = this.TableComments.AllKeys.ToList();

                    List <Task> lstTask = new List <Task>();

                    foreach (string tableName in this.TableNames)
                    {
                        Task task = Task.Run(() =>
                        {
                            TableInfo tabInfo  = new TableInfo();
                            tabInfo.TableName  = tableName;
                            tabInfo.TabComment = this.TableComments[tableName];

                            /** 该语句,包含某列是否自增列,查询慢 **/

                            strSql = @"select a.COLUMN_ID As Colorder,a.COLUMN_NAME As ColumnName,a.DATA_TYPE As TypeName,b.comments As DeText,(Case When a.DATA_TYPE='NUMBER' Then a.DATA_PRECISION When a.DATA_TYPE='NVARCHAR2' Then a.DATA_LENGTH/2 Else a.DATA_LENGTH End )As Length,a.DATA_SCALE As Scale,
	(Case When (select Count(1)  from all_cons_columns aa, all_constraints bb where aa.OWNER = '{0}' and bb.OWNER = '{0}' and aa.constraint_name = bb.constraint_name and bb.constraint_type = 'P' and aa.table_name = '{1}' And aa.column_name=a.COLUMN_NAME)>0 Then 1 Else 0 End
	 ) As IsPK,(
			 case when (select count(1) from all_triggers tri INNER JOIN all_source src on tri.trigger_Name=src.Name 
				where tri.OWNER = '{0}' and src.OWNER = '{0}' and (triggering_Event='INSERT' and table_name='{1}')
			and regexp_like(text,	concat(concat('nextval\s+into\s*?:\s*?new\s*?\.\s*?',a.COLUMN_NAME),'\s+?'),'i'))>0 
			then 1 else 0 end 
	) As IsIdentity, 
		Case a.NULLABLE  When 'Y' Then 1 Else 0 End As CanNull,
		a.data_default As DefaultVal from all_tab_columns a Inner Join all_col_comments b On a.TABLE_NAME=b.table_name 
	Where a.OWNER = '{0}' and b.OWNER = '{0}' and b.COLUMN_NAME= a.COLUMN_NAME and a.Table_Name='{1}'  order by a.column_ID Asc"    ;

                            strSql = string.Format(strSql, User, tableName);

                            try
                            {
                                if (Db.DBType == DBType.OracleDDTek)
                                {
                                    tabInfo.Colnumns = Db.GetDataTable(strSql).ConvertToListObject <ColumnInfo>();
                                }
                                else
                                {
                                    tabInfo.Colnumns = Db.GetDataTable(strSql).ConvertToListObject <ColumnInfo>();
                                }

                                List <string> lstColName         = new List <string>();
                                NameValueCollection nvcColDeText = new NameValueCollection();
                                foreach (ColumnInfo colInfo in tabInfo.Colnumns)
                                {
                                    lstColName.Add(colInfo.ColumnName);
                                    nvcColDeText.Add(colInfo.ColumnName, colInfo.DeText);

                                    var strKey = (tableName + "@" + colInfo.ColumnName);
                                    this.DictColumnInfo.Add(strKey, colInfo);

                                    //自增的列,需要查询序列名称
                                    if (colInfo.IsIdentity)
                                    {
                                        AddColSeq(tableName, colInfo.ColumnName);
                                    }

                                    if (colInfo.IsPK)
                                    {
                                        tabInfo.PriKeyColName = colInfo.ColumnName;
                                        if (colInfo.IsIdentity)
                                        {
                                            tabInfo.PriKeyType = PrimaryKeyType.AUTO;
                                        }
                                        else
                                        {
                                            tabInfo.PriKeyType = PrimaryKeyType.SET;
                                        }
                                    }

                                    Global.Dict_Oracle_DbType.TryGetValue(colInfo.TypeName, out DbType type);
                                    colInfo.DbType = type;
                                }

                                this.TableInfoDict.Add(tableName, tabInfo);
                                this.TableColumnNameDict.Add(tableName, lstColName);
                                this.TableColumnInfoDict.Add(tableName, tabInfo.Colnumns);
                                this.TableColumnComments.Add(tableName, nvcColDeText);
                            }
                            catch (Exception ex)
                            {
                                LogUtils.LogError("DB", Developer.SysDefault, ex);
                            }
                        });

                        lstTask.Add(task);
                        if (lstTask.Count(t => t.Status != TaskStatus.RanToCompletion) >= 50)
                        {
                            Task.WaitAny(lstTask.ToArray());
                            lstTask = lstTask.Where(t => t.Status != TaskStatus.RanToCompletion).ToList();
                        }
                    }
                    Task.WaitAll(lstTask.ToArray());
                }
            }
            catch (Exception ex)
            {
                LogUtils.LogError("DB", Developer.SysDefault, ex);
                return(false);
            }
            return(this.TableComments.Count == this.TableInfoDict.Count);
        }
示例#12
0
 public void onCenterClick()
 {
     LogUtils.i("onCenterClick");
     readActivity.toggleReadBar();
 }
示例#13
0
 public void onPageChanged(int chapter, int page)
 {
     LogUtils.i("onPageChanged:" + chapter + "-" + page);
 }
示例#14
0
        public IHttpActionResult List()
        {
            try
            {
                var request = new RequestImpl();

                var siteId    = request.GetQueryInt("siteId");
                var channelId = request.GetQueryInt("channelId");
                var page      = request.GetQueryInt("page");

                if (!request.IsUserLoggin ||
                    !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                       ConfigManager.ChannelPermissions.ContentView))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var columns       = ContentManager.GetContentColumns(siteInfo, channelInfo, false);
                var pluginIds     = PluginContentManager.GetContentPluginIds(channelInfo);
                var pluginColumns = PluginContentManager.GetContentColumns(pluginIds);

                var pageContentInfoList = new List <ContentInfo>();
                var count = ContentManager.GetCount(siteInfo, channelInfo);

                var pages = Convert.ToInt32(Math.Ceiling((double)count / siteInfo.Additional.PageSize));
                if (pages == 0)
                {
                    pages = 1;
                }

                if (count > 0)
                {
                    var offset = siteInfo.Additional.PageSize * (page - 1);
                    var limit  = siteInfo.Additional.PageSize;

                    var pageContentIds = ContentManager.GetContentIdList(siteInfo, channelInfo, offset, limit);

                    var sequence = offset + 1;
                    foreach (var contentId in pageContentIds)
                    {
                        var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId);
                        if (contentInfo == null)
                        {
                            continue;
                        }

                        pageContentInfoList.Add(ContentManager.Calculate(sequence++, contentInfo, columns, pluginColumns));
                    }
                }

                var permissions = new
                {
                    IsAdd         = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentAdd) && channelInfo.Additional.IsContentAddable,
                    IsDelete      = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentDelete),
                    IsEdit        = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentEdit),
                    IsTranslate   = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentTranslate),
                    IsCheck       = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ContentCheck),
                    IsCreate      = request.UserPermissionsImpl.HasSitePermissions(siteInfo.Id, ConfigManager.WebSitePermissions.Create) || request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.CreatePage),
                    IsChannelEdit = request.UserPermissionsImpl.HasChannelPermissions(siteInfo.Id, channelInfo.Id, ConfigManager.ChannelPermissions.ChannelEdit)
                };

                return(Ok(new
                {
                    Value = pageContentInfoList,
                    Count = count,
                    Pages = pages,
                    Permissions = permissions,
                    Columns = columns
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
示例#15
0
 public void Init()
 {
     LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
 }
 public virtual void OnConnected(IClientPeer clientPeer)
 {
     LogUtils.Log($"A new peer has been connected -> {clientPeer.ConnectionInformation.Ip}:{clientPeer.ConnectionInformation.Port}");
 }
示例#17
0
 public void Destroy()
 {
     LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
 }
        public virtual void Startup()
        {
            peerContainer = ServerComponents.AddComponent(new PeerContainer());

            LogUtils.Log("An application has started.");
        }
示例#19
0
 protected override void StartActions()
 {
     LogUtils.DoWarnLog($"StartActions!");
     LoadedConfiguration.ReloadFiles();
     CleanCache();
 }
        public virtual void Shutdown()
        {
            ServerComponents.RemoveAllComponents();

            LogUtils.Log("An application has been stopped.");
        }
示例#21
0
        /// <summary>
        /// 根据eps json获取eps对象数据
        /// </summary>
        /// <param name="isGetSuccess"></param>
        /// <returns></returns>
        public static HashSet <CommodityEps> GetEpcDataJson(out bool isGetSuccess)
        {
            isGetSuccess = true;

            //string com1 = "COM1";
            string           com1        = ApplicationState.GetMRfidCOM();
            HashSet <string> com1HashSet = new HashSet <string>();

            string log = "";

#if DUALCAB
            //string com4 = "COM4";
            string           com4        = ApplicationState.GetSRfidCOM();
            HashSet <string> com4HashSet = new HashSet <string>();
#endif
            HashSet <CommodityEps> currentEpcDataHs = new HashSet <CommodityEps>();

            //TODO:需要补充id
            GClient com1ClientConn = CreateClientConn(com1, "115200", out bool isCom1Connect);
            if (isCom1Connect)
            {
                com1HashSet = DealComData(com1ClientConn, com1, out isGetSuccess);
            }
            else
            {
                isGetSuccess = false;
            }

#if DUALCAB
            GClient com4ClientConn = CreateClientConn(com4, "115200", out bool isCom4Connect);
            if (isCom4Connect)
            {
                com4HashSet = DealComData(com4ClientConn, com4, out isGetSuccess);
            }
            else
            {
                isGetSuccess = false;
            }
#endif

            WaitHandle.WaitAll(manualEvents.ToArray());
            manualEvents.Clear();

            //提取com1的标签epc,并组装
            foreach (string rfid in com1HashSet)
            {
                CommodityEps commodityEps = new CommodityEps
                {
                    CommodityCodeName = $"RF{rfid.Substring(rfid.Length - 8)}",
                    EquipmentId       = ApplicationState.GetEquipId(),
                    EquipmentName     = ApplicationState.GetEquipName(),
                    StoreHouseId      = ApplicationState.GetHouseId(),
                    StoreHouseName    = ApplicationState.GetHouseName(),
                    GoodsLocationName = ApplicationState.GetCabNameByRFidCom(com1),
                    GoodsLocationId   = ApplicationState.GetCabIdByRFidCom(com1)
                };

                currentEpcDataHs.Add(commodityEps);
                LogUtils.Debug(commodityEps.CommodityCodeName + commodityEps.CommodityName);
                log += commodityEps.CommodityCodeName + " ";
            }

#if DUALCAB
            //提取com4的标签epc,并组装
            foreach (string rfid in com4HashSet)
            {
                CommodityEps commodityEps = new CommodityEps
                {
                    CommodityCodeName = $"RF{rfid.Substring(rfid.Length - 8)}",
                    EquipmentId       = ApplicationState.GetEquipId(),
                    EquipmentName     = ApplicationState.GetEquipName(),
                    StoreHouseId      = ApplicationState.GetHouseId(),
                    StoreHouseName    = ApplicationState.GetHouseName(),
                    GoodsLocationName = ApplicationState.GetCabNameByRFidCom(com1),
                    GoodsLocationId   = ApplicationState.GetCabIdByRFidCom(com1)
                };

                currentEpcDataHs.Add(commodityEps);
                LogUtils.Debug(commodityEps.CommodityCodeName + commodityEps.CommodityName);
                log += commodityEps.CommodityCodeName + " ";
            }
#endif

            Task.Factory.StartNew(a =>
            {
                LogUtils.Debug(log);
            }, log);

            LogUtils.Debug("RFID NUM:" + currentEpcDataHs.Count());
            return(currentEpcDataHs);
        }
        public IHttpActionResult Main(int siteId, int channelId, int contentId)
        {
            try
            {
                var body = new RequestBody();

                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(siteId);
                if (!publishmentSystemInfo.Additional.IsCommentable)
                {
                    return(Unauthorized());
                }

                var account  = body.GetPostString("account");
                var password = body.GetPostString("password");
                var replyId  = body.GetPostInt("replyId");
                var content  = body.GetPostString("content");

                if (replyId > 0)
                {
                    string replyUserName;
                    string replyContent;
                    DataProvider.CommentDao.GetUserNameAndContent(replyId, out replyUserName, out replyContent);
                    if (!string.IsNullOrEmpty(replyContent))
                    {
                        var displayName = BaiRongDataProvider.UserDao.GetDisplayName(replyUserName);
                        if (!string.IsNullOrEmpty(displayName))
                        {
                            displayName = $"@{displayName}:";
                        }

                        content += $" //{displayName}{replyContent}";
                    }
                }

                UserInfo userInfo;
                if (!string.IsNullOrEmpty(account) && !string.IsNullOrEmpty(password))
                {
                    string userName;
                    string errorMessage;
                    if (!BaiRongDataProvider.UserDao.ValidateAccount(account, password, out userName, out errorMessage))
                    {
                        LogUtils.AddUserLog(userName, EUserActionType.LoginFailed, "用户登录失败");
                        BaiRongDataProvider.UserDao.UpdateLastActivityDateAndCountOfFailedLogin(userName);
                        return(BadRequest(errorMessage));
                    }

                    BaiRongDataProvider.UserDao.UpdateLastActivityDateAndCountOfLogin(userName);
                    userInfo = BaiRongDataProvider.UserDao.GetUserInfoByUserName(userName);

                    body.UserLogin(userName);
                }
                else
                {
                    userInfo = body.UserInfo;
                }

                if (!publishmentSystemInfo.Additional.IsAnonymousComments && !body.IsUserLoggin)
                {
                    return(Unauthorized());
                }

                var commentInfo = new CommentInfo
                {
                    Id = 0,
                    PublishmentSystemId = siteId,
                    NodeId    = channelId,
                    ContentId = contentId,
                    GoodCount = 0,
                    UserName  = userInfo.UserName,
                    IsChecked = !publishmentSystemInfo.Additional.IsCheckComments,
                    AddDate   = DateTime.Now,
                    Content   = content
                };
                commentInfo.Id = DataProvider.CommentDao.Insert(commentInfo);

                return(Ok(new
                {
                    User = new User(userInfo),
                    Comment = new Comment(commentInfo, userInfo)
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new RequestImpl();

                var siteId        = request.GetQueryInt("siteId");
                var channelId     = request.GetQueryInt("channelId");
                var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetQueryString("contentIds"));

                if (!request.IsUserLoggin ||
                    !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                       ConfigManager.ChannelPermissions.ContentTranslate))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var retval = new List <Dictionary <string, object> >();
                foreach (var contentId in contentIdList)
                {
                    var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId);
                    if (contentInfo == null)
                    {
                        continue;
                    }

                    var dict = contentInfo.ToDictionary();
                    dict["checkState"] =
                        CheckManager.GetCheckState(siteInfo, contentInfo);
                    retval.Add(dict);
                }

                var sites    = new List <object>();
                var channels = new List <object>();

                var siteIdList = request.UserPermissionsImpl.GetSiteIdList();
                foreach (var permissionSiteId in siteIdList)
                {
                    var permissionSiteInfo = SiteManager.GetSiteInfo(permissionSiteId);
                    sites.Add(new
                    {
                        permissionSiteInfo.Id,
                        permissionSiteInfo.SiteName
                    });
                }

                var channelIdList = request.UserPermissionsImpl.GetChannelIdList(siteInfo.Id,
                                                                                 ConfigManager.ChannelPermissions.ContentAdd);
                foreach (var permissionChannelId in channelIdList)
                {
                    var permissionChannelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, permissionChannelId);
                    channels.Add(new
                    {
                        permissionChannelInfo.Id,
                        ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, permissionChannelId)
                    });
                }

                return(Ok(new
                {
                    Value = retval,
                    Sites = sites,
                    Channels = channels,
                    Site = siteInfo
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
示例#24
0
        public IHttpActionResult Upload()
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.PluginsPermissions.Add))
                {
                    return(Unauthorized());
                }

                var fileName = request.HttpRequest["fileName"];

                var fileCount = request.HttpRequest.Files.Count;

                string filePath = null;

                if (fileCount > 0)
                {
                    var file = request.HttpRequest.Files[0];

                    if (string.IsNullOrEmpty(fileName))
                    {
                        fileName = Path.GetFileName(file.FileName);
                    }

                    var extendName = fileName.Substring(fileName.LastIndexOf(".", StringComparison.Ordinal)).ToLower();
                    if (extendName == ".nupkg")
                    {
                        filePath = PathUtils.GetTemporaryFilesPath(fileName);
                        DirectoryUtils.CreateDirectoryIfNotExists(filePath);
                        file.SaveAs(filePath);
                    }
                }

                FileInfo fileInfo = null;
                if (!string.IsNullOrEmpty(filePath))
                {
                    fileInfo = new FileInfo(filePath);
                }
                if (fileInfo != null)
                {
                    return(Ok(new
                    {
                        fileName,
                        length = fileInfo.Length,
                        ret = 1
                    }));
                }

                return(Ok(new
                {
                    ret = 0
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
示例#25
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var    contentId = AuthRequest.GetQueryInt("id");
            string redirectUrl;

            if (contentId == 0)
            {
                var contentInfo = new ContentInfo();
                try
                {
                    contentInfo.ChannelId        = _nodeInfo.Id;
                    contentInfo.SiteId           = SiteId;
                    contentInfo.AddUserName      = AuthRequest.AdminName;
                    contentInfo.LastEditUserName = contentInfo.AddUserName;
                    contentInfo.LastEditDate     = DateTime.Now;

                    BackgroundInputTypeParser.SaveAttributes(contentInfo, SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributesLowercase);

                    contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items);
                    var tagCollection = TagUtils.ParseTagsString(TbTags.Text);

                    contentInfo.Title = TbTitle.Text;
                    var formatString    = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatStrong"]);
                    var formatEm        = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatEM"]);
                    var formatU         = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatU"]);
                    var formatColor     = Request.Form[ContentAttribute.Title + "_formatColor"];
                    var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor);
                    contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString);
                    foreach (ListItem listItem in CblContentAttributes.Items)
                    {
                        var value         = listItem.Selected.ToString();
                        var attributeName = listItem.Value;
                        contentInfo.Set(attributeName, value);
                    }
                    contentInfo.LinkUrl = TbLinkUrl.Text;
                    contentInfo.AddDate = TbAddDate.DateTime;
                    if (contentInfo.AddDate.Year <= DateUtils.SqlMinValue.Year)
                    {
                        contentInfo.AddDate = DateTime.Now;
                    }

                    contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
                    contentInfo.IsChecked    = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel;
                    contentInfo.Tags         = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

                    foreach (var service in PluginManager.Services)
                    {
                        try
                        {
                            service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _nodeInfo.Id,
                                                                                       contentInfo, new ExtendedAttributes(Request.Form)));
                        }
                        catch (Exception ex)
                        {
                            LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit));
                        }
                    }

                    contentInfo.Id = DataProvider.ContentDao.Insert(_tableName, SiteInfo, contentInfo);
                    //判断是不是有审核权限
                    int checkedLevelOfUser;
                    var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissions, SiteInfo, contentInfo.ChannelId, out checkedLevelOfUser);
                    if (CheckManager.IsCheckable(SiteInfo, contentInfo.ChannelId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                    {
                        //添加审核记录
                        DataProvider.ContentDao.UpdateIsChecked(_tableName, SiteId, contentInfo.ChannelId, new List <int> {
                            contentInfo.Id
                        }, 0, AuthRequest.AdminName, contentInfo.IsChecked, contentInfo.CheckedLevel, "");
                    }

                    TagUtils.AddTags(tagCollection, SiteId, contentInfo.Id);
                }
                catch (Exception ex)
                {
                    LogUtils.AddErrorLog(ex);
                    FailMessage($"内容添加失败:{ex.Message}");
                }

                CreateManager.CreateContentAndTrigger(SiteId, _nodeInfo.Id, contentInfo.Id);

                AuthRequest.AddSiteLog(SiteId, _nodeInfo.Id, contentInfo.Id, "添加内容",
                                       $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}");

                ContentUtility.Translate(SiteInfo, _nodeInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName);

                redirectUrl = PageContentAddAfter.GetRedirectUrl(SiteId, _nodeInfo.Id, contentInfo.Id,
                                                                 ReturnUrl);
            }
            else
            {
                var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableName, contentId);
                try
                {
                    var tagsLast = contentInfo.Tags;

                    contentInfo.LastEditUserName = AuthRequest.AdminName;
                    contentInfo.LastEditDate     = DateTime.Now;

                    BackgroundInputTypeParser.SaveAttributes(contentInfo, SiteInfo, _styleInfoList, Request.Form, ContentAttribute.AllAttributesLowercase);

                    contentInfo.GroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroups.Items);
                    var tagCollection = TagUtils.ParseTagsString(TbTags.Text);

                    contentInfo.Title = TbTitle.Text;
                    var formatString    = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatStrong"]);
                    var formatEm        = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatEM"]);
                    var formatU         = TranslateUtils.ToBool(Request.Form[ContentAttribute.Title + "_formatU"]);
                    var formatColor     = Request.Form[ContentAttribute.Title + "_formatColor"];
                    var theFormatString = ContentUtility.GetTitleFormatString(formatString, formatEm, formatU, formatColor);
                    contentInfo.Set(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title), theFormatString);
                    foreach (ListItem listItem in CblContentAttributes.Items)
                    {
                        var value         = listItem.Selected.ToString();
                        var attributeName = listItem.Value;
                        contentInfo.Set(attributeName, value);
                    }
                    contentInfo.LinkUrl = TbLinkUrl.Text;
                    contentInfo.AddDate = TbAddDate.DateTime;

                    var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
                    if (checkedLevel != CheckManager.LevelInt.NotChange)
                    {
                        contentInfo.IsChecked    = checkedLevel >= SiteInfo.Additional.CheckContentLevel;
                        contentInfo.CheckedLevel = checkedLevel;
                    }
                    contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

                    foreach (var service in PluginManager.Services)
                    {
                        try
                        {
                            service.OnContentFormSubmit(new ContentFormSubmitEventArgs(SiteId, _nodeInfo.Id,
                                                                                       contentInfo, new ExtendedAttributes(Request.Form)));
                        }
                        catch (Exception ex)
                        {
                            LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormSubmit));
                        }
                    }

                    DataProvider.ContentDao.Update(_tableName, SiteInfo, contentInfo);

                    TagUtils.UpdateTags(tagsLast, contentInfo.Tags, tagCollection, SiteId, contentId);

                    ContentUtility.Translate(SiteInfo, _nodeInfo.Id, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), AuthRequest.AdminName);

                    //更新引用该内容的信息
                    //如果不是异步自动保存,那么需要将引用此内容的content修改
                    //var sourceContentIdList = new List<int>
                    //{
                    //    contentInfo.Id
                    //};
                    //var tableList = DataProvider.TableDao.GetTableCollectionInfoListCreatedInDb();
                    //foreach (var table in tableList)
                    //{
                    //    var targetContentIdList = DataProvider.ContentDao.GetReferenceIdList(table.TableName, sourceContentIdList);
                    //    foreach (var targetContentId in targetContentIdList)
                    //    {
                    //        var targetContentInfo = DataProvider.ContentDao.GetContentInfo(table.TableName, targetContentId);
                    //        if (targetContentInfo == null || targetContentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString()) continue;

                    //        contentInfo.Id = targetContentId;
                    //        contentInfo.SiteId = targetContentInfo.SiteId;
                    //        contentInfo.ChannelId = targetContentInfo.ChannelId;
                    //        contentInfo.SourceId = targetContentInfo.SourceId;
                    //        contentInfo.ReferenceId = targetContentInfo.ReferenceId;
                    //        contentInfo.Taxis = targetContentInfo.Taxis;
                    //        contentInfo.Set(ContentAttribute.TranslateContentType, targetContentInfo.GetString(ContentAttribute.TranslateContentType));
                    //        DataProvider.ContentDao.Update(table.TableName, contentInfo);

                    //        //资源:图片,文件,视频
                    //        var targetSiteInfo = SiteManager.GetSiteInfo(targetContentInfo.SiteId);
                    //        var bgContentInfo = contentInfo as BackgroundContentInfo;
                    //        var bgTargetContentInfo = targetContentInfo as BackgroundContentInfo;
                    //        if (bgTargetContentInfo != null && bgContentInfo != null)
                    //        {
                    //            if (bgContentInfo.ImageUrl != bgTargetContentInfo.ImageUrl)
                    //            {
                    //                //修改图片
                    //                var sourceImageUrl = PathUtility.MapPath(SiteInfo, bgContentInfo.ImageUrl);
                    //                CopyReferenceFiles(targetSiteInfo, sourceImageUrl);
                    //            }
                    //            else if (bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)) != bgTargetContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)))
                    //            {
                    //                var sourceImageUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)));

                    //                foreach (string imageUrl in sourceImageUrls)
                    //                {
                    //                    var sourceImageUrl = PathUtility.MapPath(SiteInfo, imageUrl);
                    //                    CopyReferenceFiles(targetSiteInfo, sourceImageUrl);
                    //                }
                    //            }
                    //            if (bgContentInfo.FileUrl != bgTargetContentInfo.FileUrl)
                    //            {
                    //                //修改附件
                    //                var sourceFileUrl = PathUtility.MapPath(SiteInfo, bgContentInfo.FileUrl);
                    //                CopyReferenceFiles(targetSiteInfo, sourceFileUrl);

                    //            }
                    //            else if (bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)) != bgTargetContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)))
                    //            {
                    //                var sourceFileUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetString(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)));

                    //                foreach (var fileUrl in sourceFileUrls)
                    //                {
                    //                    var sourceFileUrl = PathUtility.MapPath(SiteInfo, fileUrl);
                    //                    CopyReferenceFiles(targetSiteInfo, sourceFileUrl);
                    //                }
                    //            }
                    //        }
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    LogUtils.AddErrorLog(ex);
                    FailMessage($"内容修改失败:{ex.Message}");
                    return;
                }

                CreateManager.CreateContentAndTrigger(SiteId, _nodeInfo.Id, contentId);

                AuthRequest.AddSiteLog(SiteId, _nodeInfo.Id, contentId, "修改内容",
                                       $"栏目:{ChannelManager.GetChannelNameNavigation(SiteId, contentInfo.ChannelId)},内容标题:{contentInfo.Title}");

                redirectUrl = ReturnUrl;
            }

            PageUtils.Redirect(redirectUrl);
        }
示例#26
0
        private void UpdatingAsync()
        {
            var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

            Task.Run(async() =>
            {
                string updateUrl = ConfigurationManager.AppSettings["UpdateUrl"];

                using (var updateManager = new UpdateManager(updateUrl)
                       )
                {
                    var ignore          = false;
                    Exception lastError = null;
                    while (true)
                    {
                        try
                        {
                            var updateInfo = await updateManager.CheckForUpdate(ignore);
                            if (updateInfo?.ReleasesToApply?.Any() == true)
                            {
                                var releases = updateInfo.ReleasesToApply;

                                Message = "正在下载更新,请稍候。";
                                await updateManager.DownloadReleases(releases, p => Progress = $"{p}%")
                                .ConfigureAwait(false);

                                Message = "正在处理更新文件,请稍候。";
                                await updateManager.ApplyReleases(updateInfo, p => Progress = $"{p}%")
                                .ConfigureAwait(false);

                                await updateManager.CreateUninstallerRegistryEntry();
                            }
                            break;
                        }
                        catch (Exception e)
                        {
                            LogUtils.Error($"{e}");
                            lastError = e;

                            if (!ignore)
                            {
                                ignore = true;
                                continue;
                            }
                            break;
                        }
                    }

                    if (lastError != null)
                    {
                        throw lastError;
                    }


                    // 可用以下方式简化
                    //var updateInfo = await updateManager.CheckForUpdate().ConfigureAwait(false);
                    //if (updateInfo?.ReleasesToApply?.Any() == true)
                    //{
                    //    this.UpdateTip = "正在更新,请稍候。";
                    //    await updateManager.UpdateApp(p =>
                    //    {
                    //        this.Progress = p;
                    //    });
                    //}
                }
            })
            .ContinueWith(task =>
            {
                _updatingView.Close();

                if (task.Exception != null)
                {
                    Message = "执行更新时出错。";
                    LogUtils.Error($"{task.Exception}");
                    task.Exception.Handle(_ => true);
                }
                else
                {
                    LogUtils.Information("等待GC完成");
                    GC.WaitForFullGCComplete();

                    LogUtils.Information("退出Application");

                    Application.Exit();

                    LogUtils.Information("重启Application");

                    UpdateManager.RestartApp();
                }
            }, scheduler);
        }
示例#27
0
        public IHttpActionResult Submit()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId        = request.GetPostInt("siteId");
                var channelId     = request.GetPostInt("channelId");
                var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetPostString("contentIds"));
                var isUp          = request.GetPostBool("isUp");
                var taxis         = request.GetPostInt("taxis");

                if (!request.IsUserLoggin ||
                    !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                       ConfigManager.ChannelPermissions.ContentEdit))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                if (ETaxisTypeUtils.Equals(channelInfo.Additional.DefaultTaxisType, ETaxisType.OrderByTaxis))
                {
                    isUp = !isUp;
                }

                if (isUp == false)
                {
                    contentIdList.Reverse();
                }

                var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);

                foreach (var contentId in contentIdList)
                {
                    var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId);
                    if (contentInfo == null)
                    {
                        continue;
                    }

                    var isTop = contentInfo.IsTop;
                    for (var i = 1; i <= taxis; i++)
                    {
                        if (isUp)
                        {
                            if (DataProvider.ContentDao.SetTaxisToUp(tableName, channelId, contentId, isTop) == false)
                            {
                                break;
                            }
                        }
                        else
                        {
                            if (DataProvider.ContentDao.SetTaxisToDown(tableName, channelId, contentId, isTop) == false)
                            {
                                break;
                            }
                        }
                    }
                }

                CreateManager.TriggerContentChangedEvent(siteId, channelId);

                request.AddSiteLog(siteId, channelId, 0, "对内容排序", string.Empty);

                return(Ok(new
                {
                    Value = contentIdList
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
示例#28
0
        private void OnGameServerButtonClicked(string serverName)
        {
            gameServerName = serverName;

            LogUtils.Log(MessageBuilder.Trace($"Selected a server with name {serverName}"));
        }
示例#29
0
 public void AddAdminLog(string action, string summary)
 {
     LogUtils.AddAdminLog(AdminName, action, summary);
 }
示例#30
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            LogUtils.Init(Directory.GetCurrentDirectory());
        }