Example #1
0
        public async Task <ViewResultBase> Edit(NullableIdInput input)
        {
            SystemDownload model = new SystemDownload();

            if (!input.Id.IsNullOrEmptyGuid())
            {
                model = await _systemDownloadLogic.GetByIdAsync(input.Id);
            }
            return(View(model));
        }
Example #2
0
 public void WriteSystemDownloadData(SystemDownload aSysDl, string aPath)
 {
     List<Logins> lLogins = aSysDl.UserData;
     List<CFCategories> lCats = aSysDl.CategoryData;
     List<ItemCategories> lItems = aSysDl.ItemButtonData;
     List<UserGroup> lUserGroup = aSysDl.UserGroupData;
     List<XElement> lXMLLogins = new List<XElement>();
     List<XElement> lXMLDeps = new List<XElement>();
     List<XElement> lXMLItemButtons = new List<XElement>();
     List<XElement> lXMLUG = new List<XElement>();
     int lDeps = 0;
     int lItemCount = 0;
     foreach (Logins lLogin in lLogins)
     {
         lXMLLogins.Add(new XElement("User",
             new XAttribute("Name", lLogin.Name),
             new XAttribute("POSUserID", lLogin.POSUserID),
             new XAttribute("PassCode", lLogin.PassCode),
             new XAttribute("UserGroup", lLogin.UserGroup)));
     }
     foreach (CFCategories lCat in lCats)
     {
         lDeps++;
         lXMLDeps.Add(new XElement("d" + lDeps.ToString(),
             new XAttribute("Name", lCat.name),
             new XAttribute("Colour", lCat.colour),
             new XAttribute("Command", lCat.command)));
     }
     foreach (ItemCategories lItem in lItems)
     {
         lItemCount++;
         lXMLItemButtons.Add(new XElement("ib" + lItemCount.ToString(),
             new XAttribute("Name", lItem.name),
             new XAttribute("Colour", lItem.colour),
             new XAttribute("Command", lItem.command),
             new XAttribute("DepartmentID", lItem.posCategoryGroupID)
             ));
     }
     foreach (UserGroup lUG in lUserGroup)
     {
         lXMLUG.Add(new XElement("UserGroup",
             new XAttribute("Name", lUG.Name),
             new XAttribute("CanLogin", lUG.CanLogin),
             new XAttribute("CanClock", lUG.CanClock),
             new XAttribute("CanEnterTrainingMode", lUG.CanEnterTrainingMode),
             new XAttribute("CanExitTrainingMode", lUG.CanExitTrainingMode),
             new XAttribute("CanAddFloat", lUG.CanAddFloat),
             new XAttribute("CanSubtractFloat", lUG.CanSubtractFloat),
             new XAttribute("CanCheckPOS", lUG.CanCheckPOS),
             new XAttribute("CanSell", lUG.CanSell),
             new XAttribute("CanSell18Plus", lUG.CanSell18Plus),
             new XAttribute("CanWaste", lUG.CanWaste),
             new XAttribute("CanPostToPMS", lUG.CanPostToPMS),
             new XAttribute("CanXRead", lUG.CanXRead),
             new XAttribute("CanZRead", lUG.CanZRead),
             new XAttribute("CanEOD", lUG.CanEOD),
             new XAttribute("CanRefund", lUG.CanRefund),
             new XAttribute("CanPriceDown", lUG.CanPriceDown),
             new XAttribute("CanStockEnquire", lUG.CanStockEnquire),
             new XAttribute("CanTransfer", lUG.CanTransfer),
             new XAttribute("CanManageDeliveries", lUG.CanManageDeliveries),
             new XAttribute("CanMinimize", lUG.CanMinimize),
             new XAttribute("CanExit", lUG.CanExit),
             new XAttribute("CanUpdate", lUG.CanUpdate),
             new XAttribute("CanAccessManagerMenu", lUG.CanAccessManagerMenu),
             new XAttribute("CanAccessEngineerMenu", lUG.CanAccessEngineerMenu)
             ));
     }
     XElement lUsers = new XElement("Users");
     XElement lDepartments = new XElement("Departments",
             new XAttribute("departments", (lDeps - 1)));
     XElement lItemButtons = new XElement("ItemButtons");
     XElement lUserGroupNode = new XElement("UserGroups");
     XElement lDownloadFile = new XElement("SystemInformation", lUsers, lDepartments, lItemButtons, lUserGroupNode);
     foreach (XElement lXMLElement in lXMLLogins)
     {
         lUsers.Add(lXMLElement);
     }
     foreach (XElement lXMLElement in lXMLUG)
     {
         lUserGroupNode.Add(lXMLElement);
     }
     foreach (XElement lXMLElement in lXMLItemButtons)
     {
         lItemButtons.Add(lXMLElement);
     }
     foreach (XElement lXMLElement in lXMLDeps)
     {
         lDepartments.Add(lXMLElement);
     }
     if (aPath != null)
     {
         lDownloadFile.Save(aPath);
     }
 }
        /// <summary>
        /// Take a full system download, dump the database and reinsert all records. 
        /// </summary>
        /// <param name="aSysDL">A System Download</param>
        /// <returns></returns>
        public bool InsertConfigDatabaseInfo(SystemDownload aSysDL)
        {
            bool lReturn = false;

            bool lOpenStatus = OpenDataBaseFile(Databases.dCONFIG);
            if (lOpenStatus)
            {
                //Database opened OK. Now empty it.
                try
                {
                    string lSQL = "DELETE FROM posusers";
                    SQLiteCommand lCommand = new SQLiteCommand(lSQL, gSQLIteCon);
                    lCommand.ExecuteNonQuery();
                    lCommand.CommandText = "DELETE FROM posusergroups";
                    lCommand.ExecuteNonQuery();
                    lCommand.CommandText = "DELETE FROM posdeptkeys";
                    lCommand.ExecuteNonQuery();
                    lCommand.CommandText = "DELETE FROM poskeys";
                    lCommand.ExecuteNonQuery();
                    try
                    {
                        string lSQLPosUsers = "INSERT INTO posusers (ID, Name, POSUSerID, PassCode, UserGroup) values ";
                        int i = 0;
                        foreach (Logins lUser in aSysDL.UserData)
                        {
                            i++;
                            lSQLPosUsers += "('" + i.ToString() + "','" + lUser.Name +
                                "','" + lUser.POSUserID + "','" + lUser.PassCode + "','" +
                                lUser.UserGroup + "'),";
                        }
                        lSQLPosUsers = lSQLPosUsers.Substring(0, (lSQLPosUsers.Length - 1));
                        lSQLPosUsers += ";";
                        lCommand.CommandText = lSQLPosUsers;
                        lCommand.ExecuteNonQuery();
                        string lSQLPosDeptKeys = "INSERT INTO posdeptkeys (id, sortID, name, colour, command) values ";
                        i = 0;
                        foreach (CFCategories lICats in aSysDL.CategoryData)
                        {
                            i++;
                            lSQLPosDeptKeys += "('" + i.ToString() + "','" + lICats.sortID + "','" +
                                lICats.name + "','" + lICats.colour + "','" + lICats.command + "'),";
                        }
                        lSQLPosDeptKeys = lSQLPosDeptKeys.Substring(0, (lSQLPosDeptKeys.Length - 1));
                        lSQLPosDeptKeys += ";";
                        lCommand.CommandText = lSQLPosDeptKeys;
                        lCommand.ExecuteNonQuery();
                        lSQLPosDeptKeys = "INSERT INTO poskeys (id, sortID, name, colour, command, posCategoryGroupID) values ";
                        i = 0;
                        foreach (ItemCategories lICats in aSysDL.ItemButtonData)
                        {
                            i++;
                            lSQLPosDeptKeys += "('" + i.ToString() + "','" + lICats.sortID + "','" +
                                lICats.name + "','" + lICats.colour + "','" + lICats.command + "','" +
                                lICats.posCategoryGroupID + "'),";
                        }
                        lSQLPosDeptKeys = lSQLPosDeptKeys.Substring(0, (lSQLPosDeptKeys.Length - 1));
                        lSQLPosDeptKeys += ";";
                        lCommand.CommandText = lSQLPosDeptKeys;
                        lCommand.ExecuteNonQuery();
                        string lSQLUG = "INSERT INTO posusergroups values ";
                        i = 0;
                        foreach (UserGroup lUG in aSysDL.UserGroupData)
                        {
                            i++;
                            lSQLUG += "('" + i.ToString() + "','" + lUG.Name + "','" + lUG.CanLogin + "','" + lUG.CanClock + "','" + lUG.CanEnterTrainingMode +
                                "','" + lUG.CanExitTrainingMode + "','" + lUG.CanAddFloat + "','" + lUG.CanSubtractFloat + "','" +
                                lUG.CanCheckPOS + "','" + lUG.CanSell + "','" + lUG.CanSell18Plus + "','" + lUG.CanWaste + "','" +
                                lUG.CanPostToPMS + "','" + lUG.CanXRead + "','" + lUG.CanZRead + "','" + lUG.CanEOD + "','" + lUG.CanRefund + "','" +
                                lUG.CanPriceDown + "','" + lUG.CanStockEnquire + "','" + lUG.CanTransfer + "','" + lUG.CanManageDeliveries + "','" +
                                lUG.CanMinimize + "','" + lUG.CanExit + "','" + lUG.CanUpdate + "','" + lUG.CanAccessManagerMenu + "','" +
                                lUG.CanAccessManagerMenu + "'),";
                        }
                        lSQLUG = lSQLUG.Substring(0, (lSQLUG.Length - 1));
                        lSQLUG += ";";
                        lCommand.CommandText = lSQLUG;
                        lCommand.ExecuteNonQuery();
                        CloseDatabase();
                        lReturn = true;
                    }
                    catch (Exception ex)
                    {
                        CloseDatabase();
                        AppLog.Log(ex.ToString(), false);
                        lReturn = false;
                    }
                }
                catch (Exception ex)
                {
                    CloseDatabase();
                    AppLog.Log(ex.ToString(), false);
                    lReturn = false;
                }
            }
            else
            {
                //Failed to open database
                lReturn = false;
            }
            return lReturn;
        }
Example #4
0
 public async Task <JsonResult> Save(SystemDownload model)
 {
     return(Json(await _systemDownloadLogic.Save(model)));
 }