コード例 #1
0
ファイル: SetUp.cs プロジェクト: benshyuv/Workshop
        private static string InitiateMarketFacade(string adminUsername, string adminPassword, ICommunicationNotificationAlerter communication,
                                                   out IMarketFacade newMarketFacade, bool useInMemoryDB)
        {
            if (string.IsNullOrEmpty(adminPassword) || string.IsNullOrWhiteSpace(adminUsername))
            {
                newMarketFacade = null;
                Logger.writeEvent("InitiateMarketFacade : Invalid input");
                return(Json.Create_json_response(false, "Invalid input"));
            }

            newMarketFacade = new MarketFacade(adminUsername, adminPassword, communication, useInMemoryDB);

            Logger.writeEvent("InitiateMarketFacade: Initialized Successfully");
            return(Json.Create_json_response(true, true));
        }
コード例 #2
0
ファイル: SetUp.cs プロジェクト: benshyuv/Workshop
        public static string Init(string adminUsername, string adminPassword, string?init_operations_loc, out NotificationManager notification,
                                  out PurchaseActions PurchaseActions, out UserActions UserActions, out StoreActions StoreActions, bool useInMemoryDB = false)
        {
            Logger.writeEvent("SetUp: Initailzing System");
            Json         = new JsonResponse();
            notification = new NotificationManager();
            string result = InitiateMarketFacade(adminUsername, adminPassword, notification, out IMarketFacade newMarketFacade, useInMemoryDB);

            PurchaseActions = new PurchaseActions(newMarketFacade);
            UserActions     = new UserActions(newMarketFacade);
            StoreActions    = new StoreActions(newMarketFacade);
            if (!Json.deserializeSuccess(result))// error on MarketFacade Init
            {
                return(result);
            }
            else if (!ExternalSystemsAreConnected(newMarketFacade))
            {
                Logger.writeEvent("SetUp: External Systems Error");
                return(Json.Create_json_response(false, "External Systems Error"));
            }
            else
            {
                if (init_operations_loc != null)
                {
                    try
                    {
                        string op_lines = File.ReadAllText(init_operations_loc);
                        Run_init_operations(op_lines, UserActions, StoreActions, PurchaseActions);
                    }
                    catch (Exception e)
                    {
                        Logger.writeError(e);
                        Logger.writeEvent("SetUp: Invalid operations File");
                        return(Json.Create_json_response(false, "Invalid operations File"));
                    }
                }
                Logger.writeEvent("SetUp: Initailzation Completed Successfully");
                return(result);
            }
        }