Example #1
0
        public void FinishImport(string groupId, int version, ImportorEnumerations.ImportGroupResult result, string userId)
        {
            ImportGroup groupEntity = new ImportGroup();

            groupEntity.Id           = groupId;
            groupEntity.ImportState  = ImportorEnumerations.ImportState.Finished;
            groupEntity.ImportResult = result;

            groupEntity.LastUpdateDate   = DateTime.Now;
            groupEntity.LastUpdateUserId = userId;
            groupEntity.CurrentVersion   = version;

            #region 执行SQL以修改对象

            ImportGroupManager manager   = new ImportGroupManager();
            string             sqlUpdate = manager.GetUpdateSql(groupEntity, "ImportState", "ImportResult");
            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlUpdate);
                    dbOperator.CommintTran();
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("结束导入过程发生异常 - ", ex);
                }
            }

            #endregion
        }
Example #2
0
        public ActionResult Format(string regex, string text, int?startOrder, int?startNumber, string light)
        {
            text = HttpUtility.UrlDecode(text);
            if (string.IsNullOrWhiteSpace(text))
            {
                return(this.Fail("Nothing given to format."));
            }
            regex = HttpUtility.UrlDecode(regex);
            if (string.IsNullOrWhiteSpace(regex))
            {
                return(this.Fail("No regular expression supplied."));
            }
            var matches = Regex.Matches(text, regex, RegexOptions.IgnoreCase);
            var dbRegex = this.Database.RegexFormats.Get(r => r.Regex == regex).FirstOrDefault();

            if (dbRegex == null)
            {
                dbRegex = new FormatRegex {
                    Regex = regex
                };
                this.Database.RegexFormats.Insert(dbRegex);
                this.Database.Save();
            }
            var import = new ImportGroup {
                Lights = {}
            };

            foreach (Match match in matches)
            {
                var order       = match.Groups ["o"];
                var number      = match.Groups ["n"];
                var importTruth = new ImportTruth {
                    Order  = order.Success ? Convert.ToInt32(order.Value) : startOrder,
                    Number = number.Success ? Convert.ToInt32(number.Value) : startNumber,
                    Text   = match.Groups ["t"].Value.Replace("\n", " ").Trim()
                };
                import.Truths.Add(importTruth);
                if (startOrder.HasValue)
                {
                    startOrder++;
                }
                if (startNumber.HasValue)
                {
                    if (startNumber < 0)
                    {
                        startNumber--;
                    }
                    else
                    {
                        startNumber++;
                    }
                }
            }
            return(Json(new { status = SUCCESS, items = import, regexId = dbRegex.Id, regexText = HttpUtility.UrlEncode(regex) }));
        }
Example #3
0
        public void AddImportGroup(string groupId, string operatorUserId, string operatorUserName, int totalCount
                                   , string fromNick, string fromTitle, string fromImageUrl, string toNick, string toTitle
                                   , ImportorEnumerations.ImportType importType, string userId)
        {
            ImportGroup groupEntity = new ImportGroup();

            groupEntity.Id                     = groupId;
            groupEntity.OperatorUserId         = operatorUserId;
            groupEntity.OperatorUserName       = operatorUserName;
            groupEntity.TotalCount             = totalCount;
            groupEntity.SuccessCount           = 0;
            groupEntity.FailCount              = 0;
            groupEntity.ImportFormSellerNick   = fromNick;
            groupEntity.ImportFormShopTitle    = fromTitle;
            groupEntity.ImportFormShopImageUrl = fromImageUrl;
            groupEntity.ImportToSellerNick     = toNick;
            groupEntity.ImportToShopTitle      = toTitle;
            groupEntity.ImportType             = importType;
            groupEntity.ImportState            = ImportorEnumerations.ImportState.Waitting;
            groupEntity.ImportResult           = ImportorEnumerations.ImportGroupResult.Pending;
            groupEntity.ListDateTime           = DateTime.Now;
            groupEntity.StartDateTime          = null;
            groupEntity.FinishDateTime         = null;

            groupEntity.CreateDate       = DateTime.Now;
            groupEntity.CreateUserId     = userId;
            groupEntity.LastUpdateDate   = DateTime.Now;
            groupEntity.LastUpdateUserId = userId;

            ImportGroupManager groupManager   = new ImportGroupManager();
            string             sqlCreateGroup = groupManager.GetCreateSql(groupEntity);

            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlCreateGroup);
                    dbOperator.CommintTran();
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("添加导入组发生异常 - ", ex);
                }
            }
        }
Example #4
0
        public void FinishImportItem(string groupId, int groupVersion, string itemId, int itemVersion
                                     , ImportorEnumerations.ImportItemResult result
                                     , string toItemIid, string toItemTitle, string toItemPrice, string toSellerNick, string toShopTitle
                                     , int successCount, int failCount, string message, string userId)
        {
            ImportGroup groupEntity = new ImportGroup();

            groupEntity.Id           = groupId;
            groupEntity.SuccessCount = successCount;
            groupEntity.FailCount    = failCount;

            groupEntity.LastUpdateDate   = DateTime.Now;
            groupEntity.LastUpdateUserId = userId;
            groupEntity.CurrentVersion   = groupVersion;

            ImportGroupManager managerGroup   = new ImportGroupManager();
            string             sqlUpdateGroup = managerGroup.GetUpdateSql(groupEntity, "SuccessCount", "FailCount");

            ImportItem itemEntity = new ImportItem();

            itemEntity.Id                 = itemId;
            itemEntity.ImportState        = ImportorEnumerations.ImportState.Finished;
            itemEntity.ImportResult       = result;
            itemEntity.FinishDateTime     = DateTime.Now;
            itemEntity.ImportToItemIid    = toItemIid;
            itemEntity.ImportToItemTitle  = toItemTitle;
            itemEntity.ImportToItemPrice  = toItemPrice;
            itemEntity.ImportToSellerNick = toSellerNick;
            itemEntity.ImportToShopTitle  = toShopTitle;
            itemEntity.ResultMessage      = message;

            itemEntity.LastUpdateDate   = DateTime.Now;
            itemEntity.LastUpdateUserId = userId;
            itemEntity.CurrentVersion   = itemVersion;

            ImportItemManager managerItem   = new ImportItemManager();
            string            sqlUpdateItem = managerItem.GetUpdateSql(itemEntity
                                                                       , "ImportState"
                                                                       , "ImportResult"
                                                                       , "FinishDateTime"
                                                                       , "ImportToItemIid"
                                                                       , "ImportToItemTitle"
                                                                       , "ImportToItemPrice"
                                                                       , "ImportToSellerNick"
                                                                       , "ImportToShopTitle"
                                                                       , "ResultMessage");

            #region 执行SQL以修改对象

            using (DbOperator dbOperator = new DbOperator(ConnString))
            {
                try
                {
                    dbOperator.BeginTran();
                    dbOperator.ExecSql(sqlUpdateGroup);
                    dbOperator.ExecSql(sqlUpdateItem);
                    dbOperator.CommintTran();
                }
                catch (Exception ex)
                {
                    dbOperator.RollbackTran();
                    throw new FacadeException("结束导入宝贝发生异常 - ", ex);
                }
            }

            #endregion
        }