Пример #1
0
        /// <summary>
        /// 登録されている数量と図面上の数量が一致しなかったらエラー
        /// </summary>
        /// <param name="lights">照明情報</param>
        /// <param name="emptyLightSerials">在庫が空である照明品番情報</param>
        /// <param name="usableLightSerials">使用可能な照明品番情報</param>
        public static void ValidateLightSerialCountNotMatch(List <Symbol> symbols)
        {
            string messageId =
                @"The count of light serial and stocked light serial does not match.
Please inquire of SMD.";

            var validator = new Validator();

            validator.Validate = delegate()
            {
                List <Symbol> lightSymbols = symbols.FindAll(p => p.IsLight);

                if (lightSymbols.Count == 0)
                {
                    return(null);
                }

                //在庫無しの品番情報
                List <LightSerial> emptyStockLightSerials;
                //邸ごとの使用できる品番情報
                List <UsableLightSerial> usableLightSerials;
                using (var service = new SocketPlanServiceNoTimeout())
                {
                    emptyStockLightSerials = new List <LightSerial>(service.GetEmptyStockLightSerials());
                    usableLightSerials     = new List <UsableLightSerial>(service.GetUsableLightSerials(Static.ConstructionCode));
                }

                if (emptyStockLightSerials.Count == 0)
                {
                    return(null);
                }

                List <Light> lights = new List <Light>();
                lightSymbols.ForEach(p => lights.Add(new Light(p)));

                //在庫数が一致しなかった照明シンボルを設定するリスト
                List <Symbol> notMatchLightSymbols = new List <Symbol>();
                //在庫数が一致しなかった品番名を設定するリスト
                List <String> notMatchLightHinbanNames = new List <string>();

                foreach (LightSerial emptyLightSerial in emptyStockLightSerials)
                {
                    UsableLightSerial usableLightSerial = usableLightSerials.Find(p => p.LightSerial == emptyLightSerial.Name);

                    if (usableLightSerial == null)//在庫数情報が取れなかった場合は在庫比較の判断ができない為。
                    {
                        continue;
                    }

                    List <Light> stockEmptyLights          = new List <Light>();
                    int          totalStockEmptyLightCount = 0;

                    //図面内に存在する在庫無し品番をカウント
                    foreach (Light light in lights)
                    {
                        List <string> hinbans = light.GetSerialsForCount();
                        int           count   = hinbans.FindAll(p => p == emptyLightSerial.Name).Count;
                        if (count == 0)
                        {
                            continue;
                        }

                        stockEmptyLights.Add(light);
                        totalStockEmptyLightCount += count;
                    }

                    if (totalStockEmptyLightCount == usableLightSerial.UsableCount)
                    {
                        continue;
                    }

                    //図面上と登録されている拾い数量が一致してなければエラーを表示
                    foreach (var light in stockEmptyLights)
                    {
                        if (notMatchLightSymbols.IndexOf(light.Symbol) == -1)
                        {
                            notMatchLightSymbols.Add(light.Symbol);
                        }
                    }

                    string infoMessage = emptyLightSerial.Name + " count " + totalStockEmptyLightCount + ", stock count " + usableLightSerial.UsableCount;;
                    notMatchLightHinbanNames.Add(infoMessage);
                }

                if (notMatchLightSymbols.Count == 0 && notMatchLightHinbanNames.Count == 0)
                {
                    return(null);
                }

                var error = new ErrorDialog(messageId, false);

                notMatchLightSymbols.ForEach(a => error.AddInfo(a));
                notMatchLightHinbanNames.ForEach(a => error.AddInfo(a));


                return(error);
            };

            validator.Run(messageId);
        }
Пример #2
0
        /// <summary>
        /// 在庫のない照明を使用してたらエラー
        /// </summary>
        /// <param name="constractionCode">工事コード</param>
        /// <param name="symbols">シンボル群</param>
        public static void ValidateLightSerialOutOfStock(List <Symbol> symbols)
        {
            string messageId =
                @"Light serial of out of stock is used.
Please check light serial.";

            var validator = new Validator();

            validator.Validate = delegate()
            {
                List <Symbol> lightSymbols = symbols.FindAll(p => p.IsLight);
                if (lightSymbols.Count == 0)
                {
                    return(null);
                }

                //在庫無しの品番情報
                List <LightSerial> emptyStockLightSerials;
                //邸ごとの使用できる品番情報
                List <UsableLightSerial> usableLightSerials;
                //加工前依頼か否か
                bool isBeforeProcessRequest;
                using (var service = new SocketPlanServiceNoTimeout())
                {
                    emptyStockLightSerials = new List <LightSerial>(service.GetEmptyStockLightSerials());
                    usableLightSerials     = new List <UsableLightSerial>(service.GetUsableLightSerials(Static.ConstructionCode));
                    isBeforeProcessRequest = service.IsBeforeProcessRequest(Static.ConstructionCode);
                }

                //非許可の照明品番が設定されていた照明シンボルを設定するリスト
                List <Symbol> denialLightSymbols = new List <Symbol>();
                //非許可の品番名を設定するリスト
                List <String> deniialLightHinbanName = new List <string>();

                List <Light> lights = new List <Light>();
                lightSymbols.ForEach(p => lights.Add(new Light(p)));

                foreach (Light light in lights)
                {
                    List <string> hinbans = light.GetSerialsForDistinct();
                    foreach (string hinban in hinbans)
                    {
                        if (!emptyStockLightSerials.Exists(p => p.Name == hinban))
                        {
                            continue;
                        }

                        if (IsUsableHinban(hinban, isBeforeProcessRequest, usableLightSerials))
                        {
                            continue;
                        }

                        if (denialLightSymbols.IndexOf(light.Symbol) == -1)
                        {
                            denialLightSymbols.Add(light.Symbol);
                        }

                        if (deniialLightHinbanName.IndexOf(hinban) == -1)
                        {
                            deniialLightHinbanName.Add(hinban);
                        }
                    }
                }

                if (denialLightSymbols.Count == 0 && deniialLightHinbanName.Count == 0)
                {
                    return(null);
                }

                var error = new ErrorDialog(messageId, false);
                denialLightSymbols.ForEach(a => error.AddInfo(a));
                deniialLightHinbanName.ForEach(a => error.AddInfo(a + " out of stock."));
                return(error);
            };

            validator.Run(messageId);
        }