예제 #1
0
        void SaveToDraft()
        {
            ShortMessage sm = new ShortMessage();

            sm.AccountID = Security.CurrentAccountID;
            sm.Receivers = Receivers;
            sm.Subject   = Subject;
            sm.Content   = Content;
            sm.SendTime  = DateTime.Now;
            sm.State     = (int)MessageState.Draft;
            MessageHelper.AddMessage(sm);
        }
예제 #2
0
        /// <summary>
        /// Includes a set of passed
        /// projects in the solution.
        /// </summary>
        ///
        /// <param name="projects">
        /// Absolute paths to project
        /// files without duplicates.
        /// </param>
        ///
        /// <remarks>
        /// Uses DTE - only works from Visual Studio.
        /// </remarks>
        private void IncludeProject(IEnumerable <string> projects)
        {
            /*
             * I don’t know how, but the AddFromFile method depends
             * on the GPC, therefore, to avoid errors, all projects
             * are forcibly unloaded.
             */

            if (IsVSIX)
            {
                ProjectHelper.UnloadProject();

                try
                {
                    foreach (string project in projects)
                    {
                        DTE.Solution.AddFromFile(project, false);
                    }
                }
                catch (Exception exception)
                {
                    MessageHelper.AddMessage(exception);
                }
                finally
                {
                    DTE.Solution.SaveAs(DTE.Solution.FileName);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Adds reference to the project. It is assumed
        /// that the original reference has been removed
        /// earlier.
        /// </summary>
        ///
        /// <param name="unevaluatedInclude">
        /// Must contain the assembly
        /// name or the absolute path
        /// to the project or Package
        /// Id.
        /// </param>
        ///
        /// <exception cref="SwitcherException"/>
        ///
        /// <returns>
        /// Returns false for duplicate <paramref name="unevaluatedInclude"/> values.
        /// </returns>
        protected virtual bool AddReference(ProjectReference reference, ReferenceType type, string unevaluatedInclude, Dictionary <string, string> metadata)
        {
            bool output = true;

            switch (type)
            {
            case ReferenceType.ProjectReference:
            case ReferenceType.PackageReference:
            case ReferenceType.Reference:
                if (reference.MsbProject.GetItemsByEvaluatedInclude(unevaluatedInclude).Any())
                {
                    output = false;
                }
                else
                {
                    reference.MsbProject.AddItem(type.ToString(), unevaluatedInclude, AdaptMetadata(unevaluatedInclude, metadata));
                }
                break;

            default:
                throw new SwitcherException(reference.MsbProject, $"Reference type not supported: { type }");
            }

            if (output)
            {
                MessageHelper.AddMessage(reference.DteProject.UniqueName, $"Dependency: { Path.GetFileName(unevaluatedInclude) } has been added. Type: { type }", TaskErrorCategory.Message);
            }

            return(output);
        }
예제 #4
0
 /// <summary>
 /// Callback for <see cref="MenuCommand"/>.
 /// </summary>
 public override void Callback(object sender, EventArgs eventArgs)
 {
     try
     {
         CommandRouter.Route(Name);
     }
     catch (Exception exception)
     {
         MessageHelper.AddMessage(exception);
     }
 }
예제 #5
0
 public static AjaxResult AddMessage(string title, string text, string reporter)
 {
     try
     {
         MessageHelper helper = new MessageHelper();
         helper.AddMessage(title, text, reporter, "");
         return(AjaxResult.Success());
     }
     catch (Exception ex)
     {
         return(AjaxResult.Error(ex.Message));
     }
 }
예제 #6
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        MessageHelper helper = new MessageHelper();

        if (EditType != "E")
        {
            helper.AddMessage(txtTitle.Text, txtContent.Text, lblReporter.Text, hdCarve.Value);
        }
        else
        {
            helper.UpdateMessage(txtTitle.Text, txtContent.Text, MessageID);
        }
        ScriptManager.RegisterStartupScript(btnOK, btnOK.GetType(), "success", "javascript:var manager = $.ligerDialog.alert('信息发布成功!', '提示', 'success', function (item, Dialog, index) {parent.$.ligerDialog.close();parent.window.f_reload();parent.$(\".l-dialog,.l-window-mask\").css(\"display\", \"none\");});", true);
    }
예제 #7
0
        /// <summary>
        /// Includes implicit, explicit project references
        /// listed in the Dependencies section of the lock
        /// file.
        /// </summary>
        ///
        /// <exception cref="SwitcherException"/>
        ///
        /// <remarks>
        /// Implicit dependencies mean transitive.
        /// </remarks>
        public virtual void SwitchPkgDependency(ProjectReference reference, LockFileTargetLibrary library, string absolutePath)
        {
            /*
             * References can be represented by several values in
             * an ItemGroup, for example, when included using the
             * Condition attribute.
             */

            ICollection <ProjectItem> items = reference.MsbProject.GetItemsByEvaluatedInclude(library.Name);

            // Implicit.
            if (!items.Any())
            {
                base.AddReference(reference, Type, absolutePath, new Dictionary <string, string>(2)
                {
                    { "Name", library.Name }
                });
            }
            // Explicit.
            else
            {
                /*
                 * Re-creating an item can lead to the loss
                 * of user metadata; in order to avoid this,
                 * the item is redefined.
                 */

                foreach (ProjectItem item in items)
                {
                    item.ItemType = Type.ToString();

                    item.SetMetadataValue("Temp", item.EvaluatedInclude);
                    item.SetMetadataValue("Name", item.EvaluatedInclude);

                    item.UnevaluatedInclude = absolutePath;
                }

                MessageHelper.AddMessage(reference.DteProject.UniqueName, $"Dependency: {library.Name } has been switched. Type: { Type }", TaskErrorCategory.Message);
            }
        }
예제 #8
0
        /// <summary>
        /// Removes references that have
        /// the Temp attribute and which
        /// were added from the Dependencies
        /// and FrameworkAssemblies sections
        /// of the lock file.
        /// </summary>
        public virtual void SwitchDependency(ProjectReference reference, ReferenceType type)
        {
            foreach (ProjectItem item in GetTempItem(reference, type))
            {
                // Implicit.
                if (!item.HasMetadata("Version"))
                {
                    reference.MsbProject.RemoveItem(item);
                }
                // Explicit.
                else
                {
                    item.UnevaluatedInclude = item.GetMetadataValue("Temp");

                    item.RemoveMetadata("Temp");
                    item.RemoveMetadata("Name");

                    item.ItemType = Type.ToString();
                }

                MessageHelper.AddMessage(reference.DteProject.UniqueName, $"Dependency: { Path.GetFileNameWithoutExtension(item.EvaluatedInclude) } has been switched back. Type: { Type }", TaskErrorCategory.Message);
            }
        }
예제 #9
0
 /// <summary>
 /// Deletes temporary projects
 /// from the solution.
 /// </summary>
 ///
 /// <remarks>
 /// See: <seealso cref="ProjectReference.IsTemp"/>
 /// </remarks>
 ///
 /// <remarks>
 /// Uses DTE - only works from Visual Studio.
 /// </remarks>
 private void CleanSolution()
 {
     if (IsVSIX)
     {
         try
         {
             foreach (ProjectReference reference in ProjectHelper.GetLoadedProject())
             {
                 if (reference.IsTemp)
                 {
                     DTE.Solution.Remove(reference.DteProject);
                 }
             }
         }
         catch (Exception exception)
         {
             MessageHelper.AddMessage(exception);
         }
         finally
         {
             DTE.Solution.SaveAs(DTE.Solution.FileName);
         }
     }
 }
        public IActionResult action()
        {
            MessageHelper messageHelper = new MessageHelper();

            messageHelper.CreateNewDoc();
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Set_NewDialog, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Get_DialogContent, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Set_SendMessage, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Set_DelDialog, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Get_DialogList, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Get_RelationsList, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Get_RelationsSearch, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Get_RelationsAcceptableList, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Set_NewFriend, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Set_AcceptFriend, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Action_Get_BatchArrProfile, "");
            messageHelper.AddMessage("action", Global.ActionsMap.Passive_Get_ReceivedMessage, "");
            return(Content(messageHelper.GetMessageDocString()));
        }
예제 #11
0
        /// <summary>
        /// 解析快递信息
        /// </summary>
        /// <param name="json">服务器返回json数据</param>
        /// <param name="ExpressInfo">快递单号信息</param>
        /// <returns>是否成功</returns>
        private static bool ParseExpressInfo(string json, ExpressInfo ExpressInfo)
        {
            try
            {
                JObject jo    = JObject.Parse(json);
                JToken  value = null;

                //快递单当前的状态
                int state = -1;
                if (jo.TryGetValue("state", out value))
                {
                    if (!Int32.TryParse(value.ToString(), out state))
                    {
                        return(false);
                    }
                }

                //查询结果状态
                if (jo.TryGetValue("status", out value))
                {
                    if (value.ToString().Equals("200"))
                    {
                        //快递单号
                        string ExpressNo = string.Empty;

                        if (jo.TryGetValue("nu", out value))
                        {
                            ExpressNo = value.ToString();
                        }
                        if (string.IsNullOrEmpty(ExpressNo))
                        {
                            return(false);
                        }
                        if (state == 3 || state == 4 || state == 6)
                        {
                            //3:签收,收件人已签收;4:退签,即货物由于用户拒签、超区等原因退回,而且发件人已经签收;
                            //6:退回,货物正处于退回发件人的途中;
                            //快递周期已结束,则将当前快递单号移入到历史表中,不在产生任何短信信息
                            SaveExpressHistoryInfo(ExpressNo, state);
                        }

                        if (jo.TryGetValue("data", out value))
                        {
                            List <ExpressProcessDetail> list = JsonConvert.DeserializeObject <List <ExpressProcessDetail> >(value.ToString());
                            if (list != null && list.Count > 0)
                            {
                                list.Reverse();
                                int length                = list.Count;
                                int maxGroupNo            = GetExpressDetailMaxGroupNo(ExpressNo);
                                ExpressProcessDetail item = null;
                                for (int i = maxGroupNo; i < length; i++)
                                {
                                    item           = list[i];
                                    item.ExpressNo = ExpressNo;
                                    item.GroupNo   = i + 1;
                                    //相对准确,但不是完全准确的一个状态
                                    item.State = GetExpressDetailState(item, maxGroupNo == 0 && i == 0);
                                }


                                //产生了新的快递进度信息,准备发送短信通知
                                if (length > maxGroupNo)
                                {
                                    var saveList = list.Where(e => e.GroupNo > maxGroupNo).ToList();
                                    //保存新的进度信息
                                    SQLHelper.BatchSaveData(saveList, "p_ExpressProcessDetail");
                                    //插入短信通知,等待任务轮训时发送短信
                                    var      lastDetail = list[length - 1];
                                    string[] Receivers  = ExpressInfo.Receiver.Split(new char[] { ',' });
                                    foreach (string Receiver in Receivers)
                                    {
                                        if (RegexHelper.IsMobile(Receiver))
                                        {
                                            //短信最大长度为40字节,20汉字
                                            string content = string.Format("亲快件*{0}!{1}", ExpressNo.Substring(ExpressNo.Length - 4 > 0 ? ExpressNo.Length - 4 : 0), lastDetail.Context.Replace(" ", ""));
                                            //由于短信接口只有20条免费短信的限制,所以改为邮件提醒
                                            //MessageHelper.AddMessage(Receiver, content.FormatStringLength(40), "");
                                        }
                                        else if (RegexHelper.IsEmail(Receiver))
                                        {
                                            bool isAddMessage = false;
                                            //修改消息添加规则,有变更就添加可能一天收很多邮件,让人厌烦
                                            //现在规则修改为快递状态为1:揽件 3:签收 5:派件 这几种状态必发
                                            //然后每天其它状态的最多发送一条
                                            var importantDetail = saveList.Where(e => e.State == 1 || e.State == 3 || e.State == 5);
                                            if (importantDetail != null && importantDetail.Count() > 0)
                                            {
                                                isAddMessage = true;
                                            }
                                            else
                                            {
                                                if (!HasSendMessage(ExpressInfo.ExpressGUID))
                                                {
                                                    isAddMessage = true;
                                                }
                                            }
                                            if (isAddMessage)
                                            {
                                                Hashtable             ht = new Hashtable();
                                                List <ExpressCompany> listExpressCompany = GetAllExpressCompany();
                                                string ExpressCompany = listExpressCompany.FirstOrDefault(e => e.CompanyCode == ExpressInfo.ExpressCompanyCode).CompanyName;
                                                ht["TotalTime"]      = lastDetail.Time.GetDayAndHours(list[0].Time);
                                                ht["T"]              = list;
                                                ht["V"]              = ExpressInfo;
                                                ht["ExpressCompany"] = ExpressCompany;
                                                ht["Status"]         = state;
                                                string content = FileGen.GetFileText(FileHelper.GetAbsolutePath("Temples/ExpressDetail.vm"), ht).ToString();
                                                //添加邮件消息提醒
                                                MessageHelper.AddMessage(Receiver, content, "快递进度变更", "快递进度", ExpressInfo.ExpressGUID, MessageType.EMAIL);
                                            }
                                        }
                                        else
                                        {
                                            TaskLog.ExpressProgressLogInfo.WriteLogE(string.Format("快递单号“{0}”的接收人“{1}”无法识别,不为邮件/手机号任何一种,请检查!", ExpressInfo.ExpressNo, ExpressInfo.Receiver));
                                        }
                                    }
                                }
                            }
                        }
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #12
0
 private void OnMqttMessage(string msg)
 {
     _recvMessageHelper.AddMessage(msg);
 }
        private void KitPosLoadInternal(KitWrapper kit, string kitCode, List <ErrorWrapper> retMessage, IUnitOfWork uow)
        {
            var errCountOld = MessageHelper.GetErrorCount(retMessage);
            var errmessage  = string.Format("Ошибка при загрузке комплектующих (комплект «{0}»)", kit.ARTNAME);
            var artNames    = kit.KITPOS.Where(p => !string.IsNullOrEmpty(p.KITPOSARTNAME)).Select(i => i.KITPOSARTNAME.ToUpper()).Distinct().ToArray();

            if (artNames.Length == 0)
            {
                var ew = new ErrorWrapper
                {
                    ERRORCODE    = MessageHelper.ErrorCode.ToString(),
                    ERRORMESSAGE =
                        string.Format("Нет артикулов в элементах комплектующей '{0}'.", kit.ARTNAME)
                };
                retMessage.Add(ew);
                throw new IntegrationLogicalException(errmessage);
            }

            var typeart  = typeof(Art);
            var artsList =
                FilterHelper.GetArrayFilterIn(string.Format("UPPER({0})", SourceNameHelper.Instance.GetPropertySourceName(typeart, Art.ArtNamePropertyName)), artNames,
                                              string.Format(" and {0} = {1}",
                                                            SourceNameHelper.Instance.GetPropertySourceName(typeart, Art.MANDANTIDPropertyName),
                                                            kit.MANDANTID));

            var artcomps = new List <Art>();

            using (var artMgr = IoC.Instance.Resolve <IBaseManager <Art> >())
            {
                if (uow != null)
                {
                    artMgr.SetUnitOfWork(uow);
                }

                foreach (var artFilter in artsList)
                {
                    var artspart = artMgr.GetFiltered(artFilter).ToArray();
                    if (artspart.Length > 0)
                    {
                        artcomps.AddRange(artspart);
                    }
                }

                foreach (var pos in kit.KITPOS)
                {
                    var    existArt = artcomps.FirstOrDefault(i => pos.KITPOSARTNAME.EqIgnoreCase(i.ArtName));
                    string artCode;

                    if (existArt == null)
                    {
                        if (pos.KITPOSINSART == 1) // НЕ создается SKU!!! (потому как НЕТ ЕИ!) - кто придумал?
                        {
                            var art = new Art
                            {
                                ArtName       = pos.KITPOSARTNAME,
                                ArtCommercDay = 0,
                                ArtPickOrder  = 1,
                                //ARTABCD = kit.ARTABCD,
                                MANDANTID = kit.MANDANTID
                            };
                            var errmessages = ArtLoadHelper.FillArtAbcd(art, kit.ARTABCD, kit.ARTNAME, Log);
                            if (errmessages.Length > 0)
                            {
                                MessageHelper.AddMessage(errmessages, retMessage);
                            }

                            SetXmlIgnore(art, false);
                            artMgr.Insert(ref art);
                            artCode = art.ArtCode;
                            Log.DebugFormat("Создан артикул комплектующей «{0}»", pos.KITPOSARTNAME);
                        }
                        else
                        {
                            var ew = new ErrorWrapper
                            {
                                ERRORCODE    = MessageHelper.ErrorCode.ToString(),
                                ERRORMESSAGE =
                                    string.Format("Не существует артикул комплектующей «{0}»", pos.KITPOSARTNAME)
                            };
                            retMessage.Add(ew);
                            continue;
                        }
                    }
                    else
                    {
                        artCode = existArt.ArtCode;
                    }

                    var skuFilter = string.Format("{0} = '{1}' and {2} = 1",
                                                  SourceNameHelper.Instance.GetPropertySourceName(typeof(SKU), SKU.ArtCodePropertyName),
                                                  artCode,
                                                  SourceNameHelper.Instance.GetPropertySourceName(typeof(SKU), SKU.SKUClientPropertyName));
                    var skuMgr = IoC.Instance.Resolve <IBaseManager <SKU> >();
                    skuMgr.SetUnitOfWork(uow);
                    var skus = skuMgr.GetFiltered(skuFilter).ToArray();
                    if (!skus.Any())
                    {
                        var ew = new ErrorWrapper
                        {
                            ERRORCODE    = MessageHelper.ErrorCode.ToString(),
                            ERRORMESSAGE =
                                string.Format("Не существует SKU комплектующей «{0}»", pos.KITPOSARTNAME)
                        };
                        retMessage.Add(ew);
                        continue;
                    }

                    var kitPosMgr = IoC.Instance.Resolve <IBaseManager <KitPos> >();
                    kitPosMgr.SetUnitOfWork(uow);
                    var kitPosObj = new KitPos();
                    kitPosObj = MapTo(pos, kitPosObj);
                    kitPosObj.KitPosSKUIDR   = skus[0].SKUID;
                    kitPosObj.KitPosCodeR    = kitCode;
                    kitPosObj.KitPosPriority = 500;
                    SetXmlIgnore(kitPosObj, false);
                    kitPosMgr.Insert(ref kitPosObj);
                }

                if (MessageHelper.GetErrorCount(retMessage) > errCountOld)
                {
                    throw new IntegrationLogicalException(errmessage);
                }
            }
        }
예제 #14
0
        /// <summary>
        /// 解析快递信息
        /// </summary>
        /// <param name="json">服务器返回json数据</param>
        /// <param name="ExpressInfo">快递单号信息</param>
        /// <returns>是否成功</returns>
        private static bool ParseExpressInfo(string json, ExpressInfo ExpressInfo)
        {
            try
            {
                JObject jo    = JObject.Parse(json);
                JToken  value = null;

                //快递单当前的状态
                string state = string.Empty;
                if (jo.TryGetValue("state", out value))
                {
                    state = value.ToString();
                }

                //查询结果状态
                if (jo.TryGetValue("status", out value))
                {
                    if (value.ToString().Equals("200"))
                    {
                        //快递单号
                        string ExpressNo = string.Empty;

                        if (jo.TryGetValue("nu", out value))
                        {
                            ExpressNo = value.ToString();
                        }
                        if (string.IsNullOrEmpty(ExpressNo))
                        {
                            return(false);
                        }
                        if (state.Equals("3") || state.Equals("4") || state.Equals("6"))
                        {
                            //3:签收,收件人已签收;4:退签,即货物由于用户拒签、超区等原因退回,而且发件人已经签收;
                            //6:退回,货物正处于退回发件人的途中;
                            //快递周期已结束,则将当前快递单号移入到历史表中,不在产生任何短信信息
                            SaveExpressHistoryInfo(ExpressNo, state);
                        }

                        if (jo.TryGetValue("data", out value))
                        {
                            List <ExpressProcessDetail> list = JsonConvert.DeserializeObject <List <ExpressProcessDetail> >(value.ToString());
                            if (list != null && list.Count > 0)
                            {
                                list.Reverse();
                                int length                = list.Count;
                                int maxGroupNo            = GetExpressDetailMaxGroupNo(ExpressNo);
                                ExpressProcessDetail item = null;
                                for (int i = maxGroupNo; i < length; i++)
                                {
                                    item           = list[i];
                                    item.ExpressNo = ExpressNo;
                                    item.GroupNo   = i + 1;
                                }


                                //产生了新的快递进度信息,准备发送短信通知
                                if (length > maxGroupNo)
                                {
                                    //保存新的进度信息
                                    SQLHelper.BatchSaveData(list.Where(e => e.GroupNo > maxGroupNo).ToList(), "p_ExpressProcessDetail");
                                    //插入短信通知,等待任务轮训时发送短信
                                    var      lastDetail = list[length - 1];
                                    string[] Receivers  = ExpressInfo.Receiver.Split(new char[] { ',' });
                                    foreach (string Receiver in Receivers)
                                    {
                                        if (RegexHelper.IsMobile(Receiver))
                                        {
                                            //短信最大长度为40字节,20汉字
                                            string content = string.Format("亲快件*{0}!{1}", ExpressNo.Substring(ExpressNo.Length - 4 > 0 ? ExpressNo.Length - 4 : 0), lastDetail.Context.Replace(" ", ""));
                                            //由于短信接口只有20条免费短信的限制,所以改为邮件提醒
                                            //MessageHelper.AddMessage(Receiver, content.FormatStringLength(40), "");
                                        }
                                        else if (RegexHelper.IsEmail(Receiver))
                                        {
                                            Hashtable             ht = new Hashtable();
                                            List <ExpressCompany> listExpressCompany = GetAllExpressCompany();
                                            string ExpressCompany = listExpressCompany.FirstOrDefault(e => e.CompanyCode == ExpressInfo.ExpressCompanyCode).CompanyName;
                                            ht["TotalTime"]      = lastDetail.Time.GetDayAndHours(list[0].Time);
                                            ht["T"]              = list;
                                            ht["V"]              = ExpressInfo;
                                            ht["ExpressCompany"] = ExpressCompany;
                                            ht["Status"]         = state;
                                            string content = FileGen.GetFileText(FileHelper.GetAbsolutePath("Temples/ExpressDetail.vm"), ht).ToString();
                                            //添加邮件消息提醒
                                            MessageHelper.AddMessage(Receiver, content, "快递进度变更", MessageType.EMAIL);
                                        }
                                    }
                                }
                            }
                        }
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }